/* Display and accessibility settings, shared by every page.
   Loaded after the page's own styles so the html[data-*] rules can win. */

/* The settings panel (and anything else) must stay hidden when hidden. */
[hidden] { display: none !important; }

/* === Skip link === */
.skip {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 60;
    background: var(--text, #111);
    color: var(--bg, var(--bg-deep, #fff));
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}
.skip:focus { top: 12px; }

/* === Focus outline === */
:focus-visible {
    outline: 2px solid var(--blue-bright, var(--accent, #3b9eff));
    outline-offset: 3px;
    border-radius: 4px;
}

/* === Settings button (added to the nav by display.js) === */
.display-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--hairline-strong, var(--border, rgba(127, 127, 127, 0.4)));
    border-radius: 999px;
    background: transparent;
    color: var(--text, inherit);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
}
.display-btn:hover { border-color: var(--blue-bright, var(--accent, #3b9eff)); }

/* Plain <nav> links (pages on style.css) become a row so the button sits right. */
nav.has-display-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
/* Sticky top bars keep their right-hand actions together. */
.topbar.has-display-btn { gap: 14px; flex-wrap: wrap; }
.topbar.has-display-btn > :nth-child(2):not(:last-child) { margin-left: auto; }

/* === Settings panel === */
.display-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(0, 0, 0, 0.55);
}
.display-panel {
    position: fixed;
    z-index: 50;
    right: 16px;
    top: 76px;
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100vh - 96px);
    overflow: auto;
    background: var(--bg-card, var(--bg-panel, #fff));
    color: var(--text, inherit);
    border: 1px solid var(--hairline-strong, var(--border, #ccc));
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
    display: grid;
    gap: 16px;
}
.display-panel header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.display-panel h2 { font-size: 1.02rem; font-weight: 600; }
.display-panel .row-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted, var(--text-secondary, inherit));
    margin-bottom: 8px;
}
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
    border: 1px solid var(--hairline-strong, var(--border, #ccc));
    background: var(--bg-deep, var(--bg, transparent));
    color: var(--text, inherit);
    border-radius: 8px;
    padding: 8px 12px;
    min-height: 40px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}
.seg button[aria-pressed="true"] {
    background: var(--blue-bright, var(--accent, #3b9eff));
    border-color: var(--blue-bright, var(--accent, #3b9eff));
    color: var(--blue-ink, #061a30);
}
.toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    font-size: 0.92rem;
    cursor: pointer;
}
.toggle input { width: 20px; height: 20px; accent-color: var(--blue-bright, var(--accent, #3b9eff)); }
.display-panel .reset {
    justify-self: start;
    background: none;
    border: 0;
    color: var(--blue-bright, var(--accent, #0066cc));
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 6px 0;
}
.display-panel .close {
    background: none;
    border: 1px solid var(--hairline-strong, var(--border, #ccc));
    color: var(--text, inherit);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    font-size: 18px;
    cursor: pointer;
}

/* === Theme: Light chosen in settings ===
   The product pages are dark by default (System keeps their look); these
   overrides give them a light palette when Light is picked. Pages on
   style.css carry their own light block there. */
html[data-theme="light"] {
    --bg-deep: #f2f5fa;
    --bg-navy: #ffffff;
    --bg-card: #ffffff;
    --bg-green: #e9f6ef;
    --text: #131a26;
    --text-secondary: #42506a;
    --text-muted: #4a586f;
    --text-faint: #5c6a80;
    --blue: #0a6ede;
    --blue-bright: #0063cc;
    --blue-pale: #004fa6;
    --blue-ink: #ffffff;
    --green: #1b6e2f;
    --green-bright: #1b6e2f;
    --green-pale: #b7ecd1;
    --green-ink: #0b3d24;
    --purple: #7a3fc4;
    --purple-bright: #7a3fc4;
    --purple-ink: #ffffff;
    --hairline: rgba(19, 26, 38, 0.12);
    --hairline-strong: rgba(19, 26, 38, 0.18);
    color-scheme: light;
}
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] body { background-color: var(--bg-deep); }
html[data-theme="light"] body::before {
    background: radial-gradient(120% 70% at 50% -5%, #dce9fb 0%, #eaf1fa 40%, #f2f5fa 100%);
}
html[data-theme="light"] .topbar { background: rgba(242, 245, 250, 0.7); }
html[data-theme="light"] .back-link .mark,
html[data-theme="light"] .brand-mark,
html[data-theme="light"] .hero-icon { border-color: rgba(19, 26, 38, 0.15); }
html[data-theme="light"] .btn-ghost { border-color: rgba(19, 26, 38, 0.25); }

/* === Text size: zoom the page content, never the panel === */
html[data-text-size="large"] body > *:not(.display-panel) { zoom: 1.125; }
html[data-text-size="larger"] body > *:not(.display-panel) { zoom: 1.25; }
/* Backstop: zoomed content never scrolls the page sideways (clip, unlike hidden, keeps sticky working). */
html[data-text-size] body { overflow-x: clip; }
html[data-text-size] :is(.nav, .topbar, nav) > * { min-width: 0; }

/* === Reading font === */
@font-face {
    font-family: "OpenDyslexic";
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/opendyslexic-400.woff2") format("woff2");
}
@font-face {
    font-family: "OpenDyslexic";
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/opendyslexic-700.woff2") format("woff2");
}
/* Lexend (Legible), self-hosted like OpenDyslexic; the browser fetches it only
   when the Legible font is chosen. Variable font: one file, every weight. */
@font-face {
    font-family: "Lexend";
    font-weight: 400 700;
    font-display: swap;
    src: url("/fonts/lexend-latin.woff2") format("woff2");
}
html[data-font="legible"] body,
html[data-font="legible"] body * {
    font-family: "Lexend", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif !important;
}
html[data-font="legible"] body { line-height: 1.7; letter-spacing: 0.01em; }
html[data-font="dyslexic"] body,
html[data-font="dyslexic"] body * {
    font-family: "OpenDyslexic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif !important;
}
html[data-font="dyslexic"] body { line-height: 1.8; word-spacing: 0.08em; }

/* === Bold text === */
html[data-bold] body { font-weight: 600; }
html[data-bold] h1, html[data-bold] h2, html[data-bold] h3,
html[data-bold] b, html[data-bold] strong, html[data-bold] th { font-weight: 800; }

/* === High contrast === */
/* :root:root out-specifies the light-theme blocks in style.css, which would
   otherwise keep their lower-contrast --text-* values in Light + High contrast. */
:root:root[data-contrast="high"] {
    --text-secondary: var(--text);
    --text-muted: var(--text);
    --text-faint: var(--text);
    --text-dim: var(--text);
    --hairline: rgba(127, 127, 127, 0.55);
    --hairline-strong: rgba(127, 127, 127, 0.75);
    --border: rgba(127, 127, 127, 0.55);
}

/* === Underline links === */
html[data-links="underline"] main a,
html[data-links="underline"] footer a,
html[data-links="underline"] .footer a,
html[data-links="underline"] nav a:not(.display-btn),
html[data-links="underline"] .topbar a,
html[data-links="underline"] .topbar-nav a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* === Reduce motion === */
html[data-motion="reduce"] { scroll-behavior: auto; }
html[data-motion="reduce"] *,
html[data-motion="reduce"] *::before,
html[data-motion="reduce"] *::after {
    transition: none !important;
    animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Long strings never force sideways scroll at Larger text. */
.beat p, .live-text p, .hero-sub, .section p, .feature-card p,
.info-card p, .callout p, .privacy-strip p, .roadmap-note, .join-cta p,
.term pre, footer, td, th, li, .contact-email, .faq-item p, a[href^="mailto:"] {
    overflow-wrap: anywhere;
}
