/* Light theme for the regression explorer, to match the course site. Every
   text color here passes at least 4.5:1 on --panel and --bg. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #c5ccd3;
  --control: #6b7682;
  --text: #14181d;
  --muted: #47505a;
  --pop: #0064a4;
  --accent: #b0126b;
  --focus: #b0126b;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Fira Sans Condensed", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
}

a { color: var(--pop); }

/* The course site's blue bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  padding: 6px 14px;
  background: #0064a4;
  color: #fff;
}

.topbar h1 { margin: 0; font-size: 1.15rem; }

.site-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
}

.site-link:hover { text-decoration: underline; }

.site-link.brand { font-size: 1.15rem; font-weight: 700; }

.site-link.brand img { border-radius: 3px; }

.site-link.back {
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid #fff;
  border-radius: 4px;
}

.topbar :focus-visible { outline-color: #fff; }

/* Inside a page of the site, its own menu does this job */
body.embedded .topbar { display: none; }

main { flex: 1; min-height: 0; display: flex; }

.view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 10px;
  padding: 10px;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 460px;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.stage.three-panels {
  grid-template-rows: minmax(0, 2.2fr) minmax(0, 2.2fr) minmax(0, 5fr);
  gap: 8px;
}

.stage.pairs {
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.stage.pairs #panel-dist { grid-column: 1 / -1; }

/* The animation runs on a layer over all three panels */
#c-fx { z-index: 5; pointer-events: none; }

.panel {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

figcaption {
  padding: 5px 10px 2px;
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 1.6em;
}

figcaption strong { color: var(--text); }

.canvas-wrap { position: relative; flex: 1; min-height: 0; }

canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* A finger on the plot moves a point, not the page */
#c-corr { touch-action: none; }

.controls {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.field-row.three { grid-template-columns: 1fr 1fr 1fr; }

label { font-size: 0.95rem; color: var(--muted); }

output { color: var(--text); font-weight: 700; }

select, input[type="file"], input[type="number"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: 4px;
  padding: 5px;
  font: inherit;
  width: 100%;
}

input[type="range"] { width: 100%; accent-color: var(--pop); margin: 4px 0; }

.checks { display: flex; flex-direction: column; gap: 6px; }

.check { display: flex; align-items: center; gap: 6px; }

.check input { width: 18px; height: 18px; accent-color: var(--pop); margin: 0; }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: 4px;
  padding: 7px 4px;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}

button:hover { background: #e6eaee; }

button.primary { background: #0064a4; border-color: #0064a4; color: #fff; font-weight: 700; }

button.primary:hover { background: #004d7f; }

button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

button:disabled { opacity: 0.55; cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.draw-row { display: grid; gap: 5px; }

.draw-row.four { grid-template-columns: repeat(4, 1fr); }

.draw-row.three { grid-template-columns: repeat(3, 1fr); }

.draw-row.two { grid-template-columns: repeat(2, 1fr); }

.readout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.95rem;
}

.readout table { width: 100%; border-collapse: collapse; }

.readout th { text-align: left; font-weight: 400; color: var(--muted); padding: 1px 6px 1px 0; }

.readout td { text-align: right; font-weight: 700; padding: 1px 0; white-space: nowrap; }

.readout table.three td { padding-left: 8px; }

.readout thead th { text-align: right; font-size: 0.85rem; padding-left: 8px; }

.readout thead th:first-child { padding: 0; }

.readout h2 { margin: 0 0 3px; font-size: 0.95rem; color: var(--text); }

.readout table + h2, .readout .extra h2 { margin-top: 8px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.browse-row { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.credit, .hint { margin: 0; font-size: 0.85rem; color: var(--muted); }

kbd {
  border: 1px solid var(--control);
  border-radius: 3px;
  padding: 0 4px;
  font: inherit;
}

/* Inside a slide: the plot fills the frame, with one bar of controls below */
body.ui-slide { font-size: 15px; }

/* The heading stays for screen readers, and the slide's title does the visual work */
body.ui-slide .topbar {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

body.ui-slide .view {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 4px;
}

body.ui-slide .stage { min-height: 0; }

body.ui-slide .controls {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  overflow: visible;
  padding: 0;
}

body.ui-slide .slide-hide { display: none; }

body.ui-slide .draw-row.four { width: 260px; }

body.ui-slide .slide-keep { width: 220px; }

body.ui-slide .readout h2, body.ui-slide .readout .extra { display: none; }

body.ui-slide .draw-row.three { width: 270px; }

body.ui-slide .draw-row.two { width: 220px; }

body.ui-slide .checks { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }

body.ui-slide .readout {
  flex: 1 1 100%;
  min-width: 260px;
  padding: 3px 8px;
}

body.ui-slide .readout table { display: block; }

body.ui-slide .readout tbody { display: flex; flex-wrap: wrap; gap: 0 16px; }

body.ui-slide .readout tr { display: flex; gap: 5px; }

@media (max-width: 760px) {
  body { height: auto; }
  .view { display: flex; flex-direction: column; }
  /* In pixels, because vh inside the page's frame would mean the frame's height */
  .stage { height: 440px; min-height: 0; flex: none; }
  .sampling .stage { height: 680px; }
  .stage.pairs { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); }
  .controls { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
