/* ============================================================================
   CalcHeadquarters Redesign — Shared Design System
   Phase 0 deliverable. Single source of design tokens + reusable classes for
   both the homepage and the calculator page template.
   Spec: design_handoff_calchq_redesign/README.md (hi-fi). Fonts loaded once
   per page via Google Fonts <link> (see snippet in redesign-icons.html).
   ============================================================================ */

/* ---------- Design tokens -------------------------------------------------- */
:root {
  /* Neutrals */
  --canvas:      #F6F3EA;   /* page background (warm cream) */
  --surface:     #FFFFFF;   /* cards, inputs, result tiles */
  --ink:         #1B1A17;   /* primary text, dark panels, logo mark */
  --ink-70:      #57544C;   /* body copy */
  --ink-50:      #8A867B;   /* secondary / meta text */
  --line:        #EDE7D9;   /* card borders */
  --line-2:      #E8E2D4;   /* input borders */

  /* Accent */
  --yellow:      #F5C542;   /* highlighter, #1 badge, hero result figures */

  /* Category — Finance */
  --finance:      #17915B;
  --finance-tint: #E3F2E9;
  --finance-deep: #0F6E43;
  /* Category — Business */
  --business:      #3B5BDB;
  --business-tint: #E6EAFB;
  --business-deep: #2D449E;
  /* Category — Career */
  --career:       #7A4DD1;
  --career-tint:  #EEE7FA;
  --career-deep:  #5C3BA0;
  /* Category — Fitness */
  --fitness:      #E5533D;
  --fitness-tint: #FBE6E1;
  --fitness-deep: #B03E2C;

  /* Panels / ads */
  --hero-gradient: linear-gradient(150deg, #FFFDF6 0%, #F1F6EE 55%, #EAF1FB 100%);
  --ad-bg:     #FBF9F2;
  --ad-border: 1.5px dashed #D8D1BF;

  /* Radii */
  --r-input:  11px;   /* inputs / buttons (10–13) */
  --r-card:   20px;   /* cards */
  --r-panel:  24px;   /* large panels / tiles (22–28) */
  --r-hero:   28px;
  --r-pill:   999px;

  /* Shadows */
  --shadow-card:   0 16px 34px rgba(27, 26, 23, .10);
  --shadow-search: 0 16px 40px rgba(0, 0, 0, .28);
  --shadow-drop:   0 20px 50px rgba(0, 0, 0, .22);
  --shadow-chip:   0 8px 24px rgba(0, 0, 0, .25);

  /* Type families */
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'Space Mono', ui-monospace, monospace;

  /* Layout */
  --maxw: 1200px;
  --pad-x: 24px;
}

/* ---------- Category helper (set --c / --c-tint / --c-deep via one class) --- */
.cat-finance  { --c: var(--finance);  --c-tint: var(--finance-tint);  --c-deep: var(--finance-deep); }
.cat-business { --c: var(--business); --c-tint: var(--business-tint); --c-deep: var(--business-deep); }
.cat-career   { --c: var(--career);   --c-tint: var(--career-tint);   --c-deep: var(--career-deep); }
.cat-fitness  { --c: var(--fitness);  --c-tint: var(--fitness-tint);  --c-deep: var(--fitness-deep); }

/* ---------- Base ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

.rd-wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad-x); }

/* ---------- Typography ----------------------------------------------------- */
.rd-h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: -.03em;
  margin: 0;
}
.rd-h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 3.4vw, 30px);
  letter-spacing: -.02em;
  margin: 0;
}
.rd-h3 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -.02em;
  margin: 0;
}
.rd-mono { font-family: var(--font-mono); font-weight: 700; }
.rd-body { color: var(--ink-70); font-size: 19px; }
.rd-meta { color: var(--ink-50); font-family: var(--font-mono); font-weight: 700; }

