/* BOREHOLE JN-1 — stylesheet.
   Layout idea: the page IS the core. A gutter on the left carries the depth
   ruler and the drill string; rock units stack to the right of it. */

:root {
  --paper: #efe6d0;
  --paper-2: #e6dabd;
  --paper-3: #dccda8;
  --ink: #1f1b16;
  --ink-soft: #4a4238;
  --flag: #ff5a1f;
  --flag-deep: #c83c08;
  --uv: #7dffa0;

  --sky: #cfd6d4;
  --fill: #85796a;
  --bay: #4d625c;
  --sand: #d9b46a;
  --melange: #4f6b4a;
  --aquifer: #174e68;
  --kaibab: #d8cba4;
  --coconino: #e6c48a;
  --hermit: #9e3d22;
  --void: #0d0c10;
  --schist: #1d1a1f;

  --gutter: 150px;
  --ruler-w: 64px;
  --hole-x: 82px;   /* left edge of the hole */
  --hole-w: 44px;

  --f-display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --f-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --f-body: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-mono: "Courier Prime", "Courier New", monospace;
  --f-hand: "Reenie Beanie", "Bradley Hand", cursive;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--schist);
  color: var(--ink);
  font: 400 1.125rem/1.62 var(--f-body);
  overflow-x: hidden;
}
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-color: var(--flag); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--flag-deep); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--flag); outline-offset: 3px; }
.s-hermit :focus-visible, .s-sand :focus-visible, .s-coconino :focus-visible { outline-color: var(--ink); }
.plate :focus-visible { outline-color: var(--flag-deep); }

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 100; background: var(--flag); color: var(--ink); padding: .5em 1em; font-family: var(--f-mono); font-weight: 700; }
.skip:focus { top: 12px; }
.fine { font-size: .88rem; color: var(--ink-soft); line-height: 1.5; }
.scrawl { font-family: var(--f-hand); font-size: 1.45em; line-height: 1; color: var(--flag-deep); display: inline-block; transform: rotate(-3deg); }
.scrawl.big { font-size: 2.2rem; display: block; margin: .4em 0 0; }
.math { font-family: var(--f-display); font-style: italic; font-size: 1.08em; white-space: nowrap; }
@media (max-width: 560px) { .math { white-space: normal; } }

/* ───────────── column, ruler, hole ───────────── */
#column { position: relative; }

#ruler {
  position: absolute; left: 0; width: var(--ruler-w); z-index: 4;
  top: 0; bottom: 0; /* JS moves the top to ground level */
  background:
    repeating-linear-gradient(to bottom, var(--ink) 0 1.5px, transparent 1.5px 200px) right / 26px 100% no-repeat,
    repeating-linear-gradient(to bottom, var(--ink) 0 1px, transparent 1px 100px) right / 16px 100% no-repeat,
    repeating-linear-gradient(to bottom, rgba(31,27,22,.55) 0 1px, transparent 1px 20px) right / 8px 100% no-repeat,
    var(--paper);
  border-right: 2px solid var(--ink);
  box-shadow: 3px 0 0 rgba(0,0,0,.18);
}
#ruler span {
  position: absolute; right: 30px; transform: translateY(-50%);
  font: 700 .72rem/1 var(--f-mono); color: var(--ink); letter-spacing: .02em;
}
#ruler span.deep { color: var(--flag-deep); }

#hole {
  position: absolute; left: var(--hole-x); width: var(--hole-w); z-index: 2;
  top: 0; height: 0;
  background: linear-gradient(90deg, #0b0a0c, #25211f 30%, #25211f 70%, #0b0a0c);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.6);
  pointer-events: none;
}
#pipe {
  position: absolute; left: 50%; top: 0; bottom: 60px; width: 14px; margin-left: -7px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 116px, #111 116px 120px),
    linear-gradient(90deg, #6d6961, #c9c4b6 45%, #8b867b 60%, #4b4740);
}
#bit { position: absolute; left: 50%; bottom: -2px; width: 60px; margin-left: -30px; line-height: 0; }
#bit svg { display: block; filter: drop-shadow(0 3px 0 rgba(0,0,0,.4)); }
.bit-teeth { transform-origin: 30px 40px; }
.drilling .bit-teeth { animation: chew .22s steps(2) infinite; }
.drilling #bit { animation: judder .12s linear infinite; }
@keyframes chew { 50% { transform: scaleX(-1); } }
@keyframes judder { 50% { transform: translateX(1px); } }

