/* ==========================================================================
   spICE ice battery picker — PARENT THEME
   Structure, layout and behaviour of the widget. Brand-neutral on purpose:
   every colour that carries the brand comes from the accent tokens below, and
   a child theme (themes/spice-theme-red.css, themes/spice-theme-blue.css)
   overrides those under .spice-root[data-spice-brand="..."].

   Load order: this file first, then one or both child themes. The children
   win on specificity, not on order, so a CMS that reorders assets is safe.

   Every rule is scoped under .spice-root so a WordPress or TYPO3 theme can
   neither leak into the widget nor be disturbed by it.
   ========================================================================== */

.spice-root {
  /* --- brand knobs: a child theme (or the host page) overrides these ------
     Non-accent palette lifted from the De Korne WordPress theme
     (theme.json presets):
       contrast   #111111   near-black
       contrast-2 #636363   mid grey
       contrast-3 #a4a4a4   light grey
       base       #f9f9f9   off-white
       base-2     #ffffff   white
     The accents here are a neutral slate, so an unbranded parent still
     renders correctly on its own — it just carries no brand.
     ---------------------------------------------------------------------- */
  --spice-accent: #3f4a56;
  --spice-accent-strong: #232b33;
  --spice-accent-soft: #eef0f3;
  /* a lighter accent for progress steps you've visited but aren't on */
  --spice-accent-visited: #8a949f;
  --spice-ink: #111111;
  --spice-ink-soft: #636363;
  --spice-line: #dcdcdc;
  --spice-surface: #ffffff;
  --spice-surface-alt: #f9f9f9;

  /* text that sits on top of a filled accent area */
  --spice-on-accent: #ffffff;
  /* the result banner: brand accent into near-black, identical in both themes */
  --spice-hero-from: #3f4a56;
  --spice-hero-to: #111111;
  /* errors must not read as "selected" — the accent already means that */
  --spice-error-bg: #111111;
  --spice-error-ink: #ffffff;

  --spice-radius: 12px;
  --spice-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;

  /* The widget's own measure, and a knob rather than a constant because how
     much room the tool deserves is the host page's business, not ours. Set it
     on the mount element (`style="--spice-max-width:1040px"`) and the inline
     declaration wins. Safe to inherit: `all: initial` below resets regular
     properties, never custom ones. */
  --spice-max-width: 860px;

  all: initial;
  display: block;
  box-sizing: border-box;
  font-family: var(--spice-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--spice-ink);
  background: var(--spice-surface);
  border: 1px solid var(--spice-line);
  border-radius: var(--spice-radius);
  padding: clamp(18px, 4vw, 32px);
  margin: 0 auto;
  container-type: inline-size;
}

/* The doubled class is deliberate, and it is the only one in this file.
   A WordPress block theme clamps every direct child of a constrained group to
   the site's content width with

     .is-layout-constrained > :where(:not(.alignleft):not(.alignright)…)

   — `:where()` scores nothing, so that rule is one class, same as `.spice-root`,
   and it is printed after this stylesheet. On De Korne content width is 620px,
   which held the widget to 620 inside a 1089px panel no matter what we asked
   for here. One more class beats it, and beats nothing else. */
.spice-root.spice-root {
  max-width: var(--spice-max-width);
}

.spice-root *,
.spice-root *::before,
.spice-root *::after {
  box-sizing: border-box;
  font-family: inherit;
}

/* --- header ------------------------------------------------------------ */
.spice-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.spice-head-text {
  flex: 1;
  min-width: 0;
}
/* The logo and the reset share the top-right corner, logo above. */
.spice-head-aside {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* --- logo slot ----------------------------------------------------------
   The parent reserves the corner but ships no artwork: which mark belongs to
   a brand is the child theme's business. A child turns this on with
   `display: block` and a `background-image`; brands without a logo simply
   never do, and the slot collapses.

   The white plate is deliberate and applies in both colour schemes: the marks
   are black-on-white artwork, which would vanish against the dark surface,
   and inverting them would wreck the two-colour square in the C.
   ---------------------------------------------------------------------- */
.spice-logo {
  display: none;
  /* Sized off the artwork's own 3.79:1 so the plate hugs the mark instead of
     leaving air around it. Artwork ships at ~6x this width - the header is
     the first thing a visitor looks at, and a soft logo there reads as a
     cheap site. */
  width: 220px;
  height: 58px;
  background-color: #ffffff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border-radius: 6px;
  padding: 4px 8px;
}
.spice-head h2 {
  margin: 0 0 4px;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--spice-ink);
}
.spice-head p {
  margin: 0;
  color: var(--spice-ink-soft);
  font-size: 15px;
}

