/* ═══════════════════════════════════════════════════════════
   RH GRAVITY TOOLS — BASE STYLES
   Shared across all tools. Loaded only when a tool is present.
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens (RH brand) ──────────────────────────── */
:root {
  --rh-primary: #400718;
  --rh-primary-hover: #5d061f;
  --rh-primary-dark: #24030c;
  --rh-primary-light: #6b1a30;
  --rh-body: #400718;
  --rh-body-soft: #86777b;
  --rh-surface: #fff9f6;
  --rh-surface-hover: #f6ede7;
  --rh-bg: #fdf9f7;
  --rh-white: #ffffff;
  --rh-border: hsla(0, 8%, 86%, 1);
  --rh-border-light: hsla(0, 8%, 92%, 1);
  --rh-strong: #000000;
  --rh-font-body: 'Source Sans 3', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --rh-radius: 8px;
  --rh-radius-lg: 12px;
  --rh-shadow: 0 2px 12px rgba(64, 7, 24, 0.08);
  --rh-shadow-lg: 0 8px 32px rgba(64, 7, 24, 0.12);
  --rh-transition: 0.3s ease;

  /* ── Shared helpers ────────────────────────────────────── */
  --rh-mid: #5e4d52;
  --rh-soft: rgba(64, 7, 24, 0.12);

  /* Accent (used in eyebrows, badges, accent borders) */
  --d-accent-bg: #fef5f0;
  --d-accent-bdr: #e8d5cb;

  /* ── Status palette (D3 LTR, D4 checklist) ─────────────── */
  --status-safe:     #2b7a4b;
  --status-safe-bg:  #eaf6ee;
  --status-safe-bdr: #b8dfc5;

  --status-ltr:      #b44c1c;
  --status-ltr-bg:   #fef3ec;
  --status-ltr-bdr:  #f0c8a5;

  --status-tail:     #a86b10;
  --status-tail-bg:  #fef8ec;
  --status-tail-bdr: #ecd39c;

  --status-clear:    #2b7a4b;
  --status-clear-bg: #eaf6ee;
  --status-clear-bdr:#b8dfc5;

  /* D4 checklist phase/status */
  --status-done: #2b7a4b;
  --status-inprogress: #b44c1c;
  --status-na: #999;

  /* ── Timeline cells (D3) ───────────────────────────────── */
  --t-qual:    #2b7a4b;
  --t-qual-bg: #d4eddb;
  --t-qual-bd: #8cc79e;

  --t-none:    #f0ebe8;
  --t-none-bd: #d8d0cb;

  --t-ltr-bg:  #fddfc7;

  --t-tail:    #a86b10;
  --t-tail-bg: #fef3dd;
  --t-tail-bd: #e5c87e;

  --t-future:  #f7f3f0;

  /* ── D1 outcome colours ────────────────────────────────── */
  --out-uk-res:      #b44c1c;
  --out-uk-res-bg:   #fef3ec;
  --out-uk-res-bdr:  #f0c8a5;

  --out-non-res:     #2b7a4b;
  --out-non-res-bg:  #eaf6ee;
  --out-non-res-bdr: #b8dfc5;

  --out-borderline:  #a86b10;
  --out-border-bg:   #fef8ec;
  --out-border-bdr:  #ecd39c;

  --out-advice:      #5e4d52;
  --out-advice-bg:   #f5f0ed;
  --out-advice-bdr:  #d8d0cb;

  /* ── D2 FIG eligibility ────────────────────────────────── */
  --fig-eligible:     #2b7a4b;
  --fig-eligible-bg:  #eaf6ee;
  --fig-eligible-bdr: #b8dfc5;

  --fig-closing:      #a86b10;
  --fig-closing-bg:   #fef8ec;
  --fig-closing-bdr:  #ecd39c;

  --fig-no:           #b44c1c;
  --fig-no-bg:        #fef3ec;
  --fig-no-bdr:       #f0c8a5;

  /* ── G2/G9 OSB & pension wrapper colours ───────────────── */
  --osb:     #4a6fa5;
  --osb-bg:  #eef3fa;
  --osb-bdr: #b8cce5;

  --pension:     #2b7a4b;
  --pension-bg:  #eaf6ee;
  --pension-bdr: #b8dfc5;

  /* ── G4 IHT exposure ───────────────────────────────────── */
  --exp-primary:     #400718;
  --exp-mid:         #5e4d52;
  --exp-white:       #ffffff;
  --exp-card-bg:     #fdf9f7;
  --exp-border:      hsla(0, 8%, 86%, 1);
  --exp-soft:        rgba(64, 7, 24, 0.12);
  --exp-risk:        #b44c1c;
  --exp-safe:        #2b7a4b;
  --exp-safe-bg:     #eaf6ee;
  --exp-safe-border: #b8dfc5;
  --exp-amber:       #a86b10;
  --exp-amber-bg:    #fef8ec;

  /* ── G5 top-slicing / gain colours ─────────────────────── */
  --col-gain:    #b44c1c;
  --col-after:   #2b7a4b;
  --col-neutral: #5e4d52;
  --col-now:     #4a6fa5;

  /* ── D4 departure phases ───────────────────────────────── */
  --phase-before:  #4a6fa5;
  --phase-year:    #b44c1c;
  --phase-ongoing: #2b7a4b;

  /* ── G1/G3 fit score & amber/green helpers ─────────────── */
  --fit-high: #2b7a4b;
  --fit-med:  #a86b10;
  --fit-low:  #b44c1c;

  --green-dark:   #2b7a4b;
  --green-light:  #eaf6ee;
  --green-border: #b8dfc5;

  --amber-dark:  #a86b10;
  --amber-light: #fef8ec;
}

