/* =========================================================================
   cyanotype.css — shared foundation
   Loaded by every page in the cyanotype design. Page-specific styles
   live in css/{page}-cyanotype.css and extend these primitives.

   Index:
     1.  Variables & themes
     2.  Reset & base
     3.  Typography
     4.  Page atmosphere (grain, exposure)
     5.  Botanical decorations
     6.  Topbar (breadcrumb + controls)
     7.  Hero / Folio block
     8.  Specimen plate primitives
     9.  Marginalia note
    10.  Buttons & links
    11.  Footer print-stamp
    12.  Lightbox
    13.  Reveal animations
    14.  Responsive
   ========================================================================= */


/* 1. Variables & themes -------------------------------------------------- */

:root {
  /* Palette */
  --ink-deep:  #061a36;
  --ink:       #0a2f5c;
  --ink-mid:   #1a4d8c;
  --ink-soft:  #6b9dc7;
  --cream:     #f4ecd5;
  --cream-mute:#c9bfa3;
  --paper:     #e8dfc8;
  --paper-edge:#d8ccaf;
  --warm:      #c47e4d;       /* sand/rust accent (used sparingly) */

  /* Theme tokens — overridden by [data-theme] below */
  --bg:           var(--paper);
  --surface:      var(--cream);
  --fg:           var(--ink-deep);
  --fg-mute:      var(--ink-mid);
  --accent:       var(--ink-mid);
  --accent-visited: #5a4a6e;
  --line:         rgba(10, 47, 92, 0.28);
  --plate-bg:     var(--cream);
  --plate-fg:     var(--ink-deep);
  --plate-rule:   rgba(10, 47, 92, 0.28);
  --plate-id-fg:  rgba(10, 47, 92, 0.70);
  --plate-shadow: 0 14px 28px -14px rgba(10, 47, 92, 0.30),
                  inset 0 0 60px rgba(10, 47, 92, 0.04);
  --grain-blend:  multiply;
  --grain-opacity: 0.22;
  --exposure:
    radial-gradient(ellipse at 18% 8%, rgba(10, 47, 92, 0.10), transparent 55%),
    radial-gradient(ellipse at 82% 92%, rgba(10, 47, 92, 0.18), transparent 60%);
  --exposure-blend: multiply;

  /* Spacing (4px base) */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px;  --sp-6: 24px;  --sp-7: 28px;  --sp-8: 32px;
  --sp-10: 40px; --sp-12: 48px; --sp-14: 56px; --sp-16: 64px;
  --sp-20: 80px; --sp-24: 96px;

  /* Type scale (fixed sizes only; display sizes use clamp()) */
  --text-2xs: 9px;
  --text-xs:  10px;
  --text-sm:  11px;
  --text-base: 13.5px;
  --text-md:  14px;

  /* Motion */
  --ease:       cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-fast:     180ms;
  --t-med:      400ms;
  --t-theme:    600ms;
}

[data-theme="night"] {
  --bg:           var(--ink-deep);
  --surface:      var(--ink);
  --fg:           var(--cream);
  --fg-mute:      var(--cream-mute);
  --accent:       var(--ink-soft);
  --accent-visited: #b8a3c9;
  --line:         rgba(244, 236, 213, 0.22);
  --plate-bg:     #0e3666;
  --plate-fg:     var(--cream);
  --plate-rule:   rgba(244, 236, 213, 0.30);
  --plate-id-fg:  rgba(244, 236, 213, 0.75);
  --plate-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.55),
                  inset 0 0 80px rgba(255, 255, 255, 0.04);
  --grain-blend:  overlay;
  --grain-opacity: 0.18;
  --exposure:
    radial-gradient(ellipse at 18% 8%, rgba(255, 255, 255, 0.06), transparent 55%),
    radial-gradient(ellipse at 82% 92%, rgba(0, 0, 0, 0.35), transparent 60%);
  --exposure-blend: soft-light;
}


/* 2. Reset & base -------------------------------------------------------- */

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

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

body {
  font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  font-optical-sizing: auto;
  font-feature-settings: "liga" 1, "kern" 1;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  letter-spacing: 0.005em;
  line-height: 1.55;
  transition: background var(--t-theme) ease, color var(--t-theme) ease;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast) ease; }
a:hover { color: var(--fg); }
.stage a:visited,
.field-note a:visited { color: var(--accent-visited); }


/* 3. Typography ---------------------------------------------------------- */

.display, h1.display {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-style: normal;
  letter-spacing: -0.02em;
  line-height: 0.95;
}

.display em, .display i, em.display { font-style: italic; font-weight: 400; }

.serif    { font-family: 'Fraunces', serif; }
.italic   { font-style: italic; }

