/* Unmanaged Marketing Site - Enhancement layer
   Accessibility (WCAG 2.2 AA), touch and motion fixes on top of style.css.
   Load LAST on every page (after style.css and the page's inline <style>):
     <link rel="stylesheet" href="./css/enhance.css">   (blog pages: ../css/enhance.css)
   Pairs with js/enhance.js. Nothing here changes layout or copy. */

/* ============================================================
   1. Contrast (WCAG 1.4.3, 4.5:1 for body-size text)
   Measured before: #BE6E38 text on #FEFCF6 = 3.74, on #F5F0E6 = 3.38,
   white on #BE6E38 buttons = 3.83, #7A7567 on #F5F0E6 = 4.05,
   #9A9488 on #FEFCF6 = 2.94, #7A7567 on the dark footer = 3.78.
   To restore the original palette, delete the two rules below.
   ============================================================ */
:root {
  --accent-brand: #BE6E38;    /* original terracotta, for reference */
  --accent-primary: #A2592A;  /* 5.12 on #FEFCF6, 4.62 on #F5F0E6, white on it 5.25 */
  --accent-hover: #8F4D22;
  --text-tertiary: #706B5E;   /* 5.18 on #FEFCF6, 4.68 on #F5F0E6 */
  --text-muted: #706B5E;
  --focus-ring: #1C1A14;
}

/* Dark surfaces need the lighter greys (5.77 on #1C1A14) and a light focus ring */
.footer,
.bg-dark,
.report-card.is-full {
  --text-tertiary: #9A9488;
  --text-muted: #9A9488;
  --focus-ring: #FEFCF6;
}

/* ============================================================
   2. Focus (WCAG 2.4.7, 2.4.11, 1.4.11)
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* style.css and two pages remove the outline on form controls; put it back */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 2px;
}

input[type="range"]:focus-visible {
  outline-offset: 6px;
}

.chart-range-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
}

/* Programmatic focus targets (skip-link target, quiz questions) are not controls */
[tabindex="-1"]:focus {
  outline: none;
}

/* Skip link (WCAG 2.4.1): injected by enhance.js, visible only on keyboard focus */
.skip-link {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  z-index: 2000;
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--text-primary);
  color: var(--surface-primary);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
  outline: 2px solid var(--surface-primary);
  outline-offset: -4px;
}

