/*
Theme Name: Calculator Australia
Theme URI: https://calculatoraustralia.com.au/
Author: Calculator Australia
Description: Theme for calculatoraustralia.com.au. Calculators that show their working, driven by one central figures file.
Version: 1.0.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: calcau
*/

/* ---------- Design tokens ---------- */
:root {
  --ink: #15171f;          /* headings, body text */
  --muted: #5b5f6b;        /* secondary text */
  --paper: #f6f5f0;        /* page background */
  --card: #ffffff;         /* panels */
  --line: #e2e0d8;         /* borders */
  --blue: #2638c4;         /* primary: links, buttons, focus */
  --blue-ink: #1a2690;     /* primary hover */
  --blue-soft: #e8eafb;    /* tints */
  --wattle: #f2b630;       /* accent: marks, highlights */
  --wattle-soft: #fdf1d3;
  --tape: #fffdf5;         /* calculator tape paper */
  --good: #23775a;
  --warn: #9a5b00;

  --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(21, 23, 31, .06), 0 8px 24px rgba(21, 23, 31, .06);
  --wrap: 1160px;
  --text: 720px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--blue-ink); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; letter-spacing: -.01em; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); font-weight: 700; margin-top: .2em; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); font-weight: 650; }
h3 { font-size: 1.2rem; font-weight: 650; }
p, ul, ol { margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
th { font-weight: 600; background: #f0efe9; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }
.skip-link:focus { position: fixed; left: 1rem; top: 1rem; z-index: 99; width: auto; height: auto; clip: auto; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
.text { max-width: var(--text); }

/* ---------- Header ---------- */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.brand:hover { color: var(--ink); }
.brand .mark { width: 34px; height: 34px; flex: none; }
.brand small { display: block; font-family: var(--font-body); font-weight: 400; font-size: .78rem; color: var(--muted); letter-spacing: 0; }
.nav ul { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; }
.nav a { display: block; padding: .5rem .8rem; border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .98rem; }
.nav a:hover, .nav .current-menu-item > a { background: var(--blue-soft); color: var(--blue-ink); }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .45rem .7rem; font: inherit; font-weight: 600; color: var(--ink); }
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 68px; background: var(--paper); border-bottom: 1px solid var(--line); padding: .5rem 1.25rem 1rem; }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; }
}

