/* ============================================================
   FirstFold Studio — "a freshly folded broadsheet under
   morning studio light, moving like paper unfolding."
   ============================================================ */

:root {
  --paper: #F8F5EE;
  --paper-deep: #EFEADE;
  --ink: #1A1712;
  --ink-muted: #5A5344;
  --ink-faint: rgba(26, 23, 18, 0.16);
  --ink-hairline: rgba(26, 23, 18, 0.28);
  --press-red: #C2391D;
  --press-red-deep: #A62F16;
  --paper-on-ink: #F4F0E6;
  --muted-on-ink: #B0A794;

  --font-serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", "Cascadia Code", Consolas, monospace;

  --ease-paper: cubic-bezier(0.16, 1, 0.3, 1);
  --measure: 62ch;
  --pad-x: clamp(20px, 5vw, 72px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--press-red); color: var(--paper-on-ink); }

a { color: inherit; }

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  background: var(--ink);
  color: var(--paper-on-ink);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 16px;
  text-decoration: none;
  transition: top 0.2s var(--ease-paper);
}
.skip-link:focus-visible { top: 12px; }

/* ---------- Masthead ---------- */

.dateline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px var(--pad-x);
  border-bottom: 1px solid var(--ink-hairline);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.masthead {
  padding: clamp(20px, 3.5vw, 40px) var(--pad-x) 0;
  text-align: center;
  border-bottom: 3px double var(--ink);
}

.masthead-brand {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 700;
  font-optical-sizing: auto;
  letter-spacing: -0.02em;
  line-height: 1;
}
.masthead-brand a { text-decoration: none; }
.masthead-brand em, .mini-brand em, .footer-brand em {
  font-style: italic;
  font-weight: 500;
}

.masthead-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(16px, 3vw, 36px);
  margin-top: clamp(16px, 2.5vw, 28px);
  padding: 14px 0;
  border-top: 1px solid var(--ink-hairline);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.masthead-nav a {
  text-decoration: none;
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease-paper), color 0.2s var(--ease-paper);
}
.masthead-nav a:hover { border-bottom-color: var(--ink); }
.masthead-nav a:focus-visible,
.footer-nav a:focus-visible {
  outline: 2px solid var(--press-red);
  outline-offset: 3px;
}
.masthead-nav a:active { color: var(--press-red); }

.masthead-nav .nav-cta {
  color: var(--press-red);
  border-bottom-color: var(--press-red);
}
.masthead-nav .nav-cta:hover {
  color: var(--press-red-deep);
  border-bottom-color: var(--press-red-deep);
}

/* ---------- Mini nav (appears past hero) ---------- */

.mini-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--pad-x);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--ink-hairline);
  transform: translateY(-110%);
  transition: transform 0.35s var(--ease-paper);
}
.mini-nav.show { transform: translateY(0); }
.mini-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

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

.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 16px 28px;
  border: 1px solid transparent;
  transition: background 0.2s var(--ease-paper), color 0.2s var(--ease-paper),
              border-color 0.2s var(--ease-paper), transform 0.2s var(--ease-paper),
              box-shadow 0.2s var(--ease-paper);
}
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.btn-primary {
  background: var(--press-red);
  color: var(--paper-on-ink);
  box-shadow: 0 1px 0 rgba(26,23,18,0.2), 0 6px 18px rgba(194,57,29,0.22);
}
.btn-primary:hover {
  background: var(--press-red-deep);
  transform: translateY(-1px);
  box-shadow: 0 2px 0 rgba(26,23,18,0.2), 0 10px 24px rgba(194,57,29,0.28);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 0 rgba(26,23,18,0.2); }

.btn-ghost {
  border-color: var(--ink-hairline);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper-on-ink); border-color: var(--ink); }
.btn-ghost:active { background: var(--press-red-deep); border-color: var(--press-red-deep); }

.btn-small { padding: 10px 18px; font-size: 12px; }

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

.hero {
  padding: clamp(72px, 10vw, 140px) var(--pad-x) clamp(64px, 8vw, 110px);
}

.eyebrow, .kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.eyebrow { margin-bottom: clamp(20px, 3vw, 32px); }

.hero-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.9rem, 8vw, 6.8rem);
  line-height: 0.98;
  letter-spacing: -0.028em;
  max-width: 26ch;
}

.flip { display: inline-block; }
.flip-stage {
  display: inline-block;
  perspective: 900px;
  vertical-align: bottom;
  white-space: nowrap;
}
html.js .flip-stage {
  transition: width 0.4s var(--ease-paper);
}
@media (prefers-reduced-motion: reduce) {
  html.js .flip-stage { transition: none; }
}
.flip-word {
  display: inline-block;
  font-style: italic;
  font-weight: 500;
  color: var(--press-red);
  transform-origin: 50% 100%;
  will-change: transform, opacity;
}
.hero-period { color: var(--ink); }

