/* =====================================================================
   AskForSeniors.com — main.css
   Primary stylesheet. Contains every required accessibility pattern.
   Authority: CLAUDE.md Section 3 + ADA Hard Rules Sections 2, 3, 4, 14.

   RULES THIS FILE ENFORCES (do not weaken without updating CLAUDE.md):
   - rem only for font-size — never px (px breaks browser zoom)
   - Body text floor 1.125rem (18px); absolute minimum 1rem (16px)
   - Legal disclaimers floor 0.9375rem (15px)
   - Line-height: body 1.6, heading 1.3
   - Left-aligned text only; letter-spacing never negative
   - 3px solid teal focus ring on every focusable element
   - Skip link is the first focusable element on every page
   - prefers-reduced-motion honored globally
   - 44x44px minimum touch target on all interactive elements
   - Color never the sole carrier of meaning (see .error / .success helpers)
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. DESIGN TOKENS — CSS custom properties (CLAUDE.md Section 5)
   --------------------------------------------------------------------- */
:root {
  /* Brand colors */
  --color-teal: #0D7377;          /* primary — passes AA on white */
  --color-teal-dark: #0A5C60;     /* hover / active variant */
  --color-white: #FFFFFF;
  --color-text-dark: #222222;     /* ~15.9:1 on white (AAA) */
  --color-text-mid: #444444;      /* ~9.7:1 on white (AAA) */
  --color-text-light: #555555;    /* ~7.4:1 on white (AAA) */
  --color-bg: #FFFFFF;
  --color-bg-light: #F0F8F8;      /* subtle teal-tinted section bg */
  --color-border: #CCDDDD;

  /* Status colors — always paired with text/icon, never color alone */
  --color-error: #B3261E;         /* ~6.3:1 on white — passes AA normal text */
  --color-error-bg: #FCEEED;
  --color-success: #1B5E20;       /* ~7.0:1 on white — passes AAA */
  --color-success-bg: #EBF3EC;

  /* Typography — rem only */
  --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-size-base: 1.125rem;       /* 18px — body floor */
  --font-size-small: 1rem;          /* 16px — absolute floor */
  --font-size-nav: 1.0625rem;       /* 17px — navigation links floor */
  --font-size-disclaimer: 0.9375rem;/* 15px — legal disclaimer floor */
  --font-size-h1: 2.25rem;
  --font-size-h2: 1.75rem;
  --font-size-h3: 1.375rem;
  --line-height-body: 1.6;
  --line-height-heading: 1.3;
  --paragraph-spacing: 1em;

  /* Layout */
  --touch-target: 44px;
  --tap-padding: 10px 16px;
  --focus-ring: 3px solid var(--color-teal);
  --focus-offset: 2px;
  --content-max-width: 70rem;
  --reading-max-width: 42rem;       /* comfortable line length for body copy */
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
}

/* ---------------------------------------------------------------------
   2. RESET / BASE
   --------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* font-size: 100% on :root respects the user's browser default.
   NEVER set this to a px value — it breaks zoom. */
:root {
  font-size: 100%;
}

html {
  -webkit-text-size-adjust: 100%; /* prevent iOS auto-inflation surprises */
}

body {
  margin: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);     /* 1.125rem / 18px */
  line-height: var(--line-height-body); /* 1.6 */
  color: var(--color-text-dark);
  background-color: var(--color-bg);
  text-align: left;                     /* never justify */
  letter-spacing: 0;                    /* never negative */
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------
   3. SKIP NAVIGATION LINK (ADA Hard Rules 14; CLAUDE.md 3.3)
   First focusable element on every page. Visible on focus.
   --------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-teal);
  color: var(--color-white);
  padding: 12px 24px;
  font-size: 1.125rem;
  font-weight: bold;
  z-index: 9999;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* ---------------------------------------------------------------------
   4. FOCUS INDICATOR (ADA Hard Rules 4.1)
   3px solid teal, 2px offset. NEVER remove outline without a replacement.
   :focus { outline: none; } is PROHIBITED.
   --------------------------------------------------------------------- */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* Fallback for browsers without :focus-visible — keep a visible ring */
:focus {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}
/* When :focus-visible is supported, suppress the ring for mouse-only focus
   but keep it for keyboard focus. The :focus-visible rule above re-adds it. */
:focus:not(:focus-visible) {
  outline: none;
}

/* ---------------------------------------------------------------------
   5. REDUCED MOTION (ADA Hard Rules 14; CLAUDE.md 3.3)
   --------------------------------------------------------------------- */
@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;
  }
}

/* ---------------------------------------------------------------------
   6. TOUCH TARGETS (CLAUDE.md 3.3, Section 5)
   44x44px minimum for every interactive element.
   --------------------------------------------------------------------- */
