/* styles.css — the mlsynth ladder lab.
   Dark navy site palette; no external fonts or assets.
   The first two-thirds is shared verbatim with the R edition's companion at
   /post/r_sc_dsc_sdid/web_app/ so the two read as a pair. The classes from
   "the anatomy panel" onward are specific to this app. */

:root {
  --bg:        #0f1729;
  --panel:     #16203a;
  --border:    #1f2b5e;
  --text:      #e8ecf2;
  --dim:       #c8d0e0;
  --muted:     #8b9dc3;
  --steel:     #6a9bcc;
  --orange:    #d97757;
  --teal:      #00d4c8;
  --gold:      #e8b04b;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  font-size: 16px;
}

main { max-width: 980px; margin: 0 auto; }

/* ---- hero ---- */
.hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 3rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  margin: 0 0 .4rem;
  color: var(--teal);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0 0 .8rem;
  font-size: clamp(1.7rem, 4.4vw, 2.5rem);
  line-height: 1.2;
  font-weight: 650;
}
.lede {
  margin: 0;
  max-width: 66ch;
  color: var(--dim);
  font-size: 1.03rem;
}
.meta-line {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: .84rem;
}

/* ---- panels ---- */
.panel {
  margin: 2.2rem 0;
  padding: 1.4rem 1.4rem 1.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  scroll-margin-top: 1rem;
}
.panel-head h2 {
  margin: 0 0 .35rem;
  font-size: 1.16rem;
  font-weight: 620;
}
.panel-head p {
  margin: 0 0 1rem;
  max-width: 68ch;
  color: var(--muted);
  font-size: .93rem;
}
.panel h3.sub {
  margin: 1.8rem 0 .2rem;
  font-size: .96rem;
  font-weight: 620;
  color: var(--dim);
}
.panel-sub {
  margin: .1rem 0 .8rem;
  max-width: 68ch;
  color: var(--muted);
  font-size: .9rem;
}

/* ---- controls ---- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.1rem;
}
.pill {
  padding: .42rem .9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font-size: .87rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.pill:hover { border-color: var(--steel); color: var(--text); }
.pill.active {
  background: var(--steel);
  border-color: var(--steel);
  color: #0f1729;
  font-weight: 600;
}
.pill:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---- charts ---- */
.chart-wrap {
  width: 100%;
  overflow-x: auto;
  margin: .4rem 0 .2rem;
}
.chart-wrap svg { width: 100%; height: auto; display: block; min-width: 520px; }

