/*
Theme Name: Amortica
Theme URI: https://amortica.com/
Author: Amortica
Author URI: https://amortica.com/
Description: Clean theme for the Amortica mortgage & loan calculator. Warm-stone palette, Bricolage Grotesque + IBM Plex Sans, single pine-green accent. The front page shows the calculator; guides and legal pages use a readable prose layout. Adapts to light/dark. No page builder, no bloat.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: amortica
*/

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  /* warm-stone neutrals, one hue family */
  --bg: #f4f2ec;
  --surface: #fffdf8;
  --surface-2: #ece9df;
  --ink: #232019;
  --ink-soft: #6b6456;
  --line: #e3ded1;
  /* single accent: pine green, desaturated */
  --accent: #1c6b4a;
  --accent-soft: #e7f0e9;
  --accent-ink: #123f2c;
  --warn: #ad4320;

  --radius: 16px;      /* containers */
  --radius-sm: 9px;    /* inner elements */
  --radius-xs: 6px;

  /* shadows: single top light source, tinted toward the accent */
  --shadow-sm: 0 1px 2px rgba(40, 34, 22, .05);
  --shadow: 0 1px 2px rgba(40, 34, 22, .05), 0 16px 40px -18px rgba(24, 58, 42, .20);
  --shadow-lift: 0 1px 2px rgba(40, 34, 22, .06), 0 22px 48px -20px rgba(24, 58, 42, .28);

  --display: "Bricolage Grotesque", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --wrap: 1060px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 220ms;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16140f;
    --surface: #201d16;
    --surface-2: #272419;
    --ink: #ece7db;
    --ink-soft: #a8a08d;
    --line: #343026;
    --accent: #57b98a;
    --accent-soft: #1e332a;
    --accent-ink: #c8ead8;
    --warn: #e07a4a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 44px -18px rgba(0, 0, 0, .6);
    --shadow-lift: 0 1px 2px rgba(0, 0, 0, .4), 0 24px 52px -20px rgba(0, 0, 0, .7);
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  color: var(--ink);
  background-color: var(--bg);
  /* faint grain in the page margins only (behind opaque surfaces) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.14'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 {
  font-family: var(--display);
  text-wrap: balance;
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 600;
}
p { text-wrap: pretty; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9em; background: var(--accent-soft); color: var(--accent-ink);
  padding: .12em .38em; border-radius: var(--radius-xs);
}

::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-xs); }

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm); font-weight: 600; box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }

.wrap { width: min(100% - 2.4rem, var(--wrap)); margin-inline: auto; }

/* =============================================================
   3. Header / footer
   ============================================================= */
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: .85rem 0; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 700; font-size: 1.12rem; letter-spacing: -0.02em; }
.brand-mark {
  display: grid; place-items: center; width: 1.75rem; height: 1.75rem;
  background: var(--accent); color: #fff; border-radius: var(--radius-xs) var(--radius-sm) var(--radius-xs) var(--radius-sm);
  font-weight: 700; font-family: var(--display);
}
.header-nav { display: flex; gap: 1.5rem; font-size: .92rem; font-weight: 500; color: var(--ink-soft); }
.header-nav a { position: relative; padding: .15rem 0; transition: color var(--dur) var(--ease); }
.header-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--accent); border-radius: 2px;
  transform: scaleX(0); transform-origin: left; transition: transform var(--dur) var(--ease);
}
.header-nav a:hover { color: var(--ink); }
.header-nav a:hover::after,
.header-nav a[aria-current="page"]::after { transform: scaleX(1); }
.header-nav a[aria-current="page"] { color: var(--ink); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 4rem; padding: 2rem 0; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: .9rem 1.6rem; justify-content: space-between; align-items: center; font-size: .87rem; color: var(--ink-soft); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.site-footer a { transition: color var(--dur) var(--ease); }
.site-footer a:hover { color: var(--accent); }

/* =============================================================
   4. Hero + tool card
   ============================================================= */
.hero { padding: 3rem 0 1rem; }
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.15rem); font-weight: 600; }
.subtitle { margin-top: .85rem; color: var(--ink-soft); max-width: 48ch; font-size: 1.06rem; }

.tool-card {
  position: relative;
  margin-top: 1.9rem; background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.15rem, 3vw, 2rem);
}
.tool-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--surface)));
  border-radius: var(--radius) var(--radius) 0 0;
}

.scenario-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.15rem; }
.scenario-head h2 { font-size: 1.15rem; }
#compare-panel h2 { font-size: 1.05rem; margin: 1.5rem 0 .85rem; }