[data-skip-target] {
  scroll-margin-top: 96px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   3. Mobile menu
   backdrop-filter on the nav makes it the containing block for the
   position:fixed overlay, which collapsed the open menu to the height
   of the nav bar (measured: 87px instead of the full viewport).
   ============================================================ */
.nav.menu-open,
.site-nav.menu-open {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

html.scroll-locked {
  overflow: hidden;
}

.nav-menu-cta {
  display: none;
}

@media (max-width: 900px) {
  .nav-links.open,
  .site-nav-links.open {
    gap: 0;
    justify-content: safe center;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: max(88px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  }

  /* Same rhythm as the old 24px gap, but the whole 56px row is tappable */
  .nav-links.open .nav-link,
  .site-nav-links.open a {
    padding: 12px 24px;
  }

  .nav-links.open .nav-menu-cta,
  .site-nav-links.open a.nav-menu-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 14px 28px;
    border-radius: 12px;
    background: var(--accent-primary);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
  }
}

.nav,
.site-nav {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

.footer {
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* ============================================================
   4. Horizontal overflow at phone width (WCAG 1.4.10 reflow)
   ============================================================ */

/* Grid children default to min-width:auto, so a wide table or mockup
   stretched the whole page (what-we-analyze measured 496px wide at 390px) */
.two-col > *,
.performance-movers > *,
.chart-row > * {
  min-width: 0;
}

/* Two grids set their columns in an inline style, which beats the
   responsive rules in style.css: security.html kept 3 columns and
   what-we-analyze.html kept 4 (448px of columns in a 294px box) on a phone.
   Same breakpoints as .feature-grid. */
@media (max-width: 900px) {
  .feature-grid[style*="repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 600px) {
  .feature-grid[style*="repeat(3"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Wrapper added around every table by enhance.js so wide tables scroll
   inside their own box instead of scrolling the page */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden; /* sideways only: never a second vertical scroller under the finger */
  -webkit-overflow-scrolling: touch;
}

/* Full-height pages: fit the visible viewport on phones. svh, not dvh: dvh
   resizes the page while the browser toolbar slides, which shifts content
   mid-scroll. */
@supports (min-height: 100svh) {
  .error-page,
  .start-page,
  .quiz-container,
  .result-container {
    min-height: 100svh;
  }
}

/* ============================================================
   5. Controls
   ============================================================ */

/* Range sliders: the input itself was 8px tall, so that was the whole
   touch target. Same 8px track and 24px thumb, 28px hit area. */
input[type="range"] {
  height: 28px;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y pinch-zoom;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  margin-top: -8px;
}

input[type="range"]::-moz-range-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(190, 110, 56, 0.3);
}

/* The homepage calculator already draws a 28px-tall track; leave it as designed */
.calc input[type="range"] {
  background: var(--border);
}

.calc input[type="range"]::-webkit-slider-runnable-track {
  height: auto;
  background: transparent;
}

.calc input[type="range"]::-webkit-slider-thumb {
  margin-top: 0;
}

.calc input[type="range"]::-moz-range-track {
  height: 28px;
  background: transparent;
}

/* start.html plan picker: the radios were display:none, so the choice
   could not be reached or changed from the keyboard */
.pricing-option {
  position: relative;
}

.pricing-option input[type="radio"] {
  display: block !important;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.pricing-option:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Small standalone links (WCAG 2.5.8, 24px minimum) */
.rr-attention-link,
.lp-footer-links a,
.result-retake a {
  display: inline-block;
  padding-top: 4px;
  padding-bottom: 4px;
}

/* No double-tap-zoom delay on controls; pinch zoom is unaffected */
a,
button,
summary,
label,
[role="button"],
[role="tab"] {
  touch-action: manipulation;
}

/* ============================================================
   6. Sample report: what-if drawer and tabs
   ============================================================ */

/* The scrim stayed visibility:hidden when open (the open rule only set
   opacity), so it neither dimmed the page nor closed the drawer on tap */
.rr-drawer-scrim.is-open {
  visibility: visible;
}

/* Closed drawer: keep its controls out of the tab order */
.rr-drawer {
  visibility: hidden;
  transition: transform .3s cubic-bezier(.76, 0, .24, 1), visibility 0s .3s;
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.rr-drawer.is-open {
  visibility: visible;
  transition: transform .3s cubic-bezier(.76, 0, .24, 1), visibility 0s;
}

/* While a finger is dragging the drawer it tracks 1:1, no easing */
.rr-drawer.is-dragging,
.rr-drawer-scrim.is-dragging {
  transition: none;
}

.rr-drawer-body {
  overscroll-behavior: contain;
}

/* "Fixed Income" was cut to "Fixed Inco..." at phone width */
.rr-drawer .target-mix-row__label {
  white-space: normal;
  overflow: visible;
}

/* The report sets its own status greens and ambers, used mostly as text:
   #5A8B50 on white measured 4.00, #C0923A on white 2.83 */
[data-report-context] {
  --success: #457340;  /* 5.56 on white */
  --warning: #876318;  /* 5.49 on white */
}

/* Copper text on the peach and sand chips measured 3.05-3.10 */
[data-report-context] .rr-chev,
[data-report-context] .rr-whatif-icon,
[data-report-context] .rr-whatif-go,
[data-report-context] .action-priority,
[data-report-context] .timeline-trade-badge {
  color: #8F4D22;
}

/* #B55948 on its pink chip measured 4.01 */
[data-report-context] .account-pill.worst {
  color: #9C4435;
}

/* Homepage report preview: swipe between the two panels */
.preview-panel {
  touch-action: pan-y pinch-zoom;
}

/* ============================================================
   7. Motion
   Extends the site's existing reveal (fade + rise, as in the sample
   report's .reveal-hidden and the quiz's fadeIn) to scroll position.
   Pure CSS: browsers without scroll-driven animations, print, and
   reduced-motion all get the static page unchanged.
   Uses `translate`, not `transform`, so the hover lift still works.
   ============================================================ */
@keyframes enhance-rise {
  from { opacity: 0; translate: 0 16px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes enhance-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media screen and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .step,
    .feature-card,
    .persona-card,
    .report-card,
    .mstat,
    .steps-col > li,
    .home-blog-card,
    .blog-card,
    .hiw-mockup,
    .callout-box,
    .article-cta {
      animation: enhance-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 120px; /* done once 120px of the card is on screen */
    }
  }

  @media (max-width: 900px) {
    .nav-links.open,
    .site-nav-links.open {
      animation: enhance-fade .2s ease;
    }
  }
}

/* Reduced motion (WCAG 2.3.3 / 2.2.2): before this, only the sample
   report's reveal and the blog hero video honoured the setting. Smooth
   scrolling, hover lifts, quiz/result entrances and the blog filter did not. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }

  .step:hover,
  .feature-card:hover,
  .home-blog-card:hover,
  .blog-card:hover,
  .feature-card:hover .feature-icon img {
    transform: none;
  }
}

@media print {
  .skip-link {
    display: none;
  }
}
