/* Sefaria Status Page Styles
 *
 * Light, scholarly theme matching Sefaria's real brand: a warm off-white
 * "page of a book" background, serif headings, a navy header with a gold
 * accent, gently rounded cards, and the signature category-color accent
 * line. Colors and type are taken from Sefaria's open-source frontend.
 */

/* Self-hosted fonts (latin subset, woff2). Served same-origin via WhiteNoise
 * — no third-party request, so the status page never depends on Google Fonts'
 * availability and leaks no visitor IPs. Roboto is Apache-2.0, Crimson Text is
 * OFL. Hebrew has no glyphs in these and falls back to a system serif (as
 * before). url()s are rewritten to hashed names by collectstatic. */
@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/roboto-v51-latin-regular.4279528ce0e7.woff2") format("woff2");
}
@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/roboto-v51-latin-500.55cfeb5304f0.woff2") format("woff2");
}
@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/roboto-v51-latin-700.10a07810f28f.woff2") format("woff2");
}
@font-face {
    font-family: "Crimson Text";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/crimson-text-v19-latin-regular.23eec75ba54d.woff2") format("woff2");
}
@font-face {
    font-family: "Crimson Text";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/crimson-text-v19-latin-600.d7a5ae87e50b.woff2") format("woff2");
}
@font-face {
    font-family: "Crimson Text";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/crimson-text-v19-latin-italic.79f4a05271df.woff2") format("woff2");
}

