﻿:root {
  /* Tells the browser we've styled form controls (inputs, selects, checkboxes)
     ourselves for both schemes -- without this, some browsers apply their own
     auto-dark-mode heuristics on top of author CSS for native form-control
     rendering, which can override the intended text/background colors inside
     <input>/<select> elements specifically (not plain text) when the visitor's
     OS/browser prefers dark mode. */
  color-scheme: light;
  --ink: #241f1c;
  --ink-soft: #6b615a;
  --ink-faint: #948a7f;
  --surface: #faf7f2;
  --panel: #f1ebe1;
  --panel-2: #e8e0d2;
  --line: #ddd3c4;
  --accent: #a3293a;
  --accent-phase: #2f6690;
  --accent-tl: #3f7d5c;
  --accent-test: #c17817;
  --focus: #a3293a;
  --danger: #a3293a;
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Consolas", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #f0e9df;
    --ink-soft: #b3a89b;
    --ink-faint: #7c7266;
    --surface: #17130f;
    --panel: #221c17;
    --panel-2: #2b241d;
    --line: #3a322a;
    --accent: #d9647a;
    --accent-phase: #74aad9;
    --accent-tl: #6fbd93;
    --accent-test: #e0a542;
    --focus: #d9647a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f0e9df;
  --ink-soft: #b3a89b;
  --ink-faint: #7c7266;
  --surface: #17130f;
  --panel: #221c17;
  --panel-2: #2b241d;
  --line: #3a322a;
  --accent: #d9647a;
  --accent-phase: #74aad9;
  --accent-tl: #6fbd93;
  --accent-test: #e0a542;
  --focus: #d9647a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
}
.pps-app {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 14px;
  padding: 14px;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 880px) {
  .pps-app { grid-template-columns: 1fr; }
}
h1.pps-title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  margin: 0 0 12px 0;
  text-wrap: balance;
  /* Fixed dark blue, not the --ink token: this heading sits directly on the
     WordPress theme's own page background (typically white), which this
     plugin doesn't control -- unlike --ink, which is also used deep inside
     the tool's own dark-surfaced cards and legitimately needs to flip light
     in dark mode there, this title needs to stay dark/readable regardless. */
  color: #1a365d;
}
.pps-charts { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pps-chartcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px 12px;
}
.pps-chartcard h2 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 6px 0;
}
.pps-chart-wrap { position: relative; width: 100%; }
canvas.pps-canvas { width: 100%; display: block; touch-action: none; cursor: crosshair; }
.pps-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.74rem; color: var(--ink-soft); margin-top: 4px; }
.pps-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pps-swatch { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.pps-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 7px;
  border-radius: 3px;
  white-space: nowrap;
  transform: translate(-50%, -115%);
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 5;
}
.pps-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- controls column ---- */
.pps-controls { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pps-viewrow { display: flex; align-items: center; gap: 14px; padding: 2px 2px 2px; }
.pps-viewrow-label { font-weight: 600; font-size: 0.8rem; color: #1a365d; }
/* The View row's own "Basic"/"All features" radio labels sit directly on the
   surrounding page background too (this row isn't inside a .pps-card), so they
   need the same fixed dark blue as the row's own label and the page title --
   the shared .pps-radioline rule (--ink) is correct only for radios inside a
   card, where the card's own dark surface makes --ink's light value legible. */
.pps-viewrow .pps-radioline { color: #1a365d; }
.pps-viewrow-spacer { flex: 1 1 auto; }
.pps-about-btn { background: none; border: none; padding: 2px; margin: 0; cursor: pointer; border-radius: 3px; line-height: 0; }
.pps-about-btn:hover { background: var(--panel-2); }
.pps-about-btn img { width: 16px; height: 16px; display: block; }
.pps-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.pps-modal-box { max-width: 90vw; text-align: center; }
.pps-about-image { max-width: 100%; height: auto; border-radius: 4px; display: block; box-shadow: 0 8px 30px rgba(0,0,0,0.35); }
/* Fixed light-on-dark, not theme tokens: this caption always sits on the modal's
   own dark scrim (rgba(0,0,0,0.45)), which does not flip with the page's theme. */
.pps-about-credit { font-size: 0.72rem; color: rgba(255,255,255,0.92); background: rgba(0,0,0,0.55); border-radius: 3px; padding: 4px 8px; margin: 8px auto 0; max-width: 420px; display: inline-block; }
.pps-card { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.pps-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.8rem;
}
.pps-card-head:hover { background: var(--panel-2); }
.pps-caret { font-size: 0.7rem; color: var(--ink-soft); width: 10px; display: inline-block; }
.pps-card-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.pps-card.collapsed .pps-card-body { display: none; }

.pps-subhead {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink); margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line);
}
.pps-subhead:first-child { border-top: none; margin-top: 0; padding-top: 0; }

.pps-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
/* Direct-child combinator, not a descendant selector: this must only style the
   row's own leading label (e.g. "min / max λ (nm)") -- as a plain descendant
   selector it also matched the Auto checkbox's <label> (.pps-autolabel is
   nested inside .pps-inline, itself a child of .pps-row), forcing it to a
   180px+ min-width/flex-grow it never needed and that was the real cause of
   these rows wrapping once the number boxes got wider. */
.pps-row > label { color: var(--ink); font-size: 0.78rem; flex: 1 1 auto; min-width: 120px; }
.pps-inline { display: flex; align-items: center; gap: 6px; }
.pps-field {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  width: 72px;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 0.78rem;
  /* !important: this embeds into an arbitrary WordPress theme, whose own global
     input styling (e.g. "input[type=text] { color: #333 }") can otherwise win
     over a plain single-class selector like this one and silently override the
     colors below, independent of the color-scheme fix elsewhere in this file. */
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  color: var(--ink) !important;
}
.pps-field:focus, select.pps-select:focus, .pps-btn:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
.pps-field.pps-narrow { width: 72px; }
.pps-field:disabled, select.pps-select:disabled { opacity: 0.5; cursor: not-allowed; }
.pps-autolabel { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--ink); }
.pps-autolabel input[type="checkbox"] { margin: 0 !important; vertical-align: middle !important; }
/* Native checkboxes/radios carry their own default margin, which throws off a
   flex row's align-items:center centering against adjacent text (the .pps-
   autolabel rule above already zeroed this for the Auto checkboxes, which is
   why those look correctly centered while these didn't) -- same fix, applied
   to every checkbox/radio + label pairing built by checkRow()/radioRow() and
   the View row's Basic/All features radios (both use these same classes). */