html.js .flip-word.fold-out {
  animation: foldOut 0.34s cubic-bezier(0.5, 0, 0.75, 0) forwards;
}
html.js .flip-word.fold-in {
  animation: foldIn 0.55s var(--ease-paper);
}
@keyframes foldOut {
  to { transform: rotateX(90deg); opacity: 0; }
}
@keyframes foldIn {
  from { transform: rotateX(-90deg); opacity: 0; }
  to   { transform: rotateX(0deg); opacity: 1; }
}

.hero-deck {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 48px;
  margin-top: clamp(40px, 6vw, 72px);
  flex-wrap: wrap;
}

.hero-sub {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 42ch;
}

.hero-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.hero-actions .btn-ghost { margin-top: 0; }
.hero-actions .btn + .btn { margin-top: 0; }
.friction {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

/* ---------- The fold line ---------- */

.fold-line {
  position: relative;
  height: 56px;
  background:
    linear-gradient(to bottom,
      var(--paper) 0%,
      rgba(26,23,18,0.055) 47%,
      rgba(26,23,18,0.12) 50%,
      rgba(255,255,255,0.5) 53%,
      var(--paper-deep) 100%);
}
.fold-line::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px dashed var(--ink-hairline);
}
.fold-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  background: var(--paper);
  border: 1px solid var(--ink-hairline);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- The First Fold scene ---------- */

.scene {
  height: 320vh;
  background: var(--ink);
  padding: 0;
}
.scene-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.scene-fallback,
.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
html.js .scene-fallback.scene-hidden { visibility: hidden; }
.scene-canvas { display: none; }
html.js .scene-canvas { display: block; }
.scene-scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(to top, rgba(26, 23, 18, 0.72), transparent);
}
.scene-copy {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0 var(--pad-x) clamp(72px, 12vh, 128px);
  display: grid;
}
.scene-beat {
  grid-area: 1 / 1;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.6rem, 4.5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--paper-on-ink);
  max-width: 22ch;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s var(--ease-paper), transform 0.5s var(--ease-paper);
}
.scene-beat.is-on { opacity: 1; transform: none; }
.scene-label {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-on-ink);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .scene { height: auto; }
  .scene-pin { position: relative; height: 100vh; }
  html.js .scene-canvas { display: none; }
  html.js .scene-fallback.scene-hidden { visibility: visible; }
  .scene-beat { opacity: 0; }
  .scene-beat[data-beat="2"] { opacity: 1; transform: none; }
}

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

section { padding: clamp(72px, 9vw, 128px) var(--pad-x); }

.section-head { margin-bottom: clamp(40px, 5vw, 64px); }
.section-head .kicker { margin-bottom: 12px; }

h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  max-width: 24ch;
}

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

.work {
  background: var(--paper-deep);
  padding-top: clamp(64px, 8vw, 112px);
}

.work-list { list-style: none; border-top: 1px solid var(--ink-hairline); }

.work-row {
  display: grid;
  grid-template-columns: 56px 1fr auto 40px;
  align-items: baseline;
  gap: 20px;
  padding: 28px 8px;
  border-bottom: 1px solid var(--ink-hairline);
  text-decoration: none;
  transition: background 0.25s var(--ease-paper), color 0.25s var(--ease-paper),
              padding-left 0.25s var(--ease-paper);
}
.work-row:hover, .work-row:focus-visible {
  background: var(--ink);
  color: var(--paper-on-ink);
  padding-left: 20px;
}
.work-row:focus-visible { outline: 2px solid var(--press-red); outline-offset: -2px; }
.work-row:active { background: var(--press-red-deep); }

.work-index {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  transition: color 0.25s var(--ease-paper);
}
.work-row:hover .work-index, .work-row:focus-visible .work-index { color: var(--muted-on-ink); }

.work-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.work-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.05;
}

.work-note {
  font-size: 15px;
  color: var(--ink-muted);
  transition: color 0.25s var(--ease-paper);
  max-width: 52ch;
}
.work-row:hover .work-note, .work-row:focus-visible .work-note { color: var(--muted-on-ink); }

.work-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  transition: color 0.25s var(--ease-paper);
  white-space: nowrap;
}
.work-row:hover .work-meta, .work-row:focus-visible .work-meta { color: var(--muted-on-ink); }

.work-arrow {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  transform: translateX(-6px);
  opacity: 0;
  transition: transform 0.25s var(--ease-paper), opacity 0.25s var(--ease-paper);
}
.work-row:hover .work-arrow, .work-row:focus-visible .work-arrow {
  transform: translateX(0);
  opacity: 1;
}

/* ---------- Services ---------- */

.service-rows { border-top: 1px solid var(--ink-hairline); }

.service-row {
  display: grid;
  grid-template-columns: minmax(80px, 220px) 1fr;
  gap: clamp(20px, 4vw, 64px);
  padding: clamp(32px, 4vw, 48px) 0;
  border-bottom: 1px solid var(--ink-hairline);
}

