/* Hallett & Voss. The Drawing Office. */

@font-face {
  font-family: 'Libre Franklin';
  src: url('../fonts/libre-franklin-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Fragment Mono';
  src: url('../fonts/fragment-mono.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #F6F7F5;
  --paper-shadow: #E8EBE7;
  --hairline: #D7DBD6;
  --ink: #22262B;
  --ink-display: #1A1E23;
  --blue: #2350B8;
  --blue-wash: rgba(35, 80, 184, .55);
  --blue-dusk: #8FAAF2;
  --dusk-hi: #232A33;
  --dusk-lo: #171C23;
  --window-warm: #EFBE6E; /* diegetic only */
  --font-sans: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Fragment Mono', 'SF Mono', Menlo, monospace;
  --dusk: 0; /* driven 0-1 by stage.js; single source of truth */
  --page-bg: var(--paper);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--page-bg);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background:
    color-mix(in srgb, var(--dusk-lo) calc(var(--dusk) * 100%), var(--paper));
  overflow-x: clip; /* demo 2 lesson: clip, never hidden */
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: -48px; left: 12px;
  z-index: 40;
  padding: 10px 16px;
  background: var(--blue);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .14em;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus-visible { top: 12px; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
html.at-dusk :focus-visible { outline-color: var(--blue-dusk); }

/* ---------- Type scale ---------- */

h1, h2, h3 {
  font-family: var(--font-sans);
  color: var(--ink-display);
  margin: 0;
}
h1 {
  font-size: clamp(2.7rem, 6vw, 4.6rem);
  font-weight: 780;
  letter-spacing: -0.02em;
  line-height: 1.04;
}
h2 {
  font-size: clamp(1.7rem, 3.2vw, 2.5rem);
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
h3 {
  font-size: 1.25rem;
  font-weight: 640;
  letter-spacing: -0.005em;
}
p { margin: 0; max-width: 65ch; }

.mono-caption, .mono-meta, .stat-chips li {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
}

/* ---------- Two-layer dusk text switch (Sol finding 3) ----------
   Text never interpolates through the background's luminance.
   Copy sits dark on stable paper panels until stage.js flips
   html.at-dusk at the precomputed threshold; each text element
   then switches dark to light via a 120ms crossfade. */

.site-header, .panel, .s4-heading, .project, .site-footer, .s1-inner {
  transition: color .12s linear, background-color .12s linear;
}

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

.cta {
  display: inline-block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .95rem;
  line-height: 1;
  padding: 14px 22px;
  text-decoration: none;
  border-radius: 0;
  white-space: nowrap;
}
.cta:active { transform: translateY(1px); }
.cta-primary {
  background: var(--blue);
  color: #fff;
  border: 1px solid var(--blue);
}
.cta-primary:hover { background: #1C429C; border-color: #1C429C; }
.cta-secondary {
  color: var(--blue);
  border: 1px solid var(--blue);
  background: transparent;
}
.cta-secondary:hover { background: rgba(35, 80, 184, .07); }
html.at-dusk .cta-secondary { color: var(--blue-dusk); border-color: var(--blue-dusk); }
html.at-dusk .cta-secondary:hover { background: rgba(143, 170, 242, .12); }

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

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
  padding: 0 clamp(16px, 3vw, 40px);
}
.site-header.scrolled {
  background: color-mix(in srgb, var(--dusk-lo) calc(var(--dusk) * 100%), var(--paper));
  border-bottom: 1px solid
    color-mix(in srgb, #2A323D calc(var(--dusk) * 100%), var(--hairline));
}
.wordmark {
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .18em;
  color: var(--ink-display);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark .amp { color: var(--blue); }
html.at-dusk .wordmark { color: #E9ECF0; }
html.at-dusk .wordmark .amp { color: var(--blue-dusk); }
.site-nav {
  display: flex;
  gap: 24px;
  margin-left: auto;
}
.site-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  padding: 6px 2px;
}
.site-nav a:hover { color: var(--blue); }
html.at-dusk .site-nav a { color: #C9CFD8; }
html.at-dusk .site-nav a:hover { color: var(--blue-dusk); }
.header-cta { padding: 10px 16px; font-size: .88rem; }

/* ---------- Sections over the stage ---------- */

main { position: relative; z-index: 5; }

section { position: relative; }

.panel {
  background: var(--paper);
  border: 1px solid var(--hairline);
  padding: clamp(28px, 4vw, 56px);
  max-width: 560px;
}
html.at-dusk .panel {
  background: #1D242D;
  border-color: #2A323D;
  color: #C9CFD8;
}
html.at-dusk .panel h2,
html.at-dusk .panel h3 { color: #E9ECF0; }

/* S1 hero: canvas is the composition; copy sits left on the paper itself */
.s1 {
  min-height: 210vh;
}
.s1-inner {
  position: sticky;
  top: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 96px clamp(16px, 4vw, 64px) 0;
  max-width: 620px;
}
.s1-sub { margin-top: 20px; }
.s1-ctas {
  display: flex;
  gap: 14px;
  margin-top: 32px;
}

/* S2 sectors: right column while the raise happens left */
.s2 {
  min-height: 190vh;
  display: flex;
  justify-content: flex-end;
  padding: 24vh clamp(16px, 4vw, 64px);
}
.s2 .panel { align-self: flex-start; position: sticky; top: 12vh; }
.sector-list {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 18px;
}
.sector-list li {
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
}
html.at-dusk .sector-list li { border-color: #2A323D; }
.sector-list p { margin-top: 2px; }

/* S3 approach: left column, the section cut sweeps behind on the right */
.s3 {
  min-height: 240vh;
  display: flex;
  justify-content: flex-start;
  padding: 24vh clamp(16px, 4vw, 64px);
}
.s3 .panel { position: sticky; top: 12vh; align-self: flex-start; }
.approach-grafs {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

/* S4 selected work: full-width editorial grid in normal flow.
   Opaque background: copy never sits on the interpolating page bg (G4). */
.s4 {
  padding: 18vh clamp(16px, 4vw, 64px) 14vh;
  /* 93% paper: ink stays >= 13:1 over any page state beneath, and the held
     model ghosts through for continuity (SPEC: canvas dims, no inner scroller) */
  background: color-mix(in srgb, var(--paper) 93%, transparent);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
html.at-dusk .s4 { background: color-mix(in srgb, #1D242D 93%, transparent); border-color: #2A323D; color: #C9CFD8; }
html.at-dusk .s4 h2, html.at-dusk .s4 h3 { color: #E9ECF0; }
.s4-heading { max-width: 1280px; margin: 0 auto; }
.project-grid {
  max-width: 1280px;
  margin: 40px auto 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(20px, 2.5vw, 36px);
}
.project { grid-column: span 2; }
.project:nth-child(1) { grid-column: span 4; }
.project:nth-child(2) { grid-column: span 2; }
.project-media {
  margin: 0 0 14px;
  background: var(--paper-shadow);
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.project:nth-child(1) .project-media { aspect-ratio: 16 / 9; }
.project-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.mono-caption { color: var(--blue); margin-top: 2px; }
html.at-dusk .mono-caption { color: var(--blue-dusk); }
.mono-meta { opacity: .72; margin-top: 2px; }
.project > p:last-child { margin-top: 8px; }

/* S5 practice: the dusk inversion happens across this section */
.s5 {
  min-height: 160vh;
  display: flex;
  justify-content: flex-end;
  padding: 30vh clamp(16px, 4vw, 64px);
}
.s5 .panel { position: sticky; top: 14vh; align-self: flex-start; }
.s5 .panel p { margin-top: 20px; }
.stat-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 0;
  padding: 0;
}
.stat-chips li {
  border: 1px solid var(--hairline);
  padding: 8px 12px;
}
html.at-dusk .stat-chips li { border-color: #2A323D; }

/* S6 contact: the finished building idles beneath */
.s6 {
  min-height: 110vh;
  display: flex;
  justify-content: flex-start;
  padding: 26vh clamp(16px, 4vw, 64px) 14vh;
}
.s6 .panel { position: sticky; top: 16vh; align-self: flex-start; }
.s6 .panel > p { margin-top: 20px; }
.contact-lines {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.contact-lines a { color: var(--blue); text-decoration: none; }
.contact-lines a:hover { text-decoration: underline; }
html.at-dusk .contact-lines a { color: var(--blue-dusk); }

/* ---------- Panel figures (S3 drawing set, S5 studio model) ---------- */

.panel-figure {
  margin: 26px 0 0;
}
.panel-figure img {
  width: 100%;
  height: auto;
  display: block;
}
.panel-figure figcaption {
  margin-top: 8px;
  opacity: .72;
}

/* ---------- Footer (B8 close: opaque, scrolls over the stage) ---------- */

.site-footer {
  position: relative;
  z-index: 6;
  min-height: 26vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 64px clamp(16px, 4vw, 64px) 40px;
  background: var(--dusk-lo);
  color: #C9CFD8;
}
.site-footer a { color: var(--blue-dusk); }
.footer-copy {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  opacity: .7;
}

/* ---------- Annotations layer (projected DOM labels) ---------- */

#annotations {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}
.annot {
  position: absolute;
  left: 0; top: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--blue);
  white-space: nowrap;
  opacity: 0;
}
html.at-dusk .annot { color: var(--blue-dusk); }
.annot .annot-leader {
  position: absolute;
  height: 1px;
  background: var(--blue-wash);
  transform-origin: 0 0;
  transition: background-color .15s, height .15s;
}
/* Pointer wake (Sol finding 9): the leader brightens, an anchor dot marks
   the element, and the label sits on a paper chip so it reads on any
   geometry tone. All land within 150ms of the wake. */
.annot.awake .annot-leader { background: var(--blue); height: 2px; }
html.at-dusk .annot.awake .annot-leader { background: var(--blue-dusk); }
.annot::after {
  content: '';
  position: absolute;
  left: -4px; top: 4px;
  width: 8px; height: 8px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transform: scale(0);
  transition: transform .18s;
}
.annot.awake::after { transform: scale(1); }
.annot .annot-label {
  background: rgba(246, 247, 245, .88);
  padding: 1px 5px;
  box-decoration-break: clone;
}
/* right-edge labels extend left of their anchor (main.js sets .flip) */
.annot.flip .annot-label { transform: translateX(calc(-100% - 12px)); }
html.at-dusk .annot .annot-label { background: rgba(23, 28, 35, .88); }

/* ---------- Diegetic title block (the drawing-sheet corner) ---------- */

#titleblock {
  position: fixed;
  right: clamp(12px, 2.5vw, 32px);
  bottom: clamp(12px, 2.5vw, 28px);
  z-index: 5;
  pointer-events: none;
  display: grid;
  border: 1px solid var(--blue-wash);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  min-width: 168px;
}
html.at-dusk #titleblock {
  background: color-mix(in srgb, #1D242D 88%, transparent);
  border-color: rgba(143, 170, 242, .5);
}
.tb-line {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--blue);
  padding: 5px 10px;
  border-top: 1px solid var(--blue-wash);
  white-space: nowrap;
  overflow: hidden;
  max-width: 0;
  transition: max-width .5s steps(18);
}
.tb-line:first-child { border-top: 0; }
html.at-dusk .tb-line { color: var(--blue-dusk); border-color: rgba(143, 170, 242, .35); }
#titleblock.draw .tb-line { max-width: 240px; }
#titleblock.draw .tb-2 { transition-delay: .25s; }
#titleblock.draw .tb-3 { transition-delay: .5s; }
#titleblock.draw .tb-4 { transition-delay: .75s; }
@media (max-width: 767px) {
  #titleblock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tb-line, #titleblock.draw .tb-line { max-width: 240px; transition: none; }
}

/* ---------- Perf HUD (?perf=1, gate G2b) ---------- */

#perf-hud {
  position: fixed;
  left: 8px; bottom: 8px;
  z-index: 60;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: rgba(20, 24, 30, .88);
  color: #D7F2C9;
  padding: 8px 10px;
  pointer-events: none;
  white-space: pre;
}

/* ---------- Phone recomposition ---------- */

@media (max-width: 767px) {
  /* two-line header: wordmark + CTA on top, anchors beneath (E6: both blind
     reviewers dinged the missing phone navigation) */
  .site-header {
    gap: 10px 12px;
    flex-wrap: wrap;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .site-nav {
    order: 3;
    width: 100%;
    gap: 18px;
    margin-left: 0;
  }
  .site-nav a {
    font-family: var(--font-mono);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .12em;
    padding: 6px 0;
  }
  .site-nav { gap: 22px; }
  .header-cta { margin-left: auto; }
  /* paper wash behind the hero copy: the taller phone header re-seated the
     sub over a plan line (mobile G4 catch); the wash holds >= 4.5:1 over
     any line work while reading as plain paper */
  .s1-inner {
    padding-top: 80px;
    max-width: none;
    background: linear-gradient(rgba(246, 247, 245, .94), rgba(246, 247, 245, .86));
  }
  html.at-dusk .s1-inner { background: linear-gradient(rgba(29, 36, 45, .94), rgba(29, 36, 45, .86)); }
  .s2, .s3, .s5, .s6 {
    justify-content: stretch;
    padding-left: 16px;
    padding-right: 16px;
  }
  /* Sol finding 3: a pinned ~42vh model window stays clear ABOVE each beat
     card; the card pins below it and scrolls on at section end. Compact
     padding keeps every card inside the lower window at 390x844. */
  .panel { max-width: none; width: 100%; padding: 20px 18px; }
  .s2 .panel, .s3 .panel, .s5 .panel, .s6 .panel { top: 42vh; }
  /* Sol pre-reveal (finding 3): the two-row header ate ~10vh of the model
     window mid-scroll. Once scrolled, the anchor row folds away (the header
     is fixed, so nothing reflows); it returns at the top of the page. */
  .site-header.scrolled .site-nav { display: none; }
  .sector-list { gap: 10px; }
  .sector-list li { padding-top: 9px; }
  .approach-grafs { margin-top: 16px; gap: 11px; }
  .project-grid { grid-template-columns: 1fr; }
  .project, .project:nth-child(1), .project:nth-child(2) { grid-column: auto; }
  .s1 { min-height: 180vh; }
  /* taller beat sections: the sticky card holds its 42vh pin long enough
     for the model window above it to tell the beat (raise, section, dusk) */
  .s2 { min-height: 260vh; }
  .s3 { min-height: 340vh; }
  .s5 { min-height: 240vh; }
  .s6 { min-height: 200vh; }
}

/* ---------- Reduced motion: completed dusk still, sections plain ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-header {
    background: var(--dusk-hi);
    border-bottom: 1px solid #2A323D;
  }
  .s1, .s2, .s3, .s5, .s6 { min-height: 0; }
  .s1-inner, .s2 .panel, .s3 .panel, .s5 .panel, .s6 .panel {
    position: static;
    min-height: 0;
  }
  .s1-inner { padding-top: 120px; padding-bottom: 48px; }
  .s2, .s3, .s5, .s6 { padding-top: 8vh; padding-bottom: 8vh; }
  #stage canvas { display: none; }
  #stage img.poster, #stage.live img.poster { opacity: 1; }
  #annotations { display: none; }
}

/* ---------- No-WebGL fold ---------- */

html.no-webgl #stage canvas { display: none; }
html.no-webgl #stage img.poster,
html.no-webgl #stage.live img.poster { opacity: 1; }
.stage-caption {
  position: fixed;
  right: 12px; bottom: 12px;
  z-index: 7;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  padding: 6px 10px;
  border: 1px solid var(--hairline);
}

/* ---------- Living render (the Ashland motion tile, Hugh's 1b) ---------- */

@media (min-width: 768px) {
  .project-wide { grid-column: span 6 !important; }
}
.project-media-live { position: relative; aspect-ratio: 21 / 9; }
.project-media-live video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .5s ease;
}
.project-media-live.playing video { opacity: 1; }
.media-note {
  position: absolute;
  right: 10px; bottom: 8px;
  margin: 0;
  color: #E9ECF0;
  background: rgba(23, 28, 35, .62);
  padding: 4px 8px;
}
@media (prefers-reduced-motion: reduce) {
  .project-media-live video { display: none; }
}