/* ── Drawer component ──────────────────────────────────── */

.rh-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(36, 3, 12, 0.5);
  z-index: 2147483646;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--rh-transition), visibility var(--rh-transition);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.rh-drawer-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

.rh-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 92vw);
  height: 100dvh;
  z-index: 2147483647;
  background: var(--rh-white);
  box-shadow: -4px 0 32px rgba(36, 3, 12, 0.15);
  transform: translateX(100%);
  transition: transform var(--rh-transition);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rh-drawer.is-open {
  transform: translateX(0);
}

.rh-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--rh-border);
  background: var(--rh-surface);
  flex-shrink: 0;
}

.rh-drawer__title {
  font-family: var(--rh-font-body);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--rh-primary);
  margin: 0;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rh-drawer__close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rh-body-soft);
  transition: background var(--rh-transition), color var(--rh-transition);
  flex-shrink: 0;
}

.rh-drawer__close:hover {
  background: var(--rh-surface-hover);
  color: var(--rh-primary);
}

.rh-drawer__close svg {
  width: 20px;
  height: 20px;
}

.rh-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
}

/* Drawer body content typography */
.rh-drawer__body h2 {
  font-family: var(--rh-font-body);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rh-primary);
  margin: 0 0 16px;
  line-height: 1.3;
}

.rh-drawer__body h3 {
  font-family: var(--rh-font-body);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--rh-primary);
  margin: 24px 0 8px;
  line-height: 1.3;
}

.rh-drawer__body p {
  font-family: var(--rh-font-body);
  font-size: 0.95rem;
  color: var(--rh-body);
  line-height: 1.65;
  margin: 0 0 12px;
}

.rh-drawer__body ul {
  padding-left: 20px;
  margin: 0 0 16px;
}

.rh-drawer__body li {
  font-family: var(--rh-font-body);
  font-size: 0.95rem;
  color: var(--rh-body);
  line-height: 1.6;
  margin-bottom: 6px;
}

.rh-drawer__body strong {
  color: var(--rh-primary-dark);
  font-weight: 600;
}

.rh-drawer__body em {
  font-style: italic;
  color: var(--rh-body-soft);
}

/* Drawer quick-stats card grid */
.rh-drawer__stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 24px;
  padding: 18px;
  background: var(--rh-surface);
  border-radius: 12px;
  border: 1px solid var(--rh-border-light);
}

.rh-drawer__stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.rh-stat__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--rh-body-soft);
  line-height: 1.2;
}

.rh-stat__value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rh-primary);
  line-height: 1.2;
}

/* Yes / No / Partial / N/A badges — distinct colours for instant legibility */
.rh-stat__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.rh-stat__badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Yes — maroon (brand): "this applies, be aware" */
.rh-stat__badge--yes {
  background: #f5e8ec;
  color: #5d061f;
  border: 1px solid rgba(93, 6, 31, 0.18);
}
.rh-stat__badge--yes::before {
  background: #5d061f;
}

/* No — green: "clear, no tax here" */
.rh-stat__badge--no {
  background: #eaf5ee;
  color: #1a6632;
  border: 1px solid rgba(26, 102, 50, 0.20);
}
.rh-stat__badge--no::before {
  background: #2a9452;
}

/* Partial / Varies / Limited — amber: "caution, check details" */
.rh-stat__badge--partial {
  background: #fef8ec;
  color: #7a4d0a;
  border: 1px solid rgba(180, 120, 30, 0.22);
}
.rh-stat__badge--partial::before {
  background: #c98b20;
}

