/* sebastianbenz.de — home. One sheet, a salutation, a sign-off. */

/* Subset to Basic Latin + a few typographic marks, and pinned to the two instances this
   sheet uses: upright 400 (opsz axis kept so optical sizing still tracks font-size) and
   italic 300 at opsz 60 for the salutation. Re-cut from the full fonts if more weights
   are ever needed — see fonts/LICENSE.txt. */
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-stretch: normal;
  font-display: swap;
  src: url("/fonts/source-serif-4-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 300;
  font-stretch: normal;
  font-display: swap;
  src: url("/fonts/source-serif-4-italic.woff2") format("woff2");
}

:root {
  color-scheme: light dark;

  --paper: #fbfbf9;
  --ink: #161616;
  --ink-soft: #5e5d58;
  --pen: #1d3fa8;

  /* paper grid: 1/12 of the width for the margin, 1.5rem vertical unit */
  --margin: calc(100vw / 12);
  --unit: 1.5rem;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1a17;
    --ink: #ece9e1;
    --ink-soft: #a39f94;
    --pen: #8fa8ff;
  }
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  /* Scale fallback serifs to Source Serif's x-height so the swap doesn't reflow the sheet */
  font-size-adjust: from-font;
  font-size: 1.125rem;
  line-height: var(--unit);
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--pen);
  color: var(--paper);
}

/* The sheet ---------------------------------------------------------------- */

.letter {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  padding: calc(var(--unit) * 2) var(--margin) calc(var(--unit) * 2);
}

/* Salutation: the image of the page */
.salutation {
  align-self: center;
  margin: 0;
  margin-left: -0.06em; /* optical alignment of the italic h with the margin */
  padding-block: calc(var(--unit) * 2);
  font-style: italic;
  font-weight: 300;
  font-variation-settings: "opsz" 60;
  font-size: clamp(5rem, 21vw, 19rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Sign-off: name, title, then the three links on one line — this is the navigation */
.signoff {
  display: grid;
  gap: 0;
}

.name,
.title {
  margin: 0;
  line-height: var(--unit);
}

.name {
  font-size: 1.25rem;
}

.title {
  font-size: 1.125rem;
  color: var(--ink-soft);
  text-wrap: balance;
}

.signoff nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.6em;
  margin-top: var(--unit);
}

.sep {
  color: var(--ink-soft);
  font-size: 1.25rem;
  line-height: var(--unit);
  user-select: none;
}

.signoff a {
  --stroke: 1px;
  position: relative;
  color: var(--pen);
  text-decoration: none;
  font-size: 1.25rem;
  /* 0.1em of clearance drops the underline below descenders; take it back from the
     line-height so each row stays exactly one unit tall */
  line-height: calc(var(--unit) - 0.1em);
  padding-bottom: 0.1em;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% var(--stroke);
  transition: background-size 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.signoff a:hover,
.signoff a:focus-visible {
  --stroke: 3px;
}

/* Pressed: same stroke, no wait — the one feedback a tap gets */
.signoff a:active {
  --stroke: 3px;
  transition-duration: 60ms;
}

/* Touch target: a tall hit area (≥44px) without moving the underline; the separator gap
   keeps neighbours from overlapping */
.signoff a::before {
  content: "";
  position: absolute;
  inset: -0.65rem -0.3em;
}

.signoff a:focus-visible {
  outline: 2px solid var(--pen);
  outline-offset: 6px;
  border-radius: 1px;
}

/* Forced colors strips background-image, so the drawn underline vanishes — fall back to
   the real one, and the thicker stroke on hover/focus becomes a thicker rule */
@media (forced-colors: active) {
  .signoff a {
    text-decoration: underline;
    text-underline-offset: 0.1em;
  }
  .signoff a:hover,
  .signoff a:focus-visible {
    text-decoration-thickness: 3px;
  }
}

/* Motion: one authored moment — the ink settles, then the underlines draw ---- */

@media (prefers-reduced-motion: no-preference) {
  .salutation {
    animation: settle 900ms var(--ease-out) backwards;
  }

  .signoff a {
    animation: draw 700ms var(--ease-out) backwards;
    animation-delay: 650ms;
  }
  .signoff a:nth-of-type(2) {
    animation-delay: 770ms;
  }
  .signoff a:nth-of-type(3) {
    animation-delay: 890ms;
  }

  @keyframes settle {
    from {
      opacity: 0;
      filter: blur(8px);
      transform: translateY(0.04em);
    }
    to {
      opacity: 1;
      filter: blur(0);
      transform: none;
    }
  }

  @keyframes draw {
    from {
      background-size: 0 var(--stroke);
    }
    to {
      background-size: 100% var(--stroke);
    }
  }
}

/* Narrow sheets ----------------------------------------------------------- */

@media (max-width: 40rem) {
  :root {
    --margin: calc(100vw / 10);
  }

  .salutation {
    font-size: clamp(4.5rem, 30vw, 9rem);
  }

  .name,
  .signoff a,
  .sep {
    font-size: 1.125rem;
  }

  .title {
    font-size: 1rem;
  }
}

/* Very short viewports (landscape phones): keep the three regions apart */
@media (max-height: 30rem) {
  .salutation {
    font-size: clamp(3.5rem, 28vh, 10rem);
    padding-block: var(--unit);
  }
}