.service-no {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--press-red);
}

.service-text h3 {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin-bottom: 12px;
}
.service-text p { color: var(--ink-muted); max-width: var(--measure); }

/* ---------- AI visibility ---------- */

.ai {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
  background: var(--paper-deep);
}

.ai-copy .kicker { margin-bottom: 12px; }
.ai-copy h2 { margin-bottom: 24px; }
.ai-copy p { color: var(--ink-muted); max-width: 52ch; margin-bottom: 16px; }
.ai-copy .btn { margin-top: 16px; }

.ai-panel {
  background: var(--ink);
  color: var(--muted-on-ink);
  border: 1px solid var(--ink);
  box-shadow: 0 1px 0 rgba(26,23,18,0.3), 0 16px 40px rgba(26,23,18,0.18);
}
.ai-panel-head {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(244,240,230,0.14);
  color: var(--muted-on-ink);
}
.ai-panel-body {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.9;
  padding: 24px 20px 28px;
  color: var(--paper-on-ink);
  overflow-x: auto;
  white-space: pre;
}

/* ---------- Editions ---------- */

.editions {
  text-align: left;
  border-bottom: 1px solid var(--ink-hairline);
}
.editions .kicker { margin-bottom: 12px; color: var(--press-red); }
.editions h2 { margin-bottom: 16px; }
.editions p { color: var(--ink-muted); max-width: var(--measure); margin-bottom: 24px; }

.editions-link {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.3rem;
  text-decoration: none;
  border-bottom: 1px solid var(--ink-hairline);
  padding-bottom: 2px;
  transition: color 0.2s var(--ease-paper), border-color 0.2s var(--ease-paper);
}
.editions-link:hover { color: var(--press-red); border-bottom-color: var(--press-red); }
.editions-link:focus-visible { outline: 2px solid var(--press-red); outline-offset: 4px; }
.editions-link:active { color: var(--press-red-deep); }

/* ---------- Close ---------- */

.close {
  background: var(--ink);
  color: var(--paper-on-ink);
  text-align: center;
  padding-top: clamp(88px, 11vw, 150px);
  padding-bottom: clamp(88px, 11vw, 150px);
}
.close-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.kicker-invert { color: var(--muted-on-ink); }
.close h2 { color: var(--paper-on-ink); }
.close p { color: var(--muted-on-ink); max-width: 44ch; }
.close .btn-primary { margin-top: 8px; }
.close-alt { font-size: 14px; }
.close-alt a {
  color: var(--paper-on-ink);
  text-underline-offset: 3px;
  transition: color 0.2s var(--ease-paper);
}
.close-alt a:hover { color: var(--press-red); }
.close-alt a:focus-visible { outline: 2px solid var(--press-red); outline-offset: 3px; }

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

.footer {
  padding: clamp(40px, 5vw, 64px) var(--pad-x);
  border-top: 3px double var(--ink);
}
.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.footer-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}
.footer-nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.footer-nav a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease-paper);
}
.footer-nav a:hover { border-bottom-color: var(--ink); }
.footer-nav a:active { color: var(--press-red); }

.colophon {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

/* ---------- Reveal (JS-gated) ---------- */

html.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
}
html.js [data-reveal].in {
  opacity: 1;
  transform: none;
  transition: opacity 0.65s var(--ease-paper), transform 0.65s var(--ease-paper);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] { opacity: 1; transform: none; transition: none; }
  html.js .flip-word.fold-out, html.js .flip-word.fold-in { animation: none; }
  .btn, .work-row, .work-arrow, .mini-nav { transition: none; }
}

/* ---------- Mobile ---------- */

@media (max-width: 820px) {
  .ai { grid-template-columns: minmax(0, 1fr); }
  .ai-copy, .ai-panel { min-width: 0; }
  .service-row { grid-template-columns: 1fr; gap: 12px; }
  .hero-deck { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .dateline { font-size: 10px; letter-spacing: 0.1em; }
  .dateline-right { display: none; }
  .masthead-nav { gap: 18px; font-size: 11px; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; padding-bottom: 16px; scrollbar-width: none; }
  .masthead-nav::-webkit-scrollbar { display: none; }
  .masthead-nav a { white-space: nowrap; flex-shrink: 0; }
  .work-row { grid-template-columns: 32px 1fr; grid-template-rows: auto auto; gap: 8px 16px; padding: 24px 4px; }
  .work-meta { grid-column: 2; grid-row: 2; }
  .work-arrow { display: none; }
  .work-row:hover, .work-row:focus-visible { padding-left: 4px; }
  .hero { padding-top: 56px; }
  .hero-title { font-size: clamp(2.5rem, 11.5vw, 3.4rem); }
  .fold-label { font-size: 9.5px; letter-spacing: 0.12em; }
  .btn { padding: 14px 22px; }
  section { padding-top: 72px; padding-bottom: 72px; }
}