/* ───────────── strata (shared) ───────────── */
.stratum {
  position: relative;
  padding: 120px 5vw 130px calc(var(--gutter) + 4vw);
  --embed: rgba(31,27,22,.42);
}
.contact { position: absolute; top: -1px; left: 0; width: 100%; height: 40px; fill: var(--prev); z-index: 1; display: block; }

.plate {
  position: relative; z-index: 3;
  max-width: 740px;
  background: var(--paper);
  background-image: linear-gradient(100deg, rgba(255,255,255,.22), rgba(255,255,255,0) 40%, rgba(120,90,40,.06));
  border: 2px solid var(--ink);
  box-shadow: 9px 9px 0 rgba(0,0,0,.38);
  padding: 30px 36px 34px;
}
.plate + .plate, .specimen-site + .plate { margin-top: 70px; }
.unit-tag {
  font: 700 .78rem/1.3 var(--f-mono); letter-spacing: .09em; text-transform: uppercase;
  margin: -30px -36px 22px; padding: 10px 36px; border-bottom: 2px solid var(--ink);
  background: var(--paper-2);
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; margin: 0 0 .5em; line-height: 1.05; }
h2 { font-size: clamp(1.9rem, 4.6vw, 2.9rem); letter-spacing: -.01em; text-wrap: balance; }
h3 { font-size: 1.5rem; }
.unit-note { font-style: italic; color: var(--ink-soft); border-left: 3px solid var(--ink); padding-left: 14px; }

/* levels of "how" */
.how { position: relative; }
.how[data-level="2"], .how[data-level="3"] {
  margin: 26px -36px 0; padding: 26px 36px 8px; border-top: 2px dashed var(--ink);
}
.how[data-level="2"] { background: var(--paper-2); }
.how[data-level="3"] { background: var(--paper-3); margin-bottom: -34px; padding-bottom: 30px; }
.how[data-level="2"]::before, .how[data-level="3"]::before {
  content: "↓ one level down"; position: absolute; top: -11px; right: 28px;
  font: 700 .7rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  background: var(--ink); color: var(--paper); padding: 4px 8px;
}
.how[data-level="3"]::before { content: "↓↓ two levels down"; }
.js .how.is-new { animation: unearth .5s ease-out; }
@keyframes unearth { from { opacity: 0; transform: translateY(-14px); } }
.how:focus { outline: none; }
.floor {
  font-family: var(--f-mono); font-size: .92rem; line-height: 1.5;
  border: 2px solid var(--ink); padding: 12px 14px; margin-top: 1.4em;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(31,27,22,.07) 10px 20px);
}

/* the orange flag */
.flag, .flag-demo {
  position: relative; display: inline-block; isolation: isolate;
  font: 700 1rem/1.2 var(--f-mono); color: var(--ink); text-decoration: none;
  background: none; border: 0; padding: .7em 2.4em .7em 1.1em; margin: 22px 0 0;
  text-align: left;
}
.flag::before, .flag-demo::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--flag);
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 50%, 100% 100%, 0 100%);
  transition: transform .15s;
  transform-origin: left center;
}
.flag::after {
  content: ""; position: absolute; left: -4px; top: -6px; bottom: -26px; width: 4px; background: var(--ink);
}
.flag:hover::before { transform: scaleX(1.04) skewY(-1.5deg); }
.flag:hover { color: var(--ink); }
.flag:active::before { background: var(--flag-deep); }
.flag-wrap { margin: 0 0 18px 4px; }
.flag-demo { margin: 0; font-size: .8rem; padding: .45em 1.8em .45em .7em; white-space: nowrap; }

.legend { list-style: none; padding: 0; margin: 1.2em 0; display: grid; gap: 16px; }
.legend li { display: grid; grid-template-columns: 128px 1fr; gap: 16px; align-items: start; }
.glint-demo, .lamp-demo { font-size: 1.7rem; line-height: 1; text-align: center; color: var(--flag-deep); }
@media (max-width: 560px) { .legend li { grid-template-columns: 1fr; gap: 6px; } .glint-demo, .lamp-demo { text-align: left; } }

/* ───────────── surface ───────────── */
.s-sky {
  min-height: 100vh; min-height: 100svh;
  padding-top: 84px; padding-bottom: 150px;
  background: linear-gradient(to bottom, #e9ebe4 0%, var(--sky) 55%, #b9c4c4 100%);
  overflow: hidden;
}
.fog i {
  position: absolute; left: -30%; width: 160%; height: 190px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,255,255,.85), rgba(255,255,255,0));
  animation: drift 70s linear infinite alternate;
}
.fog i:nth-child(1) { top: 4%; }
.fog i:nth-child(2) { top: 30%; animation-duration: 95s; animation-direction: alternate-reverse; opacity: .8; }
.fog i:nth-child(3) { top: 56%; animation-duration: 60s; opacity: .9; }
.fog i:nth-child(4) { bottom: 10px; height: 150px; animation-duration: 120s; animation-direction: alternate-reverse; z-index: 3; opacity: .75; pointer-events: none; }
@keyframes drift { from { transform: translateX(-9%); } to { transform: translateX(9%); } }

