/* ==========================================================================
   JuiceMount site base — layout, nav, sections, buttons, cards, forms,
   callouts, diagram + calculator scaffolding. Tokens come from tokens.css.
   Flat and outlined, like the mark: borders do the work, no shadows.
   ========================================================================== */

/* ---- reset-lite ---------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-text);
  line-height: var(--lh-body);
}

img, svg { max-width: 100%; height: auto; display: block; }

/* ---- type ---------------------------------------------------------------- */
h1, h2, h3 {
  font-weight: var(--fw-head);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  margin: 0 0 var(--space-4);
  text-wrap: balance;
}
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { margin: 0 0 var(--space-4); }
.lead { font-size: var(--fs-lead); }
.small { font-size: var(--fs-small); }
.muted { color: var(--text-muted); }

a {
  color: var(--link);
  text-decoration: underline;            /* links never rely on color alone */
  text-underline-offset: 0.15em;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

hr {
  border: 0;
  border-top: 1.5px solid var(--hairline-soft);
  margin: var(--space-6) 0;
}

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  padding: 0.08em 0.35em;
}

/* ---- layout --------------------------------------------------------------- */
.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.section { padding-block: var(--space-8); }

.section-head { max-width: 46rem; margin-bottom: var(--space-6); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-4);
}
.skip-link:focus { left: var(--space-2); z-index: 10; }

/* A band that stays Pulp Ink in both themes (hero, closing). Children read
   the re-scoped tokens, so cards/buttons/diagrams adapt automatically. */
.band-ink {
  background: var(--cinema-dark);
  color: var(--rind-cream);
  --bg: var(--cinema-dark);
  --surface: rgba(250, 253, 232, 0.06);
  --surface-2: rgba(250, 253, 232, 0.04);
  --text: var(--rind-cream);
  --text-muted: rgba(250, 253, 232, 0.72);
  --hairline: rgba(250, 253, 232, 0.28);
  --hairline-soft: rgba(250, 253, 232, 0.14);
  --link: #6FB1EB;
  --chart-grid: rgba(250, 253, 232, 0.12);
  --chart-saas: #6FB1EB;
  color-scheme: dark;
}

/* ---- nav ------------------------------------------------------------------ */
.site-nav {
  border-bottom: 1.5px solid var(--hairline-soft);
}
.site-nav .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text);
  font-weight: var(--fw-head);
  font-size: var(--fs-body);
  margin-right: auto;
}
.brand img { width: 30px; height: 30px; }
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav ul a {
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-small);
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
}
.site-nav ul a:hover,
.site-nav ul a[aria-current="page"] {
  border-bottom-color: var(--juice-green);
}

/* ---- buttons (Juice Green CTA; outline picks up current ink/cream) ------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font: inherit;
  font-size: var(--fs-small);
  font-weight: var(--fw-head);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: filter var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.btn-primary:hover { filter: brightness(0.96); }
.btn-outline {
  background: transparent;
  color: inherit;
  border-color: currentColor;
}
.btn-outline:hover { background: var(--surface-2); }

/* ---- cards / stats -------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1.5px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.card h3 { font-size: var(--fs-lead); margin-bottom: var(--space-2); }
.card p:last-child { margin-bottom: 0; }

.stat {
  font-family: var(--font-mono);
  font-weight: var(--fw-head);
  font-size: var(--fs-h3);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  display: block;
  margin-bottom: var(--space-2);
}

.pillars {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* ---- hero ------------------------------------------------------------------ */
.hero { padding-block: var(--space-9) var(--space-8); }
.hero h1 { max-width: 21ch; }
.hero .lead { max-width: 56ch; }
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-4);
}
.hero-qualifier { color: var(--text-muted); font-size: var(--fs-small); margin: 0; }

/* ---- figures / diagram ----------------------------------------------------- */
figure.figure {
  margin: 0 0 var(--space-5);
  background: var(--surface);
  border: 1.5px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: var(--space-5);
}
figure.figure figcaption {
  font-size: var(--fs-small);
  color: var(--text-muted);
  border-top: 1.5px solid var(--hairline-soft);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
}

.diagram { width: 100%; height: auto; --diagram-stroke: var(--text); }
.diagram text {
  font-family: var(--font-mono);
  fill: var(--text);
  font-size: 11px;
}
.diagram .d-title { font-weight: 600; font-size: 12px; }
.diagram .d-label, .diagram .d-note { fill: var(--text-muted); font-size: 10.5px; }
.diagram .d-grouplabel {
  fill: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.diagram .d-box { stroke: var(--diagram-stroke); stroke-width: 2; }
.diagram .d-box-green { fill: var(--tint-green); }
.diagram .d-box-blue { fill: var(--tint-blue); }
.diagram .d-box-slate { fill: var(--tint-slate); }
.diagram .d-group {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}
.diagram .d-arrow {
  stroke: var(--diagram-stroke);
  stroke-width: 2;
  fill: none;
}

/* ---- definition rows (how-it-works) ---------------------------------------- */
.fact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin: 0;
}
.fact-grid > div {
  border-left: 3px solid var(--tint-green-border);
  padding-left: var(--space-4);
}
.fact-grid dt { font-weight: var(--fw-head); margin-bottom: var(--space-1); }
.fact-grid dd { margin: 0; font-size: var(--fs-small); color: var(--text-muted); }

