/* ---------- Font: Inter Tight (variable, self-hosted, SIL OFL 1.1) ----------
   One file per subset covers every weight. Licence: fonts/OFL.txt */

@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-tight-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-tight-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #8a8a8a;
  --line: #000000;
  --gutter: clamp(16px, 2.2vw, 32px);
  --small: 11px;
  --theme-duration: 400ms;
  --header-h: 44px; /* everything that fills the screen is sized from these */
  --footer-h: 52px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #777777;
  --line: #ffffff;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Theme switch: while .theme-anim is on <html> (set briefly by main.js), every
   colour on the page fades at one speed. The portrait crossfades in riso.js. */
.theme-anim *,
.theme-anim *::before,
.theme-anim *::after,
.theme-anim *::placeholder {
  transition: background-color var(--theme-duration) ease,
              color var(--theme-duration) ease,
              border-color var(--theme-duration) ease !important;
}

a { color: inherit; text-decoration: none; }

/* ---------- Bars: tiny uppercase type, hairline rules ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--gutter);
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

header.bar {
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}
header.bar::after,
.row::before,
.foot::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--line);
  transform-origin: left;
}
header.bar::after { bottom: 0; }
.row::before, .foot::before { top: 0; }

.mark { font-weight: 800; letter-spacing: 0.02em; }

.primary { display: flex; align-items: center; gap: clamp(28px, 3vw, 44px); } /* name + sections left, settings right */
nav { display: flex; align-items: center; gap: 28px; }

nav a,
.theme-toggle,
.foot a {
  position: relative;
}
nav a::after,
.theme-toggle::after,
.foot a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
}
nav a:hover::after,
.theme-toggle:hover::after,
.foot a:hover::after { transform: scaleX(1); transform-origin: left; }

.theme-toggle {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Hero ---------- */

.hero {
  height: calc(100svh - var(--header-h));
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: clamp(20px, 4vh, 48px);
  padding-top: clamp(24px, 5vh, 56px);
  padding-bottom: clamp(28px, 6vh, 72px);
  overflow: hidden;
}

.frame {
  position: relative;
  margin: 0;
  flex: 1 1 0;
  min-height: 0;
  aspect-ratio: 2 / 3;
  max-width: calc(100vw - 4 * var(--gutter));
}

.portrait {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  mix-blend-mode: multiply;
}
.portrait.printed { opacity: 1; }
:root[data-theme="dark"] .portrait { mix-blend-mode: screen; }
.portrait.ghost { position: absolute; inset: 0; pointer-events: none; }

/* Line-art registration ticks at the frame corners */
.tick {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 0 solid var(--line);
}
.tl { top: -1px;    left: -1px;  border-top-width: 1px;    border-left-width: 1px; }
.tr { top: -1px;    right: -1px; border-top-width: 1px;    border-right-width: 1px; }
.bl { bottom: -1px; left: -1px;  border-bottom-width: 1px; border-left-width: 1px; }
.br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

figcaption {
  position: absolute;
  left: calc(100% + 14px);
  bottom: 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
}


/* ---------- Index rows ---------- */

.row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--gutter);
  padding: 22px var(--gutter) 96px;
  position: relative;
  scroll-margin-top: var(--header-h);
}

