/* Sunnyday dark theme for paramat3d.com (copied from the sunn3d.com kit, recolored for ParaMat3D).
   Applies when <html data-sdt-theme="dark">. Loaded after each page's own <style>, so it mostly
   re-points the pages' CSS variables; html:root[...] outranks their :root and :root[data-theme] rules.
   Brand kept: navy #013a73 bar with the lime #97d700 rule, ParaMat blue links, white wordmarks. */

html:root[data-sdt-theme="dark"] {
  color-scheme: dark;
  background-color: #061321;
  --d-bg: #061321;
  --d-panel: rgba(11, 28, 48, 0.88);
  --d-panel-solid: #0b1c30;
  --d-line: #1d3552;
  --d-line-2: #2a4566;
  --d-ink: #f0f4f7;
  --d-text: #c9d6e0;
  --d-muted: #9fb2c2;
  --d-link: #63a9e8;
  --d-link-hover: #9cc9f2;
  --d-green: #97d700;
  --d-code: #0d2036;

  /* Home, stats, legal */
  --page: #061321;
  --card: #0b1c30;
  --ink: #f0f4f7;
  --ink2: #c9d6e0;
  --ink3: #9fb2c2;
  --line: #1d3552;
  --hair: rgba(255, 255, 255, 0.08);
  --accent: #4d94d6;
  --accent-soft: rgba(77, 148, 214, 0.16);
  --cool: #63a9e8;
  --cool-soft: rgba(99, 169, 232, 0.08);
  --good: #a5dc2e;
  --good-soft: rgba(151, 215, 0, 0.14);
  --warn: #d9a441;
  --warn-soft: rgba(217, 164, 65, 0.14);

  /* Predict, progress */
  --surface: #061321;
  --panel: #0b1c30;
  --grid: #1d3552;
  --blue: #4d94d6;
  --blue-soft: #24466e;
  --locked: #7f90a3;

  /* Agents, manufacturers, outcomes, carrier */
  --muted: #9fb2c2;
  --bg: #061321;
  --rf: rgba(151, 215, 0, 0.1);
  --bad: #f08a8a;
}