.title-block { max-width: 880px; padding-bottom: 26px; }
.sheet-no { font: 700 .74rem/1.3 var(--f-mono); letter-spacing: .1em; margin: -30px -36px 18px; padding: 10px 36px; border-bottom: 2px solid var(--ink); background: var(--paper-2); }
h1 {
  font-size: clamp(3.6rem, 12.5vw, 9.6rem); line-height: .84; letter-spacing: -.035em;
  margin: .12em 0 .16em; text-transform: none;
}
h1 em { color: var(--flag-deep); font-style: italic; position: relative; padding-right: .06em; }
h1 em::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .1em; height: .1em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 10' preserveAspectRatio='none'%3E%3Cpath d='M0 5c5-6 10-6 15 0s10 6 15 0 10-6 10 0' fill='none' stroke='%23ff5a1f' stroke-width='3'/%3E%3C/svg%3E") repeat-x left / .5em 100%;
}
.subtitle { font-family: var(--f-sc); font-size: clamp(1.2rem, 2.6vw, 1.75rem); letter-spacing: .04em; margin-bottom: 1.1em; }
.block-table { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 -36px 22px; border-block: 2px solid var(--ink); font-family: var(--f-mono); font-size: .86rem; line-height: 1.35; }
.block-table div { padding: 10px 14px 10px 36px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.block-table div:nth-child(3n) { border-right: 0; }
.block-table div:nth-last-child(-n+3) { border-bottom: 0; }
.block-table dt { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.block-table dd { margin: 2px 0 0; font-weight: 700; }
.block-table .fine { font-weight: 400; font-family: var(--f-mono); font-size: .74rem; }
.lede { font-size: 1.2rem; max-width: 62ch; margin-bottom: 0; }

.horizon { position: absolute; left: 0; right: 0; bottom: 0; height: 300px; pointer-events: none; z-index: 2; }
.ground { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background: linear-gradient(90deg, var(--fill) 0 52%, #3d5f66 52% 100%); border-top: 3px solid var(--ink); }
.rig { position: absolute; bottom: 22px; left: calc(var(--hole-x) + var(--hole-w) / 2 - 80px); width: 160px; height: 260px; }
.alcatraz { position: absolute; bottom: 22px; right: 7%; width: min(300px, 34vw); height: 70px; }
.beacon { animation: beacon 5s ease-in-out infinite; }
@keyframes beacon { 0%, 80%, 100% { opacity: .15; } 88% { opacity: 1; } }

/* ───────────── lithologies ───────────── */
.s-fill {
  background-color: var(--fill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg fill='none' stroke='%231f1b16' stroke-opacity='.4' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M10 14l14-6 9 10-6 12-15-2zM64 30l18-4 6 13-14 9-12-7zM26 70l10-8 14 6-2 14-16 2zM88 84l12-10 12 8-4 14-14 2zM58 98l8-4 6 8-8 8z'/%3E%3C/g%3E%3Cg fill='%231f1b16' fill-opacity='.35'%3E%3Ccircle cx='50' cy='12' r='1.6'/%3E%3Ccircle cx='104' cy='40' r='1.6'/%3E%3Ccircle cx='8' cy='52' r='1.6'/%3E%3Ccircle cx='72' cy='66' r='1.6'/%3E%3Ccircle cx='14' cy='104' r='1.6'/%3E%3C/g%3E%3C/svg%3E");
  --embed: rgba(239,230,208,.55);
  padding-top: 90px;
}
.s-bay {
  background-color: var(--bay);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='44'%3E%3Cg stroke='%23dfe9e2' stroke-opacity='.3' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M6 8h24M52 8h16M28 30h22M70 30h14M0 30h10'/%3E%3C/g%3E%3C/svg%3E");
  --embed: rgba(223,233,226,.5);
  padding-top: 0;
}
.water-band {
  position: relative; z-index: 1; height: 300px; margin: 0 -5vw 80px calc(-1 * (var(--gutter) + 4vw));
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='30'%3E%3Cpath d='M0 15c15-10 30-10 45 0s30 10 45 0 30-10 30 0' fill='none' stroke='%23ffffff' stroke-opacity='.16' stroke-width='2'/%3E%3C/svg%3E") 0 60px / 120px 30px,
    linear-gradient(to bottom, #6f9aa0 0, #2f6672 40%, #173f4d 100%);
  border-bottom: 3px solid rgba(0,0,0,.35);
  overflow: hidden;
}
.water-note { position: absolute; left: calc(var(--gutter) + 4vw); bottom: 18px; margin: 0; font: 700 .78rem/1.3 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.7); }
@media (hover: none) { .pointer-only { display: none; } }
.s-sand {
  background-color: var(--sand);
  background-image: radial-gradient(rgba(31,27,22,.5) 1.3px, transparent 1.6px), radial-gradient(rgba(31,27,22,.32) 1px, transparent 1.3px);
  background-size: 22px 22px, 14px 14px; background-position: 0 0, 7px 9px;
}
.s-melange {
  background-color: var(--melange);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='70'%3E%3Cg fill='none' stroke='%23101a10' stroke-opacity='.45' stroke-width='1.5'%3E%3Cpath d='M0 20c20-14 40 10 70 0s50-14 70 0M0 50c25-10 45 12 70 2s45-16 70-2M0 35c30-6 50 6 70 0s40-8 70 0'/%3E%3C/g%3E%3C/svg%3E");
  --embed: rgba(233,238,220,.55);
  overflow: hidden;
}
.blocks i { position: absolute; display: block; border: 2px solid rgba(0,0,0,.55); z-index: 0; border-radius: 46% 54% 50% 50% / 60% 40% 60% 40%; }
.blocks i:nth-child(1) { width: 260px; height: 120px; right: 6%; top: 260px; background: #8c3b2a; transform: rotate(-18deg); }
.blocks i:nth-child(2) { width: 170px; height: 90px; right: 18%; top: 760px; background: #5a6c86; transform: rotate(24deg); }
.blocks i:nth-child(3) { width: 120px; height: 60px; right: 3%; top: 1180px; background: #a9c09a; transform: rotate(-8deg); }
.blocks i:nth-child(4) { width: 210px; height: 100px; right: 9%; bottom: 200px; background: #8c3b2a; transform: rotate(12deg); }
.blocks i:nth-child(5) { width: 90px; height: 50px; right: 30%; top: 80px; background: #a9c09a; transform: rotate(30deg); }
.blocks i:nth-child(6) { width: 140px; height: 70px; right: 26%; bottom: 60px; background: #5a6c86; transform: rotate(-22deg); }
.s-aquifer {
  background-color: var(--aquifer);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='46'%3E%3Cg fill='none' stroke='%239fd8ee' stroke-opacity='.3' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 12c12-8 24-8 36 0s24 8 36 0M90 34c12-8 24-8 36 0s24 8 30 2'/%3E%3C/g%3E%3C/svg%3E");
  --embed: rgba(190,230,245,.55);
}
.s-unconformity {
  background-color: var(--kaibab);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='56'%3E%3Cg fill='none' stroke='%231f1b16' stroke-opacity='.38' stroke-width='1.5'%3E%3Cpath d='M0 1h96M0 29h96M24 1v28M72 1v28M0 29v27M48 29v27M96 29v27'/%3E%3C/g%3E%3C/svg%3E");
  padding-top: 100px; padding-bottom: 110px;
}
.plate-warning { border-width: 3px; box-shadow: 9px 9px 0 var(--flag-deep); }
.plate-warning .unit-tag { background: var(--flag); }
.s-coconino {
  background-color: var(--coconino);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='150'%3E%3Cg fill='none' stroke='%237a4a16' stroke-opacity='.5' stroke-width='1.4'%3E%3Cpath d='M0 1h180M0 76h180'/%3E%3Cpath d='M-10 76 40 1M20 76 70 1M50 76l50-75M80 76l50-75M110 76l50-75M140 76l50-75M170 76l50-75' stroke-opacity='.34'/%3E%3Cpath d='M0 76c20 30 50 60 90 74M30 76c20 30 50 60 90 74M60 76c20 30 50 60 90 74M90 76c20 30 50 60 90 74M120 76c20 30 50 58 70 66M-30 76c20 30 50 60 90 74M150 76c10 16 20 28 34 40' stroke-opacity='.34'/%3E%3C/g%3E%3C/svg%3E");
}
.s-hermit {
  background-color: var(--hermit);
  background-image: repeating-linear-gradient(to bottom, rgba(0,0,0,.2) 0 1.5px, transparent 1.5px 9px), repeating-linear-gradient(to bottom, rgba(255,210,170,.1) 0 3px, transparent 3px 47px);
  --embed: rgba(255,225,200,.55);
}
.s-void {
  background: radial-gradient(ellipse 90% 70% at 60% 45%, #1b1922 0, var(--void) 70%);
  --embed: rgba(255,255,255,.4);
  padding-top: 130px;
}
.s-schist {
  background-color: var(--schist);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='60'%3E%3Cg fill='none' stroke='%23c9c4d4' stroke-opacity='.2' stroke-width='1.4'%3E%3Cpath d='M0 12c30-10 50 8 80 2s50-12 80-2 40 6 60 0M0 32c20-6 50 10 90 0s60-8 130 2M0 50c40-10 70 6 110 0s70-10 110 0'/%3E%3C/g%3E%3Cg fill='%23fff' fill-opacity='.35'%3E%3Ccircle cx='30' cy='22' r='1'/%3E%3Ccircle cx='140' cy='42' r='1.2'/%3E%3Ccircle cx='190' cy='8' r='.9'/%3E%3C/g%3E%3C/svg%3E");
  --embed: rgba(201,196,212,.16);
  padding-bottom: 170px;
}
.s-sheet { background: var(--paper-2); padding-top: 90px; padding-bottom: 170px; border-top: 3px solid var(--ink); }
.s-sheet .plate { box-shadow: none; background-color: var(--paper); }

.plate-dark, .plate-bedrock { background: #15131a; color: #e9e3d3; border-color: #6b6577; box-shadow: 9px 9px 0 rgba(0,0,0,.6); background-image: none; }
.plate-dark .unit-tag, .plate-bedrock .unit-tag { background: #221f2a; border-color: #6b6577; color: #e9e3d3; }
.plate-dark .fine, .plate-bedrock .fine { color: #a8a2b4; }
.plate-dark a:hover, .plate-bedrock a:hover { color: var(--flag); }
.plate-bedrock { background: linear-gradient(160deg, #24212b, #131117); }
.engraved {
  font-family: var(--f-sc); font-size: clamp(3rem, 11vw, 7rem); line-height: 1; letter-spacing: .06em; text-align: center;
  margin: .35em 0 .4em; color: #2b2833;
  text-shadow: -1px -1px 0 #000, 1px 1px 0 rgba(255,255,255,.22);
}
.lamp .engraved { color: var(--uv); text-shadow: 0 0 18px rgba(80,255,140,.7); }

.stamp {
  display: inline-block; font: 700 1.05rem/1 var(--f-mono); letter-spacing: .16em; color: #a12a12;
  border: 3px double #a12a12; padding: 8px 12px 6px; transform: rotate(-4deg); margin: 0 0 1.1em; opacity: .85;
}
.memo { font-family: var(--f-mono); font-size: .98rem; line-height: 1.55; border: 2px solid var(--ink); padding: 14px 16px; background: rgba(255,255,255,.35); }
.memo output { font-weight: 700; background: var(--flag); padding: 0 .3em; }

/* ───────────── specimens ───────────── */
.specimen-site { position: relative; z-index: 3; margin: 70px 0; min-height: 76px; max-width: 900px; }
.specimen {
  position: relative; display: block; width: 76px; height: 76px; padding: 12px;
  margin-left: min(var(--x, 50%), calc(100% - 80px));
  background: none; border: 2px dashed transparent; border-radius: 50%;
  color: var(--embed); transition: color .2s, transform .2s, border-color .2s;
}
.specimen svg { width: 100%; height: 100%; display: block; }
.specimen::after {
  content: "✦"; position: absolute; right: 4px; top: 0; font-size: 1rem; color: #fff; opacity: .25;
  animation: glint 7s ease-in-out infinite;
}
@keyframes glint { 0%, 86%, 100% { opacity: 0; transform: scale(.6) rotate(0); } 92% { opacity: 1; transform: scale(1.3) rotate(40deg); } }
.specimen:hover, .specimen:focus-visible { color: var(--flag); border-color: currentColor; transform: rotate(-6deg) scale(1.06); }
.specimen.found { color: var(--ink); background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 4px 0 rgba(0,0,0,.4); transform: rotate(-5deg); }
.specimen.found::after { display: none; }
.specimen-uv { opacity: .5; }
.lamp .specimen-uv:not(.found) { color: var(--uv); opacity: 1; filter: drop-shadow(0 0 10px rgba(80,255,140,.9)); }
.tag {
  position: relative; width: min(360px, 100%);
  margin: 16px 0 0 min(max(0px, calc(var(--x, 50%) - 60px)), calc(100% - 360px));
  background: #f7f0dc; border: 2px solid var(--ink); padding: 14px 18px 4px 18px;
  box-shadow: 5px 5px 0 rgba(0,0,0,.4); font-size: 1rem; line-height: 1.5;
  clip-path: polygon(18px 0, 100% 0, 100% 100%, 0 100%, 0 18px);
}
@media (max-width: 520px) { .tag { margin-left: 0; } }
.tag h3 { font-size: 1.35rem; margin-bottom: .3em; }
.tag-no { font: 700 .7rem/1.2 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; margin: 0 0 6px 10px; color: var(--ink-soft); }
.js .tag:not([hidden]) { animation: unearth .35s ease-out; }

/* field notes in the right margin, wide screens only */
.margin-note {
  display: none; position: absolute; z-index: 2; margin: 0; top: 230px; width: 250px;
  left: calc(var(--gutter) + 4vw + 740px + 70px);
  font: 400 2rem/1.05 var(--f-hand); color: var(--ink); opacity: .82; transform: rotate(3deg);
}
.s-bay .margin-note { top: 470px; }
.s-melange .margin-note { top: 440px; }
.s-fill .margin-note, .s-bay .margin-note, .s-melange .margin-note, .s-aquifer .margin-note, .s-hermit .margin-note { color: #f3ecd8; }
@media (min-width: 1300px) { .margin-note { display: block; } }

/* UV scribbles: only under the headlamp */
.uv {
  position: absolute; z-index: 3; margin: 0; max-width: 300px;
  font: 400 1.75rem/1 var(--f-hand); color: var(--uv); text-shadow: 0 0 2px #012, 0 0 3px #012, 0 0 12px rgba(60,255,122,.9);
  opacity: 0; transform: rotate(-4deg); pointer-events: none; transition: opacity .4s;
}
.stratum > .uv { top: 50px; right: 7%; }
.lamp .uv { opacity: 1; }

#lamp {
  position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(circle 250px at var(--mx, 50%) var(--my, 50%), rgba(40,14,120,.4) 0, rgba(14,8,40,.5) 55%, rgba(6,5,12,.965) 100%);
}
.lamp #lamp { opacity: 1; }

/* ───────────── HUD ───────────── */
#hud {
  position: fixed; top: 14px; right: 14px; z-index: 60; width: 264px;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 5px 5px 0 rgba(0,0,0,.4);
  font: 400 .8rem/1.3 var(--f-mono); padding: 10px 12px 8px;
}
.hud-row { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.hud-label { font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
#depth-readout { font-weight: 700; font-size: 1.15rem; min-width: 5.4em; font-variant-numeric: tabular-nums; }
#depth-bar { letter-spacing: -.05em; color: var(--flag-deep); margin-left: auto; font-size: .9rem; }
#how-count { font-weight: 700; }
#hud button { background: none; border: 1.5px solid var(--ink); padding: 3px 7px; font-size: .74rem; border-radius: 0; }
#hud button:hover { background: var(--flag); }
#hud button[aria-pressed="true"], #hud button[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
#tray-toggle { margin-left: auto; }
#tray-toggle .hud-label { color: inherit; }
.hud-buttons { gap: 5px; margin-bottom: 2px; }
#hud-remark { margin: 6px 0 0; font-style: italic; font-family: var(--f-body); font-size: .86rem; line-height: 1.35; border-top: 1px dashed var(--ink); padding-top: 6px; }
#hud-remark:empty { display: none; }
#log-index, #tray { border-top: 1px dashed var(--ink); margin-top: 8px; padding-top: 6px; max-height: 52vh; overflow: auto; }
#log-index ol, #tray ol { list-style: none; margin: 0; padding: 0; }
#log-index a { display: block; padding: 4px 2px; text-decoration: none; }
#log-index a:hover, #log-index a:focus-visible { background: var(--flag); color: var(--ink); }
#log-index i { color: var(--ink-soft); font-style: italic; font-family: var(--f-body); }
#tray li { display: flex; gap: 8px; padding: 3px 0; align-items: baseline; }
#tray li.missing { color: var(--ink-soft); }
#tray li b { width: 1.2em; text-align: center; color: var(--flag-deep); }
.tray-note { font-size: .7rem; color: var(--ink-soft); margin: 6px 0 2px; }

/* ───────────── instruments ───────────── */
.instrument {
  margin: 22px 0 24px; border: 2px solid var(--ink); background: #fbf6e6;
  font-family: var(--f-mono); font-size: .88rem; line-height: 1.45;
}
.inst-title { margin: 0; padding: 7px 12px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; }
.inst-body { padding: 14px; }
.inst-body canvas, .inst-body svg.pad { display: block; width: 100%; border: 1.5px solid var(--ink); background: #fff; touch-action: manipulation; }
.inst-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 12px; }
.inst-controls label, .inst-controls fieldset { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.inst-controls fieldset { border: 0; padding: 0; margin: 0; flex-wrap: wrap; }
.inst-controls legend { float: left; margin-right: 8px; padding: 0; font-weight: 700; }
input[type="range"] { accent-color: var(--flag-deep); width: 180px; max-width: 100% !important; height: 28px; }
input[type="radio"] { accent-color: var(--flag-deep); }
.btn { background: var(--paper); border: 2px solid var(--ink); padding: 6px 12px; font: 700 .84rem/1.2 var(--f-mono); box-shadow: 3px 3px 0 var(--ink); }
.btn:hover { background: var(--flag); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn[disabled] { opacity: .45; cursor: default; box-shadow: none; }
.btn.primary { background: var(--flag); }
.inst-out { margin: 12px 0 0; min-height: 2.9em; font-weight: 700; }
.inst-caption { margin: 10px 0 0; font-size: .78rem; color: var(--ink-soft); }
.readout { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.readout th { text-align: left; font-weight: 400; padding: 3px 8px 3px 0; }
.readout td { text-align: right; font-weight: 700; padding: 3px 0; white-space: nowrap; }
.readout tr.key td, .readout tr.key th { border-top: 2px solid var(--ink); color: var(--flag-deep); font-size: 1.12em; padding-top: 6px; }

/* shield sorter */
.card { border: 2px solid var(--ink); background: var(--paper); padding: 16px; text-align: center; }
.card .champ { font: 400 1.9rem/1.1 var(--f-display); margin: 0; }
.card .ability { margin: 4px 0 0; font-size: .86rem; letter-spacing: .04em; }
.verdict { margin: 12px 0 0; font-family: var(--f-body); font-size: 1.02rem; line-height: 1.5; font-weight: 400; min-height: 4.6em; }
.verdict b.chip { font: 700 .72rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; padding: 4px 7px; background: var(--ink); color: var(--paper); margin-right: 6px; white-space: nowrap; }
.verdict .right { color: #2d6a2d; font-family: var(--f-mono); font-weight: 700; }
.verdict .wrong { color: #a12a12; font-family: var(--f-mono); font-weight: 700; }

/* damage pipeline */
.pipe-bar { display: flex; height: 44px; border: 2px solid var(--ink); margin-top: 12px; background: #fff; overflow: hidden; }
.pipe-bar span { display: block; height: 100%; transition: width .25s; min-width: 0; }
.pipe-bar .mit { background: repeating-linear-gradient(135deg, #b9b3a3 0 6px, #d6d0c0 6px 12px); }
.pipe-bar .abs { background: #f0c23c; }
.pipe-bar .hp { background: #b3261a; }
.pipe-key { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; font-size: .8rem; }
.pipe-key i { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--ink); margin-right: 5px; vertical-align: -1px; }

/* flow pad */
.pad-wrap > * { min-width: 0; }
.inst-body { min-width: 0; overflow-wrap: anywhere; }
.pad-wrap { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 640px) { .pad-wrap { grid-template-columns: 1fr; } }
svg.pad { aspect-ratio: 1; cursor: crosshair; touch-action: none; }
.pad text { font: 700 10px var(--f-mono); fill: var(--ink); text-anchor: middle; pointer-events: none; letter-spacing: .04em; }
.pad .zone { fill: #f4ecd6; stroke: var(--ink); stroke-width: 1; }
.pad .zone.on { fill: var(--flag); }
.zone-name { font: 400 2rem/1 var(--f-display); margin: 0 0 6px; }
.zone-text { font-family: var(--f-body); font-size: 1rem; line-height: 1.5; margin: 0; }

/* mounts */
.pet-mount { margin: 10px 0 12px; min-height: 345px; display: grid; place-items: center; background: repeating-linear-gradient(45deg, rgba(31,27,22,.06) 0 8px, transparent 8px 16px); border: 2px dashed var(--ink); }
.pet-mount iframe { width: 330px; max-width: 100%; height: 345px; border: 0; }
.plate-live { max-width: 520px; transform: rotate(.6deg); }
.wall-mount { margin: 16px 0; }
.wall-mount iframe { display: block; width: 100%; height: 440px; border: 2px solid #6b6577; background: #fff; filter: invert(.93) sepia(.35) hue-rotate(200deg); }
.plate-dark .btn, .plate-bedrock .btn { background: #221f2a; color: #e9e3d3; border-color: #a8a2b4; box-shadow: 3px 3px 0 #000; }
.plate-dark .btn:hover, .plate-bedrock .btn:hover { background: var(--flag); color: var(--ink); }
.bedrock-mount { margin-top: 24px; border-top: 2px dashed #6b6577; padding-top: 6px; }
.bedrock-mount .flag { margin-right: 18px; }
.bedrock-says { font-family: var(--f-mono); font-size: .95rem; min-height: 3.2em; margin: 18px 0 0; color: #e9e3d3; }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; text-decoration-color: var(--flag); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.linkish:hover { color: var(--flag-deep); }

.credits { padding-left: 1.1em; margin: 0 0 1.6em; }
.credits li { margin-bottom: .45em; }
.sheet-foot h3 { margin-top: 1.4em; }
.signoff { font-family: var(--f-display); font-size: 1.6rem; margin-top: 1.2em; }

/* ───────────── HUD becomes a bottom bar when it would cover the plates ───────────── */
@media (max-width: 1240px) {
  #hud { top: auto; bottom: 0; right: 0; left: 0; width: auto; border-width: 2px 0 0; box-shadow: 0 -4px 0 rgba(0,0,0,.3); padding: 7px 10px calc(6px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
  .hud-row { margin: 0; }
  #depth-bar { display: none; }
  #depth-readout { font-size: 1rem; min-width: 4.6em; }
  #log-index, #tray, #hud-remark { flex-basis: 100%; order: -1; margin-top: 0; border-top: 0; border-bottom: 1px dashed var(--ink); padding-bottom: 6px; }
  .s-sheet { padding-bottom: 210px; }
}

/* ───────────── small screens ───────────── */
@media (max-width: 860px) {
  :root { --gutter: 52px; --ruler-w: 30px; --hole-x: 33px; --hole-w: 16px; }
  body { font-size: 1.06rem; }
  .stratum { padding: 90px 14px 100px calc(var(--gutter) + 8px); }
  #ruler span { right: 2px; font-size: .56rem; top: auto; background: var(--paper); padding: 1px 0; }
  #ruler { background:
    repeating-linear-gradient(to bottom, var(--ink) 0 1.5px, transparent 1.5px 200px) right / 10px 100% no-repeat,
    repeating-linear-gradient(to bottom, rgba(31,27,22,.55) 0 1px, transparent 1px 20px) right / 5px 100% no-repeat,
    var(--paper); }
  #pipe { width: 6px; margin-left: -3px; }
  #bit { width: 30px; margin-left: -15px; }
  #pipe { bottom: 30px; }
  #bit svg { width: 30px; height: 35px; }
  .plate { padding: 22px 18px 26px; box-shadow: 5px 5px 0 rgba(0,0,0,.38); }
  .unit-tag, .sheet-no { margin: -22px -18px 18px; padding: 9px 18px; font-size: .7rem; }
  .how[data-level="2"], .how[data-level="3"] { margin-inline: -18px; padding-inline: 18px; }
  .how[data-level="3"] { margin-bottom: -26px; }
  .block-table { grid-template-columns: 1fr 1fr; margin-inline: -18px; }
  .block-table div { padding-left: 18px; border-right: 1px solid var(--ink) !important; border-bottom: 1px solid var(--ink) !important; }
  .block-table div:nth-child(2n) { border-right: 0 !important; }
  .block-table div:nth-last-child(-n+2) { border-bottom: 0 !important; }
  .s-sky { padding-top: 24px; padding-bottom: 190px; }
  .rig { width: 80px; height: 130px; left: calc(var(--hole-x) + var(--hole-w) / 2 - 40px); }
  .horizon { height: 160px; }
  .water-band { height: 220px; margin: 0 -14px 60px calc(-1 * (var(--gutter) + 8px)); }
  .water-note { left: calc(var(--gutter) + 8px); }
  .plate-live { margin-left: 0; transform: none; }
  .stratum > .uv { top: 34px; right: 12px; font-size: 1.4rem; max-width: 64vw; }

  .s-sheet { padding-bottom: 210px; }
}

/* ───────────── reduced motion ───────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .specimen::after { opacity: .5; }
  .beacon { opacity: .9; }
}

@media print { #hud, #lamp, #hole, #ruler { display: none; } .stratum { padding-left: 5vw; } }
