/* Energy Law: "Control Room".
   A grid operator's console: deep navy with a faint grid, amber for action, signal green for status,
   monospace labels and numbers, a one-line diagram on the home page. Dark by default; a pale
   "daylight" console when the reader picks the light theme. Loaded after study.css. */

:root, :root[data-theme="dark"] {
  --paper: #0d1726; --ink: #e3ebf5; --ink-2: #b3c3d8; --muted: #7f95b2;
  --rule: #2a405e; --hair: #1f3149; --tint: #13223a; --accent: #ffb020;
  --ok: #3ddc84; --warn: #ff7a59; --link: #e3ebf5;
  --panel: rgba(18, 32, 52, .88); --signal: #3ddc84; --gridline: rgba(120, 160, 210, .06);
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Helvetica Neue", Helvetica, "Inter", Arial, system-ui, sans-serif;
  color-scheme: dark;
}
/* study.css switches colours under prefers-color-scheme: dark with a more specific selector; match it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1726; --ink: #e3ebf5; --ink-2: #b3c3d8; --muted: #7f95b2;
    --rule: #2a405e; --hair: #1f3149; --tint: #13223a; --accent: #ffb020;
    --ok: #3ddc84; --warn: #ff7a59; --link: #e3ebf5; color-scheme: dark;
  }
}
:root[data-theme="light"] {
  --paper: #eef2f7; --ink: #0d1726; --ink-2: #2b3d55; --muted: #5a6e88;
  --rule: #9fb2ca; --hair: #cdd8e5; --tint: #e1e8f1; --accent: #a8610a;
  --ok: #18794e; --warn: #b4361a; --link: #0d1726;
  --panel: rgba(255, 255, 255, .9); --signal: #18794e; --gridline: rgba(13, 23, 38, .05);
  color-scheme: light;
}

body { background-color: var(--paper);
       background-image: linear-gradient(var(--gridline) 1px, transparent 1px),
                         linear-gradient(90deg, var(--gridline) 1px, transparent 1px);
       background-size: 24px 24px; }
::selection { background: var(--accent); color: #0d1726; }

/* frame */
.top { border-bottom: 1px solid var(--rule); }
.brand { font-family: var(--mono); font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.brand .mark { width: .6rem; height: .6rem; border-radius: 50%; background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.top nav, .top .aside { font-family: var(--mono); font-size: .8rem; }
.top nav a, .top .aside a { color: var(--muted); }
.top nav a:hover, .top .aside a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.top .aside .cta { color: var(--accent); }
.lockbar { background: var(--accent); color: #0d1726; font-family: var(--mono); }
.foot { border-top: 1px solid var(--rule); font-family: var(--mono); font-size: .75rem; }

/* type */
h1 { color: var(--ink); letter-spacing: -.02em; }
h1 em { font-style: normal; color: var(--accent); }
h2 { border-top: 1px solid var(--rule); font-size: 1.1rem; }
main > section > h2:first-child::before, main > h2::before { content: "SEC " counter(sec, decimal-leading-zero); min-width: 4.2rem;
  font-family: var(--mono); font-size: .8rem; color: var(--signal); vertical-align: .1em; }
h3 { font-family: var(--mono); font-weight: 600; letter-spacing: .1em; color: var(--accent); }
.kicker { font-family: var(--mono); color: var(--accent); letter-spacing: .14em; font-weight: 400; }
.kicker b { color: var(--signal); }
.lede { color: var(--ink-2); }
.meta, .label, .date, .year, .timer, .para, .opara .n { font-family: var(--mono); }
.meta, .label { font-size: .8rem; }
a { text-decoration-color: var(--rule); }
a:hover { text-decoration-color: var(--accent); }
blockquote { border-left: 3px solid var(--accent); color: var(--ink-2); }
mark { background: color-mix(in srgb, var(--accent) 18%, transparent); box-shadow: inset 0 -2px 0 var(--accent); }

/* controls */
.button, button { background: var(--accent); border-color: var(--accent); color: #0d1726; font-family: var(--mono);
                  font-size: .85rem; letter-spacing: .02em; border-radius: 3px; }
.button:hover, button:hover { background: #ffc54d; border-color: #ffc54d; color: #0d1726; }
:root[data-theme="light"] .button, :root[data-theme="light"] button { color: #fff; }
:root[data-theme="light"] .button:hover, :root[data-theme="light"] button:hover { background: #8a4f06; border-color: #8a4f06; color: #fff; }
button.quiet, .button.quiet { background: transparent; color: var(--ink); border-color: var(--rule); }
button.quiet:hover { background: var(--tint); color: var(--ink); }
textarea, select, input { background: var(--tint); border-color: var(--rule); color: var(--ink); border-radius: 3px; }
.search input[type=search] { border-color: var(--rule); }
.badge { font-family: var(--mono); border-radius: 3px; }

/* panels: gates, facts, hidden notes, problems look like console panels */
.gate, .facts, .hidden { background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 4px; }
.gate { border-width: 1px 1px 1px 3px; }
.facts-grid { border-top: 1px solid var(--rule); }
.facts-grid div { border-bottom: 1px solid var(--hair); }
.facts-grid dt { font-family: var(--mono); color: var(--signal); font-size: .7rem; }
.facts-grid dd { font-family: var(--mono); font-size: 1.05rem; color: var(--ink); }
.oneline + .facts-grid dd { font-size: 1.5rem; }
.cases li { border-bottom-color: var(--hair); }
.ticks li::before { background: var(--signal); border-radius: 50%; box-shadow: 0 0 6px var(--signal); }
.opara:target { background: var(--tint); box-shadow: -8px 0 0 var(--tint), inset 3px 0 0 var(--accent); }
.progress th, .cases-table th { font-family: var(--mono); border-bottom-color: var(--rule); }
.price { font-family: var(--mono); color: var(--accent); }

/* worked problems (engine .problem cards) */
.problem { background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 4px; }
.problem header { font-family: var(--mono); font-size: .75rem; }
.problem .no { color: var(--signal); }
.problem .lvl { border-radius: 3px; }
.problem .lvl.l2 { color: var(--muted); }
.problem details { border-top: 1px solid var(--hair); }
.problem details summary { color: var(--accent); font-family: var(--mono); font-weight: 400; font-size: .85rem; }
.problem .steps li::marker { color: var(--signal); font-family: var(--mono); }

/* ---------- home: hero, one-line diagram, unit tiles ---------- */
.cr-hero { margin-bottom: calc(1*var(--u)); }
.oneline { width: 100%; height: 54px; margin: calc(2*var(--u)) 0 calc(1*var(--u)); display: block; }
.oneline .bus { stroke: var(--rule); stroke-width: 2; }
.oneline .node { fill: var(--paper); stroke: var(--signal); stroke-width: 2; }
.oneline .xf { fill: var(--paper); stroke: var(--accent); stroke-width: 2; }
.oneline text { font-family: var(--mono); font-size: 9px; fill: var(--muted); letter-spacing: .06em; }
.tiles { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: calc(1.25*var(--u)); }
.tiles li { background: var(--panel); border: 1px solid var(--rule); border-radius: 4px; padding: calc(1.5*var(--u)); margin: 0; }
.tiles .n { font-family: var(--mono); font-size: .72rem; color: var(--signal); letter-spacing: .06em; display: block; }
.tiles a { display: block; font-weight: 700; color: var(--ink); text-decoration: none; margin: 4px 0 2px; line-height: 1.25; }
.tiles a:hover { color: var(--accent); }
.tiles .c { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
@media (min-width: 1100px) { main > .tiles-wrap { grid-column: 1 / -1; } }
.changes { list-style: none; padding: 0; }
.changes li { border-left: 3px solid var(--accent); background: var(--panel); padding: var(--u) calc(1.5*var(--u)); margin: 0 0 var(--u); border-radius: 0 4px 4px 0; }
.changes .when { font-family: var(--mono); font-size: .72rem; color: var(--signal); display: block; letter-spacing: .06em; }

@media print { body { background: #fff; color: #000; } .tiles li, .problem, .changes li { background: none; } }
