/* ============================================================
   Teaching Tools — shared theme
   ------------------------------------------------------------
   Every tool links this one file:
     <link rel="stylesheet" href="../framework/theme.css">
   All colours, stroke widths and fonts are defined once as
   custom properties below. Edit them here and every tool
   updates. SVG elements pick up styling via semantic classes
   (.surface-hot, .heat-arrow, .axis ...) — no colours should
   ever appear in the SVG markup itself.
   ============================================================ */

:root {
  /* --- Typography --- */
  --font-ui:   "Segoe UI", system-ui, sans-serif;
  --font-mono: Consolas, "Cascadia Mono", monospace;

  /* --- Page & panels --- */
  --c-bg:       #f4f6f8;
  --c-panel:    #ffffff;
  --c-ink:      #1c2733;   /* main text */
  --c-ink-soft: #5a6b7b;   /* secondary text */
  --c-accent:   #0b6e99;   /* headings, buttons, active controls */
  --c-border:   #d4dbe2;

  /* --- Physics semantics --- */
  --c-hot:        #d94f2b;
  --c-cold:       #2b7bd9;
  --c-heat-flow:  #e07b39;
  --c-metal:      #b9c2cb;
  --c-fluid:      #cfe6f5;
  --c-insulation: #e8d9a0;
  --c-brick:      #d69c7e;

  /* --- Graphs --- */
  --c-axis:    #45535f;
  --c-grid:    #dfe5ea;
  --c-curve-1: #0b6e99;
  --c-curve-2: #c0392b;
  --c-curve-3: #27ae60;

  /* --- Stroke widths --- */
  --sw-outline: 2px;
  --sw-axis:    1.5px;
  --sw-grid:    1px;
  --sw-curve:   2.5px;
  --sw-arrow:   3px;
}

/* ============================================================
   Page layout
   ============================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--c-ink);
  background: var(--c-bg);
}

.tool-header {
  padding: 0.8rem 1.5rem;
  background: var(--c-panel);
  border-bottom: 2px solid var(--c-accent);
}
.tool-header h1 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--c-accent);
}
.tool-header .subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--c-ink-soft);
}

/* Figure on the left, controls on the right; stacks on narrow screens */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  padding: 1rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 850px) {
  .tool-layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: var(--c-accent);
}

/* The SVG fills its panel */
.figure-panel svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ============================================================
   Controls
   ============================================================ */

.control-row { margin-bottom: 0.9rem; }

.control-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.control-row .readout {
  font-family: var(--font-mono);
  color: var(--c-accent);
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--c-accent);
}

button {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--c-accent);
  border-radius: 6px;
  background: var(--c-accent);
  color: #fff;
  cursor: pointer;
}
button.secondary {
  background: var(--c-panel);
  color: var(--c-accent);
}
button:hover { filter: brightness(1.1); }

/* Big numeric results, e.g. computed heat flux */
.result-box {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.5rem;
}
.result-box .unit { color: var(--c-ink-soft); }

/* ============================================================
   SVG semantic classes
   ============================================================ */

/* --- Materials / regions --- */
.wall-metal      { fill: var(--c-metal);      stroke: var(--c-ink); stroke-width: var(--sw-outline); }
.wall-insulation { fill: var(--c-insulation); stroke: var(--c-ink); stroke-width: var(--sw-outline); }
.wall-brick      { fill: var(--c-brick);      stroke: var(--c-ink); stroke-width: var(--sw-outline); }
.region-fluid    { fill: var(--c-fluid); }

/* --- Hot / cold boundaries --- */
.surface-hot  { stroke: var(--c-hot);  stroke-width: calc(var(--sw-outline) * 2); }
.surface-cold { stroke: var(--c-cold); stroke-width: calc(var(--sw-outline) * 2); }
.fill-hot     { fill: var(--c-hot); }
.fill-cold    { fill: var(--c-cold); }

/* --- Heat flow arrows: dashed stroke that marches --- */
.heat-arrow {
  stroke: var(--c-heat-flow);
  stroke-width: var(--sw-arrow);
  fill: none;
  stroke-dasharray: 8 6;
  animation: heat-march 0.7s linear infinite;
}
.heat-arrow-head { fill: var(--c-heat-flow); }

@keyframes heat-march {
  to { stroke-dashoffset: -14; }
}

/* --- Graph elements --- */
.axis {
  stroke: var(--c-axis);
  stroke-width: var(--sw-axis);
  fill: none;
}
.grid-line {
  stroke: var(--c-grid);
  stroke-width: var(--sw-grid);
}
.curve   { fill: none; stroke-width: var(--sw-curve); stroke-linejoin: round; }
.curve-1 { stroke: var(--c-curve-1); }
.curve-2 { stroke: var(--c-curve-2); }
.curve-3 { stroke: var(--c-curve-3); }

/* --- SVG text --- */
.svg-label {
  font-family: var(--font-ui);
  font-size: 14px;
  fill: var(--c-ink);
}
.svg-label-soft { fill: var(--c-ink-soft); font-size: 12px; }
.svg-value {
  font-family: var(--font-mono);
  font-size: 14px;
  fill: var(--c-accent);
  font-weight: 600;
}
.svg-label-hot  { fill: var(--c-hot);  font-weight: 600; }
.svg-label-cold { fill: var(--c-cold); font-weight: 600; }
