/* cc-fee-site -- layout B (sticky inputs, live results).
 *
 * Palette and type: the subject is small-business bookkeeping -- statements,
 * ledgers, terminals -- so numbers are set in a monospace stack (ledger
 * columns, not a brochure) and the accent is a muted ledger green rather than
 * a generic SaaS blue. Prose stays in the system sans stack for readability.
 * Restrained on purpose: this is a tool people use and leave, not a landing
 * page.
 *
 * Tokens live on :root and are redefined three ways so an explicit toggle
 * (applied via data-theme -- set before first paint by the inline <head>
 * script in base.html.j2, and updated afterwards by theme.js's click
 * handler) always wins over the OS preference, in both directions.
 * Components are styled through the tokens only -- never inside a media
 * query -- so those three blocks are the only places colour is decided.
 */

:root {
  color-scheme: light dark;

  --bg: #f6f4ee;
  --bg-panel: #fffefb;
  --bg-panel-2: #f0ede4;
  --ink: #1c2430;
  --muted: #5b6472;
  --border: #d9d3c4;
  --border-strong: #b9b2a0;
  --accent: #1f5c46;
  --accent-ink: #ffffff;
  --win-bg: #edf5ef;
  --win-border: #1f5c46;
  --focus: #1f5c46;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.06);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  /* The one content column every full-bleed bar (header, footer) and `main`
   * itself align to. Defined once so the three rulesets that need it can't
   * drift apart the way `.site-header` and `main` already had -- see
   * `.content-width` below. Not a colour decision, so it lives outside the
   * three token blocks above rather than inside them. */
  --content-max: 64rem;
  --content-pad: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --bg-panel: #1a1f28;
    --bg-panel-2: #212733;
    --ink: #e8e6df;
    --muted: #9aa2ad;
    --border: #2b323d;
    --border-strong: #3b4452;
    --accent: #55b28a;
    --accent-ink: #08130f;
    --win-bg: #16241c;
    --win-border: #55b28a;
    --focus: #55b28a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161d;
  --bg-panel: #1a1f28;
  --bg-panel-2: #212733;
  --ink: #e8e6df;
  --muted: #9aa2ad;
  --border: #2b323d;
  --border-strong: #3b4452;
  --accent: #55b28a;
  --accent-ink: #08130f;
  --win-bg: #16241c;
  --win-border: #55b28a;
  --focus: #55b28a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4ee;
  --bg-panel: #fffefb;
  --bg-panel-2: #f0ede4;
  --ink: #1c2430;
  --muted: #5b6472;
  --border: #d9d3c4;
  --border-strong: #b9b2a0;
  --accent: #1f5c46;
  --accent-ink: #ffffff;
  --win-bg: #edf5ef;
  --win-border: #1f5c46;
  --focus: #1f5c46;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.06);
}

/* -------------------------------------------------- reset & base */

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-sans);
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--accent);
}

/* -------------------------------------------------- chrome */

/* Shared by `.site-header`'s inner wrapper, `.site-footer`'s inner wrapper,
 * and `main`: the one column their contents line up to. The bar itself
 * (background, border) stays full-bleed on the outer element; only this
 * class is width-constrained and centred. */
.content-width {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--content-pad);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
}

.site-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel-2);
  color: var(--ink);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  flex: none;
}

#theme-toggle:hover {
  border-color: var(--accent);
}

#theme-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
}

/* Which of the two icons is showing is the only signal a visitor gets for
 * which theme is active, so it is driven off the same three-way cascade as
 * the colour tokens above (default light, OS dark, explicit override in
 * either direction) rather than a second, JS-only source of truth. theme.js
 * only ever toggles the `data-theme` attribute these selectors already key
 * off of -- it does not touch the icons directly. */
#theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  #theme-toggle .icon-sun {
    display: none;
  }

  #theme-toggle .icon-moon {
    display: block;
  }
}

:root[data-theme="dark"] #theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] #theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="light"] #theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="light"] #theme-toggle .icon-moon {
  display: none;
}

main {
  padding-block: 2rem 4rem;
}

main > h1 {
  font-size: 1.7rem;
  margin: 0 0 0.4rem;
}

.subhead {
  color: var(--muted);
  max-width: 60ch;
  margin: 0 0 2rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--muted);
  padding: 1.25rem 1.5rem;
  font-size: 0.85rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  margin: 0 0 1.1rem;
  text-align: left;
}

.footer-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 11rem;
}

.footer-nav-heading {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.footer-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
}

.footer-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* -------------------------------------------------- calculator layout */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

@media (min-width: 48rem) {
  .split {
    grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
    align-items: start;
  }

  .col-inputs {
    position: sticky;
    top: 1.5rem;
    align-self: start;
  }
}