/* ---- callouts --------------------------------------------------------------- */
.callout {
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-4);
  font-size: var(--fs-small);
}
.callout p:last-child { margin-bottom: 0; }
.callout-info  { background: var(--tint-blue);  border-color: var(--tint-blue-border); }
.callout-warn  { background: var(--tint-amber); border-color: var(--tint-amber-border); }
.callout-ok    { background: var(--tint-green); border-color: var(--tint-green-border); }

/* ---- forms (calculator) ------------------------------------------------------ */
fieldset {
  border: 1.5px solid var(--hairline-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-4) var(--space-5) var(--space-5);
  margin: 0 0 var(--space-4);
  min-inline-size: 0;
}
legend {
  font-weight: var(--fw-head);
  font-size: var(--fs-small);
  padding-inline: var(--space-2);
}

.field { margin-bottom: var(--space-4); }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: var(--fs-small);
  font-weight: var(--fw-head);
  margin-bottom: var(--space-1);
}
.field .hint {
  display: block;
  font-size: var(--fs-small);
  color: var(--text-muted);
  font-weight: var(--fw-text);
  margin-top: var(--space-1);
}

input[type="number"],
input[type="text"],
select {
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  width: 100%;
  max-width: 100%;
}
input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
select { appearance: auto; }

.field-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.field-row input[type="range"] { flex: 1; accent-color: var(--juice-green); }
.field-row input[type="number"] { width: 7.5rem; flex: none; }

.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-small);
}
.check-row input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--juice-green);
}
.check-row input[type="number"] { width: 7.5rem; margin-left: auto; }

details.advanced {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
}
details.advanced summary {
  cursor: pointer;
  font-size: var(--fs-small);
  font-weight: var(--fw-head);
  padding-block: var(--space-1);
}
details.advanced[open] summary { margin-bottom: var(--space-3); }

/* ---- calculator layout / results ---------------------------------------------- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: start;
}

.payback-headline {
  font-size: var(--fs-h3);
  font-weight: var(--fw-head);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  margin-bottom: var(--space-2);
}
.payback-headline .num { font-size: 1.15em; }

.chart-wrap { margin-block: var(--space-4); }
.chart-wrap svg { width: 100%; height: auto; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: var(--space-2);
}
.chart-legend .swatch {
  display: inline-block;
  width: 1.4em;
  height: 0.35em;
  border-radius: 2px;
  margin-right: 0.45em;
  vertical-align: middle;
}

.receipt {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-block: var(--space-4);
}
.receipt table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}
.receipt caption {
  text-align: left;
  font-weight: var(--fw-head);
  padding-bottom: var(--space-2);
}
.receipt td, .receipt th {
  text-align: left;
  padding: 0.45rem 0;
  border-top: 1px solid var(--hairline-soft);
  vertical-align: top;
}
.receipt tr:first-child td { border-top: 0; }
.receipt td.num { text-align: right; white-space: nowrap; }
.receipt tr.total td {
  border-top: 1.5px solid var(--hairline);
  font-weight: var(--fw-head);
}
.receipt .note { color: var(--text-muted); display: block; font-size: 0.875em; }

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.share-row input { flex: 1 1 16rem; font-family: var(--font-mono); font-size: 0.8125rem; }

/* ---- footer ---------------------------------------------------------------------- */
.site-footer {
  border-top: 1.5px solid var(--hairline-soft);
  margin-top: var(--space-8);
  padding-block: var(--space-6);
  font-size: var(--fs-small);
  color: var(--text-muted);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: baseline;
}
.site-footer a { color: inherit; }
.site-footer .foot-brand { color: var(--text); font-weight: var(--fw-head); }
.site-footer .foot-map {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1.5px solid var(--hairline-soft);
}

/* ---- breakpoints ------------------------------------------------------------------ */
@media (min-width: 768px) {
  .container { padding-inline: var(--space-6); }
  .pillars { grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
  .fact-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
  .receipt { grid-template-columns: 1fr 1fr; gap: var(--space-5); }
}

@media (min-width: 980px) {
  .calc-grid { grid-template-columns: minmax(20rem, 24rem) 1fr; }
}

@media (min-width: 1280px) {
  .section { padding-block: var(--space-9); }
}

/* ---- motion discipline -------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- anchor targets + smooth scroll ------------------------------------------------ */
/* Sitewide versions of what docs.html carried locally. :where() keeps the
   selector at bare-[id] specificity, so page rules with a tighter offset
   (the docs rail's .step pair) still win their own cascade. */
:where(main, section, article, h1, h2, h3, h4)[id] { scroll-margin-top: var(--space-5); }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