.currency-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.currency-toggle button {
  padding: .48rem .85rem; font-size: .88rem; font-weight: 600; color: var(--ink-soft);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.currency-toggle button:hover { color: var(--ink); }
.currency-toggle button:active { transform: translateY(1px); }
.currency-toggle button.is-active { background: var(--accent); color: #fff; }

.calc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.1rem; }
.calc-grid-b { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: .38rem; font-size: .89rem; font-weight: 500; }
.field span em { color: var(--ink-soft); font-style: normal; font-weight: 400; }
.field-check { flex-direction: row; align-items: center; gap: .55rem; grid-column: 1 / -1; }
.field-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.input-affix {
  display: flex; align-items: center; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input-affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-affix input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  padding: .62rem .7rem; font: inherit; font-weight: 500;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.input-affix input:focus { outline: 0; }
.affix { padding: 0 .1rem 0 .7rem; color: var(--ink-soft); font-weight: 600; }
.affix-end { padding: 0 .7rem 0 .3rem; }

.tool-nojs { margin-top: 1rem; color: var(--warn); font-weight: 500; }
.js-on .tool-nojs { display: none; }

/* =============================================================
   5. Results
   ============================================================= */
.results { margin-top: 1.75rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.result-primary { display: flex; flex-direction: column; gap: .2rem; margin-bottom: 1.25rem; }
.result-label { font-size: .74rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.result-value {
  font-family: var(--sans); font-weight: 600;
  font-size: clamp(2.2rem, 6.5vw, 3rem);
  letter-spacing: -0.03em;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) { .result-value { color: var(--accent); } }
.result-sub { font-size: .94rem; color: var(--ink-soft); }

.result-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; }
.result-row > div {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: .75rem .85rem; display: flex; flex-direction: column; gap: .22rem;
}
.result-row span { font-size: .76rem; color: var(--ink-soft); }
.result-row strong { font-size: 1.06rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-note {
  margin-top: 1rem; padding: .8rem 1rem; background: var(--accent-soft);
  color: var(--accent-ink); border-radius: var(--radius-sm); font-size: .9rem;
}

.chart-wrap { margin-top: 1.6rem; }
#chart { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
#chart-legend { margin-top: .55rem; font-size: .8rem; color: var(--ink-soft); display: flex; gap: 1.2rem; flex-wrap: wrap; }
#chart-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: middle; }

.table-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.5rem; }
.btn-ghost {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55rem .95rem; font-size: .87rem; font-weight: 600; color: var(--ink-soft);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); background: var(--surface-2); }
.btn-ghost:active { transform: translateY(1px); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

#schedule { margin-top: 1rem; max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.amort { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
table.amort th, table.amort td { padding: .48rem .75rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.amort th { position: sticky; top: 0; background: var(--surface); z-index: 1; font-weight: 600; }
table.amort th:first-child, table.amort td:first-child { text-align: left; }
table.amort tr.year-row td { background: var(--accent-soft); font-weight: 600; color: var(--accent-ink); }

.privacy-badge { margin-top: 1.6rem; font-size: .89rem; color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { .privacy-badge { color: var(--accent); } }
.limits-note { margin-top: .55rem; font-size: .81rem; color: var(--ink-soft); }

/* =============================================================
   6. Ad slots (placeholders only)
   ============================================================= */
.ad-slot {
  display: grid; place-items: center; margin: 1.8rem 0;
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: .68rem; letter-spacing: .16em; font-weight: 600;
}
.ad-leaderboard { min-height: 90px; }
.ad-rectangle { min-height: 250px; max-width: 336px; margin-inline: auto; }
.ad-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 90;
  width: 220px; min-height: 90px; display: grid; place-items: center;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); color: var(--ink-soft); font-size: .66rem; letter-spacing: .16em; font-weight: 600;
}
.ad-toast-close { position: absolute; top: .2rem; right: .45rem; font-size: 1.1rem; line-height: 1; color: var(--ink-soft); transition: color var(--dur) var(--ease); }
.ad-toast-close:hover { color: var(--ink); }

/* =============================================================
   7. Content sections
   ============================================================= */
.content-section { padding: 3rem 0 3.4rem; }
.content-section > h2 { font-size: clamp(1.5rem, 3.6vw, 2rem); margin-bottom: 1.5rem; }

.steps { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; counter-reset: step; }
.steps li { background: var(--surface-2); border-radius: var(--radius); padding: 1.35rem 1.3rem 1.5rem; }
.step-icon {
  display: grid; place-items: center; width: 2.1rem; height: 2.1rem;
  border-radius: var(--radius-xs) var(--radius-sm) var(--radius-xs) var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 700; font-family: var(--display);
  margin-bottom: .85rem;
}
.steps h3 { font-size: 1.04rem; margin-bottom: .35rem; }
.steps p { font-size: .9rem; color: var(--ink-soft); }

.prose { max-width: 66ch; }
.prose > p { margin-bottom: 1.05rem; color: var(--ink-soft); }
.prose h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); margin: 2.2rem 0 .85rem; }
.prose h3 { font-size: 1.12rem; margin: 1.7rem 0 .55rem; color: var(--ink); }
.prose ul, .prose ol { margin: 0 0 1.05rem 1.25rem; color: var(--ink-soft); }
.prose li { margin-bottom: .45rem; }
.prose .lead { font-size: 1.12rem; color: var(--ink); line-height: 1.55; }
.prose .back-link {
  display: inline-block; margin-top: 1.8rem; font-weight: 600; color: var(--accent);
  transition: gap var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.prose .back-link:hover { opacity: .75; }

.use-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.use-grid article {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.2rem 1.3rem;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.use-grid article:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.use-grid h3 { font-size: 1rem; margin-bottom: .32rem; }
.use-grid p { font-size: .88rem; color: var(--ink-soft); }

/* FAQ — divided list, not a stack of cards */
#faq details { border-bottom: 1px solid var(--line); padding: 1rem 0; }
#faq details:first-of-type { border-top: 1px solid var(--line); }
#faq summary {
  font-weight: 600; cursor: pointer; list-style: none; display: flex; gap: 1rem;
  align-items: baseline; justify-content: space-between; font-size: 1rem;
}
#faq summary::-webkit-details-marker { display: none; }
#faq summary::after {
  content: "+"; font-family: var(--display); font-weight: 500; font-size: 1.3rem;
  color: var(--accent); line-height: 1; transition: transform var(--dur) var(--ease); flex: none;
}
#faq details[open] summary::after { transform: rotate(45deg); }
#faq details p { margin-top: .7rem; font-size: .93rem; color: var(--ink-soft); max-width: 62ch; }

/* card list (guides) */
.card-list { display: grid; gap: 1.1rem; grid-template-columns: repeat(2, 1fr); }
.card-list a {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.25rem 1.3rem;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-list a:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card-list h3 { font-size: 1.04rem; margin-bottom: .32rem; }
.card-list h3::after { content: " \2192"; color: var(--accent); }
.card-list p { font-size: .9rem; color: var(--ink-soft); }

.contact-box { background: var(--surface-2); border-radius: var(--radius); padding: 1.4rem; margin-top: 1.1rem; }
.contact-box a { color: var(--accent); font-weight: 600; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; gap: .35rem 1rem; }
  .header-nav { gap: 1.1rem; font-size: .84rem; flex-wrap: wrap; }
  .calc-grid, .calc-grid-b { grid-template-columns: 1fr; }
  .result-row { grid-template-columns: repeat(2, 1fr); }
  .steps, .use-grid, .card-list { grid-template-columns: 1fr; }
  .ad-toast { display: none; }
}

/* =============================================================
   9. Motion / reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* =============================================================
   10. Print
   ============================================================= */
@media print {
  .site-header, .site-footer, .ad-slot, .ad-toast, .table-actions, .currency-toggle,
  #compare-panel, .field-check, .content-section, .chart-wrap { display: none !important; }
  body { background: #fff; color: #000; }
  .tool-card { box-shadow: none; border: 0; }
  #schedule { max-height: none; overflow: visible; border: 0; }
  table.amort th { position: static; }
}

/* =============================================================
   11. WordPress glue
   ============================================================= */
body.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .site-header { top: 46px; } }

/* nav menus output <ul><li><a> */
.header-nav ul { display: flex; flex-wrap: wrap; gap: 1.5rem; list-style: none; margin: 0; padding: 0; }
.header-nav li { margin: 0; }
.header-nav .current-menu-item > a::after,
.header-nav .current_page_item > a::after { transform: scaleX(1); }
.header-nav .current-menu-item > a,
.header-nav .current_page_item > a { color: var(--ink); }
.site-footer nav ul { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; list-style: none; margin: 0; padding: 0; }
.site-footer nav li { margin: 0; }

#main { display: block; }
.page-title { font-family: var(--display); font-size: clamp(1.6rem,4vw,2.2rem); margin-bottom: 1.6rem; }

/* editor / alignment helpers */
.entry-content img, .wp-block-image img { border-radius: var(--radius-sm); }
.aligncenter { margin-inline: auto; }
.alignwide { width: min(100% - 2.4rem, 1200px); margin-inline: auto; }
.alignfull { width: 100%; }
figure { margin: 1.4rem 0; }
figcaption { font-size: .82rem; color: var(--ink-soft); margin-top: .4rem; }
blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1.4rem 0; color: var(--ink-soft); }

/* the imported calculator page carries its own inline styles; these are the
   fallback so the [amortica_calculator] shortcode also looks right */
#amortica-calc { max-width: 780px; margin-inline: auto; }
#amortica-calc .content-section { padding: 2.4rem 0; }

.pagination, .nav-links { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 2rem; }
.pagination .page-numbers, .nav-links a, .nav-links span {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .4rem .75rem; font-weight: 600; font-size: .88rem; color: var(--ink-soft);
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