.rd-highlight {           /* yellow highlighter behind headline text */
  background: var(--yellow);
  color: var(--ink);
  padding: 0 10px;
  border-radius: 8px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---------- Top bar / chrome ---------------------------------------------- */
.rd-topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(246, 243, 234, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.rd-topbar__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px var(--pad-x);
  display: flex; align-items: center; gap: 20px;
}
.rd-nav { display: flex; gap: 4px; margin-left: auto; }
.rd-nav a { padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 15px; }
.rd-nav a:hover { background: var(--surface); }
.rd-nav a.cat-finance  { color: var(--finance); }
.rd-nav a.cat-business { color: var(--business); }
.rd-nav a.cat-career   { color: var(--career); }
.rd-nav a.cat-fitness  { color: var(--fitness); }
.rd-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--ink-70);
}
.rd-status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--finance); }

/* ---------- Logo ----------------------------------------------------------- */
.rd-logo { display: inline-flex; align-items: center; gap: 10px; }
.rd-logo__mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--ink);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.rd-logo__mark i { width: 12px; height: 2.5px; border-radius: 2px; background: var(--yellow); display: block; }
.rd-logo__word { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -.02em; }

/* ---------- Buttons / pills / chips --------------------------------------- */
.rd-btn {
  font-family: var(--font-body); font-weight: 700; font-size: 15px;
  border: 0; cursor: pointer; border-radius: 13px; padding: 12px 20px;
  background: var(--finance); color: #fff; transition: filter .15s;
}
.rd-btn:hover { filter: brightness(1.05); }

.rd-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line-2);
  font-size: 14px; font-weight: 600; color: var(--ink-70); cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.rd-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }

.rd-eyebrow {           /* small tinted category pill, e.g. "Free · No sign-up" */
  display: inline-block; padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--finance-tint); color: var(--finance-deep);
  font-weight: 700; font-size: 13px;
}

/* ---------- Hero ----------------------------------------------------------- */
.rd-hero {
  position: relative; overflow: hidden;
  background: var(--hero-gradient);
  border: 1px solid #ECE6D6; border-radius: var(--r-hero);
  padding: 64px 56px 56px;
}
.rd-chip {              /* floating hero result chips */
  position: absolute;
  padding: 10px 16px; border-radius: 14px;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow-chip);
  transform: rotate(var(--r, 0deg));
  animation: floaty 6.5s ease-in-out infinite;
}
.rd-chip--yellow  { background: var(--yellow);   color: var(--ink); }
.rd-chip--coral   { background: var(--fitness);  color: #fff; }
.rd-chip--indigo  { background: var(--business); color: #fff; }

/* ---------- Search --------------------------------------------------------- */
.rd-search {
  position: relative; max-width: 640px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 18px;
  padding: 6px 6px 6px 22px; box-shadow: var(--shadow-search);
}
.rd-search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-family: var(--font-body); font-size: 17px; color: var(--ink);
  padding: 12px 0;
}
.rd-search__drop {
  position: absolute; left: 0; right: 0; top: 74px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-drop);
  overflow: hidden; display: none;
}
.rd-search__drop.is-open { display: block; }
.rd-result {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
}
.rd-result:hover { background: var(--canvas); }
.rd-result__badge {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: var(--c-tint, var(--finance-tint));
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Cards ---------------------------------------------------------- */
.rd-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 22px;
  transition: transform .15s, box-shadow .15s;
}
.rd-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card); }

.rd-icon-square {          /* tinted rounded-square icon holder (44px cards) */
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--c-tint, var(--finance-tint)); color: var(--c, var(--finance));
  display: inline-flex; align-items: center; justify-content: center;
}
.rd-icon-square--lg { width: 52px; height: 52px; border-radius: 14px; }
.rd-icon-square--solid { background: var(--c, var(--finance)); color: #fff; }

.rd-rank {                 /* rank badge on popular cards */
  width: 26px; height: 26px; border-radius: 8px; margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  background: var(--ink); color: #fff;
}
.rd-rank--1 { background: var(--yellow); color: var(--ink); }

.rd-card__eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c, var(--finance)); }
.rd-card__title { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.01em; margin: 6px 0 4px; }

