/* =====================================================================
   Meridian theme for interior pages
   Loads AFTER styles.css. Two jobs:
   1. Remap styles.css design tokens to the warm editorial palette, so
      every existing component (cards, tables, map, modal, toast, tips)
      picks it up automatically — including dark mode.
   2. Restyle the page chrome: masthead instead of sidebar, serif
      display type, warm form controls, pill buttons.
   Markup and app JS are untouched; selectors target existing classes.
   ===================================================================== */

:root {
  /* Meridian tokens */
  --paper: #faf7f2;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-faint: #a8a29e;
  --line: #e7e0d6;
  --m-accent: #0d7a5f;
  --m-accent-soft: #e6f2ee;
  --grid-line: #efe9df;
  --card-shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 10px 34px rgba(28, 25, 23, 0.07);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;

  /* dimension palette (light) */
  --d-financial: #16803c;
  --d-medical: #c2372f;
  --d-mental: #6d4fc4;
  --d-physical: #2563eb;
  --d-retirement: #0d7a5f;
  --d-social: #b45309;
  --d-security: #0369a1;
  --d-time: #be123c;

  /* remap styles.css tokens */
  --bg: var(--paper);
  --card: #ffffff;
  --text: var(--ink);
  --text-muted: var(--ink-soft);
  --border: var(--line);
  --primary: var(--m-accent);
  --primary-light: var(--m-accent-soft);
  --accent: var(--m-accent);
  --accent-dark: #0a6650;
  --hover-bg: #f3efe8;
  --hover-border: #d8d0c4;
  --ring-bg: var(--grid-line);
  --bar-bg: var(--grid-line);
  --country-fill: #ece6dc;
  --country-stroke: #ffffff;
  --country-hover: #ddd5c8;
  --icon-green-bg: var(--m-accent-soft);
  --modal-bg: #ffffff;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.05), 0 1px 3px rgba(28, 25, 23, 0.05);
  --shadow-lg: var(--card-shadow);

  /* per-page dimension accent (default: site accent) */
  --dim: var(--m-accent);
}

[data-theme="dark"] {
  --paper: #171310;
  --ink: #ece7e0;
  --ink-soft: #b3aba1;
  --ink-faint: #7d756c;
  --line: #35302a;
  --m-accent: #4fb897;
  --m-accent-soft: #17322a;
  --grid-line: #2e2823;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 38px rgba(0, 0, 0, 0.45);
  --d-financial: #2eb865;
  --d-medical: #ef6a5f;
  --d-mental: #a78bfa;
  --d-physical: #5b96f7;
  --d-retirement: #25b18a;
  --d-social: #e19008;
  --d-security: #2a9fdb;
  --d-time: #f26483;

  --bg: var(--paper);
  --card: #221d19;
  --text: var(--ink);
  --text-muted: var(--ink-soft);
  --border: var(--line);
  --primary: var(--m-accent);
  --primary-light: var(--m-accent-soft);
  --accent: var(--m-accent);
  --accent-dark: #25b18a;
  --hover-bg: #2a241f;
  --hover-border: #453e36;
  --ring-bg: var(--grid-line);
  --bar-bg: var(--grid-line);
  --country-fill: #322c26;
  --country-stroke: #221d19;
  --country-hover: #453e36;
  --icon-green-bg: var(--m-accent-soft);
  --modal-bg: #221d19;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: var(--card-shadow);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --paper: #171310;
    --ink: #ece7e0;
    --ink-soft: #b3aba1;
    --ink-faint: #7d756c;
    --line: #35302a;
    --m-accent: #4fb897;
    --m-accent-soft: #17322a;
    --grid-line: #2e2823;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 38px rgba(0, 0, 0, 0.45);
    --d-financial: #2eb865;
    --d-medical: #ef6a5f;
    --d-mental: #a78bfa;
    --d-physical: #5b96f7;
    --d-retirement: #25b18a;
    --d-social: #e19008;
    --d-security: #2a9fdb;
    --d-time: #f26483;

    --bg: var(--paper);
    --card: #221d19;
    --text: var(--ink);
    --text-muted: var(--ink-soft);
    --border: var(--line);
    --primary: var(--m-accent);
    --primary-light: var(--m-accent-soft);
    --accent: var(--m-accent);
    --accent-dark: #25b18a;
    --hover-bg: #2a241f;
    --hover-border: #453e36;
    --ring-bg: var(--grid-line);
    --bar-bg: var(--grid-line);
    --country-fill: #322c26;
    --country-stroke: #221d19;
    --country-hover: #453e36;
    --icon-green-bg: var(--m-accent-soft);
    --modal-bg: #221d19;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: var(--card-shadow);
  }
}