:root {
    /* Brand */
    --sefaria-blue: #18345D;
    --sefaria-blue-dark: #212E50;
    --sefaria-gold: #CCB479;
    --sefaria-link: #4871BF;

    /* Surfaces & text (warm, not stark white/black) */
    --bg: #FBFBFA;
    --surface: #FFFFFF;
    --surface-soft: #F6F6F4;
    --border: #EDEDEC;
    --border-strong: #E0E0DE;
    --text: #333331;
    --text-muted: #666664;
    /* Darkened from #8A8A87 to meet WCAG AA (>=4.5:1) for small text on #FBFBFA. */
    --text-faint: #6E6E6B;

    /* Status colors (from Sefaria's category palette), tuned for contrast
       on a light background. Dot/bar use the vivid hue; *-text is darkened
       so badge labels meet WCAG contrast. */
    --status-up: #5D956F;
    --status-up-text: #2F7A52;
    --status-degraded: #CCB479;
    --status-degraded-text: #876716;
    --status-down: #9B3144;
    --status-down-text: #802F3E;
    --status-maint: #4871BF;
    --status-maint-text: #2D5483;
    --status-unknown: #B7B7B4;
    --status-unknown-text: #6B6B69;

    /* The category rainbow Sefaria draws as a thin accent line. */
    --category-rainbow: linear-gradient(90deg,
            #00505E, #5698B4, #CCB37C, #5B9370, #823241,
            #5A4474, #AD4F66, #7285A6, #00807E, #4872B3);

    /* Type — Sefaria uses Adobe Garamond (serif) + Roboto (sans). We load
       Roboto and Crimson Text (Sefaria's own Garamond fallback) with system
       fallbacks so the page never blocks on web fonts. */
    --font-serif: "Crimson Text", Georgia, "Times New Roman", serif;
    --font-sans: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

    --radius: 7px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Accessibility: honor reduced-motion preferences. Status is also conveyed
   by text labels, so the pulsing dots are decorative and safe to disable. */
@media (prefers-reduced-motion: reduce) {

    .status-dot.pulse,
    .service-dot.status-down {
        animation: none;
    }

    * {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

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

html {
    background-color: #FBFBFA;
    background-color: var(--bg);
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Signature Sefaria touch: a category-color accent band at the top. */
body::before {
    content: "";
    display: block;
    height: 8px;
    background: var(--category-rainbow);
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.logo-link {
    display: flex;
    align-items: center;
}

.logo {
    height: 38px;
    width: auto;
    opacity: 0.95;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 1;
}

header h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 600;
    color: var(--sefaria-blue);
    letter-spacing: 0.01em;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Overall Status Banner */
.overall-status {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.4rem 1.6rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--status-unknown);
}

.overall-status.status-operational {
    border-left-color: var(--status-up);
}

.overall-status.status-degraded,
.overall-status.status-partial {
    border-left-color: var(--status-degraded);
}

.overall-status.status-major {
    border-left-color: var(--status-down);
}

.overall-status.status-maintenance {
    border-left-color: var(--status-maint);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-indicator {
    flex-shrink: 0;
}

.status-dot {
    display: block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--status-up);
}

.status-operational .status-dot {
    background: var(--status-up);
}

.status-degraded .status-dot,
.status-partial .status-dot {
    background: var(--status-degraded);
}

.status-major .status-dot {
    background: var(--status-down);
}

.status-maintenance .status-dot {
    background: var(--status-maint);
}

.status-dot.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(155, 49, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 7px rgba(155, 49, 68, 0);
    }
}

.status-text {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

.status-operational .status-text {
    color: var(--status-up-text);
}

.status-degraded .status-text,
.status-partial .status-text {
    color: var(--status-degraded-text);
}

.status-major .status-text {
    color: var(--status-down-text);
}

.status-maintenance .status-text {
    color: var(--status-maint-text);
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-faint);
    margin-left: auto;
}

/* Status-aware verse */
.status-quote {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
    padding: 0.75rem 1rem 0.25rem;
    border-top: 1px solid var(--border);
}

.quote-hebrew {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 500;
    direction: rtl;
    color: var(--sefaria-blue);
    line-height: 1.6;
}

.quote-english {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.5;
}

.quote-source {
    color: var(--sefaria-link);
    text-decoration: none;
    font-size: 0.78rem;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.quote-source:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Section headings */
.services h2,
.uptime h2,
.incidents h2,
.maintenance h2 {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.75rem;
    color: var(--text-faint);
}

/* Services */
.services {
    margin-bottom: 2rem;
}

.service-list {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.3rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    gap: 1rem;
}

.service-item:last-child {
    border-bottom: none;
}

.service-item:hover {
    background: var(--surface-soft);
}

.service-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.service-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--status-unknown);
}

.service-dot.status-up {
    background: var(--status-up);
}

.service-dot.status-degraded {
    background: var(--status-degraded);
}

.service-dot.status-down {
    background: var(--status-down);
    animation: pulse-small 2s infinite;
}

.service-dot.status-maintenance {
    background: var(--status-maint);
}

.service-dot.status-unknown {
    background: var(--status-unknown);
}

@keyframes pulse-small {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(155, 49, 68, 0.35);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(155, 49, 68, 0);
    }
}

.service-name {
    font-weight: 500;
    font-size: 0.98rem;
    color: var(--text);
}

.service-status {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.status-badge {
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.status-badge.status-up {
    background: rgba(93, 149, 111, 0.15);
    color: var(--status-up-text);
}

.status-badge.status-degraded {
    background: rgba(204, 180, 121, 0.25);
    color: var(--status-degraded-text);
}

.status-badge.status-down {
    background: rgba(155, 49, 68, 0.12);
    color: var(--status-down-text);
}

.status-badge.status-maintenance {
    background: rgba(72, 113, 191, 0.14);
    color: var(--status-maint-text);
}

.status-badge.status-unknown {
    background: rgba(120, 120, 120, 0.1);
    color: var(--status-unknown-text);
}

/* Response-time sparkline */
.service-spark {
    margin-left: auto;
    width: 120px;
    height: 28px;
    flex-shrink: 0;
    cursor: help;
    opacity: 0.85;
}

.service-spark svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.spark-line {
    fill: none;
    stroke: var(--sefaria-link);
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.spark-area {
    fill: var(--sefaria-link);
    opacity: 0.08;
}

.response-time {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.error-hint {
    color: var(--status-down-text);
    cursor: help;
    font-size: 0.85rem;
}

/* Uptime History */
.uptime {
    margin-bottom: 2rem;
}

.uptime-window {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    opacity: 0.7;
}

.uptime-list {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    padding: 0.5rem 1.3rem 1rem;
}

.uptime-row {
    padding: 0.8rem 0;
}

.uptime-row + .uptime-row {
    border-top: 1px solid var(--border);
}

.uptime-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.uptime-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.uptime-pct {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.uptime-bars {
    display: flex;
    gap: 2px;
    align-items: stretch;
    height: 30px;
}

.uptime-bar {
    flex: 1 1 0;
    min-width: 0;
    border-radius: 2px;
    background: var(--status-unknown);
    transition: opacity 0.15s;
}

.uptime-bar:hover {
    opacity: 0.6;
}

.uptime-bar.status-up {
    background: var(--status-up);
}

.uptime-bar.status-partial {
    background: var(--status-degraded);
}

.uptime-bar.status-down {
    background: var(--status-down);
}

.uptime-bar.status-nodata {
    background: var(--border-strong);
}

.uptime-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 0.6rem;
    color: var(--text-faint);
    font-size: 0.7rem;
}

.uptime-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.uptime-key {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.uptime-key .sw {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    display: inline-block;
}

.uptime-key .sw.status-up { background: var(--status-up); }
.uptime-key .sw.status-partial { background: var(--status-degraded); }
.uptime-key .sw.status-down { background: var(--status-down); }
.uptime-key .sw.status-nodata { background: var(--border-strong); }

/* Reassuring empty state */
.no-incidents {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--status-up);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 1rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* Subscribe */
.subscribe {
    margin-bottom: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.subscribe a {
    color: var(--sefaria-link);
    text-decoration: none;
}

.subscribe a:hover { text-decoration: underline; }

/* Incidents & Maintenance */
.incidents,
.maintenance {
    margin-bottom: 2rem;
}

.incident {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.3rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--status-unknown);
    box-shadow: var(--shadow-soft);
}

.incident.severity-high {
    border-left-color: var(--status-down);
}

.incident.severity-medium {
    border-left-color: var(--status-degraded);
}

.incident.severity-resolved {
    border-left-color: var(--status-up);
}

.incident.maintenance-window {
    border-left-color: var(--status-maint);
}

.severity-badge.maintenance {
    background: rgba(72, 113, 191, 0.14);
    color: var(--status-maint-text);
}

.incident-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.maintenance-affected {
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.incident-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.severity-badge {
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.severity-high .severity-badge {
    background: rgba(155, 49, 68, 0.12);
    color: var(--status-down-text);
}

.severity-medium .severity-badge {
    background: rgba(204, 180, 121, 0.25);
    color: var(--status-degraded-text);
}

.severity-resolved .severity-badge,
.severity-badge.resolved {
    background: rgba(93, 149, 111, 0.15);
    color: var(--status-up-text);
}

.incident-times {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.incident-header time {
    color: var(--text-faint);
    font-size: 0.75rem;
}

.incident-header .updated-time {
    font-style: italic;
}

.incident-text {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.55;
}

.no-services {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* Footer */
footer {
    margin-top: auto;
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    padding-top: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--sefaria-link);
}

.footer-links .divider {
    color: var(--border-strong);
}

.copyright {
    color: var(--text-faint);
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1.25rem 1rem;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .overall-status {
        padding: 1.1rem 1.2rem;
    }

    .status-text {
        font-size: 1.1rem;
    }

    .last-updated {
        display: none;
    }

    .service-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .service-status {
        padding-left: 1.75rem;
    }

    .service-spark {
        display: none;
    }
}