/* ---------- Category tiles ------------------------------------------------- */
.rd-tile {
  background: linear-gradient(135deg, var(--c-tint) 0%, #fff 130%);
  border: 1px solid var(--c-tint); border-radius: var(--r-panel); padding: 30px;
  transition: transform .15s;
}
.rd-tile:hover { transform: translateY(-3px); }
.rd-tile__count { font-family: var(--font-mono); font-weight: 700; color: var(--c-deep, var(--finance-deep)); }
.rd-tile__desc { color: var(--c-deep, var(--finance-deep)); }
.rd-tile__link { display: block; }
.rd-tile__pill {
  display: inline-block; padding: 6px 12px; margin: 4px 6px 0 0; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .7); color: var(--c-deep, var(--finance-deep));
  font-size: 13px; font-weight: 600; transition: background .15s;
}
a.rd-tile__pill:hover { background: #fff; }
.rd-tile__pill--more { font-family: var(--font-mono); font-weight: 700; }

/* ---------- Trust strip / ink panel --------------------------------------- */
.rd-ink-panel { background: var(--ink); color: var(--canvas); border-radius: var(--r-panel); padding: 40px; }
.rd-trust { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; text-align: center; }
.rd-trust__fig { font-family: var(--font-mono); font-weight: 700; font-size: 38px; color: var(--canvas); }
.rd-trust__fig--accent { color: var(--yellow); }
.rd-trust__label { color: rgba(246, 243, 234, .7); font-size: 14px; }

/* ---------- Footer --------------------------------------------------------- */
.rd-footer {
  background: var(--ink); color: rgba(246, 243, 234, .75);
  padding: 40px var(--pad-x); margin-top: 52px;
}
.rd-footer__inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.rd-footer .rd-logo__word { color: var(--canvas); }

/* ---------- Ad slots ------------------------------------------------------- */
.rd-ad {
  background: var(--ad-bg); border: var(--ad-border); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px;
  color: var(--ink-50); font-family: var(--font-mono); font-size: 12px; text-align: center;
}
.rd-ad--leaderboard { height: 104px; }
.rd-ad--incontent   { height: 120px; }
.rd-ad--rail        { width: 300px; height: 600px; position: sticky; top: 88px; }

/* ---------- Calculator page: inputs / results ----------------------------- */
.rd-breadcrumb { font-size: 14px; color: var(--ink-50); }
.rd-breadcrumb a { color: var(--finance); font-weight: 600; }

.rd-range { width: 100%; accent-color: var(--finance); }
.rd-range::-webkit-slider-runnable-track { background: var(--line-2); height: 6px; border-radius: 999px; }
.rd-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 3px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); margin-top: -8px; }
.rd-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 3px solid #fff; }
.rd-range-val { font-family: var(--font-mono); font-weight: 700; color: var(--finance); }

.rd-seg { display: inline-flex; gap: 8px; }
.rd-seg button {
  font-family: var(--font-body); font-weight: 700; font-size: 14px; cursor: pointer;
  padding: 10px 18px; border-radius: var(--r-input);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-70);
}
.rd-seg button.is-active { background: var(--finance); color: #fff; border-color: var(--finance); }

.rd-numin {
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  border: 1.5px solid var(--line-2); border-radius: var(--r-input);
  padding: 10px 12px; width: 100%; color: var(--ink);
}

.rd-result-card { background: var(--ink); color: var(--canvas); border-radius: var(--r-panel); padding: 28px; }
.rd-result-card__fig { font-family: var(--font-mono); font-weight: 700; font-size: 46px; color: var(--yellow); line-height: 1; }

.rd-bar { height: 12px; border-radius: 999px; overflow: hidden; display: flex; background: var(--line-2); }
.rd-bar__seg { height: 100%; }
.rd-bar__seg--pi  { background: var(--finance); }
.rd-bar__seg--tax { background: var(--business); }
.rd-bar__seg--ins { background: var(--career); }
.rd-bar__seg--pmi { background: var(--fitness); }

.rd-legend-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.rd-legend-row .sw { width: 12px; height: 12px; border-radius: 4px; }
.rd-legend-row .val { margin-left: auto; font-family: var(--font-mono); font-weight: 700; }

.rd-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; }
.rd-stat__label { font-size: 12px; color: var(--ink-50); }
.rd-stat__val { font-family: var(--font-mono); font-weight: 700; font-size: 20px; margin-top: 4px; }

