/* ==========================================================
   Design Gestalt: v1
   Light: cream / charcoal / indigo. Dark: charcoal-indigo / cream.
   Follows the system color scheme.
   ========================================================== */

/* Fonts, self-hosted (fonts/). Instrument Serif and Inter are both under the
   SIL Open Font License 1.1 (license texts alongside). Latin and Latin
   Extended only. */
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-italic-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: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-italic-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;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-normal-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: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSerif-normal-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;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/Inter-normal-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";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/Inter-normal-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 {
  color-scheme: light dark;

  /* Color tokens */
  --bg:        light-dark(#f5efe3, #14141b);
  --surface:   light-dark(#fbf7ef, #1b1b25);
  --text:      light-dark(#1e1d23, #ece7dc);
  --muted:     light-dark(#5f5b66, #a4a0b2);
  --border:    light-dark(#e2d9c8, #2a2a38);
  --accent:    light-dark(#3a3d99, #a9acf2);
  --accent-ink:light-dark(#fbf7ef, #14141b);
  --curtain:   light-dark(#262862, #22234a);
  --curtain-ink: #ece7dc;

  /* Thread shades: one indigo hue, deep ink to pale (reversed for dark mode).
     Each braid takes three neighboring steps. */
  --thread-0: light-dark(#1d1f4f, #e2e3fb);
  --thread-1: light-dark(#262862, #cfd1f8);
  --thread-2: light-dark(#30337a, #bfc1f5);
  --thread-3: light-dark(#3a3d99, #a9acf2);
  --thread-4: light-dark(#4a4eb6, #9295ea);
  --thread-5: light-dark(#5a5ec6, #7e82e0);
  --thread-6: light-dark(#7478d6, #6a6ed2);
  --thread-7: light-dark(#8f92e2, #5a5ec2);
  --thread-8: light-dark(#adb0ee, #4a4ea8);

  /* Type */
  --font-display: "Instrument Serif", ui-serif, Georgia, serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --step-hero: clamp(2.75rem, 1.6rem + 5.2vw, 6rem);
  --step-2:    clamp(2rem, 1.5rem + 2vw, 3rem);
  --step-1:    clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --step-0:    1.0625rem;
  --step--1:   0.875rem;

  /* Space & motion */
  --wrap: 68rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --section: clamp(5rem, 10vw, 9rem);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-curtain: cubic-bezier(0.76, 0, 0.24, 1);
  --radius: 14px;
}

/* Manual override from the header toggle. light-dark() follows color-scheme. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.muted { color: var(--muted); }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4rem;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Theme toggle: an illustrated sun and full moon that cross-fade (same as the Octa HQ site).
   The icon shown is the mode you'd switch to: the moon in light mode, the sun in dark. */
.theme-toggle {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in oklab, var(--text) 2.5%, transparent);
  cursor: pointer;
  transition: border-color 0.16s ease;
}
:root:not(.js) .theme-toggle { display: none; }
.theme-toggle:hover { border-color: color-mix(in oklab, var(--text) 24%, transparent); }
.theme-icon {
  position: absolute;
  inset: 6px;
  width: 20px;
  height: 20px;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.theme-icon-sun { opacity: 0; transform: scale(0.75); }
:root[data-theme="dark"] .theme-icon-moon { opacity: 0; transform: scale(0.75); }
:root[data-theme="dark"] .theme-icon-sun  { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-moon { opacity: 0; transform: scale(0.75); }
  :root:not([data-theme="light"]) .theme-icon-sun  { opacity: 1; transform: none; }
}

.header-cta {
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.3s var(--ease-out), background-color 0.3s var(--ease-out);
}
.header-cta:hover { border-color: var(--accent); background: var(--surface); }

.header-link {
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
  padding: 0.45rem 0.5rem;
  color: var(--muted);
  transition: color 0.3s var(--ease-out);
}
.header-link:hover, .header-link[aria-current="page"] { color: var(--text); }

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

.hero {
  min-height: calc(100svh - 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: 4rem 6rem;
  container-type: inline-size;
  position: relative;
  isolation: isolate;
}

/* Woven threads behind the hero (built in script.js). Full-bleed, lower band. */
.threads {
  position: absolute;
  /* Extends below the hero so threads entering from low down aren't cut off;
     they pass faintly behind the start of the next section. */
  inset: 0 auto -32vh 50%;
  width: 100vw;
  translate: -50% 0;
  z-index: -1;
  pointer-events: none;
  transition: opacity 1.8s var(--ease-out);
}
.threads canvas { display: block; width: 100%; height: 100%; }
.threads.settled { opacity: 0.85; }

/* One phrase per line, never wrapping. The longer (italic) line measures
   ~4.4em in Instrument Serif, so the size scales with the hero's width. */
.hero-title {
  font-family: var(--font-display);
  font-size: var(--step-hero); /* for browsers without container query units */
  font-size: min(6rem, 100cqi / 5.5);
  line-height: 1.08;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.hero-title .line { display: block; }
.hero-title em { font-style: italic; color: var(--accent); }

.hero-after {
  margin-top: 2.5rem;
  display: grid;
  gap: 2rem;
  justify-items: start;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.45;
  color: var(--muted);
  max-width: 34ch;
}

/* Typing effect: characters are pre-laid-out (invisible) so nothing shifts. */
.type.typing .ch { opacity: 0; }
.type.typing .ch.on { opacity: 1; }

.caret {
  display: inline-block;
  position: relative;
  width: 0;
  height: 0.9em;
  vertical-align: -0.08em;
}
.caret::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0.04em;
  width: 2px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
.caret.done { opacity: 0; transition: opacity 0.6s ease; }

@keyframes blink { 50% { opacity: 0; } }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font: 500 var(--step-0) / 1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.4s var(--ease-out), background-color 0.3s var(--ease-out);
}
.button::after {
  content: "→";
  transition: transform 0.4s var(--ease-out);
}
.button:hover { background: var(--accent); color: var(--accent-ink); }
.button:hover::after { transform: translateX(4px); }
.button:active { transform: scale(0.98); }
.button[disabled] { opacity: 0.6; cursor: progress; }

/* ---------- Sections ---------- */

.section { padding-block: var(--section) 0; }
.section:last-of-type { padding-bottom: var(--section); }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: 1.1;
}

h3 {
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.2;
  margin-bottom: 0.6rem;
}

.grid-3 {
  display: grid;
  gap: clamp(2rem, 4vw, 3.5rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.feature, .work {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.feature p, .work p { color: var(--muted); }

/* How to work together (under the "What I do" cards) */
.engage {
  margin-top: clamp(2rem, 4vw, 3rem);
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.35;
}

/* About (closes the "What I do" section) */
.about { display: grid; gap: 1.25rem; max-width: 42rem; margin-top: clamp(3.5rem, 7vw, 6rem); }
.about-lead {
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: 1.15;
}
.about p:not(.about-lead) { color: var(--muted); }
.about-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.75rem;
  margin-top: 0.75rem;
}

.text-link {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 0.25em;
  transition: text-decoration-color 0.3s var(--ease-out);
}
.text-link:hover { text-decoration-color: var(--accent); }

/* ---------- Work page ---------- */

.page-head { padding-block: clamp(4rem, 9vw, 7rem) 0; }
.page-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 2rem + 4vw, 5rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin-bottom: 1.75rem;
}
.page-lede { max-width: 48ch; }

/* Work page: section titles in the accent colour. */
.page-head ~ .section .eyebrow { color: var(--accent); }

/* Set like the hero's lede. */
.group-intro {
  font-family: var(--font-body);
  font-size: calc(var(--step-1) - 0.125rem);
  line-height: 1.45;
  max-width: 40ch;
  margin: -1.25rem 0 2.5rem;
}

.site-link {
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.3s var(--ease-out), color 0.3s var(--ease-out);
}
.site-link::after {
  content: " ↗";
  font-family: var(--font-body);
  font-size: 0.7em;
  color: var(--accent);
}
.site-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

.work-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.work-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 0.5rem 3rem;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.work-list h3 { margin: 0; }
.work-list .detail { display: grid; gap: 0.6rem; }
.work-list .detail ul { margin: 0; padding-left: 1.1rem; color: var(--muted); display: grid; gap: 0.35rem; }
.work-list .detail li { display: list-item; list-style: disc; padding: 0; border: 0; }
.work-list .stack { font-size: var(--step--1); letter-spacing: 0.02em; }
.work-list p { color: var(--muted); max-width: 60ch; }
@media (max-width: 40rem) {
  .work-list li { grid-template-columns: 1fr; }
}

.closing { display: grid; gap: 2rem; justify-items: start; }

/* ---------- Intake form ---------- */

.intake {
  display: grid;
  gap: 2.5rem 4rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  align-items: start;
}
.intake-intro { display: grid; gap: 1rem; }

.form { display: grid; gap: 1.25rem; }

.field-row {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}

.field { display: grid; gap: 0.4rem; }

label { font-size: var(--step--1); font-weight: 500; }
.optional { color: var(--muted); font-weight: 400; }

input, textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
textarea { resize: vertical; field-sizing: content; min-height: 3.5rem; }

input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}
input:user-invalid, textarea:user-invalid {
  border-color: light-dark(#b3412e, #f08f7c);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-top: 0.5rem;
}
.form-status { font-size: var(--step--1); color: var(--muted); }
.form-status.is-error { color: light-dark(#b3412e, #f08f7c); }

.form-done {
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.form-done h3 { margin-bottom: 0.5rem; }

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

.site-footer {
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 2rem;
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ---------- Curtain (hidden unless motion is OK) ---------- */

.curtain { display: none; }

/* ==========================================================
   Motion: only when the visitor hasn't asked for less.
   ========================================================== */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  /* Curtain sweeps off to the right, revealing the site. The page itself stays
     still so the headline can be "pulled out" by the curtain's edge (script.js). */
  .curtain {
    display: grid;
    place-items: center;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--curtain);
    color: var(--curtain-ink);
    animation: curtain-right 1.1s var(--ease-curtain) 0.7s both;
    pointer-events: none;
  }
  .curtain-mark {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 1.2rem + 2.5vw, 3rem);
    letter-spacing: 0.01em;
    animation: mark 1.2s var(--ease-out) both;
  }

  /* With JS, the hero's supporting text waits for the headline to finish typing. */
  .js .hero-after {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
  }
  .js.hero-ready .hero-after { opacity: 1; transform: none; }

  /* Failsafe: if JS never signals, show it anyway. */
  .js:not(.hero-ready) .hero-after { animation: failsafe 0.01s 10s forwards; }

  /* Scroll reveal via CSS scroll-driven animations, where supported.
     Browsers without support simply show the content. */
  @supports (animation-timeline: view()) {
    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
  }
}

/* Arriving from another page in the same visit: no curtain (script.js skips
   the typing too), and the hero shows in its final state straight away: the
   supporting text doesn't fade in, and the threads start at their settled
   strength instead of fading down to it. */
.no-intro .curtain { display: none; }
.js.no-intro .hero-after { opacity: 1; transform: none; transition: none; }
.no-intro .threads { transition: none; }
/* The threads are drawn by script.js, which runs just after the first paint,
   so the hero waits for them and everything appears in the same frame
   (script.js draws the threads, then marks the hero ready). Failsafe: shown
   anyway after 1.5s if the script never runs. */
.js.no-intro:not(.hero-ready) .hero { visibility: hidden; animation: show-hero 0s 1.5s forwards; }
@keyframes show-hero { to { visibility: visible; } }

/* Theme switch crossfade (View Transitions, where supported). */
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.45s; animation-timing-function: ease; }

@keyframes curtain-right {
  to { transform: translateX(100%); }
}
@keyframes mark {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: none; }
}
@keyframes failsafe {
  to { opacity: 1; transform: none; }
}
