/*
Theme Name: CalcSite
Description: Fast, minimal theme for the Calc Engine calculator site. White background, slate text, mint accent.
Version: 1.1.0
Requires PHP: 8.1
License: GPL-2.0-or-later
Text Domain: calcsite
*/

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f8fa;
  --text: #44475b;
  --text-strong: #2b2d3a;
  --text-muted: #7c7e8c;
  --border: #e9e9eb;
  --accent: #00b386;
  --accent-ink: #ffffff;
  --accent-soft: #ebf9f5;
  --accent-text: #04a77d;
  --blue: #5367ff;
  --blue-soft: #eef0ff;
  --radius: 12px;
  --chart-1: #00b386; --chart-2: #5367ff; --chart-3: #ffb61b; --chart-4: #eb5b3c;
  --chart-5: #a586ff; --chart-6: #2ab9d8; --chart-7: #ff8db4; --chart-8: #b0b2bd;
  --wrap: 1180px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.25; letter-spacing: -.01em; font-weight: 600; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.skip-link { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 50; }
.skip-link:focus { left: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- Header ---------------- */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.header-row { display: flex; align-items: center; gap: 1.25rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; color: var(--text-strong); text-decoration: none; letter-spacing: -.02em; flex: none; }
.brand svg { width: 30px; height: 30px; }
.main-nav { flex: 1; display: flex; align-items: center; gap: 1rem; }
.menu { list-style: none; margin: 0; padding: 0; display: flex; gap: .1rem; flex: 1; }
.has-dd { position: relative; }
.dd-toggle { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 0; font: inherit; font-size: .93rem; font-weight: 500; color: var(--text); padding: .55rem .65rem; border-radius: 8px; cursor: pointer; }
.dd-toggle svg { transition: transform .15s; color: var(--text-muted); }
.dd-toggle:hover, .has-dd.open > .dd-toggle { color: var(--text-strong); background: var(--surface-2); }
.has-dd.open > .dd-toggle svg { transform: rotate(180deg); }
.dd { position: absolute; top: calc(100% + 6px); left: 0; min-width: 260px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(43,45,58,.12); padding: .4rem; display: none; z-index: 45; }
.dd::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.dd-wide .dd { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, auto); grid-auto-flow: column; min-width: 540px; }
.dd-cols3 .dd { grid-template-columns: repeat(3, 1fr); min-width: 720px; left: auto; right: -200px; }
.dd-cols4 .dd { grid-template-columns: repeat(4, 1fr); min-width: 900px; left: auto; right: -260px; }
.dd-right { left: auto; right: 0; }
@media (hover: hover) and (min-width: 961px) {
  .has-dd:hover > .dd, .has-dd:focus-within > .dd { display: block; }
  .dd-wide:hover > .dd, .dd-wide:focus-within > .dd { display: grid; }
  .has-dd:hover > .dd-toggle svg { transform: rotate(180deg); }
}
.has-dd.open > .dd { display: block; }
.dd-wide.open > .dd { display: grid; }
.dd a { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 8px; text-decoration: none; color: var(--text); }
.dd a:hover, .dd a[aria-current="true"] { background: var(--accent-soft); }
.dd a strong { display: block; font-size: .92rem; font-weight: 600; color: var(--text-strong); }
.dd a small { display: block; font-size: .78rem; color: var(--text-muted); }
.dd-dot { width: 20px; height: 14px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.dd-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.flag { border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); flex: none; }
.header-search { display: flex; align-items: center; gap: .45rem; border: 1px solid var(--border); border-radius: 8px; padding: 0 .6rem; color: var(--text-muted); background: #fff; }
.header-search input { border: 0; outline: none; font: inherit; font-size: .9rem; width: 10rem; padding: .5rem 0; color: var(--text-strong); background: transparent; }
.header-search:focus-within { border-color: var(--accent); }
.country-btn { border: 1px solid var(--border) !important; }
.country-btn span { font-weight: 600; font-size: .85rem; }
.nav-burger { display: none; margin-left: auto; background: none; border: 0; padding: .5rem; cursor: pointer; }
.nav-burger span { display: block; width: 22px; height: 2px; background: var(--text-strong); margin: 4px 0; border-radius: 2px; }

@media (max-width: 960px) {
  .nav-burger { display: block; }
  .main-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border); padding: .75rem 16px 1rem; flex-direction: column; align-items: stretch; box-shadow: 0 12px 24px rgba(43,45,58,.08); max-height: calc(100vh - 64px); overflow-y: auto; }
  .main-nav.is-open { display: flex; }
  .menu { flex-direction: column; }
  .dd-toggle { width: 100%; justify-content: space-between; padding: .75rem .5rem; font-size: 1rem; }
  .dd, .dd-wide .dd, .dd-cols3 .dd, .dd-cols4 .dd { position: static; box-shadow: none; border: 0; min-width: 0; padding: 0 0 .5rem .25rem; grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
  .header-search input { width: 100%; }
  .country-dd .dd { position: static; }
}

/* ---------------- Layout ---------------- */
.site-main { padding: 1.5rem 0 3.5rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2.25rem; align-items: start; }
.layout-main { min-width: 0; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } .layout > .side { position: static; } }

