/* Atlantis personal themes and densities (account appearance, 0.9.5 contract).
   base.html sets <body data-theme="…" data-density="…"> from the login's saved
   appearance (defaults: trident-default / comfortable).  The appearance page
   reuses the same attributes on its preview swatches, so every theme here is a
   complete token set that also works on a nested [data-theme] element.

   Rules for whoever restyles this later (uxA-DESIGN.md has the full list):
   * Themes change the SHELL only — page background, surfaces, text, lines and
     the sidebar.  They never set --brand / --brand-* : those belong to the
     organisation (portal/branding.py) and are already AA-safe.
   * Every pair test_account_appearance.ThemeTokenContrastTests checks must stay
     at 4.5:1 for text and 3:1 for focus rings / UI lines.
   * Keep the Trident gold trim (--nav-trim, --nav-rule) in every theme.
   * Density never shrinks a touch target below 44px. */

/* ── Trident default: today's look, declared in full for nested swatches ─── */
[data-theme="trident-default"] {
  --paper: #f7f8fa; --card: #ffffff; --text: #162d4c; --quiet: #536278; --line: #e3e8ef; --soft-blue: #eef4fb;
  --ux-ink: #172b48; --ux-muted: #52637a; --ux-border: #d6e0ec; --ux-surface: #f5f7fb; --ux-focus: #007dc5;
  --ink: #1f2330; --mid: #5b6474; --light: #8a93a5; --rule: #e1e4ea; --bg: #f5f6f9;
  --nav-bg: #ffffff; --nav-border: #e3e8ef; --nav-trim: #c9a84c; --nav-rule: #ddc989; --nav-divider: #e3e8ef;
  --nav-ink: #17395f; --nav-sublink: #3f536c; --nav-caption: #536278;
  --nav-hover-bg: #edf3fa; --nav-hover-ink: #17395f; --nav-open-bg: #f2f6fa;
  --nav-section-bg: #edf3fa; --nav-section-border: #b3c8df;
  --nav-current-bg: var(--brand-action, #002561); --nav-current-ink: var(--brand-on-action, #ffffff);
  --nav-current-trim: #c9a84c; --nav-focus: #166ab5;
  --nav-logo-tile: transparent; --nav-logo-pad: 0px; --nav-tile-bg: transparent; --nav-badge-ring: transparent;
}

/* ── Navy ("midnight"): navy sidebar, gold highlights, white logo tile ──── */
[data-theme="navy"] {
  --paper: #f3f5f9; --card: #ffffff; --text: #162d4c; --quiet: #4e5d73; --line: #d9e0ea; --soft-blue: #eaf0f8;
  --ux-ink: #172b48; --ux-muted: #4e5d73; --ux-border: #cfd9e6; --ux-surface: #f3f5f9; --ux-focus: #007dc5;
  --ink: #1f2330; --mid: #4e5d73; --light: #5b6474; --rule: #d9e0ea; --bg: #f3f5f9;
  --nav-bg: #0a2452; --nav-border: #0a2452; --nav-trim: #c9a84c; --nav-rule: #c9a84c; --nav-divider: #23427a;
  --nav-ink: #f1f5fb; --nav-sublink: #d3deec; --nav-caption: #c5d2e4;
  --nav-hover-bg: #183c78; --nav-hover-ink: #ffffff; --nav-open-bg: #12316a;
  --nav-section-bg: #12316a; --nav-section-border: #3a5b91;
  --nav-current-bg: #f3dfad; --nav-current-ink: #0a2452; --nav-current-trim: #a8842f; --nav-focus: #f3dfad;
  --nav-logo-tile: #ffffff; --nav-logo-pad: 8px; --nav-tile-bg: #ffffff; --nav-badge-ring: #f3dfad;
}

/* ── Light: white page, softer lines, airy sidebar ──────────────────────── */
[data-theme="light"] {
  --paper: #ffffff; --card: #ffffff; --text: #162d4c; --quiet: #536278; --line: #e8ecf2; --soft-blue: #f3f7fc;
  --ux-ink: #172b48; --ux-muted: #52637a; --ux-border: #e1e7ef; --ux-surface: #ffffff; --ux-focus: #007dc5;
  --ink: #1f2330; --mid: #5b6474; --light: #66707f; --rule: #e8ecf2; --bg: #ffffff;
  --nav-bg: #fcfdfe; --nav-border: #e8ecf2; --nav-trim: #c9a84c; --nav-rule: #e3d29c; --nav-divider: #e8ecf2;
  --nav-ink: #17395f; --nav-sublink: #3f536c; --nav-caption: #536278;
  --nav-hover-bg: #eff4fa; --nav-hover-ink: #17395f; --nav-open-bg: #f5f8fc;
  --nav-section-bg: #eff4fa; --nav-section-border: #c9d7e8;
  --nav-current-bg: var(--brand-action, #002561); --nav-current-ink: var(--brand-on-action, #ffffff);
  --nav-current-trim: #c9a84c; --nav-focus: #166ab5;
  --nav-logo-tile: transparent; --nav-logo-pad: 0px; --nav-tile-bg: transparent; --nav-badge-ring: transparent;
}

/* ── High contrast: near-black text, visible lines, strong focus ────────── */
[data-theme="high-contrast"] {
  --paper: #ffffff; --card: #ffffff; --text: #0b1a30; --quiet: #2e3b4f; --line: #6b7a90; --soft-blue: #e8f0fa;
  --ux-ink: #0b1a30; --ux-muted: #2e3b4f; --ux-border: #6b7a90; --ux-surface: #ffffff; --ux-focus: #003a8c;
  --ink: #0b1a30; --mid: #2e3b4f; --light: #3b4a60; --rule: #6b7a90; --bg: #ffffff;
  --nav-bg: #ffffff; --nav-border: #0b1a30; --nav-trim: #c9a84c; --nav-rule: #8a6d1f; --nav-divider: #6b7a90;
  --nav-ink: #0b1a30; --nav-sublink: #1d2b40; --nav-caption: #2e3b4f;
  --nav-hover-bg: #dfe9f6; --nav-hover-ink: #001a40; --nav-open-bg: #eef3f9;
  --nav-section-bg: #dfe9f6; --nav-section-border: #0b1a30;
  --nav-current-bg: #002561; --nav-current-ink: #ffffff; --nav-current-trim: #c9a84c; --nav-focus: #003a8c;
  --nav-logo-tile: transparent; --nav-logo-pad: 0px; --nav-tile-bg: #ffffff; --nav-badge-ring: #0b1a30;
}

/* ── Teal: deep-teal accents on a soft aqua shell ───────────────────────── */
[data-theme="teal"] {
  --paper: #f2f7f7; --card: #ffffff; --text: #14313a; --quiet: #46606a; --line: #d3e2e4; --soft-blue: #e6f2f2;
  --ux-ink: #14313a; --ux-muted: #46606a; --ux-border: #cfe0e2; --ux-surface: #f2f7f7; --ux-focus: #0a6676;
  --ink: #14313a; --mid: #46606a; --light: #5a7179; --rule: #d3e2e4; --bg: #f2f7f7;
  --nav-bg: #eef6f6; --nav-border: #d3e2e4; --nav-trim: #c9a84c; --nav-rule: #c9a84c; --nav-divider: #d3e2e4;
  --nav-ink: #0c4651; --nav-sublink: #24525b; --nav-caption: #3e5f66;
  --nav-hover-bg: #d9eaec; --nav-hover-ink: #0c4651; --nav-open-bg: #e3f0f1;
  --nav-section-bg: #d9eaec; --nav-section-border: #9cc6cb;
  --nav-current-bg: #0e5260; --nav-current-ink: #ffffff; --nav-current-trim: #c9a84c; --nav-focus: #0a6676;
  --nav-logo-tile: #ffffff; --nav-logo-pad: 6px; --nav-tile-bg: #ffffff; --nav-badge-ring: transparent;
}

/* High contrast needs more than colour: form borders that read at 3:1 and a
   thicker focus ring.  Body-scoped so the appearance swatches are unaffected. */
body[data-theme="high-contrast"] :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { border-color: #5b6b80; }
body[data-theme="high-contrast"] :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline-width: 4px; }
body[data-theme="high-contrast"] .card { box-shadow: none; }

/* ── Density ─────────────────────────────────────────────────────────────── */
/* Comfortable is today's spacing (the fallbacks in portal-navigation.css).
   Compact tightens space around things, never the 44px tap targets. */
[data-density="comfortable"] {
  --nav-gap: 8px; --nav-item-min: 48px; --nav-item-pad: 12px 14px; --nav-sub-pad: 10px 11px; --nav-sub-gap: 3px;
  --nav-group-margin: 7px 0 5px 14px;
}
[data-density="compact"] {
  --nav-gap: 4px; --nav-item-min: 44px; --nav-item-pad: 9px 12px; --nav-sub-pad: 8px 10px; --nav-sub-gap: 1px;
  --nav-group-margin: 3px 0 3px 12px;
}
/* :where() keeps these at low specificity, so a page's own layout still wins a tie. */
body[data-density="compact"] { line-height: 1.5; }
body.portal-workspace[data-density="compact"] main.wrap { padding: 22px 32px 36px; }
body[data-density="compact"] :where(.card) { padding: 14px 16px; }
body[data-density="compact"] :where(th, td) { padding: 7px 10px; }
body.portal-workspace[data-density="compact"] :where(.section-heading) { margin-top: 14px; }
body.portal-workspace[data-density="compact"] :where(h1) { font-size: 30px; }
body.portal-workspace[data-density="compact"] .portal-navigation .portal-logo { min-height: 96px; }
body.portal-workspace[data-density="compact"] .portal-navigation .portal-label { margin-bottom: 16px; }
body.portal-workspace[data-density="compact"] .portal-navigation .nav-account { margin-top: 18px; padding-top: 12px; }
@media (max-width: 1099px) {
  body.portal-workspace[data-density="compact"] main.wrap { padding: 18px 16px 32px; }
  body.portal-workspace[data-density="compact"] .portal-navigation .portal-logo { min-height: 64px; }
  body.portal-workspace[data-density="compact"] :where(h1) { font-size: 26px; }
}

/* Personal themes are a screen preference: print and forced colours keep the
   system / print styles. */
@media print {
  body[data-theme] { --paper: #ffffff; --text: #111111; --quiet: #333333; }
}