/* --- progress ---------------------------------------------------------- */
.spice-progress {
  display: flex;
  gap: 6px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}
.spice-progress li {
  flex: 1;
  display: flex;
}
.spice-progress-bar {
  flex: 1;
  height: 4px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--spice-line);
  transition: background 0.25s ease;
  font: inherit;
  cursor: default;
  -webkit-appearance: none;
  appearance: none;
}
.spice-progress-bar[data-state="current"] {
  background: var(--spice-accent);
  box-shadow: 0 0 0 3px var(--spice-accent-soft);
}
.spice-progress-bar[data-state="visited"] {
  background: var(--spice-accent-visited);
  cursor: pointer;
}
.spice-progress-bar[data-state="visited"]:hover,
.spice-progress-bar[data-state="visited"]:focus-visible {
  background: var(--spice-accent);
}
.spice-progress-bar:focus-visible {
  outline: 2px solid var(--spice-accent);
  outline-offset: 2px;
}

/* --- step -------------------------------------------------------------- */
.spice-step-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  /* the darker accent keeps small uppercase text above 4.5:1 on white */
  color: var(--spice-accent-strong);
  margin: 0 0 6px;
}
.spice-question {
  margin: 0 0 4px;
  font-size: clamp(18px, 2.6vw, 22px);
  font-weight: 620;
  letter-spacing: -0.01em;
}
.spice-hint {
  margin: 0 0 18px;
  color: var(--spice-ink-soft);
  font-size: 14.5px;
}

/* --- clickable boxes --------------------------------------------------- */
.spice-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.spice-boxes[data-cols="2"] {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.spice-boxes[data-compact] {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}

.spice-box {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 16px;
  min-height: 76px;
  border: 1.5px solid var(--spice-line);
  border-radius: var(--spice-radius);
  background: var(--spice-surface);
  color: var(--spice-ink);
  cursor: pointer;
  font-size: 15.5px;
  font-weight: 560;
  transition: border-color 0.15s ease, background 0.15s ease,
    transform 0.08s ease, box-shadow 0.15s ease;
}
.spice-box:hover {
  border-color: var(--spice-accent);
  background: var(--spice-surface-alt);
}
.spice-box:active {
  transform: translateY(1px);
}
.spice-box:focus-visible {
  outline: 3px solid var(--spice-accent-soft);
  outline-offset: 2px;
  border-color: var(--spice-accent);
}
.spice-box[aria-pressed="true"] {
  border-color: var(--spice-accent);
  background: var(--spice-accent-soft);
  box-shadow: inset 0 0 0 1px var(--spice-accent);
}
.spice-box .spice-box-sub {
  font-size: 13px;
  font-weight: 420;
  color: var(--spice-ink-soft);
}
.spice-box[aria-pressed="true"] .spice-box-sub {
  color: var(--spice-accent-strong);
}
.spice-box[data-compact] {
  min-height: 0;
  align-items: center;
  text-align: center;
  padding: 14px 10px;
}

/* --- fields ------------------------------------------------------------ */
.spice-field {
  margin-bottom: 18px;
}
.spice-field > label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.spice-input-wrap {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--spice-line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--spice-surface);
  max-width: 320px;
}
.spice-input-wrap:focus-within {
  border-color: var(--spice-accent);
  box-shadow: 0 0 0 3px var(--spice-accent-soft);
}
.spice-input-wrap input {
  border: 0;
  outline: 0;
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
  min-width: 0;
  color: var(--spice-ink);
  background: transparent;
}
.spice-unit {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--spice-surface-alt);
  border-left: 1px solid var(--spice-line);
  font-size: 14px;
  color: var(--spice-ink-soft);
  white-space: nowrap;
}

