/* ════════════════════════════════════════════════════════════════════════
   easy-view.css — "Easy View" accessibility comfort mode
   ------------------------------------------------------------------------
   A per-device toggle (localStorage 'torus_easyview') that makes the WHOLE
   dashboard easier on the eyes: bigger, bolder, higher-contrast text and
   clearer focus rings. Activated from the nav pill; previewed in a GSAP
   demo modal. All overrides are scoped under `html.easy-view`.

   Cosmic-glass design language (UI.md): tokens from css/base.css, warm
   emerald/amber accent for the control so it reads as "comfort", inline SVG,
   reduced-motion safe.
   ════════════════════════════════════════════════════════════════════════ */

/* ── 1. The nav control (pill, warm emerald accent) ───────────────────────── */
.nav-easyview-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  flex-shrink: 0;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.28);
  border-radius: var(--r-sm);
  color: rgba(110, 231, 183, 0.92);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  transition: all var(--t-base) var(--ease-out);
}
.nav-easyview-btn:hover {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.55);
  color: var(--accent-emerald);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.22);
  transform: translateY(-1px);
}
.nav-easyview-btn:active { transform: translateY(0) scale(0.97); }
.nav-easyview-btn:focus-visible {
  border-color: rgba(52, 211, 153, 0.7);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.3);
}
.nav-easyview-btn .nav-ev-ic { flex-shrink: 0; transition: transform var(--t-base) var(--ease-out); }
.nav-easyview-btn:hover .nav-ev-ic { transform: scale(1.08) rotate(-4deg); }
/* ON state — filled + glowing so it's obvious the mode is active. */
.nav-easyview-btn.is-on {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.7);
  color: #ecfdf5;
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.3), inset 0 0 14px rgba(52, 211, 153, 0.12);
}
@media (prefers-reduced-motion: no-preference) {
  .nav-easyview-btn.is-on .nav-ev-ic { animation: ev-ic-breathe 3.4s ease-in-out infinite; }
}
@keyframes ev-ic-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

html[data-theme="light"] .nav-easyview-btn {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.3);
  color: rgba(5, 120, 87, 0.95);
}
html[data-theme="light"] .nav-easyview-btn.is-on {
  background: rgba(5, 150, 105, 0.16);
  border-color: rgba(5, 150, 105, 0.6);
  color: #065f46;
}

@media (max-width: 768px) {
  .nav-easyview-btn .nav-ev-label { display: none; }
  .nav-easyview-btn { padding: 0; width: 32px; justify-content: center; }
}

/* ════════════════════════════════════════════════════════════════════════
   2. THE GLOBAL COMFORT MODE — everything bigger / bolder / brighter
   ════════════════════════════════════════════════════════════════════════ */

/* Brighten the shared text + border tokens so EVERY component that consumes
   them (most of the app) gains contrast at once. */
html.easy-view {
  --text-secondary: rgba(255, 255, 255, 0.98);
  --text-muted:     rgba(255, 255, 255, 0.84);
  --text-dim:       rgba(255, 255, 255, 0.62);
  --glass-border:   rgba(255, 255, 255, 0.2);
  --glass-border-2: rgba(255, 255, 255, 0.32);
  --glass-border-3: rgba(255, 255, 255, 0.46);
}
html.easy-view[data-theme="light"] {
  --text-secondary: rgba(19, 16, 58, 0.96);
  --text-muted:     rgba(19, 16, 58, 0.8);
  --text-dim:       rgba(19, 16, 58, 0.56);
  --glass-border:   rgba(60, 45, 110, 0.34);
  --glass-border-2: rgba(60, 45, 110, 0.46);
}

/* Bigger — scale the whole UI up. `zoom` is the one lever that enlarges both
   px- and rem-sized type without breaking flow (transform:scale would).
   Modest 1.1 keeps overflow minimal while being clearly perceptible. */
html.easy-view body {
  zoom: 1.1;
  line-height: 1.62;
  letter-spacing: 0.004em;
}

/* Bolder — raise the WEIGHT FLOOR only. `:where()` is 0-specificity, so this
   lifts default-weight text to 600 but never flattens a heading/label that a
   component intentionally weighted heavier. */
:where(html.easy-view) :where(p, span, li, td, th, dd, dt, a, small,
  label, figcaption, button, input, select, textarea, .nav-tab-label) {
  font-weight: 600;
}

