/* ==========================================================================
   Labs · World3
   Loaded only on /labs/world3/. Builds on site.css (tokens, fonts, page
   header, prose); everything here is specific to the simulation.
   ========================================================================== */

/* Land colours for the arable-land bar, the same in both themes */
:root {
  --daisy-black: #161616;
  --daisy-white: #f7f7f7;
  --ground: #8f8f8f;
}

.panel h3, .btn, .seg button, .readout dt, .chart-head, .legend {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.page-header .label { color: var(--muted); margin: 0 0 0.9rem; }
.page-header .tour-btn { margin-top: 1.5rem; }

/* ---------- Lab: charts + panel ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 3rem; align-items: start; }
@media (max-width: 960px) { .lab { grid-template-columns: minmax(0, 1fr); gap: 2rem; } }

@media (max-width: 960px) { .stage-wrap { position: static; } }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; color: var(--ink-soft); margin: 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 0.45rem; }
.sw { width: 0.8rem; height: 0.8rem; border: 1px solid var(--muted); display: inline-block; flex: none; }
.sw-round { border-radius: 50%; }

/* Panel */
.panel { border-top: 1px solid var(--ink); }
.panel section { padding: 1.1rem 0 1.25rem; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: 0; }
.panel h3 { color: var(--ink); display: flex; align-items: center; gap: 0.75rem; margin: 0 0 0.9rem; }
.panel h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; margin: 0; }
.readout div { min-width: 0; }
.readout dt { color: var(--muted); font-size: 0.62rem; margin-bottom: 0.15rem; }
.readout dd { margin: 0; font-family: var(--serif); font-size: 2rem; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.readout dd small { font-size: 0.95rem; color: var(--ink-soft); margin-left: 0.15rem; letter-spacing: 0; }
.readout .wide { grid-column: 1 / -1; }
.readout .dim dd { color: var(--muted); }


.row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.btn {
  font-family: var(--mono); background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 0;
  padding: 0.5rem 0.8rem; cursor: pointer; line-height: 1.2;
}
.btn:hover, .btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.btn-wide { flex: 1; }

.seg { display: flex; border: 1px solid var(--ink); }
.seg button {
  flex: 1; min-width: 0; font-family: var(--mono); background: var(--paper); color: var(--ink); border: 0; border-left: 1px solid var(--ink);
  border-radius: 0; padding: 0.45rem 0.3rem; cursor: pointer; line-height: 1.2; font-size: 0.62rem;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.ctl { margin-top: 0.9rem; }
.ctl:first-child { margin-top: 0; }
.ctl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.2rem; }
.ctl-head label, .ctl-head span:first-child { font-size: 0.88rem; color: var(--ink-soft); }
.ctl-head output { font-family: var(--mono); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.hint { font-size: 0.8rem; line-height: 1.45; color: var(--muted); margin: 0.35rem 0 0; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 1.4rem; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--ink); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 0.85rem; height: 0.85rem; margin-top: calc(-0.425rem + 0.5px); background: var(--paper); border: 1px solid var(--ink); border-radius: 0; }
input[type="range"]::-moz-range-thumb { width: 0.85rem; height: 0.85rem; background: var(--paper); border: 1px solid var(--ink); border-radius: 0; }
input[type="range"]:hover::-webkit-slider-thumb { background: var(--ink); }
input[type="range"]:hover::-moz-range-thumb { background: var(--ink); }
input[type="range"]:focus-visible { outline-offset: 4px; }

.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--ink-soft); cursor: pointer; }
.check input { -webkit-appearance: none; appearance: none; width: 0.85rem; height: 0.85rem; border: 1px solid var(--ink); margin: 0; display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }
.checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin-top: 0.9rem; }