/* segmented control */
.spice-seg {
  display: inline-flex;
  border: 1.5px solid var(--spice-line);
  border-radius: 10px;
  overflow: hidden;
}
.spice-seg button {
  appearance: none;
  border: 0;
  background: var(--spice-surface);
  color: var(--spice-ink-soft);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
}
.spice-seg button + button {
  border-left: 1px solid var(--spice-line);
}
.spice-seg button[aria-pressed="true"] {
  background: var(--spice-accent);
  color: var(--spice-on-accent);
}

.spice-duty-card {
  border: 1px solid var(--spice-line);
  border-radius: var(--spice-radius);
  padding: 18px;
  margin-bottom: 16px;
  background: var(--spice-surface-alt);
}
.spice-duty-card h4 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 650;
  color: var(--spice-accent-strong);
}

/* --- site-specific dimensions ------------------------------------------ */
.spice-dims {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.spice-dim > label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.spice-dim .spice-input-wrap {
  max-width: none;
}
/* The calculated edge is an answer, not an input: tint it with the accent so
   it reads as the tool talking back rather than a field left blank. */
.spice-dim[data-derived] .spice-input-wrap {
  border-color: var(--spice-accent);
  background: var(--spice-accent-soft);
}
.spice-dim[data-derived] input {
  color: var(--spice-accent-strong);
  font-weight: 650;
  -webkit-text-fill-color: var(--spice-accent-strong); /* Safari, disabled input */
  opacity: 1;
}
.spice-dim-note {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--spice-ink-soft);
  min-height: 1em;
}
.spice-dim[data-derived] .spice-dim-note {
  color: var(--spice-accent-strong);
  font-weight: 550;
}
.spice-unit-card[data-derived] {
  border-style: dashed;
}

.spice-details {
  margin: -4px 0 18px;
  font-size: 14px;
}
.spice-details summary {
  cursor: pointer;
  color: var(--spice-ink-soft);
  font-weight: 540;
}
.spice-details[open] summary {
  margin-bottom: 12px;
}