button,
a,
input,
select,
textarea,
[role="button"] {
  min-height: var(--touch-target);
  min-width: var(--touch-target);
}

/* Inline text links inside running prose are exempt from the 44px box
   (they inherit line-height), but must remain easily tappable. We scope
   the min-size rule above to standalone interactive controls by relaxing
   it for links inside paragraphs and list text. */
p a,
li a,
.prose a {
  min-height: 0;
  min-width: 0;
}

/* ---------------------------------------------------------------------
   7. TYPOGRAPHY (ADA Hard Rules 2; CLAUDE.md 3.1)
   --------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-heading); /* 1.3 */
  color: var(--color-text-dark);
  margin: 0 0 var(--space-md);
  font-weight: 700;
}

h1 { font-size: var(--font-size-h1); margin-bottom: var(--space-lg); }
h2 { font-size: var(--font-size-h2); margin-top: var(--space-lg); }
h3 { font-size: var(--font-size-h3); margin-top: var(--space-lg); }

p {
  margin: 0 0 var(--paragraph-spacing); /* 1em bottom margin minimum */
  max-width: var(--reading-max-width);
}

a {
  color: var(--color-teal);
  text-decoration: underline; /* never rely on color alone for links */
}

a:hover,
a:focus {
  color: var(--color-teal-dark);
}

small,
.text-small {
  font-size: var(--font-size-small); /* 1rem / 16px floor */
}

/* Legal / compliance disclaimers — 15px floor, never finer */
.disclaimer,
.legal-text {
  font-size: var(--font-size-disclaimer); /* 0.9375rem / 15px */
  line-height: var(--line-height-body);
  color: var(--color-text-mid);
}

ul, ol {
  margin: 0 0 var(--paragraph-spacing);
  padding-left: 1.5em;
  max-width: var(--reading-max-width);
}

li {
  margin-bottom: 0.5em;
}

/* ---------------------------------------------------------------------
   8. LAYOUT HELPERS
   --------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

main {
  display: block;
  padding-block: var(--space-lg);
}

/* ---------------------------------------------------------------------
   9. SCREEN-READER-ONLY UTILITY
   Visually hidden but available to assistive technology.
   --------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Made visible when focused (e.g. a visually-hidden control that should
   appear on keyboard focus). */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ---------------------------------------------------------------------
   10. BUTTONS & CTA LINKS
   --------------------------------------------------------------------- */
.btn,
button,
[role="button"] {
  font-family: inherit;
  font-size: var(--font-size-base); /* 18px floor */
  line-height: var(--line-height-heading);
  padding: var(--tap-padding);
  border-radius: 6px;
  cursor: pointer;
}

.btn-primary,
.cta-button {
  display: inline-block;
  background: var(--color-teal);
  color: var(--color-white);
  border: 2px solid var(--color-teal);
  text-decoration: none;
  font-weight: 700;
  text-align: center;
}

.btn-primary:hover,
.btn-primary:focus,
.cta-button:hover,
.cta-button:focus {
  background: var(--color-teal-dark);
  border-color: var(--color-teal-dark);
  color: var(--color-white); /* keep 4.5:1+ in hover state */
}

.btn-secondary {
  display: inline-block;
  background: var(--color-white);
  color: var(--color-teal-dark);
  border: 2px solid var(--color-teal);
  text-decoration: none;
  font-weight: 700;
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: var(--color-bg-light);
  color: var(--color-teal-dark);
}

/* Disabled controls must remain visible — minimum 3:1, never invisible */
button:disabled,
.btn:disabled {
  opacity: 1;                 /* do not fade into invisibility */
  background: #E0E0E0;
  color: #595959;             /* ~7:1 on #E0E0E0 region */
  border-color: #B0B0B0;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------
   11. FORMS (ADA Hard Rules 5; CLAUDE.md 3.4)
   --------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-lg);
  max-width: var(--reading-max-width);
}

label {
  display: block;
  font-size: var(--font-size-base); /* 18px floor */
  font-weight: 700;
  color: var(--color-text-dark);
  margin-bottom: var(--space-sm);
}

input,
select,
textarea {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--font-size-base); /* 18px floor */
  line-height: var(--line-height-body);
  color: var(--color-text-dark);
  background: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-teal);
}

/* Placeholders must pass 4.5:1 — no low-opacity placeholders */
::placeholder {
  color: var(--color-text-light); /* #555 — ~7.4:1 on white */
  opacity: 1;                      /* never reduce opacity below visibility */
}

/* Required marker — paired with text "(required)" in markup, never * alone */
.required-marker {
  color: var(--color-error);
}

/* Invalid field styling — paired with text error message, never color alone */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--color-error);
  border-width: 2px;
}