/* ---------------- Home ---------------- */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem; align-items: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3rem); line-height: 1.1; margin: .6rem 0 .9rem; }
.hero p { margin: 0 0 1.25rem; max-width: 36rem; font-size: 1.05rem; }
.hero-kicker { display: inline-block; font-size: .8rem; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); padding: .3rem .75rem; border-radius: 999px; }
.hero-search { display: flex; max-width: 34rem; gap: .5rem; }
.hero-search input { flex: 1; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: #fff; color: var(--text-strong); }
.hero-search input:focus { outline: none; border-color: var(--accent); }
.hero-search button, .button { padding: .8rem 1.25rem; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.hero-search button:hover, .button:hover { background: #00a079; }
.hero-links { font-size: .9rem; margin-top: 1rem !important; color: var(--text-muted); }
.hero-links a { color: var(--text); }
.hero-art svg { display: block; max-width: 420px; margin-left: auto; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding-top: 1rem; } .hero-art { order: -1; } .hero-art svg { max-width: 260px; margin: 0 auto; } }
.home-section { margin: 2.75rem 0; }
.home-section > h2 { font-size: 1.45rem; margin: 0 0 1.1rem; }
.home-countries { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.home-country { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.home-country h3 { font-size: 1.05rem; margin: 0 0 .7rem; display: flex; align-items: center; gap: .55rem; }
.home-country h3 a { margin-left: auto; font-size: .82rem; font-weight: 600; text-decoration: none; }
.home-country ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.home-country li a { text-decoration: none; color: var(--text); font-size: .93rem; }
.home-country li a:hover { color: var(--accent-text); }
.trust { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin: 2.75rem 0; }
.trust div { padding: 1.1rem 1.2rem; border-radius: var(--radius); background: var(--surface-2); font-size: .93rem; }
.trust strong { display: block; margin-bottom: .3rem; color: var(--text-strong); }

/* ---------------- Blog ---------------- */
.archive-head { margin: .5rem 0 1.25rem; }
.archive-head h1 { margin: 0 0 .4rem; font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem); }
.archive-head p { margin: 0; color: var(--text); max-width: 60ch; }
.filter-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.filter-tabs a { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .88rem; font-weight: 500; }
.filter-tabs a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pagination { display: flex; gap: .4rem; justify-content: center; margin: 2.25rem 0 0; flex-wrap: wrap; }
.pagination .page-numbers { padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); font-size: .9rem; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Single post */
.entry { min-width: 0; }
.entry-head { margin-bottom: 1.25rem; }
.entry-title { font-size: clamp(1.7rem, 1.25rem + 1.8vw, 2.4rem); margin: .5rem 0 .6rem; line-height: 1.2; }
.entry-meta { color: var(--text-muted); font-size: .87rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.entry .wp-post-image { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); margin: 0 0 1.5rem; display: block; }
.entry-content { line-height: 1.8; font-size: 1.03rem; }
.entry-content > * { max-width: 70ch; }
.entry-content > .calc-embed, .entry-content > figure, .entry-content > .wp-block-table, .entry-content > .toc { max-width: none; }
.entry-content h2 { margin-top: 2.25rem; font-size: 1.45rem; }
.entry-content h3 { margin-top: 1.6rem; font-size: 1.15rem; }
.entry-content li { margin: .3rem 0; }
.entry-content .wp-block-table { margin: 1.5rem 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.entry-content .wp-block-table table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .93rem; line-height: 1.5; }
.entry-content .wp-block-table th, .entry-content .wp-block-table td { border-bottom: 1px solid var(--border); padding: .6rem .85rem; text-align: right; }
.entry-content .wp-block-table tr:last-child th, .entry-content .wp-block-table tr:last-child td { border-bottom: 0; }
.entry-content .wp-block-table th:first-child { text-align: left; font-weight: 500; color: var(--text); }
.entry-content .wp-block-table thead th { background: var(--surface-2); font-weight: 600; color: var(--text-strong); font-size: .85rem; }
.entry-content .wp-block-table a { text-decoration: none; }
.entry-content figcaption { font-size: .8rem; color: var(--text-muted); padding: .55rem .85rem; border-top: 1px solid var(--border); background: var(--surface-2); }
.toc { background: var(--surface-2); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1.5rem 0; }
.toc p { margin: 0 0 .4rem; color: var(--text-strong); }
.toc ol { margin: 0; padding-left: 1.2rem; columns: 2 16rem; column-gap: 2rem; font-size: .93rem; }
.toc li { margin: .2rem 0; break-inside: avoid; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent-text); }
.entry-content h2[id] { scroll-margin-top: 80px; }
.post-related { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ---------------- Footer ---------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface-2); padding: 2.5rem 0 2rem; font-size: .9rem; color: var(--text-muted); }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1.75rem; }
.footer-cols h3 { font-size: .92rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .45rem; }
.footer-cols h3 a { color: var(--text-strong); text-decoration: none; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.footer-cols a { color: var(--text-muted); text-decoration: none; }
.footer-cols a:hover { color: var(--accent-text); }
.disclaimer { margin-top: 2rem; font-size: .8rem; }
.brand .wordmark { font-weight: 800; letter-spacing: -.03em; font-size: 1.2rem; color: var(--text-strong); }
.brand .wordmark b { color: var(--accent); font-weight: 800; }
.brand svg { width: 32px; height: 32px; }