.row h2 {
  margin: 0;
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.row h2 span { display: inline-block; width: 3.2em; color: var(--muted); }

.body p { margin: 0 0 1em; max-width: 38em; }

.statement {
  display: inline-block;
  margin: 0 0 1.2em;
  font-size: clamp(26px, 3.6vw, 52px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.035em;
  max-width: 16em;
}

/* ---------- Note form: line-art fields ---------- */

.note textarea,
.note input {
  width: 100%;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 0 10px;
  outline: none;
}
/* Fixed-height writing area so nothing below it moves while typing: two lines
   of statement-size type; longer notes switch to reading size (.long, set in
   main.js) in the same box, then scroll inside it. */
.note {
  --note-size: clamp(26px, 3.6vw, 52px);
  --note-h: calc(var(--note-size) * 2.16 + 10px);
}
.note textarea {
  height: var(--note-h);
  font-size: var(--note-size);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.035em;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
}
.note textarea.long {
  font-size: clamp(16px, 1.35vw, 20px);
  line-height: 1.45;
  letter-spacing: -0.005em;
}
.note textarea::placeholder,
.note input::placeholder { color: var(--muted); opacity: 1; }
.note input:focus { border-bottom-width: 2px; padding-bottom: 9px; }
.note textarea:focus { box-shadow: inset 0 -1px 0 var(--line); } /* thicker rule without changing height */

.note-foot {
  display: flex;
  align-items: flex-end;
  gap: var(--gutter);
  margin-top: 18px;
}
.note input {
  flex: 1;
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.note-count {
  flex: none;
  padding-bottom: 11px;
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums; /* digits don't jitter while typing */
  color: var(--muted);
  transition: color .2s;
}
.note-count.near { color: var(--fg); }

/* Send: a text button like the header links, with the same sliding underline. */
.note button {
  position: relative;
  flex: none;
  font: inherit;
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 0 0 11px;
  cursor: pointer;
}
.note button::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .35s var(--ease-out);
}
.note button:hover::after,
.note button:focus-visible::after { transform: scaleX(1); transform-origin: left; }
.note button:focus-visible { outline: none; }
.note button:disabled { color: var(--muted); cursor: default; }

/* Turnstile: collapsed unless it asks the visitor for a tick (main.js adds .open). Not
   display:none, so the check can still run unseen. */
.ts { height: 0; overflow: hidden; }
.ts.open { height: auto; overflow: visible; margin-top: 18px; }

.note-status {
  min-height: 1.4em;
  margin: 14px 0 0;
  font-size: var(--small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
}
.note-status.show { opacity: 1; transform: none; }
.note-status.error { color: var(--fg); }

/* Sending: the words dim while they travel; on success they fade out in place. */
.note textarea { transition: color .45s ease, opacity .3s ease; }
.note.sending textarea { opacity: .45; }
.note textarea.sent { color: transparent; }

.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Footer ---------- */

.foot { position: relative; height: var(--footer-h); }
.folio { display: none; color: var(--muted); }

/* ---------- 404 ---------- */

.lost { min-height: calc(100svh - var(--header-h) - var(--footer-h)); }
.lost .row { padding: clamp(56px, 12vh, 140px) var(--gutter) 96px; } /* no portrait column here, so keep side margins */
.lost .row::before { display: none; }
.lost .row h2 span { width: 3.6em; }
.home-link {
  font-size: var(--small);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.lost .folio { display: inline; }

/* ---------- Page transitions ----------
   Moving between pages crossfades instead of cutting (Chrome, Edge, Safari 18.2+;
   other browsers just navigate). The header is its own layer, so it holds still. */

@view-transition { navigation: auto; }
header.bar { view-transition-name: site-header; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: .45s; animation-timing-function: ease; }

/* Theme switch via startViewTransition (main.js): the whole page is one snapshot,
   so the header joins the root layer for it, and the fade uses the theme duration. */
:root.vt-theme header.bar { view-transition-name: none; }
:root.vt-theme::view-transition-old(root),
:root.vt-theme::view-transition-new(root) { animation-duration: var(--theme-duration); }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- First-visit intro ----------
   html.intro is set in <head> once per tab session (skipped for reduced motion),
   so a reload shows the page already in place. Rows below the fold are revealed
   by main.js as they scroll into view. */

@keyframes intro-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes intro-fade { from { opacity: 0; } }
@keyframes intro-draw { from { transform: scaleX(0); } }
@keyframes intro-tick { from { opacity: 0; transform: scale(0.2); } }

.intro header.bar::after { animation: intro-draw 1.4s var(--ease-out) both; }
.intro .mark { animation: intro-rise .9s var(--ease-out) .15s both; }
.intro nav > * { animation: intro-rise .9s var(--ease-out) both; }
.intro nav > :nth-child(1) { animation-delay: .25s; }
.intro nav > :nth-child(2) { animation-delay: .32s; }
.intro nav > :nth-child(3) { animation-delay: .39s; }

.intro .tick { animation: intro-tick 1s var(--ease-out) .5s both; }
.tl { transform-origin: top left; }
.tr { transform-origin: top right; }
.bl { transform-origin: bottom left; }
.br { transform-origin: bottom right; }
.intro .portrait { transition: opacity 1.6s ease .2s; }
.intro figcaption { animation: intro-fade 1.2s ease 1.3s both; }


.intro .row:not(.in)::before,
.intro .foot:not(.in)::before { transform: scaleX(0); }
.intro .row:not(.in) > *,
.intro .foot:not(.in) > * { opacity: 0; }
.intro .row.in::before,
.intro .foot.in::before { animation: intro-draw 1.4s var(--ease-out) both; }
.intro .row.in > *,
.intro .foot.in > * { animation: intro-rise 1s var(--ease-out) .15s both; }
.intro .row.in > :nth-child(2),
.intro .foot.in > :nth-child(2) { animation-delay: .27s; }

/* ---------- Wide screens: portrait pinned left, sections to its right ---------- */

@media (min-width: 900px) {
  /* The whole page is one printed sheet: header and footer frame a single screen. */
  .row::before { right: clamp(32px, 5vw, 96px); } /* divider stays inside the sheet */
  .foot .to-top { display: none; }
  .folio { display: inline; }
  main.home {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr 1fr; /* About and Note split the portrait's height evenly */
  }
  .hero {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: start;
    position: sticky;
    top: var(--header-h);
    height: calc(100svh - var(--header-h) - var(--footer-h));
    padding: clamp(24px, 5vh, 56px) clamp(56px, 6vw, 112px) clamp(24px, 5vh, 56px) var(--gutter);
    gap: 0;
  }
  .frame {
    flex: none;
    height: 100%;
    max-width: none;
  }
  .row {
    grid-column: 2;
    grid-template-columns: 1fr 3fr;
    align-content: start;
    column-gap: clamp(24px, 3vw, 56px);
    padding: clamp(28px, 7vh, 104px) clamp(32px, 5vw, 96px) clamp(16px, 4vh, 72px) 0;
  }
  /* No rule under the header for the first section. */
  .hero + .row::before { display: none; }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  nav { gap: 16px; }
  .hero { height: auto; min-height: 0; }
  .frame { flex: none; width: 74vw; }
  figcaption { display: none; }
  .row { grid-template-columns: 1fr; padding-top: 56px; padding-bottom: 128px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  html { scroll-behavior: auto; }
}
