/* ==========================================================================
   Ethnohack — instrument readout
   Direction: a laboratory panel. Hairlines instead of cards, mono for every
   measured value, a serif only where the historical sources speak.
   A single light theme.
   ========================================================================== */

:root {
  --bg:         #FBFBFA;
  --bg-2:       #F4F5F3;
  --surface:    #FFFFFF;
  --hairline:   #E4E6E2;
  --hairline-2: #CFD3CE;
  --ink:        #10151A;
  --ink-dim:    #56616C;
  --ink-faint:  #8A949E;
  --accent:     #1B63C9;
  --accent-dim: #7FAEEA;
  --accent-wash: rgba(27,99,201,0.07);
  --quiet:      #C2C7C1;
  --grid:       #ECEEEA;
  --ring:       rgba(27,99,201,0.4);

  --font-serif: 'EB Garamond', Georgia, serif;
  --font-sans:  'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:  'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --step: clamp(14px, 1.1vw, 15px);
  --maxw: 1360px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3 { font-weight: 400; text-wrap: balance; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
::selection { background: var(--accent-wash); }

/* ---------- ambient field ------------------------------------------------ */
#field {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; opacity: .5;
}
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 10%, transparent 75%);
}

/* ---------- chrome ------------------------------------------------------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px; height: 52px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--hairline);
}
.bar .mark {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink);
}
.bar .mark b { color: var(--accent); font-weight: 500; }
.bar .sep { flex: 1; }
.bar .read {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .08em;
  color: var(--ink-faint); white-space: nowrap;
}
@media (max-width: 760px) { .bar .read { display: none; } }
.ghost {
  font: inherit; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-dim); background: transparent;
  border: 1px solid var(--hairline-2); border-radius: 2px;
  padding: 6px 12px; cursor: pointer; transition: color .18s, border-color .18s;
}
.ghost:hover { color: var(--ink); border-color: var(--accent-dim); }
.scan { position: absolute; left: 0; bottom: -1px; height: 1px; width: 0; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* ---------- shell -------------------------------------------------------- */
.shell {
  position: relative; z-index: 2;
  max-width: var(--maxw); margin: 0 auto;
  padding: 52px 24px 140px;
  display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 56px;
}
.index { position: sticky; top: 92px; align-self: start; }
.index ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.index a {
  display: flex; gap: 12px; align-items: baseline;
  padding: 6px 0 6px 12px; text-decoration: none;
  border-left: 1px solid var(--hairline);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .06em;
  color: var(--ink-faint); transition: color .2s, border-color .2s;
}
.index a .n { color: var(--quiet); transition: color .2s; }
.index a:hover { color: var(--ink-dim); border-left-color: var(--hairline-2); }
.index a[data-on="1"] { color: var(--ink); border-left-color: var(--accent); }
.index a[data-on="1"] .n { color: var(--accent); }

main { display: flex; flex-direction: column; gap: 132px; min-width: 0; }
section { scroll-margin-top: 92px; }

/* ---------- section furniture ------------------------------------------- */
.tag {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 22px;
}
.tag::after {
  content: ""; height: 1px; flex: 1; background: var(--hairline-2);
  transform-origin: left; transform: scaleX(0);
}
.on .tag::after { animation: sweep 1.1s cubic-bezier(.16,.84,.32,1) forwards; }
@keyframes sweep { to { transform: scaleX(1); } }

h2 {
  font-family: var(--font-serif);
  font-size: clamp(30px, 4.4vw, 52px);
  line-height: 1.08; letter-spacing: -.012em; color: var(--ink);
}
.lede { color: var(--ink-dim); font-size: clamp(15px, 1.5vw, 17.5px); max-width: 62ch; margin-top: 18px; }
.sub { color: var(--ink-dim); max-width: 62ch; margin-top: 14px; }
em { color: var(--ink); font-style: italic; }