/* ---------- Hero ---------- */
.hero { padding: 3.5rem 0 3rem; }
.hero .wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 3rem; align-items: center; }
.hero .eyebrow { display: inline-flex; gap: .5rem; align-items: center; font-weight: 600; font-size: .9rem; color: var(--muted); }
.hero .eyebrow::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--wattle); }
.hero h1 { margin: .4em 0 .4em; }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--wattle-soft) 62%); }
.hero p.lead { font-size: 1.2rem; color: var(--muted); max-width: 34ch; }
.hero .actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
@media (max-width: 900px) { .hero .wrap { grid-template-columns: 1fr; gap: 2rem; } }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .8rem 1.25rem; border-radius: 999px; font-weight: 700; text-decoration: none; border: 2px solid var(--blue); background: var(--blue); color: #fff; font-family: var(--font-body); font-size: 1rem; cursor: pointer; }
.btn:hover { background: var(--blue-ink); border-color: var(--blue-ink); color: #fff; }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.ghost:hover { background: var(--blue-soft); color: var(--blue-ink); }

/* ---------- Basic calculator (homepage) ---------- */
.basic-calc { background: var(--ink); border-radius: 22px; padding: 1.1rem; box-shadow: var(--shadow); max-width: 380px; justify-self: end; width: 100%; }
.basic-calc .screen { background: var(--tape); border-radius: 12px; padding: .9rem 1rem; text-align: right; font-family: var(--font-mono); min-height: 88px; display: flex; flex-direction: column; justify-content: flex-end; }
.basic-calc .screen .expr { color: var(--muted); font-size: .9rem; min-height: 1.3em; overflow-wrap: anywhere; }
.basic-calc .screen .val { font-size: 2rem; font-weight: 600; overflow-wrap: anywhere; line-height: 1.2; }
.basic-calc .keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; margin-top: .9rem; }
.basic-calc button { font-family: var(--font-mono); font-size: 1.15rem; padding: .85rem 0; border-radius: 12px; border: 0; background: #2a2d38; color: #fff; cursor: pointer; }
.basic-calc button:hover { background: #363a48; }
.basic-calc button.op { background: #3a3f8f; }
.basic-calc button.eq { background: var(--wattle); color: var(--ink); font-weight: 700; }
.basic-calc button.fn { background: #4a4e5c; }
.basic-calc .zero { grid-column: span 2; }
@media (max-width: 900px) { .basic-calc { justify-self: start; } }

/* ---------- Sections and cards ---------- */
.section { padding: 3rem 0; }
.section.alt { background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.25rem; }
.section-head h2 { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.2rem; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--blue); color: var(--ink); transform: translateY(-2px); }
.card .tag { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card h3 { margin: .35rem 0 .3rem; font-size: 1.12rem; }
.card p { margin: 0; color: var(--muted); font-size: .96rem; }
.trust { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.trust div { border-left: 3px solid var(--wattle); padding-left: 1rem; }
.trust strong { display: block; font-family: var(--font-head); font-size: 1.1rem; }
.trust span { color: var(--muted); font-size: .96rem; }
@media (max-width: 760px) { .trust { grid-template-columns: 1fr; } }

/* ---------- Page and article ---------- */
.page-head { padding: 2rem 0 .5rem; }
.breadcrumbs { font-size: .9rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.byline { display: flex; flex-wrap: wrap; gap: .4rem 1rem; color: var(--muted); font-size: .95rem; margin-top: .25rem; }
.byline .checked::before { content: "\2713  "; color: var(--good); font-weight: 700; }
.entry { padding: 1rem 0 3rem; }
.entry > * { max-width: var(--text); }
.entry > .calc, .entry > .wide, .entry > table { max-width: none; }
.entry h2 { margin-top: 2em; }
.answer { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: var(--radius-sm); padding: 1rem 1.2rem; font-size: 1.08rem; }
.sources { font-size: .92rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 2rem; }

/* ---------- Calculator ---------- */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1.25rem; margin: 1.5rem 0 2rem; }
@media (max-width: 880px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.calc > * { min-width: 0; }
.calc-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); align-self: start; }
.field { margin-bottom: 1rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field .hint { display: block; font-size: .88rem; color: var(--muted); margin-top: .25rem; }
.input-wrap { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.input-wrap .affix { display: flex; align-items: center; padding: 0 .75rem; background: #f3f2ed; color: var(--muted); font-weight: 600; }
.input-wrap input, .calc select { flex: 1; min-width: 0; border: 0; padding: .7rem .8rem; font: inherit; font-size: 1.1rem; font-variant-numeric: tabular-nums; background: transparent; color: var(--ink); }
.input-wrap input:focus { outline: none; }
.calc select { border: 1.5px solid var(--line); border-radius: var(--radius-sm); width: 100%; background: #fff; }
.calc select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; padding: .5rem .85rem; border: 1.5px solid var(--line); border-radius: 999px; font-weight: 600; font-size: .95rem; cursor: pointer; background: #fff; }
.seg input:checked + label { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--blue); outline-offset: 2px; }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 600; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--blue); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .9rem; }
.row2 > * { min-width: 0; }
.input-wrap input { width: 100%; }
@media (max-width: 420px) { .row2 { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.calc-note { font-size: .86rem; color: var(--muted); margin: .25rem 0 0; }
.calc-note.example { color: var(--warn); }

/* The tape: results printed like a calculator roll, showing the working */
.tape-wrap { align-self: start; }
@media (min-width: 881px) { .tape-wrap { position: sticky; top: 84px; } }
.headline { background: var(--ink); color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 1.1rem 1.3rem 1rem; }
.headline .k { font-size: .9rem; color: #c9cbd6; font-weight: 600; }
.headline .v { font-family: var(--font-head); font-size: clamp(2rem, 4.5vw, 2.7rem); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.headline .v small { font-size: .45em; font-weight: 600; color: var(--wattle); margin-left: .3rem; }
.tape {
  position: relative;
  background: var(--tape);
  border: 1px solid var(--line);
  border-top: 0;
  padding: 1.1rem 1.3rem 1.6rem;
  font-family: var(--font-mono);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
}
.tape::after { /* torn edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: -9px; height: 10px;
  background: radial-gradient(circle at 6px -2px, var(--tape) 6px, transparent 6.5px) 0 0 / 12px 10px repeat-x;
}
.tape .t-title { font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }
.tape .t-line { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.tape .t-line span:first-child { color: #3b3e49; }
.tape .t-line span:last-child { white-space: nowrap; }
.tape .t-line.indent span:first-child { padding-left: 1.2em; color: var(--muted); }
.tape .t-rule { border-top: 1.5px dashed #c9c6ba; margin: .45rem 0; }
.tape .t-total { font-weight: 700; font-size: 1rem; }
.tape .t-note { color: var(--muted); font-size: .82rem; padding-top: .35rem; font-family: var(--font-body); }
.tape-tools { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.1rem; font-size: .88rem; color: var(--muted); }
.tape-tools button { font: inherit; font-weight: 600; background: none; border: 1.5px solid var(--line); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; color: var(--ink); }
.tape-tools button:hover { border-color: var(--blue); color: var(--blue); }
.periods { margin-top: 1.2rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow-x: auto; }
.periods table { font-size: .95rem; min-width: 480px; }
.periods th[scope="row"] { white-space: nowrap; background: #f7f6f2; position: sticky; left: 0; }
.periods td:not(:first-child), .periods th:not(:first-child) { text-align: right; }
.periods tr.net td { font-weight: 700; }

/* ---------- FAQ ---------- */
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: .6rem; }
.faq summary { cursor: pointer; padding: .9rem 1.1rem; font-weight: 650; font-family: var(--font-head); list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--blue); font-weight: 700; }
.faq details[open] summary::after { content: "\2212"; }
.faq .a { padding: 0 1.1rem .9rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #c9cbd6; padding: 3rem 0 2rem; margin-top: 2rem; font-size: .95rem; }
.site-footer a { color: #fff; }
.site-footer .cols { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 2rem; }
.site-footer h4 { color: #fff; margin: 0 0 .6rem; font-size: 1rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: .35rem; }
.site-footer .warning { border-top: 1px solid #2c2f3b; margin-top: 2rem; padding-top: 1.25rem; font-size: .86rem; }
@media (max-width: 860px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print { .site-header, .site-footer, .calc-form, .tape-tools { display: none; } .calc { display: block; } }