/* per-page dimension accent */
body[data-dim="financial"]  { --dim: var(--d-financial); }
body[data-dim="medical"]    { --dim: var(--d-medical); }
body[data-dim="mental"]     { --dim: var(--d-mental); }
body[data-dim="physical"]   { --dim: var(--d-physical); }
body[data-dim="retirement"] { --dim: var(--d-retirement); }
body[data-dim="security"]   { --dim: var(--d-security); }
body[data-dim="social"]     { --dim: var(--d-social); }
body[data-dim="time"]       { --dim: var(--d-time); }

/* ---------------------------------------------------------------------
   Layout: single column with masthead, no sidebar/aside
   --------------------------------------------------------------------- */
.site-layout { display: block; }
.site-layout__main { width: 100%; }
.site-aside { display: none; }

.site-sidebar {
  position: static;
  width: auto;
  height: auto;
  border: none;
  background: transparent;
  padding: 0;
}

.container { max-width: 860px; }

/* ---------------------------------------------------------------------
   Masthead (injected by masthead.js into #siteSidebar)
   --------------------------------------------------------------------- */
.m-masthead-wrap {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.m-masthead {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.m-wordmark {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.m-wordmark em { color: var(--m-accent); font-style: italic; }
.m-mast-right { display: flex; align-items: center; gap: 22px; }
.m-mast-right a.m-link {
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color .15s, border-color .15s;
}
.m-mast-right a.m-link:hover { color: var(--ink); border-color: var(--ink); }
.m-mast-right .m-link-btn {
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0 0 2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.m-mast-right .m-link-btn:hover { color: var(--ink); border-color: var(--ink); }
.m-mode-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
}
.m-mode-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.m-mode-btn .m-ico-sun { display: none; }
[data-theme="dark"] .m-mode-btn .m-ico-sun { display: block; }
[data-theme="dark"] .m-mode-btn .m-ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .m-mode-btn .m-ico-sun { display: block; }
  [data-theme="system"] .m-mode-btn .m-ico-moon { display: none; }
}
.m-masthead { position: relative; }
@media (max-width: 760px) {
  .m-mast-right a.m-link,
  .m-mast-right .m-link-btn { display: none; }
  .m-masthead .mnav-btn { display: grid; }
}
@media (max-width: 560px) {
  .m-masthead { padding: 16px; gap: 12px; }
  .m-wordmark { font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .m-mast-right { gap: 12px; flex-shrink: 0; }
  .m-mode-btn, .m-masthead .mnav-btn { width: 34px; height: 34px; }
}

/* Wide tables (guides) scroll inside their own box instead of the page. */
@media (max-width: 640px) {
  .page-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------------------------------------------------------------------
   Page header → chapter hero
   --------------------------------------------------------------------- */
header {
  text-align: left;
  padding: 48px 0 26px;
}
header h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 50px);
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.08;
  margin-bottom: 12px;
}
header p {
  font-size: 16.5px;
  color: var(--ink-soft);
  max-width: 54ch;
  margin-left: 0;
  margin-right: 0;
}
.chapter-rule {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 2.6px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.chapter-rule::after { content: ""; flex: 0 0 56px; height: 1px; background: var(--dim); opacity: .5; }

/* ---------------------------------------------------------------------
   Cards & section typography
   --------------------------------------------------------------------- */
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}
.card h2, h2.section-heading, .section-heading {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.4px;
}
.card h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.2px; }
.card h2 .icon {
  border-radius: 10px;
}

/* ---------------------------------------------------------------------
   Domain sections (assessment questionnaires)
   --------------------------------------------------------------------- */
.domain-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.domain-header { background: transparent; }
.domain-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.domain-chevron { color: var(--ink-faint); }

/* form controls */
.form-group label { font-weight: 600; color: var(--ink); }
.form-group select {
  background-color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
}
.form-group select:focus {
  outline: none;
  border-color: var(--dim);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dim) 18%, transparent);
}
.range-value {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  color: var(--dim);
}
input[type="range"] { accent-color: var(--dim); }
input[type="range"]::-webkit-slider-thumb {
  background: var(--dim);
  border-color: var(--card);
}
input[type="range"]::-moz-range-thumb {
  background: var(--dim);
  border-color: var(--card);
}

/* ---------------------------------------------------------------------
   Buttons → pills
   --------------------------------------------------------------------- */
.btn-primary {
  border-radius: 999px;
  background: var(--dim);
  font-weight: 600;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--dim) 85%, var(--ink));
  transform: translateY(-2px);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--dim) 30%, transparent);
}
.btn-secondary, .btn-copy {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-weight: 600;
}
.btn-secondary:hover, .btn-copy:hover { color: var(--ink); border-color: var(--ink-faint); background: var(--card); }

