/* =========================================================================
   THE RECURSION ATLAS
   Aesthetic: archival observatory plate-book. Warm near-black, bone ink,
   a single vermilion accent + muted brass. Fraunces display serif paired
   with IBM Plex Mono for catalog marks. Asymmetric specimen grid.
   ========================================================================= */

:root {
  --bg:        #120f17;   /* warm violet-black */
  --bg-2:      #181320;   /* raised panel       */
  --bg-3:      #20192a;   /* canvas matte       */
  --ink:       #ece0d0;   /* warm bone          */
  --ink-soft:  #b8aa9a;
  --ink-mute:  #82766c;
  --line:      #322a3c;
  --accent:    #e0633a;   /* vermilion          */
  --accent-2:  #c9a24b;   /* muted brass        */
  --shadow:    0 24px 60px -28px rgba(0,0,0,.85);

  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --edge: clamp(1.1rem, 4vw, 4.5rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* faint radial vignette + warm top glow for depth */
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(224,99,58,.10), transparent 55%),
    radial-gradient(100% 60% at 50% 120%, rgba(201,162,75,.06), transparent 60%);
  background-attachment: fixed;
}

/* --- film grain overlay (fixed, never scrolls/repaints content) --- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: .04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

em { font-style: italic; color: var(--ink); }

/* =========================== MASTHEAD =================================== */
.masthead {
  padding: clamp(2.5rem, 7vw, 6rem) var(--edge) clamp(1.5rem, 4vw, 3rem);
  max-width: 1500px;
  margin: 0 auto;
}
.masthead__row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .22em;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}
.masthead__mark--right { text-align: right; }

.masthead__title {
  font-weight: 400;
  font-size: clamp(3.4rem, 15vw, 12rem);
  line-height: .86;
  letter-spacing: -.02em;
  margin: clamp(1.5rem, 5vw, 3.5rem) 0 0;
  font-optical-sizing: auto;
}
.masthead__title-line { display: block; }
.masthead__title-line--accent {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
  padding-left: clamp(2rem, 12vw, 9rem);
  margin-top: -.06em;
}

.masthead__sub {
  max-width: 46ch;
  margin: clamp(1.6rem, 4vw, 2.5rem) 0 0 auto;
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  color: var(--ink-soft);
  text-align: left;
}
.masthead__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .2em;
  color: var(--ink-mute);
}
.masthead__meta .dot { color: var(--accent); }

/* staggered intro reveal */
.masthead__title-line, .masthead__sub, .masthead__meta, .masthead__row { animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
.masthead__row { animation-delay: .05s; }
.masthead__title-line:nth-child(1) { animation-delay: .12s; }
.masthead__title-line:nth-child(2) { animation-delay: .22s; }
.masthead__sub { animation-delay: .34s; }
.masthead__meta { animation-delay: .44s; }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

/* ============================ HERO ===================================== */
.hero {
  max-width: 1500px;
  margin: clamp(2rem, 5vw, 4rem) auto 0;
  padding: 0 var(--edge);
  display: grid;
  grid-template-columns: 1.55fr .9fr;
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: stretch;
}
.hero__frame {
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg-3);
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 11;
  overflow: hidden;
}
.hero__canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.hero__canvas:active { cursor: grabbing; }

.hero__hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: .6rem .85rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .08em;
  color: var(--ink-soft);
  background: linear-gradient(to top, rgba(10,8,14,.78), transparent);
  pointer-events: none;
}
.hero__loading {
  position: absolute; top: .8rem; right: .9rem;
  display: flex; gap: .3rem; opacity: 0; transition: opacity .25s;
}
.hero__loading.is-busy { opacity: 1; }
.hero__loading span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: blip 1s infinite ease-in-out;
}
.hero__loading span:nth-child(2) { animation-delay: .15s; }
.hero__loading span:nth-child(3) { animation-delay: .3s; }
@keyframes blip { 0%,100% { opacity: .25; transform: scale(.7);} 50% { opacity: 1; transform: scale(1);} }

.hero__caption {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: .4rem;
}
.plate-no {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .25em;
  color: var(--accent);
  text-transform: uppercase;
}
.plate-title {
  font-weight: 400;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.02;
  margin: .5rem 0 .8rem;
  letter-spacing: -.01em;
}
.hero__caption p, .plate__caption p {
  color: var(--ink-soft);
  font-size: .98rem;
  margin: 0 0 1.2rem;
  max-width: 42ch;
}
.hero__controls { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.hero__controls button {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .06em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  padding: .5rem .8rem;
  cursor: pointer;
  transition: border-color .25s, color .25s, background .25s, transform .15s;
}
.hero__controls button:hover { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.hero__controls button:active { transform: translateY(1px); }
.hero__controls .is-reset { border-color: var(--accent-2); color: var(--accent-2); }
.hero__controls .is-reset:hover { background: var(--accent-2); color: var(--bg); }
.hero__hint { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; color: var(--ink-mute); }

/* ============================ ATLAS GRID =============================== */
.atlas {
  max-width: 1500px;
  margin: clamp(3.5rem, 8vw, 7rem) auto 0;
  padding: 0 var(--edge);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(1.4rem, 2.6vw, 2.6rem);
}
.plate {
  grid-column: span 3;
  border: 1px solid var(--line);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color .4s, transform .4s;
}
.plate:hover { border-color: #463a52; }
.plate--wide { grid-column: span 4; }
.plate--tall { grid-column: span 2; }
/* keep the wide/tall row balanced on the second row */
#plate-julia { grid-column: span 4; }
#plate-clifford { grid-column: span 2; }
#plate-flow { grid-column: span 2; }
#plate-phyllotaxis { grid-column: span 4; }
#plate-harmonograph { grid-column: span 2; }

.plate__canvas-wrap {
  position: relative;
  background: var(--bg-3);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
#plate-harmonograph .plate__canvas-wrap { aspect-ratio: 3 / 4; }
.plate__canvas { display: block; width: 100%; height: 100%; }
.plate__caption { padding: clamp(1.1rem, 2vw, 1.7rem); }
.plate__caption .plate-title { font-size: clamp(1.4rem, 2.2vw, 1.9rem); }

/* reveal plates as they scroll into view */
.plate { opacity: 0; transform: translateY(28px); }
.plate.is-seen { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .plate { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* ============================ COLOPHON ================================ */
.colophon {
  max-width: 1500px;
  margin: clamp(4rem, 9vw, 8rem) auto 0;
  padding: 0 var(--edge) clamp(3rem, 7vw, 6rem);
}
.colophon__rule { height: 1px; background: var(--line); margin-bottom: 2.5rem; }
.colophon__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
}
.colophon__label {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: .7rem;
}
.colophon__grid p { color: var(--ink-soft); font-size: .92rem; margin: 0; max-width: 38ch; }
.colophon__sign {
  margin-top: clamp(2.5rem, 6vw, 5rem);
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .2em;
  color: var(--ink-mute);
  text-align: center;
}

/* ============================ RESPONSIVE ============================== */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero__frame { aspect-ratio: 4 / 3; }
  .atlas { grid-template-columns: repeat(2, 1fr); }
  .plate, .plate--wide, .plate--tall,
  #plate-julia, #plate-clifford, #plate-flow,
  #plate-phyllotaxis, #plate-harmonograph { grid-column: span 2; }
  .colophon__grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .masthead__title-line--accent { padding-left: 1.5rem; }
  .masthead__sub { margin-right: 0; }
}