/* ---------- Calculator page: layout / header / content -------------------- */
.rd-calc-layout { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
.rd-calc-header { display: flex; gap: 16px; align-items: flex-start; margin: 20px 0 24px; }
.rd-calc-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c, var(--finance)); }
.rd-calc-header h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.02em; margin: 4px 0 0; }
.rd-calc-intro { color: var(--ink-70); font-size: 16px; max-width: 640px; margin-top: 10px; }

.rd-tool-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }
.rd-inputs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 26px; }
.rd-field { margin-bottom: 20px; }
.rd-field:last-child { margin-bottom: 0; }
.rd-field__top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; gap: 12px; }
.rd-field__label { font-size: 14px; font-weight: 600; color: var(--ink-70); }
.rd-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rd-results { display: flex; flex-direction: column; gap: 16px; }
.rd-result-card__label { font-size: 13px; color: rgba(246,243,234,.7); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.rd-result-card__sub { color: rgba(246,243,234,.7); font-size: 13px; margin-top: 8px; font-family: var(--font-mono); }
.rd-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.rd-chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 24px; margin-top: 20px; }
.rd-chart-card h3 { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin: 0 0 16px; }

.rd-content { max-width: 720px; }
.rd-content h2 { font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: -.02em; margin: 32px 0 12px; }
.rd-content h3 { font-family: var(--font-display); font-weight: 700; font-size: 18px; margin: 22px 0 8px; }
.rd-content p, .rd-content li { color: var(--ink-70); font-size: 16px; line-height: 1.7; }
.rd-content ul { margin: 8px 0 0 20px; }
.rd-content li { margin-bottom: 6px; }
.rd-tip { background: var(--finance-tint); border-radius: var(--r-card); padding: 16px 20px; margin: 18px 0; }
.rd-tip p { color: var(--finance-deep); margin: 0; }

.rd-faq-item { border-bottom: 1px solid var(--line); }
.rd-faq-q { font-weight: 700; font-size: 16px; padding: 16px 0; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.rd-faq-q::after { content: "+"; font-family: var(--font-mono); color: var(--ink-50); }
.rd-faq-item.open .rd-faq-q::after { content: "−"; }
.rd-faq-a { color: var(--ink-70); font-size: 15px; line-height: 1.7; padding: 0 0 16px; display: none; }
.rd-faq-item.open .rd-faq-a { display: block; }

.rd-related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 8px; }
.rd-related-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; transition: transform .15s, box-shadow .15s; display: block; }
.rd-related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.rd-related-card .lbl { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c, var(--finance)); }
.rd-related-card .nm { font-weight: 600; font-size: 14px; margin-top: 4px; }

@media (max-width: 900px) {
  .rd-calc-layout { grid-template-columns: 1fr; }
  .rd-ad--rail { position: static; width: 100%; height: 250px; }
  .rd-tool-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .rd-field-row { grid-template-columns: 1fr; }
  .rd-stat-grid { grid-template-columns: 1fr; }
}

/* ---------- Keyframes ------------------------------------------------------ */
@keyframes floaty {
  0%, 100% { transform: rotate(var(--r, 0deg)) translateY(0); }
  50%      { transform: rotate(var(--r, 0deg)) translateY(-9px); }
}
@keyframes popin {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .rd-chip { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------- Responsive ----------------------------------------------------- */
@media (max-width: 900px) {
  .rd-hero { padding: 40px 24px 32px; }
  .rd-chip { display: none; }              /* declutter hero on mobile */
  .rd-trust { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .rd-nav { display: none; }               /* replace with menu in Phase 1 */
  .rd-body { font-size: 17px; }
}
