/**
 * Insulated vs. Non-Insulated Materials Investigation - styles.
 *
 * Visual language matches the Thermal Energy Lab (Space Grotesk display
 * type + Inter body, the same paper/ink/accent palette shape, .{prefix}-btn
 * pill controls, .{prefix}-panel cards) under this lab's own "ins-" prefix -
 * a page-local palette per the house lab convention (see thermal-energy.css)
 * rather than a shared stylesheet, since each standalone lab view renders
 * its own <html> document.
 *
 * Layout thesis: unlike Thermal Energy's single always-running apparatus,
 * this lab's "experiment" IS the sequence of discrete timed trials, so the
 * chart, results table, and ranking are three stacked full-width panels
 * (no side rail) - there is no single dominant visual to give a wide main
 * column to. The material picker + controls sit in one setup bar above all
 * three, matching Thermal Energy's sample bar.
 *
 * WCAG 2.1 AA: 0.75rem minimum font size, 44px touch targets on primary
 * controls, every state (best/worst insulator, which material a line/row
 * belongs to) is labeled in text, never conveyed by color alone.
 */
:root {
  --bg: #eef3fb;
  --paper: #fff;
  --ink: #15233c;
  --muted: #5c6b85;
  --line: #d7e0ef;
  --grid: rgba(47, 107, 255, .08);

  --accent: #7c3aed;
  --accent-bg: #f5f0ff;
  --good: #2f9e44;
  --good-bg: #ebfbee;
  --bad: #e03131;
  --bad-bg: #fff0f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 26px 26px,
    var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
  font-size: 1rem;
}

.ins-wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; }