/* ---------- hero --------------------------------------------------------- */
.hero { padding-top: 24px; }
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(38px, 7.2vw, 88px);
  line-height: 1.02; letter-spacing: -.022em;
}
.hero h1 .fade { color: var(--ink-faint); }
.verdict {
  display: flex; align-items: center; gap: 14px; margin-top: 34px;
  padding: 14px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .06em; color: var(--ink-dim);
  max-width: 62ch;
}
.verdict .led {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none;
  box-shadow: 0 0 0 0 var(--accent-wash);
}
.on .verdict .led { animation: pulse 2.6s ease-out infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--ring); }
  70%  { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.verdict strong { color: var(--ink); font-weight: 500; }

/* ---------- readouts ----------------------------------------------------- */
.readouts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 56px; border-top: 1px solid var(--hairline);
}
.readout { padding: 22px 22px 22px 0; border-right: 1px solid var(--hairline); }
.readout:last-child { border-right: none; }
.readout .v {
  font-family: var(--font-mono); font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 300; letter-spacing: -.02em; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.readout .v.hi { color: var(--accent); }
.readout .k {
  margin-top: 12px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; max-width: 26ch;
}
@media (max-width: 680px) { .readout { border-right: none; border-bottom: 1px solid var(--hairline); padding-right: 0; } }

/* ---------- rows (replaces cards) ---------------------------------------- */
.rows { margin-top: 42px; border-top: 1px solid var(--hairline); }
.row {
  display: grid; grid-template-columns: 56px 1fr; gap: 24px;
  padding: 26px 0; border-bottom: 1px solid var(--hairline);
}
.row .idx { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); letter-spacing: .1em; padding-top: 3px; }
.row h3 { font-size: 16.5px; color: var(--ink); font-weight: 500; }
.row p { color: var(--ink-dim); margin-top: 7px; max-width: 64ch; }
.row .meter { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-faint); margin-top: 9px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; gap: 8px; } }

.duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0; margin-top: 42px; border-top: 1px solid var(--hairline); }
.duo > div { padding: 26px 28px 26px 0; border-bottom: 1px solid var(--hairline); }
.duo h3 { font-size: 16.5px; font-weight: 500; margin-bottom: 8px; }
.duo p { color: var(--ink-dim); }
.duo p + p { margin-top: 10px; }

/* ---------- claim -------------------------------------------------------- */
.claim {
  margin-top: 38px; padding: 34px 0 34px 30px;
  border-left: 1px solid var(--accent);
  font-family: var(--font-serif); font-size: clamp(19px, 2.5vw, 28px);
  line-height: 1.38; color: var(--ink); max-width: 56ch;
}
.aside {
  margin-top: 34px; padding: 24px 28px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 3px;
  color: var(--ink-dim); max-width: 72ch;
}
.aside strong { color: var(--ink); font-weight: 500; }

/* ---------- instrument panels (charts) ----------------------------------- */
.panel { margin-top: 42px; border-top: 1px solid var(--hairline-2); padding-top: 18px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.panel-head .id {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-faint);
}
.panel-head .sep { flex: 1; }
.plot { margin-top: 18px; position: relative; }
.plot svg { display: block; width: 100%; overflow: visible; }
.cap { margin-top: 16px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.6; max-width: 76ch; }
.cap b { color: var(--ink-dim); font-weight: 400; font-family: var(--font-mono); }

.keys { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 14px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); letter-spacing: .04em; }
.keys .key { display: inline-flex; align-items: center; gap: 8px; }
.keys .sw { width: 9px; height: 9px; flex: none; }

/* ---------- controls ----------------------------------------------------- */
.ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 18px; }
.ctl .lbl { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); margin-right: 2px; }
.tog {
  font: inherit; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .06em;
  padding: 7px 14px; cursor: pointer; color: var(--ink-dim);
  background: transparent; border: 1px solid var(--hairline-2); border-radius: 2px;
  transition: color .18s, border-color .18s, background .18s;
}
.tog:hover { color: var(--ink); border-color: var(--accent-dim); }
.tog[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }
select, input[type="search"] {
  font: inherit; font-family: var(--font-mono); font-size: 11.5px;
  padding: 7px 12px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline-2); border-radius: 2px;
}
input[type="search"] { min-width: 230px; }

