/* ──────────────────────────────────────────────────────────────────────────
   DailyRite shared shell styles (Phase 14).

   Extracted from base.html's inline <style> and re-authored mobile-first:
   the narrow-screen layout is the default, and `@media (min-width: 768px)` /
   `@media (min-width: 1024px)` progressively restore the roomier tablet/desktop
   presentation. Replaces the old single desktop-first 640px-max patch.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Masthead face ───────────────────────────────────────────────────────────
   Fraunces (SIL OFL, license in ../fonts/OFL.txt), self-hosted so no external
   request and CSP's font-src 'self' stays untouched. Single variable woff2
   covers weights 600–700 (latin subset, ~36KB). Headings only — body copy
   stays on the system sans stack. */
@font-face {
    font-family: 'Fraunces';
    src: url("../fonts/fraunces-latin-600-700.eb2486760f75.woff2") format('woff2');
    font-weight: 600 700;
    font-style: normal;
    font-display: swap;
}

/* ── Newsprint theme ─────────────────────────────────────────────────────────
   LIGHT (warm paper) is the default; DARK (ink) applies on explicit opt-in
   (html[data-theme="dark"]) or as the OS-preference default when the user has
   not chosen light. Every text/accent pairing below clears WCAG AA (>=4.5:1).
   In-text links are also underlined (see the `a` rule) so colour is never the
   only distinguishing cue. */
:root {
    --bg: #f2ede3;
    --surface: #fbf9f4;
    --surface-2: #e8e1d3;
    --border: #d8cfbe;
    --text: #1b1a17;
    --heading: #111010;
    --text-muted: #57534a;      /* ~6.4:1 on --surface */
    --primary: #a4161a;         /* deep red — #fff text ~6:1 */
    --primary-hover: #7d1013;
    --accent: #a4161a;          /* links (underlined) */
    --danger: #b3261e;
    --success: #1f6b2e;         /* #fff text ~6.5:1 */
    --warning: #b45309;         /* #fff text ~5:1 */
    --on-primary: #fff;
    --on-success: #fff;
    --on-warning: #fff;
    --on-danger: #fff;
    --radius: 8px;
    --input-bg: var(--surface-2);

    /* Newspaper headline face */
    --font-serif: 'Fraunces', Georgia, 'Iowan Old Style', 'Times New Roman', serif;

    /* Phase 14 mobile-first tokens (theme-independent) */
    --bp-tablet: 768px;
    --bp-desktop: 1024px;
    --tap-min: 44px;      /* minimum comfortable touch target */
    --space-touch: 12px;
}

html[data-theme="dark"] {
    --bg: #14130f;
    --surface: #1d1b16;
    --surface-2: #272420;
    --border: #38342c;
    --text: #ecebe4;
    --heading: #f7f4ec;
    --text-muted: #a8a29a;
    --primary: #c62828;         /* #fff text ~5.2:1 */
    --primary-hover: #a11f1f;
    --accent: #f08a84;          /* light red link on ink */
    --danger: #e5736b;
    --success: #66bb6a;
    --warning: #ffb74d;
    --on-primary: #fff;
    --on-success: #000;
    --on-warning: #1a1206;
    --on-danger: #000;
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --bg: #14130f;
        --surface: #1d1b16;
        --surface-2: #272420;
        --border: #38342c;
        --text: #ecebe4;
        --heading: #f7f4ec;
        --text-muted: #a8a29a;
        --primary: #c62828;
        --primary-hover: #a11f1f;
        --accent: #f08a84;
        --danger: #e5736b;
        --success: #66bb6a;
        --warning: #ffb74d;
        --on-primary: #fff;
        --on-success: #000;
        --on-warning: #1a1206;
        --on-danger: #000;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    /* Mobile default: stop the long email / wide rows from forcing a sideways
       scroll on narrow screens. Reset at the tablet breakpoint below. */
    overflow-x: hidden;
}
/* In-text links are underlined so colour is never the only cue (WCAG 1.4.1).
   Navigation and button-styled links opt out below — they're already distinct. */
a { color: var(--accent); text-decoration: underline; }
a:hover { text-decoration: underline; }
.navbar a, .navbar-brand,
.site-footer-links a,
.btn, a.btn,
.cta, .price-cta, .browser-btn,
.theme-toggle {
    text-decoration: none;
}

/* Newspaper headline face across the shell. The briefing view opts back out
   (see briefing-web.css) so it stays visually identical to the extension. */
h1, h2, h3, .navbar-brand { font-family: var(--font-serif); }

/* ── Navbar ───────────────────────────────────────────────────────────────
   Mobile default: wrap so the links never overflow the row. */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 6px 14px;
}
.navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--heading);
    text-decoration: none;
}
.navbar-links { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.navbar-links a {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-min);
}
.navbar-links a:hover { color: var(--heading); text-decoration: none; }
/* The long email is what blew out the row on phones — hide it on mobile. */
.navbar-email { display: none; color: var(--text-muted); font-size: 0.9rem; }

