/* medjournal.net — Complete Evidence Standard */

:root {
  --bg:        #fbfaf8;
  --bg-alt:    #f2efea;
  --panel:     #ffffff;
  --ink:       #16181d;
  --ink-soft:  #4d5560;
  --ink-faint: #7c8794;
  --rule:      #ddd8d0;
  --accent:    #1f5f8b;
  --accent-2:  #14415f;
  --bad:       #b3311f;
  --bad-bg:    #fbeeeb;
  --good:      #1c6b46;
  --good-bg:   #eaf4ee;
  --warn:      #9a6a12;
  --radius:    10px;
  --measure:   34rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14161a;
    --bg-alt:    #1b1e24;
    --panel:     #1e222a;
    --ink:       #e9eaec;
    --ink-soft:  #b3b9c2;
    --ink-faint: #868e99;
    --rule:      #333944;
    --accent:    #6fb3dd;
    --accent-2:  #a5d3ef;
    --bad:       #ef8b78;
    --bad-bg:    #351f1a;
    --good:      #6fc79a;
    --good-bg:   #16301f;
    --warn:      #dcae5a;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.012em;
  margin: 0 0 .6em;
}

p { margin: 0 0 1.1em; max-width: var(--measure); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.wrap { width: min(100% - 2.5rem, 60rem); margin-inline: auto; }
.narrow { max-width: var(--measure); }

section { padding: clamp(3rem, 8vw, 6rem) 0; border-top: 1px solid var(--rule); }
section:first-of-type { border-top: 0; }

.eyebrow {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .74rem; font-weight: 650; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 1.2rem;
}

.lede { font-size: 1.18rem; color: var(--ink-soft); }
.small { font-size: .88rem; color: var(--ink-soft); }
.tiny  { font-size: .78rem; color: var(--ink-faint); }
.mono  { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- hero --- */
.hero { padding: clamp(4rem, 12vw, 8rem) 0 clamp(3rem, 7vw, 5rem); }
.hero h1 { font-size: clamp(2.1rem, 6.2vw, 3.9rem); max-width: 20ch; }
.hero .issuer {
  margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--rule);
  font-size: .93rem; color: var(--ink-soft); max-width: var(--measure);
}

/* --------------------------------------------------------------- panels --- */
.panel {
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: clamp(1.2rem, 3vw, 2rem);
}
.panel + .panel { margin-top: 1.2rem; }

/* ------------------------------------------------------------ 2x2 table --- */
.tbl2 { width: 100%; border-collapse: collapse; margin: .4rem 0 1.4rem; font-size: .95rem; }
.tbl2 caption { text-align: left; color: var(--ink-soft); font-size: .85rem; padding-bottom: .7rem; }
.tbl2 th, .tbl2 td { border: 1px solid var(--rule); padding: .6rem .8rem; text-align: right; }
.tbl2 th { background: var(--bg-alt); font-weight: 600; font-size: .82rem; color: var(--ink-soft); }
.tbl2 th:first-child, .tbl2 td:first-child { text-align: left; }
.tbl2 td.num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.tbl2 td.num.live { transition: background-color .35s ease, color .35s ease; border-radius: 3px; }
.tbl2 td.num.bump { background: var(--bad-bg); color: var(--bad); font-weight: 700; }

/* ---------------------------------------------------------- p-value dial --- */
.dial { margin: 1.6rem 0 .4rem; }
.dial-track {
  position: relative; height: 44px; border-radius: 6px;
  background: linear-gradient(90deg, var(--good-bg) 0%, var(--good-bg) 50%, var(--bad-bg) 50%, var(--bad-bg) 100%);
  border: 1px solid var(--rule); overflow: hidden;
}
.dial-line { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--ink-faint); }
.dial-line::after {
  content: "α = 0.05"; position: absolute; top: 50%; left: 8px; transform: translateY(-50%);
  font-size: .7rem; letter-spacing: .04em; color: var(--ink-faint); white-space: nowrap;
}
.dial-needle {
  position: absolute; top: -3px; bottom: -3px; width: 4px; border-radius: 3px;
  background: var(--accent); transition: left .9s cubic-bezier(.4,0,.2,1), background-color .9s ease;
}
.dial-val {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: .55rem; font-size: .85rem; color: var(--ink-soft);
}
.dial-val strong { font-size: 1.5rem; color: var(--ink); font-family: ui-monospace, Menlo, Consolas, monospace; }
.dial-val strong.ns { color: var(--warn); }