/* ---------------------------------------------------------------------
   12. STATUS MESSAGES — color + icon/text, never color alone (CLAUDE.md 3.2)
   --------------------------------------------------------------------- */
.error,
[role="alert"].error {
  color: var(--color-error);
  background: var(--color-error-bg);
  border-left: 4px solid var(--color-error);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
}

/* Decorative icon glyph paired with every error/success message in markup */
.error::before {
  content: "⚠ ";
  font-weight: 700;
}

.success {
  color: var(--color-success);
  background: var(--color-success-bg);
  border-left: 4px solid var(--color-success);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
}

.success::before {
  content: "✓ ";
  font-weight: 700;
}

/* Empty alert containers should not render a stray icon/box */
[role="alert"]:empty {
  display: none;
}

/* ---------------------------------------------------------------------
   13. TOOL RESULTS REGION (CLAUDE.md 3.4)
   --------------------------------------------------------------------- */
#tool-results,
.tool-results {
  margin-top: var(--space-lg);
}

/* ---------------------------------------------------------------------
   14. HEADER & NAVIGATION
   --------------------------------------------------------------------- */
.site-header {
  background: var(--color-white);
  border-bottom: 2px solid var(--color-border);
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-block: var(--space-md);
}

.site-logo {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--color-teal-dark);
  text-decoration: none;
}

.main-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  max-width: none;
}

.main-nav li {
  margin: 0;
}

.main-nav a {
  display: inline-block;
  font-size: var(--font-size-nav); /* 17px floor */
  font-weight: 600;
  color: var(--color-text-dark);
  text-decoration: none;
  padding: 10px 12px;
}

.main-nav a:hover,
.main-nav a:focus,
.main-nav a[aria-current="page"] {
  color: var(--color-teal-dark);
  text-decoration: underline;
}

/* Mobile nav toggle — hidden on wide screens, shown on narrow */
.nav-toggle {
  display: none;
  background: var(--color-white);
  color: var(--color-teal-dark);
  border: 2px solid var(--color-teal);
  font-size: var(--font-size-base);
  font-weight: 700;
}

/* ---------------------------------------------------------------------
   15. FOOTER
   --------------------------------------------------------------------- */
.site-footer {
  background: var(--color-bg-light);
  border-top: 2px solid var(--color-border);
  margin-top: var(--space-xl);
  padding-block: var(--space-lg);
  color: var(--color-text-mid);
}

.site-footer nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin: 0 0 var(--space-md);
  padding: 0;
  max-width: none;
}

.site-footer a {
  color: var(--color-teal-dark);
  font-size: var(--font-size-base);
}

.site-footer .disclaimer {
  margin-bottom: var(--space-sm);
}

/* ---------------------------------------------------------------------
   16. AFFILIATE / CTA WRAPPERS (rendered by affiliate-link.js; CLAUDE.md 4.3)
   Disclosure is always shown before/adjacent to the link.
   --------------------------------------------------------------------- */
.affiliate-link-wrapper,
.whatsupp-cta,
.broker-cta,
.ship-cta {
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-md);
  margin-block: var(--space-lg);
  background: var(--color-bg-light);
}

.affiliate-disclosure,
.cta-disclosure {
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-disclaimer); /* 15px floor */
  color: var(--color-text-mid);
}

.broker-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.cta-fine-print {
  margin-top: var(--space-sm);
  font-size: var(--font-size-disclaimer);
  color: var(--color-text-mid);
}

/* ---------------------------------------------------------------------
   17. NOSCRIPT MESSAGE (CLAUDE.md Section 2 — graceful degradation)
   --------------------------------------------------------------------- */
.noscript-message {
  background: var(--color-error-bg);
  border-left: 4px solid var(--color-error);
  color: var(--color-text-dark);
  padding: var(--space-md);
  font-size: var(--font-size-base);
}

/* ---------------------------------------------------------------------
   18. RESPONSIVE — mobile-first scale-up (CLAUDE.md Section 5)
   NEVER reduce font-size on mobile — stack instead.
   --------------------------------------------------------------------- */
@media (max-width: 40rem) {
  /* Collapse main nav behind a toggle on narrow viewports */
  .nav-toggle {
    display: inline-block;
  }

  .main-nav {
    flex-basis: 100%;
  }

  .main-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .main-nav a {
    display: block;
    padding: 12px 8px;
    border-top: 1px solid var(--color-border);
  }

  /* Collapsed by default on mobile; JS toggles [hidden] / aria-expanded */
  .main-nav[data-collapsible="true"][hidden] {
    display: none;
  }

  h1 { font-size: 1.875rem; } /* still well above body floor — scale, don't shrink text */
}