/* N/A — neutral grey */
.rh-stat__badge--na {
  background: #f2f2f2;
  color: #777;
  border: 1px solid rgba(0, 0, 0, 0.10);
}
.rh-stat__badge--na::before {
  background: #bbb;
}

/* Legacy dl grid — kept for any existing Tier 2 fallback */
.rh-drawer__data-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0 0 20px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.rh-drawer__data-grid dt {
  color: var(--rh-body-soft);
  font-weight: 400;
}

.rh-drawer__data-grid dd {
  color: var(--rh-primary);
  font-weight: 600;
  margin: 0;
}

.rh-drawer__summary {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--rh-body-soft);
  margin: 0 0 12px;
}

.rh-drawer__summary:last-of-type {
  margin-bottom: 0;
}

/* Drawer related reading links (SEO cross-linking) */
.rh-drawer__related {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--rh-surface);
  border-radius: var(--rh-radius);
  border: 1px solid var(--rh-border-light);
}

.rh-drawer__related-title {
  font-family: var(--rh-font-body);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--rh-body-soft);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0 0 12px;
}

.rh-drawer__related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rh-drawer__related-list li {
  margin: 0;
}

.rh-drawer__related-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid var(--rh-border-light);
  border-radius: 8px;
  font-family: var(--rh-font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--rh-primary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  line-height: 1.35;
}

.rh-drawer__related-list a::after {
  content: '→';
  font-size: 1rem;
  opacity: 0.5;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}

.rh-drawer__related-list a:hover {
  background: #fdf7f8;
  border-color: var(--rh-primary);
  transform: translateX(2px);
}

.rh-drawer__related-list a:hover::after {
  opacity: 1;
  transform: translateX(3px);
}



/* ── Drawer guide page link ─────────────────────────────── */
/* Secondary action: links to the full country guide page.
   Sits between related reading and the main CTA. */

.rh-drawer__guide-link-wrap {
  margin-top: 20px;
}

.rh-drawer__guide-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  background: #fff;
  border: 2px solid var(--rh-primary);
  border-radius: var(--rh-radius);
  font-family: var(--rh-font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--rh-primary);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  line-height: 1.35;
}

.rh-drawer__guide-link svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.rh-drawer__guide-link:hover {
  background: var(--rh-primary);
  color: #fff;
  transform: translateX(2px);
}

.rh-drawer__guide-link:hover svg {
  opacity: 1;
  transform: translateX(3px);
}


/* Drawer CTA at bottom of guide content */
.rh-drawer__cta {
  margin-top: 32px;
  padding: 20px;
  background: var(--rh-surface);
  border-radius: var(--rh-radius);
  border: 1px solid var(--rh-border);
  text-align: center;
}

.rh-drawer__cta p {
  font-size: 0.9rem;
  color: var(--rh-body-soft);
  margin-bottom: 12px;
}

.rh-drawer__cta-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--rh-primary);
  color: var(--rh-white);
  font-family: var(--rh-font-body);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--rh-radius);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--rh-transition);
}

.rh-drawer__cta-btn:hover {
  background: var(--rh-primary-hover);
}

/* When the CTA button appears inside the dark qualifier section,
   invert it to white so it's visible against the maroon background */