/* ---------- Charts ---------- */
.section-h {
  color: var(--ink); display: flex; align-items: center; gap: 1rem; margin: 4rem 0 1.25rem;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 400; text-transform: uppercase; letter-spacing: 0.12em;
}
.section-h::after { content: ""; flex: 1; height: 1px; background: var(--ink); }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.chart { border: 1px solid var(--line); padding: 1rem 1rem 0.75rem; min-width: 0; }
.chart-big { grid-column: 1 / -1; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem 1rem; color: var(--ink); margin-bottom: 0.6rem; }
.chart-head .legend { color: var(--muted); font-size: 0.62rem; }
.chart canvas { display: block; width: 100%; height: 15rem; }
.chart-big canvas { height: 22rem; }
.chart figcaption { font-family: var(--serif); font-style: italic; font-size: 0.9rem; color: var(--ink-soft); margin-top: 0.5rem; }
.ln { width: 1.4rem; height: 0; border-top: 1.5px solid var(--ink); display: inline-block; }
.ln-dash { border-top: 1.5px dashed var(--muted); }
.ln-dot { border-top: 2px dotted var(--ink-soft); }
.band { width: 0.9rem; height: 0.6rem; background: var(--wash); border: 1px solid var(--line); display: inline-block; }
@media (max-width: 760px) { .charts { grid-template-columns: 1fr; } .chart-big canvas { height: 17rem; } }

.prose li .btn { margin-left: 0.35rem; padding: 0.25rem 0.5rem; font-size: 0.6rem; vertical-align: 0.1em; }
.eq {
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.9; background: var(--wash); border-left: 2px solid var(--ink);
  padding: 0.9rem 1.2rem; margin: 0 0 1.5rem; overflow-x: auto; white-space: pre;
}
.refs p { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.6; }


/* ---------- Guided tour ---------- */
.tour-btn {
  flex: none; font: inherit; font-family: var(--nav-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em;
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink); padding: 0.45rem 0.7rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.45rem;
}
.tour-btn:hover { background: var(--ink); color: var(--paper); }
.tour-btn::before { content: "?"; display: grid; place-items: center; width: 0.95rem; height: 0.95rem; border: 1px solid currentColor; border-radius: 50%; font-size: 0.6rem; letter-spacing: 0; }

.tour-shade { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55); }
.tour-spot {
  position: fixed; z-index: 50; pointer-events: none;
  outline: 1px solid var(--ink); outline-offset: 0;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.55);
  transition: left 0.35s var(--ease), top 0.35s var(--ease), width 0.35s var(--ease), height 0.35s var(--ease);
}
.tour-spot::after { content: ""; position: absolute; inset: -6px; border: 1px dashed var(--paper); opacity: 0.9; }
.tour-card {
  position: fixed; z-index: 60; width: min(23rem, calc(100vw - 2rem)); max-height: calc(100vh - 6rem); overflow: auto;
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink); padding: 1.1rem 1.25rem 1.1rem;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.25);
}
.tour-card.sheet { left: 0.75rem !important; right: 0.75rem; top: auto !important; bottom: 0.75rem; width: auto; max-height: 46vh; }
.tour-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.tour-x { background: none; border: 0; color: var(--ink); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 0.15rem; }
.tour-bar { display: flex; gap: 3px; margin: 0.6rem 0 0.9rem; }
.tour-bar i { flex: 1; height: 2px; background: var(--line); }
.tour-bar i.on { background: var(--ink); }
.tour-card h2 { font-size: 1.45rem; margin: 0 0 0.45rem; }
.tour-card p { font-family: var(--serif); font-size: 0.95rem; line-height: 1.6; color: var(--ink-soft); margin: 0; }
.tour-task {
  display: flex; align-items: center; gap: 0.6rem; margin-top: 0.9rem !important; padding: 0.55rem 0.7rem;
  border: 1px dashed var(--ink); font-family: var(--mono) !important; font-size: 0.7rem !important; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink) !important;
}
.tour-task[hidden] { display: none; }
.tour-check { flex: none; width: 0.8rem; height: 0.8rem; border: 1px solid var(--ink); border-radius: 50%; animation: tour-pulse 1.8s var(--ease) infinite; }
@keyframes tour-pulse { 0% { box-shadow: 0 0 0 0 var(--ink); } 70%, 100% { box-shadow: 0 0 0 0.4rem transparent; } }
.tour-task.done { border-style: solid; background: var(--ink); color: var(--paper) !important; }
.tour-task.done .tour-check { animation: none; border-color: var(--paper); background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); }
.tour-nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 1rem; }
.tour-nav .btn[disabled] { visibility: hidden; }
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--paper); color: var(--ink); }
.tour-hint { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); letter-spacing: 0.08em; margin-top: 0.75rem; text-transform: uppercase; }
@media (max-width: 700px) { .tour-hint { display: none; } }

