/* ============================================================
   KIDAB — Shared Stylesheet
   © 2026 Sentinel Mesh, Erbil, Republic of Iraq. All rights reserved.
   File:      frontend/css/shared.css
   Version:   1.0.14
   Created:   2026-04-30
   Updated:   2026-05-19
   Author:    Sentinel Mesh

   PURPOSE
   ───────
   De-duplicate chrome elements (reset · body baseline · beta strip ·
   header · floating language toggle · footer · focus + a11y universals)
   currently duplicated between main.css v3.6.0 and legal.css v2.0.0.
   Single source of truth for shared UI across all kidab.io public
   pages, with comprehensive device + accessibility adaptation.

   APPLICABILITY MATRIX (F-PRE-01 fix)
   ────────────────────────────────────
   §1 Reset                  → ALL pages
   §2 Body baseline          → ALL pages
   §3 Beta Strip             → Pages that include .beta-strip element
                                (currently: index.html · beta-terms.html)
                               INTERIOR pages MUST add their own
                                body padding-top:36px when strip present
   §4 Header + nav           → INTERIOR pages only
                                (privacy · terms · beta-terms · contact · help)
   §5 Floating lang-toggle   → HERO page only (index.html)
   §6 Footer                 → ALL pages (kebab-case markup)
   §7 Utility classes        → ALL pages
   §8 Focus + a11y universal → ALL pages
   §9 Print                  → ALL pages (auto-engages on print)
   §10 Reduced-data          → ALL pages (disables expensive blur)
   §11 Reduced-transparency  → ALL pages (opaque fallbacks)
   §12 Pointer/hover gate    → ALL pages (touch-vs-mouse divergence)
   §13 PWA standalone        → ALL pages (when installed as PWA)
   §14 Responsive ladder     → ALL pages

   DESIGN DECISIONS APPLIED
   ────────────────────────
   - D-COLOR-01: Light (Shell White #FFFFFF) is functional default;
                 dark via [data-theme="dark"] or
                 @media (prefers-color-scheme: dark)
   - D-TYPO-01:  UI chrome (nav, buttons) uses var(--font-system)
   - Rule 11.21: All values via canonical tokens from tokens.css v2.0.0
   - Rule 11.15: .woff2 only (declared in fonts.css v3.2.0)
   - WCAG 2.2 AA: touch targets ≥24px · :focus-visible ·
                  prefers-reduced-motion · forced-colors ·
                  non-text contrast 3:1 (§1.4.11)

   DEVICE COVERAGE
   ───────────────
   - Mobile portrait/landscape · tablet portrait/landscape · desktop
   - Foldable · notched (iPhone X+) · ultrawide
   - Touch · stylus · mouse · keyboard · D-pad (smart TV)
   - PWA standalone · browser · in-app browser
   - 1x · 2x · 3x display density
   - Light · dark · forced colors · high contrast preferences
   - Reduced motion · reduced data · reduced transparency preferences



   ============================================================ */


/* ============================================================
   §1 — RESET
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  list-style: none;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: light dark;
}


/* ============================================================
   §2 — BODY BASELINE
   ============================================================ */