/* ---------- tooltip ------------------------------------------------------ */
.tip {
  position: fixed; z-index: 80; pointer-events: none; opacity: 0;
  transform: translateY(4px); transition: opacity .13s, transform .13s;
  background: var(--surface); border: 1px solid var(--hairline-2);
  padding: 11px 13px; max-width: 290px; border-radius: 3px;
  box-shadow: 0 14px 40px rgba(16,21,26,.14);
}
.tip.on { opacity: 1; transform: none; }
.tip .n { font-size: 13px; color: var(--ink); font-weight: 500; }
.tip .n i { color: var(--ink-dim); font-weight: 400; }
.tip .r { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-dim); margin-top: 4px; font-variant-numeric: tabular-nums; }
.tip .r b { color: var(--accent); font-weight: 400; }

/* ---------- tables ------------------------------------------------------- */
.sheet { margin-top: 18px; max-height: 460px; overflow: auto; border: 1px solid var(--hairline); border-radius: 3px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--bg-2);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 400;
}
td { color: var(--ink-dim); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.t { font-family: var(--font-sans); color: var(--ink); white-space: normal; min-width: 190px; }
td.w { font-family: var(--font-sans); white-space: normal; min-width: 230px; }
tr.mal td.t { color: var(--accent); }
tbody tr:hover td { background: var(--accent-wash); }
.meta { margin-top: 10px; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); }
[hidden] { display: none !important; }

/* ---------- close -------------------------------------------------------- */
.close { border-top: 1px solid var(--hairline); margin-top: 34px; padding-top: 24px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); line-height: 1.9; }

/* ---------- motion: additive only ---------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.anim .r1.on-el { animation: rise .7s cubic-bezier(.16,.84,.32,1) both; }
.anim .d1.on-el { animation-delay: .06s; }
.anim .d2.on-el { animation-delay: .12s; }
.anim .d3.on-el { animation-delay: .18s; }
.anim .d4.on-el { animation-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  .anim .r1.on-el { animation: none; }
  .on .tag::after { animation: none; transform: scaleX(1); }
  .on .verdict .led { animation: none; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; gap: 28px; padding-top: 40px; }
  .index { position: static; }
  .index ol { flex-direction: row; overflow-x: auto; gap: 2px; padding-bottom: 6px; }
  .index a { border-left: none; border-bottom: 1px solid var(--hairline); padding: 6px 10px; white-space: nowrap; }
  .index a[data-on="1"] { border-left-color: transparent; border-bottom-color: var(--accent); }
  .index a .t { display: none; }
  main { gap: 96px; }
}

/* ==========================================================================
   Figures: isometric dioramas (Blender, EEVEE, orthographic 54.736°/45°)
   ========================================================================== */
.withart { display: grid; grid-template-columns: minmax(0,1fr) 352px; gap: 48px; align-items: start; }
.withart > .art { position: relative; }
.art img { display: block; width: 100%; height: auto; }
.art figcaption {
  margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint);
  text-align: center;
}
/* a soft pool of light under the slab so it sits on the page rather than floating */
.art::before {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 16%; height: 22%;
  background: radial-gradient(ellipse at center, var(--accent-wash) 0%, transparent 70%);
  filter: blur(14px); pointer-events: none;
}
@keyframes drift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes land  { from { opacity: 0; transform: translateY(26px) scale(.965); } to { opacity: 1; transform: none; } }
.anim .art img { animation: drift 7s ease-in-out infinite; }
.anim .art.on-el img { animation: land .85s cubic-bezier(.16,.84,.32,1) both, drift 7s ease-in-out 1s infinite; }

@media (max-width: 1080px) {
  .withart { grid-template-columns: 1fr; gap: 28px; }
  .withart > .art { max-width: 320px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .anim .art img, .anim .art.on-el img { animation: none; }
}

/* ---------- inline icons ---------- */
.ico { width: 19px; height: 19px; stroke: currentColor; fill: none;
       stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }
.row .idx .ico { margin-top: 1px; }
#sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* a diorama that stands alone in a column rather than beside text */
.art-solo { max-width: 330px; margin: 36px auto 0; }

/* ---------- the opening figure ---------- */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 56px; align-items: center; }
.hero-art { margin: 0; }
.hero-art::before { left: 16%; right: 16%; bottom: 20%; height: 20%; }
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .hero-art { max-width: 340px; margin: 4px auto 0; }
}
