/* CAVEIA — cyanotype drawing-set system.
   One world for caveia.dev and caveia.dev/2045: Prussian-blue paper,
   white technical-pen line, revision-pencil orange reserved for actions. */

@font-face { font-family: "Big Shoulders"; src: url("../fonts/big-shoulders-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Big Shoulders"; src: url("../fonts/big-shoulders-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Big Shoulders"; src: url("../fonts/big-shoulders-900.woff2") format("woff2"); font-weight: 900; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: dark;

  /* Paper: cyanotype exposure from deep to washed. */
  --paper-950: #061a3a;
  --paper-900: #08214a;
  --paper-800: #0c2c5e;
  --paper-700: #133f80;
  --paper-600: #1a56a6;

  /* Line: technical pen on blueprint paper. */
  --line: #eaf4ff;
  --line-soft: rgba(234, 244, 255, 0.78);
  --line-faint: rgba(234, 244, 255, 0.46);
  --line-rule: rgba(234, 244, 255, 0.32);
  --grid-minor: rgba(234, 244, 255, 0.055);
  --grid-major: rgba(234, 244, 255, 0.12);

  /* Revision pencil: the single active accent (actions, live state). */
  --mark: #ff7a1a;
  --mark-ink: #08214a;


  --f-display: "Big Shoulders", "Barlow", sans-serif;
  --f-body: "Barlow", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;

  /* The 10-division graticule: every layout measure is a multiple of --cell. */
  --cell: 0.75rem;              /* 12px */
  --major: calc(var(--cell) * 10);

  --gutter: clamp(1rem, 4vw, 3.75rem);
  --sheet-inset: clamp(0.75rem, 1.6vw, 1.5rem);
  --nav-h: 3.75rem;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-faint) var(--paper-950);
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--line);
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  background-color: var(--paper-800);
  /* Grain, uneven exposure, then the graticule. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .92 0 0 0 0 .96 0 0 0 0 1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(120% 90% at 30% 20%, rgba(26, 86, 166, 0.55), transparent 60%),
    radial-gradient(90% 70% at 85% 90%, rgba(6, 26, 58, 0.7), transparent 70%),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 240px 240px, 100% 100%, 100% 100%, var(--major) var(--major), var(--major) var(--major), var(--cell) var(--cell), var(--cell) var(--cell);
  background-attachment: scroll, fixed, fixed, scroll, scroll, scroll, scroll;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--mark); color: var(--mark-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper-950); }
::-webkit-scrollbar-thumb { background: var(--line-faint); border: 3px solid var(--paper-950); border-radius: 0; }
input, textarea { caret-color: var(--mark); }

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; text-decoration-color: var(--line-faint); }
a:hover { text-decoration-color: var(--mark); }
p { margin: 0 0 1em; max-width: 68ch; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; text-wrap: balance; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 100;
  background: var(--mark); color: var(--mark-ink); padding: 0.6rem 1rem;
  font: 600 0.95rem var(--f-body); text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

/* ---------- Focus: marching drafting dashes; press inverts. ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px dashed var(--mark);
  outline-offset: 4px;
  animation: ants-offset 0.9s steps(4) infinite;
}
@keyframes ants-offset { 0% { outline-offset: 4px; } 50% { outline-offset: 6px; } 100% { outline-offset: 4px; } }

/* ---------- Type roles ---------- */
.display {
  font-family: var(--f-display);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  line-height: 0.88;
}
.mono { font-family: var(--f-mono); font-size: 0.8rem; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.label {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--line-soft);
}
.lede { font-size: clamp(1.125rem, 1.4vw, 1.3rem); line-height: 1.5; color: var(--line); max-width: 58ch; }
.quote {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 2.8vw, 2.5rem);
  line-height: 1.12;
  margin: 0;
  max-width: 34ch;
}
.quote cite { display: block; margin-top: 0.6rem; font: 500 0.95rem/1.4 var(--f-body); color: var(--line-soft); font-style: normal; }

