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

/* The planet keeps its real colours in both themes: black daisies stay black */
: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: planet + 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; } }

.stage-wrap { position: sticky; top: 6.5rem; }
@media (max-width: 960px) { .stage-wrap { position: static; } }
.stage { position: relative; width: 100%; max-width: 40rem; margin: 0 auto; aspect-ratio: 1; }
.stage canvas { position: absolute; left: 10%; top: 10%; width: 80%; height: 80%; touch-action: none; cursor: crosshair; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.orbit { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 7; vector-effect: non-scaling-stroke; animation: flow 30s linear infinite; }
.orbit-inner { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 1 6; vector-effect: non-scaling-stroke; animation: flow 45s linear infinite reverse; }
.sun { fill: var(--paper); stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sun-core { fill: var(--ink); }
.sun-rays { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 1 4; vector-effect: non-scaling-stroke; animation: flow 20s linear infinite; }
.sun-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; fill: var(--ink-soft); text-transform: uppercase; }
@keyframes flow { to { stroke-dashoffset: -220; } }

.stage-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1.25rem; max-width: 40rem; margin: 0.75rem auto 0; }
.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%; }
.probe { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); min-height: 1.2em; }
.heat-scale { display: none; align-items: center; gap: 0.5rem; }
.heat-scale i { display: block; width: 7rem; height: 0.6rem; border: 1px solid var(--ink); background: linear-gradient(90deg, var(--paper), var(--ink)); }
.view-heat .heat-scale { display: inline-flex; }
.view-heat .legend-daisies { display: none; }

/* 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); }

.cover { display: flex; height: 0.9rem; border: 1px solid var(--ink); background: var(--ground); margin-top: 0.4rem; }
.cover span { display: block; height: 100%; transition: width 0.2s linear; }
.cover .cb { background: var(--daisy-black); }
.cover .cw { background: var(--daisy-white); }
.cover-num { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.68rem; color: var(--ink-soft); margin-top: 0.35rem; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }

.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); }