/* Links stay obviously link-like for low-vision users. */
html.easy-view a:not([class]) { text-decoration: underline; text-underline-offset: 2px; }

/* Much clearer keyboard focus everywhere. */
html.easy-view :focus-visible {
  outline: 3px solid var(--accent-emerald) !important;
  outline-offset: 2px !important;
}

/* Don't let any dim/translucent text fall below readable. Catches the common
   utility patterns used across the app. */
:where(html.easy-view) :where(
  [class*="-sub"], [class*="-meta"], [class*="-hint"], [class*="-muted"],
  [class*="-dim"], [class*="-caption"], [class*="-label"], .small, small
) {
  opacity: 1;
}

/* The comfort mode never needs heavy ambient motion — calm is the point. */
@media (prefers-reduced-motion: no-preference) {
  html.easy-view #overview-canvas { opacity: 0.5; }
}

/* ════════════════════════════════════════════════════════════════════════
   3. THE PREVIEW MODAL
   ════════════════════════════════════════════════════════════════════════ */
.ev-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 5, 15, 0.66);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  opacity: 0;
}
.ev-overlay.is-open { opacity: 1; }

.ev-modal {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden auto;
  border-radius: var(--r-xl, 24px);
  border: 1px solid var(--glass-border-2);
  background:
    radial-gradient(130% 120% at 0% 0%, rgba(52, 211, 153, 0.12), transparent 52%),
    radial-gradient(130% 120% at 100% 0%, rgba(56, 189, 248, 0.1), transparent 52%),
    rgba(11, 16, 33, 0.94);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 50px rgba(52, 211, 153, 0.1);
  color: var(--text-primary);
  font-family: var(--font-body);
}
html[data-theme="light"] .ev-modal {
  background:
    radial-gradient(130% 120% at 0% 0%, rgba(5, 150, 105, 0.12), transparent 52%),
    radial-gradient(130% 120% at 100% 0%, rgba(2, 132, 199, 0.1), transparent 52%),
    rgba(244, 247, 255, 0.96);
}

/* ambient drifting glow blobs behind content */
.ev-aurora { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.ev-aurora i {
  position: absolute; width: 240px; height: 240px; border-radius: 50%;
  filter: blur(60px); opacity: 0.5;
}
.ev-aurora i:nth-child(1) { top: -80px; left: -60px; background: rgba(52, 211, 153, 0.5); }
.ev-aurora i:nth-child(2) { bottom: -90px; right: -60px; background: rgba(56, 189, 248, 0.4); }
@media (prefers-reduced-motion: no-preference) {
  .ev-aurora i:nth-child(1) { animation: ev-drift 11s ease-in-out infinite; }
  .ev-aurora i:nth-child(2) { animation: ev-drift 13s ease-in-out infinite reverse; }
}
@keyframes ev-drift {
  0%,100% { transform: translate(0, 0); }
  50%     { transform: translate(26px, 20px); }
}

.ev-inner { position: relative; z-index: 1; padding: 26px 28px 24px; }

.ev-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-1);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-base) var(--ease-out);
}
.ev-close:hover { color: var(--accent-rose); border-color: rgba(251, 113, 133, 0.5); transform: rotate(90deg); }
.ev-close:focus-visible { outline: 2px solid var(--accent-emerald); outline-offset: 2px; }

.ev-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-right: 36px; }
.ev-badge {
  flex-shrink: 0;
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  background: radial-gradient(120% 120% at 30% 20%, rgba(52, 211, 153, 0.28), rgba(52, 211, 153, 0.06));
  color: #6ee7b7;
  box-shadow: inset 0 0 18px rgba(52, 211, 153, 0.18);
}
.ev-title { margin: 0; font-family: var(--font-display); font-size: 23px; font-weight: 700; letter-spacing: -0.01em; }
.ev-sub { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); }

/* ── Live before/after demo stage ─────────────────────────────────────────── */
.ev-demo {
  position: relative;
  margin: 4px 0 20px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: rgba(4, 7, 18, 0.5);
  padding: 14px;
  overflow: hidden;
}
html[data-theme="light"] .ev-demo { background: rgba(255, 255, 255, 0.5); }
.ev-demo svg { display: block; width: 100%; height: auto; }

/* ── Benefit points ───────────────────────────────────────────────────────── */
.ev-points { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 22px; }
.ev-point { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-secondary); }
.ev-point svg { flex-shrink: 0; color: var(--accent-emerald); }
@media (max-width: 520px) { .ev-points { grid-template-columns: 1fr; } }