/* Base: navy glow over near-black navy, behind everything (pages paint no body background). */
html[data-sdt-theme="dark"] body {
  background: transparent !important;
}
html[data-sdt-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(1100px 560px at 80% -8%, rgba(1, 58, 115, 0.55), rgba(1, 58, 115, 0) 70%),
    radial-gradient(900px 620px at -10% 45%, rgba(1, 58, 115, 0.26), rgba(1, 58, 115, 0) 70%),
    linear-gradient(180deg, #061321, #040d18);
}
html[data-sdt-theme="dark"] ::selection { background: var(--d-green); color: #061321; }
/* Zero-specificity html part: beats the pages' bare a{color:...} but not their nav/footer/button link rules. */
:where(html[data-sdt-theme="dark"]) a { color: var(--d-link); }
:where(html[data-sdt-theme="dark"]) a:hover { color: var(--d-link-hover); }

/* ---- Background layers (created by sdt-bg.js) ---- */
html[data-sdt-theme="dark"] .sdt-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
html[data-sdt-theme="dark"] .sdt-bg canvas { display: block; width: 100%; height: 100%; }

/* Still frame of the consensus background for pages that run no script (the carrier page's CSP is
   script-src 'none'). The phone still uses the fewer, fainter under-720-px lines. */
html[data-sdt-theme="dark"][data-sdt-bg="still"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("/assets/sdt/consensus-still.svg") center / cover no-repeat;
}
@media (max-width: 719px) {
  html[data-sdt-theme="dark"][data-sdt-bg="still"] body::after {
    background-image: url("/assets/sdt/consensus-still-phone.svg");
  }
}

/* ---- Home ---- */
/* Selected goal and primary export buttons: white text needs a deeper blue than the link accent. */
html[data-sdt-theme="dark"] .goal button.on {
  background: #1b5d9e;
  border-color: #3f86cc;
  color: #fff;
}
html[data-sdt-theme="dark"] .exbtns .btn.pri {
  background: #1b5d9e;
  border-color: #3f86cc;
  color: #fff;
}
/* Phones: the four action buttons (two per row) ran ~19 px past a 375 px screen, where the page clips
   them. Keep the labels on one line; tighten the padding and scale the text a little on narrow phones. */
@media (max-width: 639px) {
  html[data-sdt-theme="dark"] .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-sdt-theme="dark"] .actions .btn { padding: 0 8px; gap: 5px; font-size: clamp(13px, 3.9vw, 15.5px); }
}
html[data-sdt-theme="dark"] #drop { background: var(--d-panel-solid); box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5); }
html[data-sdt-theme="dark"] .export { background: rgba(99, 169, 232, 0.07); }
html[data-sdt-theme="dark"] #toast { background: #f0f4f7; color: #061321; }

/* ---- Stats, legal: the inline-styled brand bar held the wordmark at a fixed 17 px height (~338 px
   wide), so it ran 180 px past a 375 px screen. Let it shrink the way the homepage bar does. ---- */
html[data-sdt-theme="dark"] .brandbar > div:not(.bb-in) > a:first-child { flex: 0 1 auto; min-width: 0; }
html[data-sdt-theme="dark"] .brandbar > div:not(.bb-in) > a:first-child img {
  height: auto !important;
  width: auto;
  max-height: 17px;
  max-width: 100%;
}
html[data-sdt-theme="dark"] .brandbar > div:not(.bb-in) > nav { flex-shrink: 0; gap: clamp(12px, 3vw, 22px) !important; }

/* ---- Predict, progress: give the chart and result tiles a panel so text never sits on the field ---- */
html[data-sdt-theme="dark"] :is(.tile, .controls, .gate, .boundary) { background: var(--d-panel); }
html[data-sdt-theme="dark"] .rc { background: var(--d-panel); }

/* ---- Agents, manufacturers, outcomes ---- */
html[data-sdt-theme="dark"] main:not(.wrap) {
  background: var(--d-panel);
  border-color: var(--d-line);
}
html[data-sdt-theme="dark"] :is(.callout, .notice) {
  background: rgba(151, 215, 0, 0.08);
  color: var(--d-text);
}
html[data-sdt-theme="dark"] pre {
  background: var(--d-code);
  color: #dce8f0;
  border: 1px solid var(--d-line);
}
html[data-sdt-theme="dark"] :is(input, textarea, select):not([type="checkbox"]):not([type="radio"]) {
  background: var(--d-code);
  color: var(--d-ink);
  border-color: var(--d-line-2);
}
html[data-sdt-theme="dark"] :is(input, textarea)::placeholder { color: #8a9db0; opacity: 1; }
html[data-sdt-theme="dark"] button:not(.primary):not(.camclose):not(.danger) { border-color: var(--d-line-2); }
html[data-sdt-theme="dark"] main:not(.wrap) button:not(.primary) { background: #10263f; color: var(--d-ink); }
html[data-sdt-theme="dark"] main:not(.wrap) button:not(.primary):hover { background: #16314f; }
html[data-sdt-theme="dark"] .primary { background: #013a73; border-color: #2f6db0; color: #fff; }
html[data-sdt-theme="dark"] .danger { color: var(--bad); }
html[data-sdt-theme="dark"] :is(.card, .result, .empty) { border-color: var(--d-line); }
html[data-sdt-theme="dark"] footer { color: var(--d-muted); }

/* ---- OpenSpool carrier ---- */
html[data-sdt-theme="dark"] .facts { background: var(--d-line); border-color: var(--d-line); }
html[data-sdt-theme="dark"] :is(.fact, .step, .dl:not(.primary)) { background: var(--d-panel); }
html[data-sdt-theme="dark"] .dl:hover { border-color: #2f6db0; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
html[data-sdt-theme="dark"] .pn { background: rgba(206, 109, 117, 0.12); }
html[data-sdt-theme="dark"] .adapter { background: rgba(75, 154, 102, 0.14); }
html[data-sdt-theme="dark"] .gap { color: #b9e05d; border-color: #6f9634; }
html[data-sdt-theme="dark"] .callout.warn { background: rgba(208, 138, 19, 0.1); }
html[data-sdt-theme="dark"] code { background: var(--d-code); color: #dce8f0; }
html[data-sdt-theme="dark"] pre code { background: transparent; }
html[data-sdt-theme="dark"] footer:has(> .wrap) { background: rgba(4, 13, 24, 0.82); border-top: 1px solid var(--d-line); }
html[data-sdt-theme="dark"] footer:has(> .wrap) a { color: #b9e05d; }

/* ---- 404: let the field show behind the centered message ---- */
html[data-sdt-theme="dark"] body:has(.bars) { background: transparent !important; }
html[data-sdt-theme="dark"] body:has(.bars) a { color: #97d700; }