/* ---------------------------------------------------------------------
   Results: score ring, verdict, stats, bars
   --------------------------------------------------------------------- */
.score-ring-fill { stroke: var(--dim); }
.score-pct {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -1.5px;
}
.score-verdict {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.stat-box {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.stat-value {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.4px;
}
.bar-track { height: 6px; border-radius: 3px; }
.bar-fill { border-radius: 3px; background: var(--dim); }
.bar-header span:last-child {
  font-family: var(--serif);
  font-style: italic;
  color: var(--dim);
}

/* ---------------------------------------------------------------------
   Category tracker (other-dimension cards at page bottom)
   --------------------------------------------------------------------- */
.category-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  transition: transform .16s, box-shadow .16s;
}
.category-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow); }
.category-name { font-family: var(--serif); font-weight: 600; letter-spacing: -0.2px; }
.category-score { font-family: var(--serif); font-style: italic; font-weight: 600; }

/* ---------------------------------------------------------------------
   Shared footer & modal accents
   --------------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); background: transparent; }
.footer-links a { color: var(--ink-soft); }
.footer-links a:hover { color: var(--ink); }
.footer-sep { color: var(--line); }
.footer-copy, .footer-copy a { color: var(--ink-faint); }

.modal .btn-primary { background: var(--m-accent); }
.modal .btn-primary:hover { background: color-mix(in srgb, var(--m-accent) 85%, var(--ink)); }


/* ---------------------------------------------------------------------
   Dashboard sign-in landing
   --------------------------------------------------------------------- */
#dashboardLanding,
[data-theme="dark"] #dashboardLanding {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--card-shadow);
}
.dl-eyebrow {
  justify-self: start;
  color: var(--m-accent);
  background: var(--m-accent-soft);
  border-color: transparent;
}
.dl-headline {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.5px;
}
.dl-login-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: none;
}
input.dl-login-input {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--card);
}
input.dl-login-input:focus {
  border-color: var(--m-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--m-accent) 18%, transparent);
}
input.dl-login-input.dl-login-input--error,
input.dl-login-input.dl-login-input--error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent);
}
.dl-login-btn { background: var(--m-accent); }
.dl-login-btn:hover { background: color-mix(in srgb, var(--m-accent) 85%, var(--ink)); }
.dl-turnstile-loading { padding: 0 4px; }
@media (max-width: 640px) {
  #dashboardLanding { padding: 22px 16px; }
}

/* ---------------------------------------------------------------------
   Inline ad slots (inline-ads.js) — sit in the reading flow, clearly
   labelled, and stay hidden when no ad is active.
   --------------------------------------------------------------------- */
.inline-ad {
  margin: 28px 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--dim, var(--m-accent));
  border-radius: 14px;
  background: var(--card);
}
.inline-ad[hidden] { display: none; }
.inline-ad__label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.inline-ad__title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.inline-ad__body {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 8px;
}
.inline-ad__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--dim, var(--m-accent));
  text-decoration: none;
}
.inline-ad__link:hover { text-decoration: underline; }
.inline-ad .adsbygoogle { min-height: 90px; }

/* On phones the ad becomes a full-bleed tinted band with hairlines and a
   centered, rule-flanked label, so it reads as a clear break from content
   without shouting. The negative margin matches the 14px page gutter. */
@media (max-width: 640px) {
  .inline-ad {
    margin: 36px -14px;
    padding: 18px 20px 20px;
    border: none;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: color-mix(in srgb, var(--ink) 3.5%, var(--paper));
  }
  .inline-ad__label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }
  .inline-ad__label::before,
  .inline-ad__label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
  }
  .inline-ad__link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    margin-top: 2px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    text-decoration: none;
  }
  .inline-ad__link:hover { text-decoration: none; border-color: var(--dim, var(--m-accent)); }
}

/* Guides index: featured tool callout */
.guides-tool-callout {
  display: grid;
  gap: 4px;
  margin: 0 0 36px;
  padding: 22px 24px;
  border-radius: 16px;
  background: var(--m-accent-soft);
  border: 1px solid color-mix(in srgb, var(--m-accent) 30%, transparent);
  color: var(--ink);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.guides-tool-callout:hover { transform: translateY(-2px); box-shadow: var(--card-shadow); text-decoration: none; }
.guides-tool-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--m-accent);
}
.guides-tool-title { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.guides-tool-desc { font-size: 14.5px; color: var(--ink-soft); }
.guides-tool-callout .guide-card-tag { color: var(--m-accent); margin-top: 8px; }