/* --- actions ----------------------------------------------------------- */
.spice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--spice-line);
}
.spice-btn {
  appearance: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.spice-btn-primary {
  background: var(--spice-accent);
  color: var(--spice-on-accent);
}
.spice-btn-primary:hover:not(:disabled) {
  background: var(--spice-accent-strong);
}
.spice-btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.spice-btn-ghost {
  background: transparent;
  color: var(--spice-ink-soft);
  border-color: var(--spice-line);
}
.spice-btn-ghost:hover {
  color: var(--spice-ink);
  border-color: var(--spice-ink-soft);
}
/* Reset sits in the header, always in the same place, on every screen. An
   outline button: findable at a glance, but it never outranks the primary
   action of the step it sits above. */
.spice-btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  background: var(--spice-surface);
  border-color: var(--spice-line);
  color: var(--spice-ink-soft);
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.spice-btn-reset:hover {
  color: var(--spice-accent-strong);
  border-color: var(--spice-accent);
  background: var(--spice-accent-soft);
}
.spice-btn-reset:focus-visible {
  outline: 3px solid var(--spice-accent-soft);
  outline-offset: 2px;
  border-color: var(--spice-accent);
}
.spice-reset-icon {
  font-size: 15px;
  line-height: 1;
}

/* Under ~380px the header would wrap the title into a column of single
   words before the corner gives up any room, so drop it below instead. */
@container (max-width: 380px) {
  .spice-head {
    flex-direction: column;
    align-items: stretch;
  }
  .spice-head-aside {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  /* Narrow widget: the mark gives up room before the reset does. */
  .spice-logo {
    width: 150px;
    height: 40px;
  }
}
.spice-spacer {
  flex: 1;
}

/* Deliberately not accent-on-tint: that would look like a selected box.
   Near-black with an accent rule reads as a system message instead. */
.spice-error {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--spice-error-bg);
  border: 0;
  border-left: 4px solid var(--spice-accent);
  color: var(--spice-error-ink);
  font-size: 14px;
}

/* --- result ------------------------------------------------------------ */
.spice-result-hero {
  background: linear-gradient(
    135deg,
    var(--spice-hero-from) 0%,
    var(--spice-hero-to) 100%
  );
  color: #fff;
  border-radius: var(--spice-radius);
  padding: clamp(20px, 4vw, 30px);
  margin-bottom: 20px;
}
/* Every colour inside the banner comes from the banner. Inheritance alone is
   not enough: a host theme styling bare elements — De Korne's global styles
   carry `h3 { color: #111 }` — beats an inherited value, and printed the
   headline in near-black against the near-black end of the gradient. Nothing
   in here is meant to carry its own colour, so one rule covers it. */
.spice-result-hero * {
  color: inherit;
}
.spice-result-hero .spice-eyebrow {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.82;
  margin: 0 0 8px;
}
.spice-result-hero h3 {
  margin: 0 0 10px;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 680;
  letter-spacing: -0.015em;
}
.spice-result-hero p {
  margin: 0;
  font-size: 15.5px;
  opacity: 0.94;
}

/* What decided the size - shown between the hero and the unit cards. */
.spice-basis {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 18px;
}
.spice-chip {
  display: inline-block;
  padding: 5px 11px;
  border: 1px solid var(--spice-line);
  border-radius: 999px;
  background: var(--spice-surface-alt);
  color: var(--spice-ink-soft);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.35;
}

.spice-units {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.spice-unit-card {
  border: 1.5px solid var(--spice-accent);
  background: var(--spice-accent-soft);
  border-radius: var(--spice-radius);
  padding: 16px;
}
.spice-unit-card .spice-unit-count {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--spice-accent-strong);
}
.spice-unit-card .spice-unit-name {
  font-weight: 620;
  margin-top: 2px;
}
.spice-unit-card .spice-unit-cap {
  font-size: 13px;
  color: var(--spice-ink-soft);
}

.spice-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--spice-line);
  border: 1px solid var(--spice-line);
  border-radius: var(--spice-radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.spice-figure {
  background: var(--spice-surface);
  padding: 14px 16px;
}
.spice-figure dt {
  font-size: 12.5px;
  color: var(--spice-ink-soft);
  margin-bottom: 3px;
}
.spice-figure dd {
  margin: 0;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.spice-notes {
  margin: 0 0 20px;
  padding: 0 0 0 20px;
  color: var(--spice-ink-soft);
  font-size: 14px;
}
.spice-notes li {
  margin-bottom: 6px;
}

.spice-cta {
  padding: 18px;
  border: 1px dashed var(--spice-accent);
  border-radius: var(--spice-radius);
  background: var(--spice-accent-soft);
  font-size: 15.5px;
  font-weight: 560;
  color: var(--spice-accent-strong);
  margin-bottom: 4px;
}
.spice-cta a {
  color: var(--spice-accent-strong);
}

.spice-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- dark ---------------------------------------------------------------
   Only the neutral half of the dark palette lives here; each child theme
   supplies its own lightened accent, because the light-mode brand colour
   rarely clears 4.5:1 against a near-black surface. Filled accent areas then
   need dark text on top. The result banner keeps its light-theme
   accent-to-black gradient in both modes.
   ---------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  .spice-root:not([data-spice-theme="light"]) {
    --spice-accent: #8d98a5;
    --spice-accent-strong: #b3bcc7;
    --spice-accent-soft: #1b1f24;
    --spice-accent-visited: #5a646f;
    --spice-ink: #f9f9f9;
    --spice-ink-soft: #a4a4a4;
    --spice-line: #333333;
    --spice-surface: #111111;
    --spice-surface-alt: #1c1c1c;
    --spice-on-accent: #111111;
    --spice-error-bg: #000000;
    --spice-error-ink: #ffffff;
  }
}

.spice-root[data-spice-theme="dark"] {
  --spice-accent: #8d98a5;
  --spice-accent-strong: #b3bcc7;
  --spice-accent-soft: #1b1f24;
  --spice-accent-visited: #5a646f;
  --spice-ink: #f9f9f9;
  --spice-ink-soft: #a4a4a4;
  --spice-line: #333333;
  --spice-surface: #111111;
  --spice-surface-alt: #1c1c1c;
  --spice-on-accent: #111111;
  --spice-error-bg: #000000;
  --spice-error-ink: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  .spice-root * {
    transition: none !important;
  }
}