.tour-invite {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40; width: min(19rem, calc(100vw - 2rem));
  background: var(--paper); border: 1px solid var(--ink); padding: 1rem 1.1rem; box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.2);
}
.tour-invite p { font-family: var(--serif); font-size: 0.95rem; line-height: 1.5; color: var(--ink-soft); margin: 0.35rem 0 0.85rem; }
.tour-invite .label { color: var(--muted); }

/* ---------- World3 ---------- */
:root { --lost: #c9c9c9; }

/* charts are the main view */
.charts-col { min-width: 0; }
.charts-col .chart-big canvas { height: 26rem; }
.charts-col .multiples { margin-top: 1rem; }
@media (max-width: 960px) { .charts-col .chart-big canvas { height: 18rem; } }

.readout .yr dd { font-size: 3rem; }
.readout dd { font-size: 1.65rem; }
.land { display: flex; height: 0.9rem; border: 1px solid var(--ink); background: var(--ground); margin-top: 0.4rem; }
.land span { display: block; height: 100%; }
.land .l-farm { background: var(--daisy-black); }
.land .l-built { background: var(--daisy-white); }
.land .l-lost { background: var(--lost); }
.land-num { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 0.75rem; font-family: var(--mono); font-size: 0.66rem; color: var(--ink-soft); margin-top: 0.35rem; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.sw-sq { border-radius: 0; }

.scen { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--ink); }
.scen button {
  font-family: var(--mono); font-size: 0.72rem; background: var(--paper); color: var(--ink); border: 0; border-radius: 0;
  border-left: 1px solid var(--ink); padding: 0.5rem 0; cursor: pointer; line-height: 1.2; font-variant-numeric: tabular-nums;
}
.scen button:nth-child(5n + 1) { border-left: 0; }
.scen button:nth-child(n + 6) { border-top: 1px solid var(--ink); }
.scen button:hover { background: var(--wash); }
.scen button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.scen-note { margin: 0.6rem 0 0; font-size: 0.88rem; line-height: 1.5; color: var(--ink-soft); min-height: 4.4em; }
.scen-note strong { font-weight: 500; color: var(--ink); }
.checks-col { display: grid; gap: 0.45rem; margin-top: 0.9rem; }

/* charts */
.chart canvas { cursor: col-resize; touch-action: pan-y; }
.legend li[data-k] { cursor: default; transition: opacity 0.15s; }
.legend.focusing li[data-k]:not(.on) { opacity: 0.35; }
.ln-thick { border-top: 3px solid var(--muted); }
.ln-thin { border-top: 1px solid var(--ink); }
.ln-dot2 { border-top: 2px dotted var(--ink); }
.ln-long { border-top: 1.5px dashed var(--ink); }
.dot-obs { width: 0.55rem; height: 0.55rem; border: 1px solid var(--ink); border-radius: 50%; display: inline-block; }
.multiples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.mini { padding: 0.75rem 0.8rem 0.55rem; }
.mini .chart-head { margin-bottom: 0.35rem; }
.mini .chart-head span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mini .chart-head output { font-family: var(--mono); color: var(--ink-soft); text-transform: none; letter-spacing: 0.02em; white-space: pre-line; min-height: 2.5em; line-height: 1.3; font-variant-numeric: tabular-nums; }
.mini canvas { height: 8.5rem; }
.multiples-key { margin-top: 0.75rem; }
@media (max-width: 960px) { .multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .multiples { grid-template-columns: minmax(0, 1fr); } }
/* equations: native MathML, no library */
.eqs { background: var(--wash); border-left: 2px solid var(--ink); padding: 0.4rem 1.2rem; margin: 0 0 1.5rem; }
.eq-row { display: grid; grid-template-columns: minmax(0, 1fr) 13rem; align-items: center; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.eq-row:last-child { border-bottom: 0; }
.eq-row math { margin: 0; font-size: 1.12rem; justify-self: start; overflow-x: auto; max-width: 100%; color: var(--ink); }
.eq-row span { font-family: var(--serif); font-style: italic; font-size: 0.88rem; color: var(--ink-soft); }
math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; }
@media (max-width: 620px) { .eq-row { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; } }
.mini .chart-head { flex-direction: column; flex-wrap: nowrap; gap: 0.1rem; }
.prose .note { font-size: 0.9rem; color: var(--ink-soft); }