.col-inputs {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.col-inputs fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 0.9rem 0.5rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.col-inputs legend {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 0.3rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field input,
.field select,
#mix {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 0.5rem 0.6rem;
  width: 100%;
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0.25rem 0 0;
}

/* -------------------------------------------------- results */

.col-results {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.verdict {
  border: 1px solid var(--win-border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  background: var(--win-bg);
}

.verdict #verdict {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

/* Side by side only while both columns can still hold a money figure at the
 * size .num sets it in; below that they stack.
 *
 * A plain `1fr 1fr` resolves each track's minimum to min-content, and
 * "$61,250.00/mo" is a single unbreakable monospace run -- there is no space
 * in it to wrap at. So a large enough monthly volume pushed this grid wider
 * than its container, the container wider than the viewport, and the page
 * scrolled sideways with the winning figure partly off-screen. It happened at
 * the default numbers on a 320px phone and as soon as a visitor typed a
 * mid-six-figure volume on a 390px one.
 *
 * Two guards, because either alone still leaves a gap. `auto-fit` with
 * `minmax(min(100%, 10rem), 1fr)` caps each track's minimum at 10rem (or the
 * container, whichever is smaller, so the track can never itself overflow)
 * and drops to a single column when two no longer fit. `overflow-wrap:
 * anywhere` on .num then removes the unbreakable-run floor outright: it
 * affects min-content sizing, not just visual wrapping, so no figure a
 * visitor can type widens the track again -- it wraps inside the card
 * instead. The wrap lands on the "/mo" unit first at any realistic volume.
 */
.cmp {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 1rem;
}

.cmp .col {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: var(--bg-panel);
}

.cmp .col h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.cmp .col.win {
  border-color: var(--win-border);
  border-width: 2px;
  background: var(--win-bg);
  padding: calc(1rem - 1px);
}

.cmp .col.win h3 {
  color: var(--accent);
}

.cmp .num {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cmp .unit {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.col-results > p {
  margin: 0;
  color: var(--muted);
}

.col-results > p span {
  color: var(--ink);
  font-weight: 600;
}

/* The ad slot. Always rendered (see home.html.j2) so the box occupies the
 * same space whether or not ADSENSE_CLIENT/ADSENSE_SLOT are set -- an empty
 * build and a monetised one lay out identically, and a real unit loading in
 * later does not shift anything below it. min-height is a guess at a
 * responsive AdSense unit's typical height; close enough that "the box
 * grew" is the most a visitor could notice. */

.ad-slot {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--bg-panel);
}

.ad-slot-placeholder {
  font-size: 0.78rem;
  color: var(--muted);
}

/* AdSense's own snippet writes this as style="display:block" on the <ins>.
 * It cannot live there: this site's style-src is 'self' with no
 * 'unsafe-inline', and a browser that does not implement the CSP3
 * style-src-attr directive falls the attribute back to style-src and drops
 * it. A responsive ad unit measures the <ins> to pick a size, and an
 * inline-display <ins> gives it nothing to measure -- so the declaration is
 * revenue-load-bearing and belongs somewhere the policy already allows. */

.adsbygoogle {
  display: block;
}

/* The estimates-not-advice line, directly under the result it qualifies.
 * Quieter than the figures above it and louder than the citation below: a
 * disclaimer nobody reads is the same as no disclaimer, and one that competes
 * with the answer is worse than either. */

.result-note {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0.25rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* The homepage's explanatory sections, below the calculator. Same measure and
 * heading scale as a content page's <article class="prose">, because they are
 * the same kind of reading. */

.home-prose {
  margin-top: 2.5rem;
}

/* The blended interchange disclosure. Deliberately quiet -- it is a citation,
 * not a result -- but present rather than tucked behind a disclosure widget:
 * it is the one figure in this calculation the visitor cannot type in, and
 * the page's own subhead promises the arithmetic is shown. */

.reference-note {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.reference-note h2 {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.reference-note b,
.reference-note strong {
  color: var(--ink);
  font-weight: 600;
}

.reference-note b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ref-source {
  font-size: 0.78rem;
  margin-bottom: 0.75rem;
}

/* A weighting no primary source publishes, set apart from the citation above
 * it so the two cannot be read as the same kind of claim. The rule down the
 * side is the whole point: a reader skimming should be able to see where the
 * sourced part of the figure stops. */
.ref-assumption {
  font-size: 0.78rem;
  margin: 0 0 0.9rem;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border-strong);
}

/* Nothing on the site ships with this attribute today -- the interchange note
 * is swapped by rewriting text rather than by hiding five copies of it -- but
 * the rule is kept because the user-agent default for [hidden] is a `display`
 * value, and any element placed in a flex or grid container here would
 * otherwise stay on screen while claiming to be hidden. */
[hidden] {
  display: none !important;
}

/* -------------------------------------------------- numeric stability
 *
 * Every money and rate value gets tabular figures (fixed digit width) and a
 * monospace face, so as the visitor types the digits realign instead of
 * jittering -- the whole point of a live calculator is to look stable while
 * it updates.
 */

#verdict,
#flat-cost,
#ipp-cost,
#flat-effective,
#ipp-effective,
#annual-saving,
#breakeven,
.field input {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* -------------------------------------------------- content pages */

.prose {
  max-width: 68ch;
}

.prose h2 {
  margin: 2rem 0 0.6rem;
  font-size: 1.25rem;
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose .callout {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.prose .callout h3 {
  margin-top: 0;
}

.prose .callout table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.prose .callout th,
.prose .callout td {
  text-align: left;
  padding: 0.3rem 0.5rem 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.prose .callout td:last-child,
.prose .callout th:last-child {
  text-align: right;
  padding-right: 0;
}

.prose .cta {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 600;
}

.article-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 0.5rem 0 0;
}

.article-links a {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: var(--bg-panel);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}

.article-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.section-heading {
  margin: 2.5rem 0 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* -------------------------------------------------- focus & motion */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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