/* !important, matching the .pps-field/.pps-select fix: a WordPress theme's own
   global input[type=checkbox]/input[type=radio] styling (its own margin resets
   are extremely common) can otherwise win over this plain descendant selector
   and silently reintroduce the vertical misalignment this is meant to fix. */
.pps-checkline input, .pps-radioline input {
  margin: 0 !important;
  vertical-align: middle !important;
}
.pps-select {
  font-family: var(--font-ui);
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 0.78rem;
  max-width: 100%;
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  color: var(--ink) !important;
}
.pps-unit { color: var(--ink); font-size: 0.72rem; }
.pps-btn {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  padding: 4px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  cursor: pointer;
}
.pps-btn:hover { border-color: var(--accent); }
.pps-btn.pps-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.pps-checkline, .pps-radioline { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink); }
.pps-results { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; }
.pps-results .k { color: var(--ink); font-size: 0.76rem; }
.pps-results .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.8rem; text-align: right; }
.pps-material-row { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.pps-material-row:last-child { border-bottom: none; }
.pps-error {
  background: color-mix(in oklab, var(--danger) 12%, var(--panel));
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 9px;
  border-radius: 3px;
  font-size: 0.76rem;
}
.pps-hidden { display: none !important; }
::selection { background: color-mix(in oklab, var(--accent) 35%, transparent); }