.tier-badge {
    background: var(--primary);
    color: var(--on-primary);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Light/dark toggle — a compact icon button that matches the navbar links. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover { color: var(--heading); border-color: var(--text-muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 20px;
}
.card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 16px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────
   inline-flex + min-height keeps labels centered while guaranteeing a
   44px touch target on every device. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap-min);
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: var(--on-success); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-group input, .form-group select {
    width: 100%;
    min-height: var(--tap-min);
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Standalone dashboard inputs (outside .form-group wrappers). */
.dash-input {
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
}
.dash-input:focus {
    outline: none;
    border-color: var(--primary);
}
/* Mobile default: single column; two columns from the tablet breakpoint. */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* ── Toast ───────────────────────────────────────────────────────────────
   Mobile default: full-width along the bottom so it never collides with a
   thumb (or the future settings bottom sheet). Pinned bottom-right ≥768px. */
.toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    text-align: center;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #fff;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); color: var(--on-success); }
.toast-error { background: var(--danger); color: var(--on-danger); }

.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 48px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.site-footer-links { display: flex; gap: 18px; }

.legal { max-width: 760px; margin: 0 auto; padding: 28px 16px 48px; line-height: 1.65; }
.legal h1 { color: var(--heading); font-size: 1.6rem; margin-bottom: 6px; }
.legal .updated { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 28px; }
.legal h2 { color: var(--heading); font-size: 1.1rem; margin: 30px 0 10px; }
.legal h3 { color: var(--text); font-size: 0.95rem; margin: 18px 0 6px; }
.legal p, .legal li { color: var(--text); font-size: 0.92rem; }
.legal ul { margin: 8px 0 8px 22px; }
.legal li { margin-bottom: 6px; }
.legal code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.legal table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 0.86rem; }
.legal th, .legal td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal th { background: var(--surface-2); color: var(--heading); }
/* Wide legal tables scroll horizontally instead of forcing the page wider. */
.legal .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.legal .table-wrap table { min-width: 520px; }

.pwa-install-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
    font-size: 0.88rem; color: var(--text);
}
.pwa-install-bar[hidden] { display: none; }
.pwa-install-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-pwa-install {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--tap-min);
    background: var(--primary); color: #fff; border: none; padding: 6px 14px;
    border-radius: 6px; font-weight: 500; cursor: pointer; font-size: 0.85rem;
}
.btn-pwa-install[hidden] { display: none !important; }
.btn-pwa-install:hover { background: var(--primary-hover); }
.btn-pwa-dismiss {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1rem; line-height: 1; padding: 4px;
    min-width: var(--tap-min); min-height: var(--tap-min);
}
/* z-index must clear the dashboard's mobile settings sheet overlay (1100 in
   dashboard.css): on phones the "Add to home screen" button lives INSIDE that
   sheet, and at 1000 the modal opened behind it — the tap looked like a no-op.
   Guarded by tests/test_pwa.py::test_install_modal_stacks_above_settings_sheet. */
.pwa-install-modal {
    position: fixed; inset: 0; z-index: 1200;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(0, 0, 0, 0.6);
}
.pwa-install-modal[hidden] { display: none !important; }
.pwa-install-modal-panel {
    width: 100%; max-width: 420px; margin: 0;
}
.pwa-install-modal-lead {
    font-size: 0.88rem; color: var(--text-muted); line-height: 1.55;
    margin: 0 0 14px;
}
.pwa-install-modal-steps {
    margin: 0 0 18px; padding-left: 1.2rem;
    font-size: 0.88rem; color: var(--text); line-height: 1.55;
}
.pwa-install-modal-steps li + li { margin-top: 8px; }
.pwa-install-modal-actions {
    display: flex; justify-content: flex-end;
}
.offline-banner {
    padding: 8px 16px; background: var(--warning); color: var(--on-warning);
    font-size: 0.85rem; text-align: center;
}
.offline-banner[hidden] { display: none; }

/* ── Tablet and up (≥768px) ─────────────────────────────────────────────── */
@media (min-width: 768px) {
    body { overflow-x: visible; }

    .navbar { padding: 16px 32px; flex-wrap: nowrap; gap: 16px; }
    .navbar-links { gap: 16px; flex-wrap: nowrap; }
    .navbar-email { display: inline; }

    .container { padding: 32px 24px; }
    .card { padding: 24px; }
    .form-row { grid-template-columns: 1fr 1fr; }

    .toast {
        left: auto;
        right: 24px;
        bottom: 24px;
        text-align: left;
    }

    .site-footer { padding: 20px 32px; }
    .legal { padding: 40px 24px 64px; }
    .pwa-install-bar { padding: 10px 32px; }
    .offline-banner { padding: 8px 32px; }
}

/* ── Desktop and up (≥1024px) ───────────────────────────────────────────── */
@media (min-width: 1024px) {
    /* Wide desktop: let the masthead face breathe a little more. */
    .navbar-brand { font-size: 1.2rem; }
}

/* ── What's-new bar (base.html) + /changelog/ page ─────────────────────── */
.whats-new-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
    font-size: 0.88rem; color: var(--text);
}
/* Mobile-first: badge + wrapping title + link, no summary. From the tablet
   breakpoint it becomes one line — title never wraps, the summary soaks up
   the slack and truncates. */
.whats-new-text { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap; }
.whats-new-summary { display: none; color: var(--text-muted); }
.whats-new-link { white-space: nowrap; font-weight: 500; }
@media (min-width: 768px) {
    .whats-new-text { flex-wrap: nowrap; }
    .whats-new-text strong { white-space: nowrap; }
    .whats-new-summary {
        display: inline; flex: 1; min-width: 0;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
}
.changelog-kind {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.changelog-kind-new { color: var(--primary); border-color: var(--primary); }
.changelog-kind-improved { color: var(--success); border-color: currentColor; }
.changelog-kind-fixed { color: var(--text-muted); }
/* /corrections/ reuses the changelog chips: status + section */
.changelog-kind-open { color: var(--warning, #b45309); border-color: currentColor; }
.changelog-kind-wont-fix { color: var(--text-muted); }
.changelog-entry { padding: 18px 0; border-top: 1px solid var(--border); }
.changelog-entry:first-of-type { border-top: none; }
.changelog-meta { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.82rem; }
.changelog-entry h2 { margin: 6px 0 8px; }
.changelog-entry h2 a { color: inherit; text-decoration: none; }
.changelog-entry h2 a:hover { text-decoration: underline; }
.changelog-try { font-weight: 500; }