/* ---------------------------------------------------------------- dots ---- */
.arms { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; margin: 1.2rem 0; }
@media (max-width: 620px) { .arms { grid-template-columns: 1fr; } }
.arm h4 { margin: 0 0 .1rem; font-size: .95rem; font-family: inherit; font-weight: 650; }
.arm .cnt { font-size: .8rem; color: var(--ink-soft); margin-bottom: .55rem; font-variant-numeric: tabular-nums; }
.grid {
  display: grid; gap: 1px; padding: 6px; border: 1px solid var(--rule);
  border-radius: 6px; background: var(--bg-alt); position: relative;
}
.grid.small { gap: 4px; padding: 10px; }
.dot { width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--rule); }
.dot.evt { background: var(--bad); }
.dot.big { min-width: 14px; }
.flyer {
  position: absolute; border-radius: 50%; background: var(--bad); z-index: 5;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 28%, transparent);
  transition: transform 1.15s cubic-bezier(.45,.05,.35,1);
}

/* ------------------------------------------------------------- metrics ---- */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule);
  border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin: 1.4rem 0; }
@media (max-width: 620px) { .metrics { grid-template-columns: 1fr; } }
.metric { background: var(--panel); padding: 1.1rem 1.2rem; }
.metric .k { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.metric .v { font-size: 1.75rem; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; margin: .15rem 0 .1rem; }
.metric .d { font-size: .8rem; color: var(--ink-soft); }
.metric.is-bad .v { color: var(--bad); }
.metric.is-good .v { color: var(--good); }

/* neutrality scale — markers, not a fill bar. A value of 0.011 must read as
   "pinned at the neutrality end", not as an empty/broken bar. */
/* The padding is load-bearing: marker labels sit ~50px above the rail and the
   axis captions ~30px below it, both absolutely positioned. Without reserved
   space they escape the box and land on top of the surrounding paragraphs. */
.nbscale { margin: 1.8rem 0 1rem; padding: 3.4rem 0 2.2rem; }
.nbscale-track {
  position: relative; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--bad) 26%, var(--bg-alt)) 0%,
    var(--bg-alt) 22%,
    color-mix(in srgb, var(--good) 22%, var(--bg-alt)) 100%);
  border: 1px solid var(--rule);
}
.nbscale-track::before, .nbscale-track::after {
  position: absolute; top: 16px; font-size: .72rem; color: var(--ink-faint); white-space: nowrap;
}
.nbscale-track::before { content: "0.0 — at neutrality"; left: 0; }
.nbscale-track::after  { content: "1.0 — maximal separation"; right: 0; }

/* Markers are VISIBLE BY DEFAULT. They carry the nb value, which is content,
   not decoration — it must never depend on script running. JS opts into the
   entrance animation by adding .armed; if JS is absent, blocked, or errors,
   the reader still sees every value. */
.nbmark {
  position: absolute; top: 50%; width: 15px; height: 15px; border-radius: 50%;
  border: 3px solid var(--panel); transform: translate(-50%, -50%) scale(1);
  transition: transform .7s cubic-bezier(.34,1.4,.5,1), left .7s ease;
  background: var(--accent);
}
.nbscale.armed .nbmark { transform: translate(-50%, -50%) scale(0); }
.nbmark.is-bad  { background: var(--bad); }
.nbmark.is-good { background: var(--good); }
.nbmark > b {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  font: 600 .76rem/1.3 ui-monospace, Menlo, Consolas, monospace;
  color: var(--ink); white-space: nowrap; text-align: center;
}
.nbmark > b em { display: block; font-style: normal; font-weight: 500;
  font-family: inherit; font-size: .68rem; color: var(--ink-faint); letter-spacing: .02em; }
/* Every label goes ABOVE the rail; the axis captions own the space below it.
   (An earlier .flip variant put a label below the rail, where it collided with
   the "0.0 — at neutrality" caption.) */

/* A marker near either end would centre its label off the edge of the track,
   so labels at the extremes align inward instead. */
.nbmark.edge-left  > b { left: 0;    right: auto; transform: none; text-align: left; }
.nbmark.edge-right > b { left: auto; right: 0;    transform: none; text-align: right; }

.nbscale-foot { margin-top: .4rem; }