/* HERO ---------------------------------------------------------------- */
.ins-hero { padding: 14px 16px 8px; text-align: center; }
.ins-hero-title { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.ins-eyebrow {
  display: inline-block; font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; font-size: .72rem; color: #fff;
  background: var(--accent); padding: 5px 12px; border-radius: 6px;
}
.ins-hero h1 {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  font-size: clamp(1.5rem, 3.6vw, 2.2rem); line-height: 1.06; letter-spacing: -.02em;
}
.ins-hero .ins-sub { max-width: 660px; margin: 4px auto 0; color: var(--muted); font-size: .88rem; font-weight: 500; }

/* LAB SHELL ------------------------------------------------------------ */
.ins-lab {
  background: var(--paper); border: 1px solid var(--line); border-radius: 20px;
  padding: 14px; margin-top: 8px; box-shadow: 0 8px 28px rgba(21, 35, 60, .05);
}

/* SETUP: material picker ------------------------------------------------ */
.ins-setupbar {
  padding: 10px 12px; background: #fbfcfe; border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 10px;
}
.ins-materials { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ins-material-btn {
  --ins-material-color: var(--accent);
  display: flex; align-items: center; gap: 8px; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 9px 12px; cursor: pointer; font: inherit; font-size: .86rem; font-weight: 600;
  min-height: 44px; transition: .13s;
}
.ins-material-btn:hover { border-color: var(--ins-material-color); box-shadow: 0 3px 10px rgba(21, 35, 60, .1); }
.ins-material-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.ins-material-btn[aria-pressed="true"] {
  border-color: var(--ins-material-color); background: color-mix(in srgb, var(--ins-material-color) 12%, #fff);
}
.ins-material-btn[disabled] { opacity: .55; cursor: not-allowed; }
.ins-material-swatch {
  width: 14px; height: 14px; border-radius: 4px; flex: none;
  background: var(--ins-material-color); border: 1px solid rgba(0, 0, 0, .15);
}
.ins-material-swatch-sm { width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.ins-material-name { flex: 1; }

.ins-material-info {
  color: var(--muted); font-size: .84rem; font-weight: 500; line-height: 1.5;
  padding: 0 4px; margin: 8px 0 10px;
}

/* CONTROLS BAR ----------------------------------------------------------- */
.ins-controlsbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 10px 12px; background: #fbfcfe; border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 10px;
}
.ins-ctl { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; min-width: 200px; }
.ins-ctl label { font-weight: 600; font-size: .84rem; white-space: nowrap; }
.ins-val { font-family: 'Space Grotesk', sans-serif; font-weight: 700; min-width: 58px; text-align: right; }
.ins-runbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

input[type=range].ins-range,
input[type=range]#ins-starttemp,
input[type=range]#ins-mass {
  -webkit-appearance: none; appearance: none; height: 8px; border-radius: 999px;
  background: var(--line); outline: none; flex: 1; min-width: 110px;
}
input[type=range]#ins-starttemp::-webkit-slider-thumb,
input[type=range]#ins-mass::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(124, 58, 237, .45); cursor: pointer;
}
input[type=range]#ins-starttemp::-moz-range-thumb,
input[type=range]#ins-mass::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; cursor: pointer;
}
input[type=range]#ins-starttemp:focus-visible,
input[type=range]#ins-mass:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.ins-btn {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: .84rem;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; min-height: 44px;
}
.ins-btn:hover { border-color: var(--accent); color: var(--accent); }
.ins-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.ins-btn[disabled] { opacity: .55; cursor: not-allowed; }
.ins-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.ins-btn-primary:hover { color: #fff; background: #6c2bd9; }

/* LIVE READOUT ------------------------------------------------------------ */
.ins-live-readout {
  background: var(--accent-bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 14px; font-size: .88rem; font-weight: 600; margin-bottom: 10px;
}

/* PANELS ------------------------------------------------------------------ */
.ins-panel {
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; margin-bottom: 10px;
}
.ins-panel h3 {
  font-family: 'Space Grotesk', sans-serif; font-size: .78rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}
.ins-caption { color: var(--muted); font-size: .75rem; font-weight: 500; margin-top: 4px; }
.ins-empty { color: var(--muted); font-size: .86rem; font-weight: 500; padding: 6px 2px; }
.ins-empty[hidden] { display: none; }

/* CHART --------------------------------------------------------------- */
#ins-chart { width: 100%; height: auto; display: block; }
.ins-gridline { stroke: var(--line); stroke-dasharray: 3 3; }
.ins-axis-label { font: 600 9px 'Inter', sans-serif; fill: var(--muted); }
.ins-curve { stroke-width: 2.4; }
.ins-curve-live { stroke-dasharray: 5 4; }
.ins-point { stroke: #fff; stroke-width: 1; }
.ins-curve-label { font: 700 9px 'Space Grotesk', sans-serif; }
.ins-live-dot { stroke: #fff; stroke-width: 2; }

/* RESULTS TABLE --------------------------------------------------------- */
.ins-table-wrap { overflow-x: auto; }
.ins-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.ins-table th, .ins-table td {
  padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.ins-table th { font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.ins-table th:first-child, .ins-table td:first-child { text-align: left; }
.ins-table tr { border-left: 4px solid var(--ins-row-color, transparent); }
.ins-table-material { font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.ins-table-drop { font-weight: 700; }

.ins-tag {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px; margin-left: 4px;
}
.ins-tag-best { color: var(--good); background: var(--good-bg); border: 1px solid rgba(47, 158, 68, .35); }
.ins-tag-worst { color: var(--bad); background: var(--bad-bg); border: 1px solid rgba(224, 49, 49, .3); }

/* RANKING LIST ----------------------------------------------------------- */
.ins-ranking { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ins-rank-item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  border-left: 4px solid var(--ins-row-color, var(--accent)); background: #fff; font-size: .86rem;
}
.ins-rank-pos { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--muted); min-width: 26px; }
.ins-rank-name { font-weight: 600; flex: 1 1 auto; }
.ins-rank-drop { font-weight: 700; font-variant-numeric: tabular-nums; }

/* NOTEBOOK -------------------------------------------------------------- */
.ins-notebook { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.ins-section-label {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--accent);
  letter-spacing: .09em; text-transform: uppercase; font-size: .74rem; margin-bottom: 6px;
}
.ins-panel-h {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: .95rem;
  margin: 12px 0 6px;
}
.ins-props { font-size: .9rem; color: var(--ink); }
.ins-obs-field { display: block; margin: 8px 0; }
.ins-obs-field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.ins-obs-field textarea {
  width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: .92rem;
}
#ins-event-log { list-style: none; }
#ins-event-log li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
#ins-save-status { font-size: .8rem; color: var(--muted); margin-left: 8px; }

/* MISC -------------------------------------------------------------------- */
.ins-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.ins-copyright { text-align: center; font-size: .75rem; color: var(--muted); padding: 12px 0; }

/* RESPONSIVE ---------------------------------------------------------------- */
@media (max-width: 640px) {
  .ins-runbtns { margin-left: 0; width: 100%; }
  .ins-ctl { flex: 1 1 100%; }
}

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