/* ---------- Buttons: revision-pencil orange is only for actions. ---------- */
.btn {
  --b-bg: transparent; --b-fg: var(--line); --b-bd: var(--line);
  display: inline-flex; align-items: center; gap: 0.6rem;
  min-height: 2.75rem; padding: 0.7rem 1.15rem;
  background: var(--b-bg); color: var(--b-fg);
  border: 1.5px solid var(--b-bd); border-radius: 0;
  font: 600 0.95rem/1 var(--f-body); letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer;
  transition: background-color 0.18s var(--ease-out), color 0.18s var(--ease-out), border-color 0.18s var(--ease-out);
}
.btn svg { width: 1.05em; height: 1.05em; flex: none; }
.btn:hover { --b-bd: var(--mark); }
.btn:active { --b-bg: var(--line); --b-fg: var(--paper-900); --b-bd: var(--line); }
.btn--mark { --b-bg: var(--mark); --b-fg: var(--mark-ink); --b-bd: var(--mark); }
.btn--mark:hover { --b-bg: #ff8f3d; --b-fg: var(--mark-ink); --b-bd: #ff8f3d; }
.btn--mark:active { --b-bg: var(--line); --b-fg: var(--paper-900); --b-bd: var(--line); }

/* ---------- Sheet index (navigation) ---------- */
.index {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 var(--gutter);
  background: rgba(8, 33, 74, 0.92);
  border-bottom: 1px solid var(--line-rule);
  backdrop-filter: blur(6px);
}
.index__home { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; font: 900 1.35rem/1 var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; }
.index__home svg { width: 1.6rem; height: 1.6rem; }
.index__sheets { display: flex; gap: 0; margin: 0 auto; padding: 0; list-style: none; }
.index__sheets a {
  display: flex; align-items: baseline; gap: 0.35rem; padding: 0.55rem 0.7rem; white-space: nowrap;
  text-decoration: none; color: var(--line-soft);
  font: 500 0.75rem/1 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.index__sheets a b { font-weight: 500; color: var(--line-faint); }
.index__sheets a:hover { color: var(--line); }
.index__sheets a[aria-current="true"] { color: var(--line); border-bottom-color: var(--mark); }
.index__sheets a[aria-current="true"] b { color: var(--mark); }
.index__tools { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.lang { display: flex; gap: 3px; padding: 3px; font: 500 0.75rem/1 var(--f-mono); letter-spacing: 0.1em; border: 1px solid #345678; background: #040c19; box-shadow: inset 0 1px 0 #54718d, 0 2px 0 #020711; }
.lang a, .lang span { position: relative; padding: .65rem .65rem .55rem; text-decoration: none; border: 1px solid #294663; background: linear-gradient(#122941, #071426); color: #a2b7cf; }
.lang a::before, .lang span::before { content: ""; position: absolute; top: 3px; left: 30%; width: 40%; height: 2px; background: #263c54; }
.lang [aria-current="true"] { background: linear-gradient(#153a5b, #09213a); color: #c1efff; border-color: #37769e; text-shadow: 0 0 7px #3a94c0; }
.lang [aria-current="true"]::before { background: #6dd7ff; box-shadow: 0 0 6px #3bb5ec; }
.lang a:hover { color: #eaf8ff; border-color: #68b9e3; }
.index .btn { min-height: 2.25rem; padding: 0.5rem 0.85rem; font-size: 0.85rem; }
.index__toggle { display: none; }
@media (min-width: 1361px) {
  .index > nav { min-width: 0; overflow-x: auto; }
  .index__home, .index__tools { flex-shrink: 0; }
}

@media (max-width: 1360px) {
  .index__sheets {
    position: fixed; inset: var(--nav-h) 0 auto 0; flex-direction: column;
    background: var(--paper-900); border-bottom: 1px solid var(--line-rule);
    padding: 0.5rem var(--gutter) 1rem; display: none;
  }
  .index[data-open="true"] .index__sheets { display: flex; }
  .index__sheets a { padding: 0.85rem 0; font-size: 0.85rem; border-bottom: 1px solid var(--line-rule); }
  .index__sheets a[aria-current="true"] { border-bottom-color: var(--mark); }
  .index__toggle {
    display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.25rem; padding: 0.45rem 0.7rem;
    background: transparent; color: var(--line); border: 1px solid var(--line-rule);
    font: 500 0.75rem/1 var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  }
  .index__toggle svg { width: 1rem; height: 1rem; }
}
@media (max-width: 560px) {
  .index { gap: 0.5rem; }
  .index__tools .btn { display: none; }
  .index__home span { display: none; }
}

/* ---------- Sheets ---------- */
main { display: block; }
.sheet {
  position: relative;
  padding: calc(var(--nav-h) + var(--cell) * 6) var(--gutter) calc(var(--cell) * 10);
  isolation: isolate;
}
.sheet + .sheet { padding-top: calc(var(--cell) * 12); }
/* The drawn border of each sheet, inset from the paper edge. */
.sheet::before {
  content: ""; position: absolute; z-index: -1;
  inset: var(--sheet-inset); top: calc(var(--sheet-inset) + var(--nav-h) * 0.25);
  border: 1.5px solid var(--line-rule);
  pointer-events: none;
}
.sheet + .sheet::before { top: var(--sheet-inset); }
/* Zone rulers generated by site.js (decorative). */
.zones { position: absolute; inset: var(--sheet-inset); pointer-events: none; z-index: -1; }
.zones__row, .zones__col { position: absolute; display: flex; justify-content: space-around; font: 500 0.7rem/1 var(--f-mono); color: var(--line-faint); letter-spacing: 0.1em; }
.zones__row { left: 0; right: 0; top: -0.95rem; }
.zones__col { top: 0; bottom: 0; left: -0.9rem; flex-direction: column; }
.zones__row span, .zones__col span { position: relative; }
.zones__row span::after { content: ""; position: absolute; left: 50%; top: 0.95rem; width: 1px; height: 0.45rem; background: var(--line-rule); }
@media (max-width: 720px) { .zones { display: none; } .sheet::before { inset: 0.5rem; } }

/* The sheet number sits in its own strip above the content (sheets after the first
   start at cell × 12), so it never lies behind live text. */
.sheet__numeral {
  position: absolute; z-index: -1; right: calc(var(--sheet-inset) + var(--cell) * 2); top: calc(var(--sheet-inset) + var(--cell) * 0.75);
  font: 900 clamp(4.5rem, 7.5vw, 7.25rem)/0.8 var(--f-display);
  color: transparent; -webkit-text-stroke: 1.5px var(--line-rule);
  user-select: none; pointer-events: none;
}

.sheet__head { display: grid; gap: calc(var(--cell) * 2); margin-bottom: calc(var(--cell) * 5); max-width: 62rem; }
.sheet__title { font: 900 clamp(2.75rem, 6.4vw, 5.75rem)/0.86 var(--f-display); text-transform: uppercase; letter-spacing: 0.005em; }

/* ---------- Title block (cajetín) ---------- */
.titleblock {
  display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); border: 1.5px solid var(--line);
  background: rgba(8, 33, 74, 0.72);
  font-size: 0.95rem;
}
.titleblock > div:not(.titleblock__action) { display: contents; }
.titleblock dt, .titleblock dd { margin: 0; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line-rule); }
.titleblock dt { font: 500 0.72rem/1.6 var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--line-soft); border-right: 1px solid var(--line-rule); white-space: nowrap; }
.titleblock dd { font-weight: 600; overflow-wrap: anywhere; }
.titleblock > div:last-child dt, .titleblock > div:last-child dd { border-bottom: 0; }
.titleblock__action { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.75rem; padding: 0.7rem 0.8rem; border-top: 1.5px solid var(--line); }
.titleblock__action .btn { flex: 1 1 auto; justify-content: center; }
.titleblock .status { color: var(--mark); }

/* ---------- Prints: photographs pasted on the sheet with tape. ---------- */
.print {
  --tilt: -1.2deg;
  position: relative; margin: 0;
  padding: 0.55rem 0.55rem 0.7rem;
  background: #f1efe6;
  color: var(--paper-900);
  transform: rotate(var(--tilt));
  box-shadow: 0 10px 24px -12px rgba(2, 10, 26, 0.75);
  transition: transform 0.45s var(--ease-out), box-shadow 0.45s var(--ease-out);
}
.print img { width: 100%; background: var(--paper-700); }
.print figcaption { padding: 0.55rem 0.15rem 0; font: 500 0.86rem/1.4 var(--f-body); color: #24364f; }
.print figcaption b { color: var(--paper-900); font-weight: 500; }
.print::before, .print::after {
  content: ""; position: absolute; width: 5.5rem; height: 1.4rem;
  background: url("../img/tape-a.webp") center / 100% 100% no-repeat;
}
.print::after { background-image: url("../img/tape-b.webp"); }
.print:nth-of-type(3n)::before { background-image: url("../img/tape-c.webp"); }
.print::before { top: -0.7rem; left: 12%; transform: rotate(-6deg); }
.print::after { top: -0.6rem; right: 10%; transform: rotate(5deg); }
.print:hover, .print:focus-within { transform: rotate(0deg) translateY(-6px); box-shadow: 0 22px 40px -16px rgba(2, 10, 26, 0.85); }
.print--bare { padding: 0; background: none; box-shadow: none; }
.print--bare::before, .print--bare::after { display: none; }

/* Annotation callouts drawn as leader lines. */
.callout { font: 700 0.8rem/1.3 var(--f-body); letter-spacing: 0.07em; text-transform: uppercase; color: var(--line); }
.callout small { display: block; margin-top: 0.15rem; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--line-soft); font-size: 0.86rem; line-height: 1.35; }

.notes { counter-reset: note; list-style: none; padding: 0; margin: 0; display: grid; gap: calc(var(--cell) * 1.5); }
.notes li { counter-increment: note; display: grid; grid-template-columns: 2.25rem 1fr; gap: 0.5rem; max-width: 60ch; }
.notes li::before { content: counter(note) "."; font: 500 0.85rem/1.55 var(--f-mono); color: var(--line-soft); }
.notes strong { font-weight: 600; }

/* Pen-draw: decorative strokes draw themselves once when seen. */
.draw path, .draw line, .draw polyline, .draw circle { stroke-dasharray: var(--len, 1200); stroke-dashoffset: 0; }
.js .draw:not(.is-drawn) path, .js .draw:not(.is-drawn) line, .js .draw:not(.is-drawn) polyline, .js .draw:not(.is-drawn) circle { stroke-dashoffset: var(--len, 1200); }
.js .draw path, .js .draw line, .js .draw polyline, .js .draw circle { transition: stroke-dashoffset 1.6s var(--ease-out); }

/* ---------- Footer ---------- */
.foot {
  padding: calc(var(--cell) * 5) var(--gutter) calc(var(--cell) * 6);
  border-top: 1px solid var(--line-rule);
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: baseline;
  font-size: 0.9rem; color: var(--line-soft);
}
.foot a { color: var(--line); }

/* Language suggestion (one-time, non-blocking). */
.lang-hint {
  position: fixed; z-index: 60; right: var(--gutter); top: calc(var(--nav-h) + 0.75rem);
  display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.8rem 0.7rem 1rem;
  background: var(--paper-900); border: 1.5px solid var(--line); max-width: calc(100vw - 2rem);
  font-size: 0.95rem;
}
@media (max-width: 720px) { .lang-hint { top: auto; bottom: 0.75rem; right: 0.75rem; left: 0.75rem; } }
.lang-hint button { background: none; border: 0; color: var(--line-soft); cursor: pointer; padding: 0.4rem; font: inherit; }

/* Spanish caps carry accents: open display leading so Ó/É never touch the line above. */
:lang(es) .display, :lang(es) .sheet__title, :lang(es) .quote { line-height: 0.98; }

/* ---------- Motion safety ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .draw:not(.is-drawn) path, .js .draw:not(.is-drawn) line, .js .draw:not(.is-drawn) polyline, .js .draw:not(.is-drawn) circle { stroke-dashoffset: 0; }
}