body {
  background: var(--surface-primary, #FFFFFF);
  color: var(--text-primary, #1A1A18);
  font-family: var(--font-body, 'Cormorant Garamond'), serif;
  font-size: 1rem;
  line-height: var(--lh-body, 1.65);
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[dir="rtl"] body,
[lang="ar"] body,
[lang="ckb"] body {
  font-family: var(--font-ar, 'Noto Naskh Arabic'), serif;
  line-height: var(--lh-body-ar, 1.8);
}

a {
  color: var(--link-color, #7A5A1E);
  text-decoration: none;
  transition: color var(--transition-fast, 150ms ease);
}


/* ============================================================
   §3 — BETA STRIP
   BETA-LOCK pillar 3 — fixed top banner during private beta.
   Uses page surface (transparent bg + var(--text-secondary)).
   Light: #5C4A30 on #FFFFFF = 7.5:1 AAA.
   Dark:  #BFA87C on #0B1A2E = 7.8:1 AAA.
   F-PRE-09: z-index 210 explicitly above header (200).
   Pages including .beta-strip MUST add body { padding-top: 36px }
   in page-specific CSS to clear the fixed strip.
   ============================================================ */

.beta-strip {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 210;
  height: calc(36px + env(safe-area-inset-top, 0));
  padding-top: env(safe-area-inset-top, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  background: transparent;
  border-bottom: 1px solid var(--border-default, rgba(92, 74, 48, 0.12));
  font-family: var(--font-display, 'Cinzel'), serif;
  font-size: 0.5625rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary, #5C4A30);
  padding-left: 1rem;
  padding-right: 1rem;
  white-space: nowrap;
  overflow: hidden;
}

/* Dark mode: text-secondary resolves to #BFA87C on #0B1A2E = 7.8:1 AAA */
[data-theme="dark"] .beta-strip {
  border-bottom-color: var(--border-default, rgba(198, 156, 62, 0.12));
  color: var(--text-secondary, #BFA87C);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .beta-strip {
    border-bottom-color: var(--border-default, rgba(198, 156, 62, 0.12));
    color: var(--text-secondary, #BFA87C);
  }
}

.beta-strip__diamond {
  font-size: 0.375rem;
  opacity: 0.5;
}

.beta-strip__sep {
  opacity: 0.35;
  font-family: var(--font-body, 'Cormorant Garamond'), serif;
  font-size: 0.75rem;
  line-height: 1;
}

[dir="rtl"] .beta-strip,
[lang="ar"] .beta-strip,
[lang="ckb"] .beta-strip {
  letter-spacing: 0;
  font-family: var(--font-ar-disp, 'Amiri'), serif;
}

@media (max-width: 480px) {
  .beta-strip__diamond { display: none; }
  .beta-strip {
    gap: 0.375rem;
    font-size: 0.5rem;
    letter-spacing: 0.1em;
  }
}

@media (max-width: 380px) {
  .beta-strip {
    font-size: 0.4375rem;
    gap: 0.25rem;
    letter-spacing: 0.06em;
  }
  .beta-strip__sep {
    font-size: 0.625rem;
  }
}


/* ============================================================
   AUTH FLASH PREVENTION
   Protected pages hidden until script confirms auth via
   data-auth-ready on <html>.
   body.page-talent-acquisition replaces body.page-employer-dashboard
   (file renamed employer.html → talent-acquisition.html, S47).
   ============================================================ */

html:not([data-auth-ready]) body.page-admin,
html:not([data-auth-ready]) body.page-profile,
html:not([data-auth-ready]) body.page-portal,
html:not([data-auth-ready]) body.page-onboarding,
html:not([data-auth-ready]) body.page-apply,
html:not([data-auth-ready]) body.page-post-job,
html:not([data-auth-ready]) body.page-talent-acquisition,
html:not([data-auth-ready]) body.page-admin-invites { visibility: hidden; }


/* ============================================================
   §4 — STICKY HEADER + NAVIGATION
   Used by INTERIOR pages only.
   ============================================================ */

header[role="banner"] {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(92, 74, 48, 0.25);
}

[data-theme="dark"] header[role="banner"] {
  background: rgba(11, 26, 46, 0.94);
  border-bottom-color: rgba(198, 156, 62, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) header[role="banner"] {
    background: rgba(11, 26, 46, 0.94);
    border-bottom-color: rgba(198, 156, 62, 0.25);
  }
}

.header-inner {
  max-width: var(--max-width-content, 72rem);
  margin: 0 auto;
  padding: 0 var(--space-6, 1.5rem);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-inner .logo {
  font-family: var(--font-display, 'Cinzel'), serif;
  font-size: 1.125rem;
  letter-spacing: 0.14em;
  color: var(--text-brand, #5C4A30);
  text-decoration: none;
}

[dir="rtl"] .header-inner .logo,
[lang="ar"] .header-inner .logo,
[lang="ckb"] .header-inner .logo {
  letter-spacing: 0;
  font-family: var(--font-ar-disp, 'Amiri'), serif;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-5, 1.25rem);
}

.lang-btn {
  background: none;
  border: 1px solid rgba(92, 74, 48, 0.25);
  color: var(--text-secondary, #5C4A30);
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: var(--fs-sm, 0.875rem);
  padding: 5px 12px;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  transition: border-color var(--transition-fast, 150ms ease),
              color var(--transition-fast, 150ms ease);
  min-height: 24px;
  min-width: 44px;
}

[data-theme="dark"] .lang-btn {
  border-color: rgba(198, 156, 62, 0.25);
}

.header-badge {
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-brand-gold, #C69C3E);
  margin-left: var(--space-2, 0.5rem);
  vertical-align: middle;
}

.theme-btn {
  background: none;
  border: 1px solid rgba(92, 74, 48, 0.25);
  color: var(--text-secondary, #5C4A30);
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: var(--fs-sm, 0.875rem);
  padding: 5px 12px;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  transition: border-color var(--transition-fast, 150ms ease),
              color var(--transition-fast, 150ms ease);
  min-height: 24px;
  min-width: 44px;
}

[data-theme="dark"] .theme-btn {
  border-color: rgba(198, 156, 62, 0.25);
}

.back-link {
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  color: var(--text-tertiary, #8A6B42);
  font-size: var(--fs-sm, 0.875rem);
  text-decoration: none;
  transition: color var(--transition-fast, 150ms ease);
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

/* Sign-in button — styled link, shown when unauthenticated.
   Wired by user-menu.js. Matches Google/Microsoft header CTA style. */
/* [hidden] enforcement — CSS display: flex/inline-flex beats UA display: none.
   Without this, [hidden] has no visual effect on these elements. */
.header-signin-btn[hidden],
.header-user-menu[hidden] {
  display: none !important;
}

.header-signin-btn {
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: var(--fs-sm, 0.875rem);
  font-weight: 500;
  color: var(--interactive-primary, #8A6520);
  border: 1px solid rgba(92, 74, 48, 0.25);
  padding: 5px 14px;
  border-radius: var(--radius-md, 8px);
  text-decoration: none;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  transition: border-color var(--transition-fast, 150ms ease),
              color var(--transition-fast, 150ms ease),
              background var(--transition-fast, 150ms ease);
}

[data-theme="dark"] .header-signin-btn {
  color: var(--interactive-primary, #D4A843);
  border-color: rgba(198, 156, 62, 0.25);
}

.header-signin-btn:focus-visible {
  outline: 2px solid var(--focus-ring, #8A6520);
  outline-offset: 2px;
  border-radius: var(--radius-md, 8px);
}

/* User menu container — relative position anchors the dropdown */
.header-user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

/* Avatar circle button */
.header-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full, 9999px);
  background: var(--color-night-lapis, #0B1A2E);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast, 150ms ease),
              background var(--transition-fast, 150ms ease);
  flex-shrink: 0;
}

.header-avatar-btn[aria-expanded="true"],
.header-avatar-btn:focus-visible {
  border-color: var(--interactive-primary, #8A6520);
  outline: none;
}

[data-theme="dark"] .header-avatar-btn {
  background: var(--color-brand-gold, #C69C3E);
}

/* Initials inside avatar */
.header-avatar-initials {
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-river-sand, #E6D2AE);
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
}

[data-theme="dark"] .header-avatar-initials {
  color: var(--color-night-lapis, #0B1A2E);
}

/* Dropdown panel */
.header-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2, 0.5rem));
  right: 0;
  min-width: 220px;
  background: var(--surface-primary, #FFFFFF);
  border: 1px solid var(--border-default, rgba(92, 74, 48, 0.12));
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(6, 14, 26, 0.16));
  z-index: var(--z-dropdown, 100);
  overflow: hidden;
  animation: dropdownOpen 150ms ease both;
}

[dir="rtl"] .header-dropdown {
  right: auto;
  left: 0;
}

[data-theme="dark"] .header-dropdown {
  background: var(--surface-elevated, #0F2035);
  border-color: var(--border-default, rgba(198, 156, 62, 0.12));
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.4));
}

@keyframes dropdownOpen {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* User info block (name + role — decorative, not interactive) */
.header-dropdown__info {
  padding: var(--space-4, 1rem) var(--space-5, 1.25rem) var(--space-3, 0.75rem);
}

.header-dropdown__name {
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: var(--fs-sm, 0.875rem);
  font-weight: 600;
  color: var(--text-primary, #1A1A18);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

[data-theme="dark"] .header-dropdown__name {
  color: var(--text-primary, #E6D2AE);
}

.header-dropdown__role {
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: var(--fs-caption, 0.75rem);
  color: var(--text-tertiary, #8A6B42);
  margin-top: 2px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .header-dropdown__role {
  color: var(--text-tertiary, #8A7A62);
}

/* RTL Arabic/Kurdish — TYPOGRAPHY Rule 1 */
[dir="rtl"] .header-dropdown__name,
[lang="ar"] .header-dropdown__name,
[lang="ckb"] .header-dropdown__name,
[dir="rtl"] .header-dropdown__role,
[lang="ar"] .header-dropdown__role,
[lang="ckb"] .header-dropdown__role,
[dir="rtl"] .header-dropdown__item,
[lang="ar"] .header-dropdown__item,
[lang="ckb"] .header-dropdown__item {
  font-family: var(--font-ar, 'Noto Naskh Arabic', serif);
  letter-spacing: 0;
}

/* Separator */
.header-dropdown__sep {
  height: 1px;
  background: var(--border-default, rgba(92, 74, 48, 0.12));
  margin: 0;
}

[data-theme="dark"] .header-dropdown__sep {
  background: var(--border-default, rgba(198, 156, 62, 0.12));
}

/* Dropdown items */
.header-dropdown__item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font-system, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: var(--fs-sm, 0.875rem);
  color: var(--text-secondary, #5C4A30);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast, 150ms ease),
              color var(--transition-fast, 150ms ease);
}

[dir="rtl"] .header-dropdown__item {
  text-align: right;
}

[data-theme="dark"] .header-dropdown__item {
  color: var(--text-secondary, #BFA87C);
}

.header-dropdown__item:focus-visible {
  outline: 2px solid var(--focus-ring, #8A6520);
  outline-offset: -2px;
  border-radius: 0;
}

/* Sign out — carnelian danger color */
.header-dropdown__item--signout {
  color: var(--color-carnelian, #A63A2A);
}

[data-theme="dark"] .header-dropdown__item--signout {
  color: var(--color-carnelian, #A63A2A);
}


/* ============================================================
   §5 — FLOATING LANGUAGE TOGGLE (HERO page only)
   ============================================================ */

.lang-toggle {
  position: fixed;
  top: calc(36px + env(safe-area-inset-top, 0) + var(--space-5, 1.25rem));
  inset-inline-end: calc(var(--space-5, 1.25rem) + env(safe-area-inset-right, 0));
  z-index: var(--z-dropdown, 100);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: 52px;
  padding: 0 var(--space-4, 1rem);
  background: rgba(15, 32, 53, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(198, 156, 62, 0.25);
  border-radius: 18px;
  cursor: pointer;
  transition: border-color var(--transition-fast, 150ms ease),
              background var(--transition-fast, 150ms ease);
}

.lang-toggle__label {
  font-family: var(--font-body, 'Cormorant Garamond'), serif;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #BFA87C);
  letter-spacing: 0.02em;
  line-height: 1;
}

[dir="rtl"] .lang-toggle__label,
[lang="ar"] .lang-toggle__label,
[lang="ckb"] .lang-toggle__label {
  letter-spacing: 0;
  font-family: var(--font-ar, 'Noto Naskh Arabic'), serif;
}


/* ============================================================
   §6 — FOOTER (UNIFIED · kebab-case)
   ============================================================ */

footer[role="contentinfo"] {
  border-top: 1px solid rgba(92, 74, 48, 0.25);
  padding: 2rem var(--space-6, 1.5rem);
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0));
  position: relative;
  z-index: 1;
}

[data-theme="dark"] footer[role="contentinfo"] {
  border-top-color: rgba(198, 156, 62, 0.25);
}

.footer-inner {
  max-width: var(--max-width-content, 72rem);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-tertiary, #8A6B42);
}

[dir="rtl"] .footer-copy,
[lang="ar"] .footer-copy,
[lang="ckb"] .footer-copy {
  font-family: var(--font-ar, 'Noto Naskh Arabic'), serif;
}

.footer-links {
  display: flex;
  gap: var(--space-5, 1.25rem);
}

.footer-links a {
  color: var(--text-tertiary, #8A6B42);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color var(--transition-fast, 150ms ease);
}

[dir="rtl"] .footer-links a,
[lang="ar"] .footer-links a,
[lang="ckb"] .footer-links a {
  font-family: var(--font-ar, 'Noto Naskh Arabic'), serif;
}


/* ============================================================
   §7 — UTILITY CLASSES
   ============================================================ */

.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;
}

[dir="rtl"],
.rtl { direction: rtl; }

[dir="ltr"],
.ltr { direction: ltr; }


/* ============================================================
   §8 — FOCUS + WCAG 2.2 ACCESSIBILITY UNIVERSALS
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--focus-ring, #8A6520);
  outline-offset: 3px;
  border-radius: var(--radius-sm, 4px);
}

@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;
  }
}

@media (forced-colors: active) {
  header[role="banner"],
  footer[role="contentinfo"] {
    forced-color-adjust: none;
    background: Canvas;
    border-color: ButtonText;
  }

  .beta-strip {
    forced-color-adjust: none;
    background: Canvas;
    color: CanvasText;
    border-bottom-color: ButtonText;
  }

  .header-inner .logo,
  .footer-copy {
    color: CanvasText;
  }

  .lang-btn,
  .lang-toggle,
  .back-link,
  .header-signin-btn,
  .header-avatar-btn,
  .footer-links a {
    border: 1px solid ButtonText;
    color: LinkText;
  }

  .header-user-menu,
  .header-dropdown {
    forced-color-adjust: none;
    background: Canvas;
    border-color: ButtonText;
  }

  :focus-visible {
    outline: 3px solid Highlight;
  }
}

@media (prefers-contrast: more) {
  header[role="banner"],
  footer[role="contentinfo"] {
    border-color: var(--text-primary, #1A1A18);
  }
  .lang-btn,
  .lang-toggle,
  .header-avatar-btn {
    border-color: var(--text-primary, #1A1A18);
  }
  :focus-visible {
    outline-width: 3px;
  }
}


/* ============================================================
   §9 — PRINT
   ============================================================ */

@media print {
  *,
  *::before,
  *::after {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .beta-strip,
  header[role="banner"],
  footer[role="contentinfo"],
  .lang-btn,
  .lang-toggle,
  .back-link,
  .header-signin-btn,
  .header-user-menu {
    display: none !important;
  }

  body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 11pt;
    line-height: 1.5;
    padding: 0;
    margin: 0;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  a[href]:not([href^="#"]):not([href^="javascript"])::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: var(--color-dry-clay, #666);
  }

  p, li {
    orphans: 3;
    widows: 3;
  }
}


/* ============================================================
   §10 — REDUCED-DATA
   ============================================================ */

@media (prefers-reduced-data: reduce) {
  header[role="banner"],
  .lang-toggle {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  header[role="banner"] {
    background: var(--surface-primary, #FFFFFF);
  }

  [data-theme="dark"] header[role="banner"] {
    background: var(--color-night-lapis, #0B1A2E);
  }

  .lang-toggle {
    background: var(--color-deep-lapis, #0F2035);
  }
}


/* ============================================================
   §11 — REDUCED-TRANSPARENCY
   ============================================================ */

@media (prefers-reduced-transparency: reduce) {
  header[role="banner"] {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--surface-primary, #FFFFFF);
  }

  [data-theme="dark"] header[role="banner"] {
    background: var(--color-night-lapis, #0B1A2E);
  }

  .lang-toggle {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--color-deep-lapis, #0F2035);
  }
}


/* ============================================================
   §12 — POINTER / HOVER GATING
   Wrap all :hover in @media (hover: hover) to prevent
   stuck-hover on touch devices.
   ============================================================ */

@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--link-hover, #8A6520);
    text-decoration: underline;
  }

  .lang-btn:hover {
    border-color: var(--text-primary, #1A1A18);
    color: var(--interactive-primary, #8A6520);
  }

  .theme-btn:hover {
    border-color: var(--text-primary, #1A1A18);
    color: var(--interactive-primary, #8A6520);
  }

  .back-link:hover {
    color: var(--interactive-primary, #8A6520);
  }

  .lang-toggle:hover {
    border-color: rgba(198, 156, 62, 0.40);
    background: rgba(15, 32, 53, 0.6);
  }

  .header-signin-btn:hover {
    border-color: var(--interactive-primary, #8A6520);
    color: var(--interactive-primary, #8A6520);
    background: rgba(138, 101, 32, 0.06);
  }

  .header-avatar-btn:hover {
    border-color: var(--interactive-primary, #8A6520);
  }

  .header-dropdown__item:hover {
    background: rgba(92, 74, 48, 0.06);
    color: var(--text-primary, #1A1A18);
  }

  .header-dropdown__item--signout:hover {
    background: rgba(166, 58, 42, 0.06);
    color: var(--color-carnelian, #A63A2A);
  }

  .footer-links a:hover {
    color: var(--interactive-primary, #8A6520);
    text-decoration: none;
  }
}

a:focus-visible {
  color: var(--link-hover, #8A6520);
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--color-link, #DBBE72);
  outline-offset: 2px;
}


/* ============================================================
   §13 — PWA STANDALONE MODE
   ============================================================ */

@media (display-mode: standalone) {
  .header-inner {
    height: 56px;
  }

  .beta-strip {
    padding-top: max(env(safe-area-inset-top, 0), 12px);
  }

  html {
    scroll-behavior: auto;
  }
}


/* ============================================================
   §14 — RESPONSIVE LADDER
   ============================================================ */

@media (max-width: 599px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3, 0.75rem);
  }

  .footer-links {
    flex-wrap: wrap;
    gap: var(--space-4, 1rem);
  }
}

@media (min-width: 600px) {
  .header-inner {
    padding: 0 var(--space-8, 2rem);
  }

  footer[role="contentinfo"] {
    padding: 2rem var(--space-8, 2rem);
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0));
  }
}

@media (min-width: 768px) {
  .header-inner {
    padding: 0 var(--space-10, 2.5rem);
  }
}

@media (min-width: 1024px) {
  .header-inner {
    padding: 0 var(--space-12, 3rem);
  }
}


/* ════════════════════════════════════════════════════════════════════
   SKIP LINK (WCAG 2.4.1 — Bypass Blocks, Level A)
   Visually hidden until keyboard focused. First focusable element in page.
   ════════════════════════════════════════════════════════════════════ */
.skip-link {
  position: absolute;
  top: -9999px;
  inset-inline-start: 8px;
  z-index: 10000;
  padding: 0.5rem 1rem;
  background: var(--color-brand-gold, #D4A843);
  color: var(--color-brand-dark, #0B1A2E);
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--color-brand-dark, #0B1A2E);
  outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════════════
   DROPDOWN PANEL
   ════════════════════════════════════════════════════════════════════ */

/* ── Panel ──────────────────────────────────────────────────────────── */
.user-dropdown-panel {
  position: fixed;
  z-index: var(--z-dropdown, 800);
  top: 60px;   /* JS fallback — overridden by positionDropdown() */
  right: 16px; /* JS fallback — overridden by positionDropdown() */
  width: 240px;
  box-sizing: border-box; /* [CSS-03] padding stays within 240px */
  max-height: calc(100vh - 80px); /* [CSS-05] never overflows viewport */
  overflow-y: auto;               /* [CSS-06] scroll when items exceed max-height */
  background: var(--surface-elevated, #ffffff);
  border: 1px solid var(--border-subtle, #e2e5ea);
  border-radius: var(--radius-lg, 14px);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 2px 8px  rgba(0, 0, 0, 0.06);
  padding: var(--space-2, 0.5rem) 0;
  outline: none;
  animation: udp-in 0.15s ease;
}

/* §0 — hidden override — prevents CSS display overriding [hidden] attribute */
.user-dropdown-panel[hidden] { display: none !important; }

/* ── Open animation ─────────────────────────────────────────────────── */
@keyframes udp-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── prefers-reduced-motion (WCAG 2.3.3 — Level AAA) ──────────────────
   [A11Y-11] Disables animation for users who opt out of motion effects.
   Applies to: vestibular disorders, epilepsy, motion sensitivity. */
@media (prefers-reduced-motion: reduce) {
  .user-dropdown-panel {
    animation: none;
  }
}

/* ── Dark mode — OS preference ──────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  html:not([data-theme='light']) .user-dropdown-panel {
    background: var(--surface-elevated, #1e2028);
    border-color: var(--border-subtle, #2e3038);
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.4),
      0 2px 8px  rgba(0, 0, 0, 0.2);
  }
}

/* ── Dark mode — explicit toggle ────────────────────────────────────── */
[data-theme='dark'] .user-dropdown-panel {
  background: var(--surface-elevated, #1e2028);
  border-color: var(--border-subtle, #2e3038);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 2px 8px  rgba(0, 0, 0, 0.2);
}

/* ── Windows High Contrast Mode [A11Y-13] ───────────────────────────────
   forced-colors: active = Windows HC, Forced Colors, or High Contrast browser setting.
   In forced-colors, background/border/shadow are overridden by system.
   We must use system color keywords and restore borders explicitly. */
@media (forced-colors: active) {
  .user-dropdown-panel {
    border: 2px solid ButtonText;
    box-shadow: none;
    background: Canvas;
    color: CanvasText;
  }
  .udp-item:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .udp-sep {
    background: ButtonText;
  }
}

/* ── User info block (aria-hidden="true" — name readable via btn aria-label) */
.udp-info {
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
}

.udp-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a2e);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.udp-role {
  font-size: 0.8125rem;
  color: var(--text-secondary, #5f6368);
  margin: var(--space-1, 0.25rem) 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Separator ──────────────────────────────────────────────────────── */
.udp-sep {
  height: 1px;
  background: var(--border-subtle, #e2e5ea);
  margin: var(--space-1, 0.25rem) 0;
  border: none;
}

/* ── Menu items ─────────────────────────────────────────────────────── */
.udp-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--text-primary, #1a1a2e);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  /* [LING-05/CSS-04] text-align:start instead of text-align:left
     'start' maps to left in LTR (English) and right in RTL (Arabic).
     'left' would force left-align even in Arabic RTL — incorrect. */
  text-align: start;
  transition: background 0.1s ease;
}

.udp-item:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
}

.udp-item:focus-visible {
  outline: 2px solid var(--color-brand-gold, #D4A843);
  outline-offset: -2px;
  border-radius: var(--radius-sm, 6px);
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
}

.udp-item--signout {
  color: var(--text-secondary, #5f6368);
}

.udp-item--signout:hover,
.udp-item--signout:focus-visible {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
}

/* ── Mobile — bottom sheet (iOS HIG / Material 3) ───────────────────── */
@media (max-width: 520px) {
  .user-dropdown-panel {
    left: 8px;
    right: 8px;
    width: auto;
    top: auto !important; /* disable JS positioning on mobile */
    bottom: 0;
    max-height: 60vh;
    border-radius: var(--radius-lg, 14px) var(--radius-lg, 14px) 0 0;
    animation: udp-in-mobile 0.2s ease;
  }

  @media (prefers-reduced-motion: reduce) {
    .user-dropdown-panel {
      animation: none;
    }
  }
}

@keyframes udp-in-mobile {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* §15b — AUTH STATE OVERRIDES */
 
/* Force beta strip hidden when set by initAuthState() */
.beta-strip[hidden] { display: none !important; }
 
/* Skip link: disable transition for reduced-motion users (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}

[tabindex="-1"]:focus {
  outline: none;
}
 