.rh-tool-iht-map__cta .rh-drawer__cta-btn {
  background: #fff;
  color: var(--rh-primary);
  border: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.rh-tool-iht-map__cta .rh-drawer__cta-btn:hover {
  background: #f5e8eb;
  color: var(--rh-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

/* ── Mobile drawer adjustments ─────────────────────────── */
@media (max-width: 640px) {
  .rh-drawer {
    width: 100vw;
  }

  .rh-drawer__header {
    padding: 16px 16px 12px;
  }

  .rh-drawer__body {
    padding: 16px;
  }
}


/* ═══════════════════════════════════════════════════════════
   TOOLKIT COMPONENT
   Card list + modal used by [rh_toolkit] shortcode.
   Shared across all toolkit pages. One CSS, centralised.
   ═══════════════════════════════════════════════════════════ */

/* ── Card list layout ──────────────────────────────────── */

.rh-toolkit {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px 0;
}

.rh-toolkit__tools {
  display: flex;
  flex-direction: column;
}

/* ── Individual card ───────────────────────────────────── */

.rh-gravity-tool .rh-toolkit__card,
.rh-toolkit__card {
  background: var(--rh-white);
  border: 1.5px solid var(--rh-border);
  border-radius: var(--rh-radius-lg);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.rh-gravity-tool .rh-toolkit__card:hover,
.rh-toolkit__card:hover {
  border-color: var(--rh-primary);
  box-shadow: 0 4px 20px rgba(64, 7, 24, 0.08);
}

.rh-gravity-tool .rh-toolkit__card:focus-within,
.rh-toolkit__card:focus-within {
  border-color: var(--rh-primary);
  box-shadow: 0 0 0 3px rgba(64, 7, 24, 0.12);
}

.rh-toolkit__card-inner {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 22px 24px;
}

/* Step number circle */
.rh-toolkit__step {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--rh-primary);
  color: var(--rh-white);
  font-family: var(--rh-font-body);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

/* Card body */
.rh-toolkit__card-body {
  flex: 1;
  min-width: 0;
}

.rh-toolkit__card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.rh-gravity-tool .rh-toolkit__card-name,
.rh-toolkit__card-name {
  font-family: var(--rh-font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--rh-primary);
  line-height: 1.3;
  margin: 0;
}

.rh-toolkit__card-type {
  display: inline-block;
  font-family: var(--rh-font-body);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rh-primary-light);
  background: rgba(64, 7, 24, 0.05);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rh-gravity-tool .rh-toolkit__card-desc,
.rh-toolkit__card-desc {
  font-family: var(--rh-font-body);
  font-size: 0.88rem;
  color: #5e4d52;
  line-height: 1.5;
  margin: 0;
}

/* Open tool button */
.rh-gravity-tool .rh-toolkit__card-action,
.rh-toolkit__card-action {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  align-self: center;
  font-family: var(--rh-font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--rh-primary);
  background: rgba(64, 7, 24, 0.05);
  border: 1px solid rgba(64, 7, 24, 0.12);
  border-radius: var(--rh-radius);
  padding: 8px 16px;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.rh-gravity-tool .rh-toolkit__card-action:hover,
.rh-toolkit__card-action:hover {
  background: var(--rh-primary);
  color: var(--rh-white);
}

.rh-toolkit__card-action svg {
  width: 14px;
  height: 14px;
}

/* Connector line between cards */
.rh-toolkit__connector {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  position: relative;
}

.rh-toolkit__connector::before {
  content: '';
  position: absolute;
  left: 58px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--rh-border);
}


/* ── Toolkit modal ─────────────────────────────────────── */

.rh-toolkit-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(36, 3, 12, 0.6);
  z-index: 2147483646 !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.rh-toolkit-modal-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

.rh-toolkit-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(94vw, 1200px);
  height: min(90vh, 900px);
  z-index: 2147483647 !important;
  background: var(--rh-white);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(36, 3, 12, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.rh-toolkit-modal.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.rh-toolkit-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--rh-border);
  background: var(--rh-surface);
  flex-shrink: 0;
}

.rh-gravity-tool .rh-toolkit-modal__title,
.rh-toolkit-modal__title {
  font-family: var(--rh-font-body);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rh-primary);
  margin: 0;
}

.rh-toolkit-modal__close {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rh-body-soft);
  transition: background 0.2s ease, color 0.2s ease;
}

.rh-toolkit-modal__close:hover {
  background: var(--rh-surface-hover);
  color: var(--rh-primary);
}

.rh-toolkit-modal__close:focus-visible {
  outline: 2px solid var(--rh-primary);
  outline-offset: 2px;
}

.rh-toolkit-modal__close svg {
  width: 22px;
  height: 22px;
}

.rh-toolkit-modal__body {
  flex: 1;
  overflow: hidden;
}

.rh-toolkit-modal__iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.rh-toolkit-modal__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--rh-body-soft);
  font-family: var(--rh-font-body);
  font-size: 0.9rem;
}

.rh-toolkit-modal__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--rh-border);
  border-top-color: var(--rh-primary);
  border-radius: 50%;
  animation: rh-tk-spin 0.8s linear infinite;
}

@keyframes rh-tk-spin {
  to { transform: rotate(360deg); }
}


/* ── Toolkit responsive ────────────────────────────────── */

@media (max-width: 680px) {
  .rh-toolkit__card-inner {
    gap: 12px;
    padding: 16px;
  }

  .rh-toolkit__card-body {
    /* Let header + description stack naturally */
  }

  .rh-toolkit__card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .rh-toolkit__connector::before {
    left: 37px;
  }

  .rh-toolkit-modal {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: translateY(20px);
  }

  .rh-toolkit-modal.is-open {
    transform: translateY(0);
  }
}