.mono {
  font-family: 'IBM Plex Mono', ui-monospace, 'Menlo', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.label {
  font-family: 'IBM Plex Mono', ui-monospace, 'Menlo', monospace;
  font-size: var(--text-sm);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-mute);
}

.caption {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.92em;
  color: var(--fg-mute);
  line-height: 1.6;
}


/* 4. Page atmosphere ----------------------------------------------------- */

/* Paper grain — SVG fractal noise, blended with surface */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

/* Uneven exposure — sun-bright top-left, shadow bottom-right */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: var(--exposure);
  mix-blend-mode: var(--exposure-blend);
}


/* 5. Botanical decorations ---------------------------------------------- */

.botanical {
  position: fixed;
  pointer-events: none;
  opacity: 0.18;
  z-index: 0;
  color: var(--fg);
}
.botanical svg { display: block; width: 100%; height: 100%; }
.botanical svg path { fill: currentColor; }
.botanical.left  { top: -40px; left: -60px; width: 380px; height: 520px; transform: rotate(-12deg); }
.botanical.right { bottom: -80px; right: -80px; width: 460px; height: 600px; transform: rotate(8deg) scaleX(-1); }
[data-theme="paper"] .botanical { opacity: 0.22; }


/* 6. Topbar -------------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-6) var(--sp-8);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-sm);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.topbar .meta { display: flex; gap: var(--sp-7); align-items: center; flex-wrap: wrap; }
.topbar .meta > * { display: inline-flex; align-items: center; gap: var(--sp-2); }
.topbar .controls { display: flex; gap: var(--sp-3); align-items: center; }

/* Folio running header — used on every page except the index.
   Left: prominent current-folio block (mono eyebrow + serif title).
   Right: small mono links to the other folios + controls. */
.folio-running {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-6);
  padding: var(--sp-6) var(--sp-8) 18px;
  border-bottom: 1px solid var(--line);
}
.folio-running .here { line-height: 1; }
.folio-running .here .eyebrow {
  display: block;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-xs);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
}
.folio-running .here .title {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.4vw, 26px);
  letter-spacing: 0.005em;
  color: var(--fg);
}
.folio-running .links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-xs);
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.folio-running .links a {
  color: var(--fg-mute);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) ease, border-color var(--t-fast) ease;
  position: relative;
}
.folio-running .links a::after {
  content: "";
  position: absolute;
  inset: -12px -6px;
}
.folio-running .links a:hover {
  color: var(--fg);
  border-bottom-color: var(--line);
}
.folio-running .links a.home { color: var(--fg); }
.folio-running .links a.home::before {
  content: "↩";
  font-family: inherit;
  letter-spacing: 0;
  margin-right: 2px;
  opacity: 0.85;
}
.folio-running .controls {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin-left: 4px;
}

/* Topbar icon button (theme toggle, about, etc.) */
.icon-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: var(--text-md);
  transition: background var(--t-fast) ease,
              transform var(--t-med) var(--ease),
              border-color var(--t-fast) ease,
              color var(--t-fast) ease;
}
.icon-btn:hover {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
  transform: rotate(20deg);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}


/* 7. Hero / Folio block -------------------------------------------------- */

.stage {
  position: relative;
  z-index: 5;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-10) var(--sp-12) var(--sp-20);
}

.plate-no {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-sm);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-mute);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.plate-no::before { content: ""; flex: 0 0 36px; height: 1px; background: var(--line); }
.plate-no::after  { content: ""; flex: 1;        height: 1px; background: var(--line); }

.folio-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}
.folio-title em { font-style: italic; font-weight: 400; color: var(--fg-mute); }

.folio-subtitle {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-base);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-mute);
  border-top: 1px solid var(--line);
  padding-top: 18px;
  max-width: 640px;
  line-height: 1.9;
  margin-bottom: 56px;
}


/* 8. Specimen plate primitives ------------------------------------------ */

.plate {
  position: relative;
  background: var(--plate-bg);
  color: var(--plate-fg);
  border: 1px solid var(--line);
  padding: 22px 20px 18px;
  overflow: hidden;
  box-shadow: var(--plate-shadow);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: transform var(--t-med) var(--ease),
              box-shadow var(--t-med) ease;
}
.plate:hover { transform: translateY(-4px); }
.plate.is-link { cursor: pointer; }

/* Subtle paper grain inside the plate (optional) */
.plate::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.93  0 0 0 0 0.84  0 0 0 0.4 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.10;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* Registration corner marks (4 per plate) */
.plate .corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--plate-rule);
  pointer-events: none;
}
.plate .corner.tl { top: 8px;    left: 8px;    border-right: none; border-bottom: none; }
.plate .corner.tr { top: 8px;    right: 8px;   border-left: none;  border-bottom: none; }
.plate .corner.bl { bottom: 8px; left: 8px;    border-right: none; border-top: none; }
.plate .corner.br { bottom: 8px; right: 8px;   border-left: none;  border-top: none; }

