/* app.css — global resets, layout, motion primitives, and helpers.
   Design tokens (colors, type, spacing) live in tokens.css.
   Scroll is driven by Lenis (darkroom.engineering/lenis); anchor jumps are
   handed to the Lenis instance from App.jsx, so we no longer set
   `html { scroll-behavior: smooth }` (it would double-smooth). */

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

html, body { width: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--highlight-wash); }
:focus-visible { outline: 1px solid var(--vermilion); outline-offset: 3px; }

/* ============================================================
   PAGE SHELL — collapsible rail + scrolling content column
   ============================================================ */
.site { display: flex; align-items: flex-start; }
.rail {
  flex: 0 0 auto; width: var(--rail-w); position: sticky; top: 0; height: 100vh; z-index: 40;
  transition: width 460ms var(--ease-cinematic); overflow: hidden;
}
.site.nav-collapsed .rail { width: 60px; }
.content { flex: 1 1 auto; min-width: 0; }
.section { padding: var(--section-pad); scroll-margin-top: 58px; }

/* rail collapse toggle */
.rail-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: none; border: 1px solid var(--rule-strong); padding: 7px 10px;
  font-family: var(--font-micro); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3); transition: color 220ms var(--ease-soft), border-color 220ms var(--ease-soft);
}
.rail-toggle:hover { color: var(--vermilion); border-color: var(--vermilion); }

/* mobile top bar + full-screen menu */
.mobilebar {
  display: none; position: sticky; top: 0; z-index: 60;
  align-items: center; justify-content: space-between;
  height: 58px; padding: 0 20px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--rule);
}
.mobilemenu {
  position: fixed; inset: 0; z-index: 80; background: var(--paper);
  display: flex; flex-direction: column; padding: 22px 24px 30px; overflow-y: auto;
  animation: menufade 260ms var(--ease-soft);
}
@keyframes menufade { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   RESPONSIVE COLUMN HELPERS (media queries can't touch inline styles,
   so section grids opt into these classes)
   ============================================================ */
.cols { display: grid; gap: clamp(28px, 4vw, 64px); }
.cols--intro    { grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.72fr); align-items: center; }
.cols--mainrail { grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); align-items: start; }
.cols--notes    { grid-template-columns: minmax(0, 0.36fr) minmax(0, 1fr); align-items: start; }
.cols--about    { grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr); align-items: start; }
.cols--resume   { grid-template-columns: minmax(0, 0.6fr) minmax(0, 1.4fr); align-items: center; }
.cols--contact  { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.cols--media    { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
.cols--colophon { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols--elsewhere{ grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Work — irregular magazine columns */
.workgrid { column-count: 3; column-gap: clamp(18px, 2vw, 30px); }
.workcard { break-inside: avoid; margin-bottom: clamp(20px, 2.4vw, 34px); }

/* Résumé sheet body — two manual columns of sections, one on small screens */
.resume-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 clamp(18px, 2.4vw, 34px); }
@media (max-width: 640px) { .resume-body { grid-template-columns: minmax(0, 1fr); } }

/* ============================================================
   HORIZONTAL REELS & FILMSTRIPS
   ============================================================ */
.reel, .filmstrip {
  display: flex; overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.reel > * { scroll-snap-align: start; }
.filmstrip > * { scroll-snap-align: center; }
.reel::-webkit-scrollbar, .filmstrip::-webkit-scrollbar { height: 4px; }
.reel::-webkit-scrollbar-thumb, .filmstrip::-webkit-scrollbar-thumb { background: var(--rule-strong); }
.reel::-webkit-scrollbar-track, .filmstrip::-webkit-scrollbar-track { background: var(--rule); }
.reel { scrollbar-width: none; }
.reel::-webkit-scrollbar { display: none; }

/* ============================================================
   FLIPPABLE ARTIFACT (Résumé) — 3D card turn
   ============================================================ */
.flip { perspective: 2200px; }
.flip-inner {
  position: relative; transform-style: preserve-3d;
  transition: transform 900ms var(--ease-cinematic);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-back { position: absolute; inset: 0; transform: rotateY(180deg); }
.flip-shadow { box-shadow: 0 26px 60px rgba(20, 18, 15, 0.22); }

/* ============================================================
   GRAIN + MOTION PRIMITIVES
   ============================================================ */
.grain-field {
  position: absolute; inset: 0; opacity: 0.45; mix-blend-mode: multiply; pointer-events: none;
  background-image: radial-gradient(rgba(20,18,15,0.22) 0.5px, transparent 0.6px);
  background-size: 3px 3px;
}
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes bounce { 0%,100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
@keyframes rise   { from { transform: translateY(0); } to { transform: translateY(-50%); } }
@keyframes driftX { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes nudge  { 0%,100% { transform: translateY(0); opacity: .45; } 50% { transform: translateY(4px); opacity: 1; } }
@keyframes pulse  { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }
@keyframes stopmo { to { transform: translateX(-50%); } }
@keyframes float  { 0%,100% { transform: translateY(0) rotate(var(--tilt, 0deg)); } 50% { transform: translateY(-6px) rotate(var(--tilt, 0deg)); } }

.stars-pop:hover span { transform: translateY(-2px) scale(1.18) !important; }
.stopmo-track { display: flex; gap: 8px; width: max-content; animation: stopmo 9s steps(14) infinite; }

image-slot { width: 100%; height: 100%; display: block; }

/* ============================================================
   BREAKPOINTS
   ============================================================ */
@media (min-width: 981px) { .mobilebar { display: none !important; } }

@media (max-width: 1200px) and (min-width: 981px) {
  .workgrid { column-count: 2; }
  .cols--elsewhere { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 40px; }
}

@media (max-width: 980px) {
  .site { flex-direction: column; }
  .rail { display: none; }
  .mobilebar { display: flex; }
  .cols--intro, .cols--mainrail, .cols--notes, .cols--about,
  .cols--resume, .cols--contact, .cols--media { grid-template-columns: minmax(0, 1fr); }
  .cols--colophon { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .cols--elsewhere { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
  .workgrid { column-count: 1; }
  .cols--contact { align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .flip-inner { transition: none; }
}