/* -------------------------------------------------------------- pattern --- */
.pattern { display: inline-flex; align-items: center; gap: .55rem; padding: .5rem .85rem;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--panel); }
.pattern .lamp { width: 13px; height: 13px; border-radius: 50%; background: var(--rule); }
.pattern .lamp.on  { background: var(--good); }
.pattern .lamp.off { background: var(--bad); }
.pattern .txt { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; letter-spacing: .05em; }

.verdict { margin-top: 1rem; padding: .9rem 1.1rem; border-left: 3px solid var(--bad);
  background: var(--bad-bg); border-radius: 0 6px 6px 0; font-size: .97rem; }
.verdict.ok { border-left-color: var(--good); background: var(--good-bg); }

/* --------------------------------------------------------------- choice --- */
.choice { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.4rem 0 0; }
.btn {
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  padding: .7rem 1.4rem; border-radius: 7px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; transition: filter .15s ease, transform .1s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.wide { width: 100%; padding: .85rem 1.4rem; font-size: 1rem; }
.btn[disabled] { opacity: .45; cursor: default; }

.reveal { display: none; }
.reveal.shown { display: block; animation: fade .55s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ fi vs gfi --- */
.bars { margin: 1.4rem 0; display: grid; gap: .85rem; }
.bar-row { display: grid; grid-template-columns: 11rem 1fr; gap: .9rem; align-items: center; font-size: .87rem; }
@media (max-width: 620px) { .bar-row { grid-template-columns: 1fr; gap: .3rem; } }
.bar-lab strong { display: block; font-weight: 600; }
.bar-lab span { color: var(--ink-faint); font-size: .78rem; }
.bar-pair { display: grid; gap: 4px; }
.bar { height: 15px; border-radius: 3px; display: flex; align-items: center; }
.bar > i { display: block; height: 100%; border-radius: 3px; }
.bar.fi  > i { background: var(--ink-faint); }
.bar.gfi > i { background: var(--accent); }
.bar em { font-style: normal; font-size: .72rem; margin-left: .5rem; color: var(--ink-soft);
  font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }

.legend { display: flex; gap: 1.2rem; font-size: .78rem; color: var(--ink-soft); margin-bottom: .9rem; }
.legend i { display: inline-block; width: 22px; height: 9px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }
.legend .a { background: var(--ink-faint); }
.legend .b { background: var(--accent); }

/* -------------------------------------------------------------- standard -- */
.standard { background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: clamp(1.4rem, 4vw, 2.6rem); }
.standard ol { margin: 1.2rem 0 0; padding-left: 1.3rem; }
.standard li { margin-bottom: .95rem; max-width: var(--measure); }
.standard li strong { color: var(--ink); }

/* ---------------------------------------------------------------- form ---- */
.form { display: grid; gap: 1rem; margin-top: 1.6rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 620px) { .row2 { grid-template-columns: 1fr; } }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .3rem; }
input[type=text], input[type=email] {
  width: 100%; font: inherit; font-size: .95rem; padding: .62rem .75rem;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--bg); color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.checks { display: grid; gap: .55rem; margin-top: .2rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .92rem; color: var(--ink); font-weight: 400; }
.check input { margin-top: .25rem; flex: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.flash { padding: 1rem 1.2rem; border-radius: 7px; margin-bottom: 1.4rem; font-size: .95rem; }
.flash.ok  { background: var(--good-bg); border: 1px solid var(--good); color: var(--good); }
.flash.err { background: var(--bad-bg);  border: 1px solid var(--bad);  color: var(--bad); }

/* --------------------------------------------------------- signatories ---- */
.sigs { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.sig { background: var(--panel); padding: .85rem 1rem; font-size: .87rem; }
.sig strong { display: block; font-weight: 600; }
.sig span { color: var(--ink-soft); }
.sigs-empty { color: var(--ink-soft); font-size: .93rem; }
.count { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 2.2rem; }

/* --------------------------------------------------------------- doors ---- */
.doors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
@media (max-width: 700px) { .doors { grid-template-columns: 1fr; } }
.door { background: var(--panel); padding: 1.4rem 1.3rem; text-decoration: none; color: inherit; display: block; }
.door:hover { background: var(--bg-alt); }
.door strong { display: block; font-size: 1.02rem; margin-bottom: .25rem; color: var(--accent); }
.door span { font-size: .85rem; color: var(--ink-soft); }

footer { border-top: 1px solid var(--rule); padding: 3rem 0 4rem; font-size: .85rem; color: var(--ink-soft); }
footer p { max-width: 46rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