.plate .plate-id {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-sm);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--plate-id-fg);
  position: relative;
  z-index: 1;
}

.plate .plate-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.plate .plate-label {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-size: var(--text-lg);
  letter-spacing: 0.01em;
  border-top: 1px solid var(--plate-rule);
  padding-top: 10px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.plate .plate-label .latin {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-style: normal;
  font-size: var(--text-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--plate-id-fg);
}

/* Cream-framed image inside a plate (specimen card) */
.plate-image {
  background: var(--cream);
  padding: 6px;
  border: 1px solid var(--plate-rule);
  position: relative;
  z-index: 1;
}
.plate-image img { display: block; width: 100%; height: auto; }


/* 9. Marginalia note ----------------------------------------------------- */

.marginalia {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--fg-mute);
  max-width: 320px;
  line-height: 1.6;
  position: relative;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.marginalia .attr {
  display: block;
  margin-top: var(--sp-2);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-style: normal;
  font-size: var(--text-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--plate-id-fg);
}


/* 10. Buttons & links --------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: var(--sp-3) 18px;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-sm);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast) ease,
              color var(--t-fast) ease,
              border-color var(--t-fast) ease;
}
.btn:hover {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.btn-ghost { border-color: transparent; padding-left: 0; padding-right: 0; }
.btn-ghost:hover { background: transparent; color: var(--fg); border-color: transparent; text-decoration: underline; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 36px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-sm);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--fg-mute);
  text-decoration: none;
  border: none;
  padding: 0;
  transition: color var(--t-fast) ease;
}
.back-link::before { content: "\2190"; letter-spacing: 0; opacity: 0.85; }
.back-link:hover { color: var(--fg); }

a.text-link {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
  transition: border-color var(--t-fast) ease;
}
a.text-link:hover { border-color: currentColor; }

a:focus-visible,
.back-link:focus-visible,
.tech-bubble:focus-visible,
.specimen:focus-visible,
#scroll-prompt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}


/* 11. Footer print-stamp ------------------------------------------------ */

.print-stamp {
  margin-top: var(--sp-20);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--text-xs);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-mute);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: var(--sp-6);
}
.print-stamp .seal {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
}
.print-stamp .seal::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 157, 199, 0.18);
}


/* 12. Lightbox ---------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 26, 54, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-med) ease,
              visibility var(--t-med) ease;
  cursor: zoom-out;
}
.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox-frame {
  max-width: 90vw;
  max-height: 88vh;
  background: var(--cream);
  padding: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lightbox-frame img {
  max-width: 100%;
  max-height: calc(88vh - 80px);
  object-fit: contain;
  display: block;
}
.lightbox-caption {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-deep);
  text-align: center;
  padding: 4px 8px 6px;
}
.lightbox-close {
  position: absolute;
  top: -36px;
  right: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cream);
  background: transparent;
  border: 1px solid rgba(244, 236, 213, 0.4);
  padding: 6px 10px;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(244, 236, 213, 0.12); }


/* 13. Reveal animations ------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 900ms var(--ease) forwards;
}
.reveal.d1 { animation-delay:  80ms; }
.reveal.d2 { animation-delay: 200ms; }
.reveal.d3 { animation-delay: 360ms; }
.reveal.d4 { animation-delay: 520ms; }
.reveal.d5 { animation-delay: 680ms; }
.reveal.d6 { animation-delay: 840ms; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; animation: none; }
  .icon-btn:hover { transform: none; }
  .plate:hover { transform: none; }
}


/* 14. Responsive -------------------------------------------------------- */

@media (max-width: 900px) {
  .topbar { padding: var(--sp-4) 22px; flex-wrap: wrap; gap: 14px; }
  .topbar .meta { gap: var(--sp-4); font-size: var(--text-xs); }
  .stage { padding: var(--sp-6) 22px 60px; }
  .folio-subtitle { margin-bottom: 36px; }
  .folio-running {
    padding: var(--sp-4) 22px 14px;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .folio-running .links { gap: 14px; font-size: var(--text-xs); letter-spacing: 0.22em; }
}

@media (max-width: 600px) {
  .folio-running .here .title { font-size: 18px; }
  .folio-running .links { gap: 10px; }
  .botanical.left  { width: 240px; height: 320px; opacity: 0.10; }
  .botanical.right { width: 280px; height: 360px; opacity: 0.10; }
  .print-stamp { font-size: var(--text-2xs); }
}