/* ---- readout ---- */
.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem 2.4rem;
  align-items: baseline;
  margin: 1rem 0 .4rem;
  padding: 1rem 1.1rem;
  background: rgba(106, 155, 204, 0.08);
  border-left: 3px solid var(--steel);
  border-radius: 4px;
}
.stat { display: flex; flex-direction: column; }
.stat .num {
  font-size: 1.7rem;
  font-weight: 650;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat .lab {
  font-size: .8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.blurb {
  flex-basis: 100%;
  margin: .2rem 0 0;
  max-width: 72ch;
  color: var(--dim);
  font-size: .92rem;
}

.note {
  margin: .9rem 0 0;
  max-width: 74ch;
  color: var(--dim);
  font-size: .92rem;
  border-left: 3px solid var(--teal);
  padding-left: .9rem;
}

.error {
  padding: 1rem;
  border: 1px solid var(--orange);
  border-radius: 8px;
  color: var(--orange);
}

/* ---- tooltip ---- */
.tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  max-width: 320px;
  padding: .5rem .7rem;
  background: rgba(15, 23, 41, 0.97);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .84rem;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  transition: opacity .12s;
}
.tooltip .dim { color: var(--muted); }

/* ---- footer ---- */
footer {
  max-width: 980px;
  margin: 3rem auto 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .88rem;
}
footer a { color: var(--steel); }
footer .cite { font-size: .82rem; margin-top: .6rem; }
code {
  padding: .1em .35em;
  background: rgba(232, 236, 242, 0.08);
  border-radius: 3px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ======================================================================
   From here down: components this app needs and the R edition does not.
   ====================================================================== */

/* ---- the in-page nav and part dividers ---- */
.toc {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .5rem;
  margin: 1.6rem 0 0;
  padding: .9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .82rem;
}
.toc-head {
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: .68rem;
  margin-right: .1rem;
}
.toc-head:not(:first-child) { margin-left: .7rem; }
.toc a {
  color: var(--dim);
  text-decoration: none;
  padding: .12rem .45rem;
  border: 1px solid transparent;
  border-radius: 999px;
}
.toc a:hover { color: var(--text); border-color: var(--steel); }

.part {
  margin: 2.6rem 0 -.6rem;
  color: var(--muted);
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* ---- two-column layout for the anatomy and hazard panels ---- */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin: .4rem 0 .2rem;
}

/* ---- the anatomy panel ---- */
.code-card {
  padding: 1rem 1.1rem 1.1rem;
  background: rgba(15, 23, 41, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
}
.code-card h3 {
  margin: 0 0 .7rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.code-card pre {
  margin: 0 0 .9rem;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.55;
}
.code-card pre code {
  padding: 0;
  background: none;
  color: var(--dim);
  white-space: pre;
}
.code-card .kw { color: var(--steel); }

.fieldlist { list-style: none; margin: 0; padding: 0; }
.fieldlist li {
  padding: .42rem 0;
  border-top: 1px solid var(--border);
  font-size: .88rem;
  line-height: 1.5;
}
.fieldlist li:first-child { border-top: none; }
.fieldlist .name {
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
}
.fieldlist .val {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
  word-break: break-word;
}
.fieldlist .why { display: block; color: var(--muted); font-size: .84rem; }
.fieldlist.accessors .name { color: var(--gold); }

.trap {
  margin: 1.6rem 0 0;
  padding: 1rem 1.1rem;
  background: rgba(217, 119, 87, 0.10);
  border: 1px solid rgba(217, 119, 87, 0.4);
  border-radius: 8px;
}
.trap h3 {
  margin: 0 0 .5rem;
  font-size: .95rem;
  font-weight: 620;
  color: var(--orange);
}
.trap p { margin: 0 0 .6rem; font-size: .9rem; color: var(--dim); max-width: 72ch; }
.trap p:last-child { margin-bottom: 0; }
.trap .pair {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 2.6rem;
  margin: .7rem 0 .9rem;
}
.trap .pair div { display: flex; flex-direction: column; }
.trap .pair .num {
  font-size: 1.45rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.trap .pair .lab {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.trap .bad .num { color: var(--orange); }
.trap .good .num { color: var(--teal); }

/* ---- the name-clash cards ---- */
.hazard {
  padding: 1rem 1.1rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 41, 0.6);
}
.hazard h3 { margin: 0 0 .5rem; font-size: 1rem; font-weight: 620; }
.hazard h3 code { font-size: .92em; }
.hazard p { margin: 0 0 .6rem; font-size: .9rem; color: var(--dim); }
.hazard .verdict {
  margin: .8rem 0 0;
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.hazard-bad { border-color: rgba(217, 119, 87, 0.45); }
.hazard-bad .verdict { color: var(--orange); }
.hazard-good { border-color: rgba(0, 212, 200, 0.4); }
.hazard-good .verdict { color: var(--teal); }

/* ---- the zeta slider ---- */
.dial-view { display: none; }
.dial-view.on { display: block; }
.slider-row {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin: .2rem 0 .6rem;
  flex-wrap: wrap;
}
.slider-row label {
  color: var(--muted);
  font-size: .84rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.slider-row input[type="range"] {
  flex: 1 1 240px;
  min-width: 200px;
  accent-color: var(--steel);
}
.slider-row output {
  color: var(--text);
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- the inference table ---- */
.table-wrap { width: 100%; overflow-x: auto; margin-top: 1rem; }
.tbl {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: .87rem;
}
.tbl th, .tbl td {
  padding: .45rem .7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tbl th {
  color: var(--muted);
  font-weight: 600;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.failed td { color: var(--orange); }
.tbl code { font-size: .84em; }

@media (max-width: 640px) {
  .panel { padding: 1.1rem .9rem 1.2rem; }
  .readout { gap: 1rem 1.4rem; }
  .stat .num { font-size: 1.4rem; }
  .toc { font-size: .78rem; }
  .code-card { padding: .9rem .8rem 1rem; }
}