/* ── Footer: a single big on/off button ───────────────────────────────────── */
.ev-foot {
  display: flex;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}
.ev-apply {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; padding: 0 22px;
  border-radius: 14px;
  border: 1px solid rgba(52, 211, 153, 0.5);
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.95), rgba(45, 212, 191, 0.9));
  color: #04121a;
  font-family: var(--font-body);
  font-size: 16px; font-weight: 800; letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(52, 211, 153, 0.3);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-base) var(--ease-out), filter var(--t-base) var(--ease-out), background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
.ev-apply:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(52, 211, 153, 0.42); filter: brightness(1.05); }
.ev-apply:active { transform: translateY(0) scale(0.98); }
.ev-apply:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* When the mode is already ON, the button means "turn it off" — soften it to a
   neutral outline so it doesn't look like a primary call-to-action. */
.ev-apply.is-on {
  background: rgba(148, 163, 184, 0.14);
  border-color: var(--glass-border-2);
  color: var(--text-secondary);
  box-shadow: none;
}
.ev-apply.is-on:hover {
  background: rgba(251, 113, 133, 0.14);
  border-color: rgba(251, 113, 133, 0.5);
  color: var(--accent-rose);
  box-shadow: 0 0 18px rgba(251, 113, 133, 0.18);
  filter: none;
}

/* Reduced motion — the modal still appears, just without the choreography. */
@media (prefers-reduced-motion: reduce) {
  .ev-overlay, .ev-modal { opacity: 1 !important; transform: none !important; }
}

/* ── Light overrides for JS inline styles ──
   easy-view.js injects the before/after demo SVG (demoSvg()) with hardcoded
   light-blue / white text fills (#dce9ff, #9fc0e6, #ffffff, #cfe4ff) and a
   near-white card stroke (rgba(255,255,255,.16)). On the light modal card those
   text nodes and the stroke go invisible. Re-ink them to the dark text tokens
   and give the card a visible border. The emerald magnifier + glow keep their
   accent colour (reads on both). Dark mode is untouched. */
html[data-theme="light"] .ev-demo svg > rect { stroke: var(--glass-border-3) !important; }
/* "before" state — dim/small text, originally light-blue on dark */
html[data-theme="light"] .ev-before .ev-bttl { fill: var(--text-secondary) !important; }
html[data-theme="light"] .ev-before .ev-b-l,
html[data-theme="light"] .ev-before .ev-b-v,
html[data-theme="light"] .ev-before .ev-b-v tspan { fill: var(--text-muted) !important; }
/* "after" state — bold/bright text, originally #fff / #cfe4ff on dark.
   The after texts carry no class, so target the group's text/tspan directly. */
html[data-theme="light"] .ev-after text,
html[data-theme="light"] .ev-after tspan { fill: var(--text-primary) !important; }

/* ── Light-mode gap fix (appended) ───────────────────────────────────────
   The badge glyph colour is hardcoded #6ee7b7 (pale emerald) which vanishes
   against the light emerald-tinted badge on the white modal. Drop to the
   darkened emerald accent for readable contrast. */
html[data-theme="light"] .ev-badge { color: var(--accent-emerald); }

/* ── MOBILE (2026-07-06 overhaul) — scoped, desktop untouched ──────────── */
@media (max-width: 768px) {
  /* Easy View's zoom:1.1 pushes fixed-width dashboard content past a 390px
     viewport → site-wide horizontal scroll. Soften to 1.05 on phones.
     (js/easy-view.js zoomTarget() mirrors this so the GSAP tween lands here.) */
  html.easy-view body { zoom: 1.05; }

  /* Preview modal → bottom sheet. Also drops the stacked backdrop blurs
     (blur(10) overlay + blur(22) modal) that stutter on mobile GPUs; the
     modal surfaces are ~0.94 opaque so they hold up without blur. */
  .ev-overlay {
    align-items: flex-end;
    padding: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .ev-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: calc(100vh - 32px); /* fallback */
    max-height: 88dvh;              /* dynamic viewport — keeps the Turn on/off
                                       button above the browser chrome */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .ev-inner {
    padding: 24px 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}

/* Touch-target sizing only */
@media (pointer: coarse) {
  .ev-close { width: 44px; height: 44px; }
}
