/* ── Font size scaling ─────────────────────────────────────────────── */
html[data-fontsize="large"]  { font-size: 112%; }
html[data-fontsize="xlarge"] { font-size: 125%; }

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── High contrast – system preference ─────────────────────────────── */
@media (prefers-contrast: more) {
  :root {
    --ink:      #000000;
    --ink2:     #000000;
    --ink3:     #000000;
    --teal:     #005f6b;
    --border:   rgba(0,0,0,0.5);
    --light-bg: #ffffff;
    --paper:    #ffffff;
  }
}

/* ── High contrast – manual toggle (.high-contrast on <html>) ───────── */
html.high-contrast {
  --ink:      #000000;
  --ink2:     #000000;
  --ink3:     #000000;
  --teal:     #005f6b;
  --border:   rgba(0,0,0,0.5);
  --light-bg: #ffffff;
  --paper:    #ffffff;
}

/* ── High contrast – Tailwind utility overrides ────────────────────── */
/*
 * Tailwind utility classes use hardcoded hex values, not CSS variables.
 * These rules override the most common classes in the analysis result card
 * and app UI so that html.high-contrast has an actual visual effect.
 * Scope: only under html.high-contrast to avoid affecting normal mode.
 */

/* Neutral text shades → pure black */
html.high-contrast .text-neutral-400,
html.high-contrast .text-neutral-500,
html.high-contrast .text-neutral-600,
html.high-contrast .text-neutral-700,
html.high-contrast .text-neutral-800 { color: #000000 !important; }

/* Neutral backgrounds → white */
html.high-contrast .bg-white,
html.high-contrast .bg-neutral-50,
html.high-contrast .bg-neutral-100 { background-color: #ffffff !important; }

/* Neutral borders → visible dark */
html.high-contrast .border-neutral-100,
html.high-contrast .border-neutral-200 { border-color: rgba(0,0,0,0.4) !important; }

/* Deadline chips – expired / urgent (red) */
html.high-contrast .bg-red-50,
html.high-contrast .bg-red-100  { background-color: #fff0f0 !important; }
html.high-contrast .text-red-700,
html.high-contrast .text-red-800 { color: #7f0000 !important; }
html.high-contrast .border-red-200 { border-color: #7f0000 !important; }

/* Deadline chips – soon (orange) */
html.high-contrast .bg-orange-50  { background-color: #fff4e5 !important; }
html.high-contrast .text-orange-700 { color: #7a3500 !important; }
html.high-contrast .border-orange-200 { border-color: #7a3500 !important; }

/* Deadline chips – future (green) */
html.high-contrast .bg-green-50  { background-color: #f0fff4 !important; }
html.high-contrast .text-green-700 { color: #145214 !important; }
html.high-contrast .border-green-200 { border-color: #145214 !important; }

/* Result card disclaimer strip */
html.high-contrast .bg-bw-mint\/10 { background-color: #e6fff8 !important; }
html.high-contrast .border-bw-primary\/20 { border-color: #005f6b !important; }

/* bw-badge confidence labels (rendered by results.js) */
html.high-contrast .bw-badge-high { background-color: #145214 !important; color: #ffffff !important; }
html.high-contrast .bw-badge-med  { background-color: #7a3500 !important; color: #ffffff !important; }
html.high-contrast .bw-badge-low  { background-color: #444444 !important; color: #ffffff !important; }

/* Tailwind-based system preference mirror */
@media (prefers-contrast: more) {
  .text-neutral-400,
  .text-neutral-500,
  .text-neutral-600,
  .text-neutral-700,
  .text-neutral-800 { color: #000000 !important; }

  .border-neutral-100,
  .border-neutral-200 { border-color: rgba(0,0,0,0.4) !important; }

  .bg-red-50,
  .bg-red-100  { background-color: #fff0f0 !important; }
  .text-red-700,
  .text-red-800 { color: #7f0000 !important; }
  .border-red-200 { border-color: #7f0000 !important; }

  .bg-orange-50  { background-color: #fff4e5 !important; }
  .text-orange-700 { color: #7a3500 !important; }
  .border-orange-200 { border-color: #7a3500 !important; }

  .bg-green-50  { background-color: #f0fff4 !important; }
  .text-green-700 { color: #145214 !important; }
  .border-green-200 { border-color: #145214 !important; }

  .bw-badge-high { background-color: #145214 !important; color: #ffffff !important; }
  .bw-badge-med  { background-color: #7a3500 !important; color: #ffffff !important; }
  .bw-badge-low  { background-color: #444444 !important; color: #ffffff !important; }
}

/* ── Accessibility toolbar ──────────────────────────────────────────── */
.a11y-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.a11y-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  border: 1.5px solid var(--border, rgba(1,42,50,0.11));
  border-radius: 7px;
  background: transparent;
  color: var(--ink2, #02454f);
  font-size: .78rem;
  font-weight: 600;
  font-family: 'Instrument Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  line-height: 1;
}

.a11y-btn:hover,
.a11y-btn[aria-pressed="true"] {
  border-color: var(--teal, #028090);
  color: var(--teal, #028090);
  background: var(--teal-pale, #e0f4f6);
}

.a11y-contrast-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ── Mobile Navigation ──────────────────────────────────────────────── */

/* Hamburger button – hidden on desktop, flex on mobile */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border, rgba(1,42,50,0.11));
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  color: var(--deep, #012A32);
  flex-shrink: 0;
  transition: background .18s, border-color .18s;
}
.nav-hamburger:hover {
  background: var(--teal-pale, #e0f4f6);
  border-color: var(--teal, #028090);
}
.nav-hamburger svg { display: block; }

/* Mobile drawer – inside <nav>, positioned below the bar */
.nav-mobile-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  box-shadow: 0 8px 24px rgba(1,42,50,0.11), 0 2px 8px rgba(1,42,50,0.07);
  border-radius: 0 0 14px 14px;
  padding: .75rem clamp(1rem,4vw,2.5rem) 1.25rem;
  z-index: 199;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  /* Hidden by default; animated open via .is-open */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s .2s;
}
.nav-mobile-menu.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .2s ease, transform .2s ease, visibility 0s 0s;
}

/* Nav links list inside drawer */
.nav-mobile-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-mobile-links a {
  display: block;
  padding: 9px 12px;
  color: var(--ink2, #02454f);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 9px;
  transition: color .18s, background .18s;
}
.nav-mobile-links a:hover {
  color: var(--teal, #028090);
  background: var(--teal-pale, #e0f4f6);
}

/* Divider between links/login and a11y section */
.nav-mobile-divider {
  border: none;
  border-top: 1px solid var(--border, rgba(1,42,50,0.11));
  margin: .25rem 0;
}

/* Accessibility controls row inside drawer */
.nav-mobile-a11y {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.nav-mobile-a11y-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink3, #4a8a92);
  white-space: nowrap;
}

/* Responsive breakpoints */
@media (max-width: 720px) {
  .na-desktop { display: none !important; }
  .nav-hamburger { display: flex; }
}
@media (min-width: 721px) {
  .nav-hamburger { display: none !important; }
  .nav-mobile-menu { display: none !important; }
}

/* ── Accessibility Dropdown (Desktop) ──────────────────────────────── */

/* Wrapper – provides position context for the panel */
.a11y-dd {
  position: relative;
}

/* AA toggle button */
.a11y-dd-btn {
  padding: 5px 10px;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.a11y-dd-btn[aria-expanded="true"] {
  border-color: var(--teal, #028090);
  color: var(--teal, #028090);
  background: var(--teal-pale, #e0f4f6);
}

/* Dropdown panel */
.a11y-dd-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--border, rgba(1,42,50,0.11));
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(1,42,50,0.11), 0 2px 8px rgba(1,42,50,0.07);
  padding: .875rem;
  z-index: 201;
  display: flex;
  flex-direction: column;
  gap: .875rem;
  /* Hidden by default; animated open via .is-open */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility 0s .18s;
}
.a11y-dd-panel.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .18s ease, transform .18s ease, visibility 0s 0s;
}

/* Section within panel */
.a11y-dd-section {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

/* Section label */
.a11y-dd-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink3, #4a8a92);
}

/* Contrast button in panel: show icon + text side by side */
.a11y-dd-panel .a11y-contrast-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: 6px 10px;
  font-size: .82rem;
  font-weight: 500;
  width: 100%;
  justify-content: flex-start;
}
