/* SmokePing screen styles. Replaces the upstream stylesheet; markup comes from
   config/basepage.html and the CGI (menu, panels, navigator form). */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2125;
    --text-muted: #5b636d;
    --border: #d9dde3;
    --accent: #2f6fd0;
    --accent-soft: #e8f0fc;
    --focus: #2f6fd0;
    --radius: 4px;
    --sidebar-width: 264px;
    --topbar-height: 48px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --graph-filter: none;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171b;
        --surface: #1b1f24;
        --text: #e3e6ea;
        --text-muted: #9aa3ad;
        --border: #2e343b;
        --accent: #7aa7ec;
        --accent-soft: #1f2b3d;
        --focus: #7aa7ec;
        /* Graphs stay white plates: inverting them would turn 20/20 loss (dark red) into
           the palest swatch and break the loss-severity scale. Dimming keeps hue order. */
        --graph-filter: brightness(0.9);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* ---- Top bar ---- */

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar-height);
    padding: 0 var(--space-4) 0 var(--space-2);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.wordmark {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}
.wordmark:hover { text-decoration: none; }

.icon-button,
.toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.icon-button { width: 32px; padding: 0; }
.icon-button:hover { background: var(--accent-soft); }

.toggle {
    margin-left: auto;
    padding: 0 var(--space-3);
    border-color: var(--border);
    color: var(--text-muted);
}
.toggle::before {
    content: "";
    width: 8px;
    height: 8px;
    margin-right: var(--space-2);
    border: 1px solid currentColor;
    border-radius: 50%;
}
.toggle[aria-pressed="true"] { color: var(--text); }
.toggle[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }
.toggle:hover { background: var(--accent-soft); }

/* ---- Sidebar navigation ---- */

.sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 10;
    width: var(--sidebar-width);
    overflow-y: auto;
    padding: var(--space-3) 0 var(--space-6);
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar form { margin: 0; }

.filter { padding: var(--space-2) var(--space-4) var(--space-3); }

.filter-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.filter input {
    width: 100%;
    height: 32px;
    padding: 0 var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.menu { list-style: none; margin: 0; padding: 0; }
.menu .menu .menulink { padding-left: 32px; }
.menu .menu .menu .menulink { padding-left: 48px; font-size: 13px; }

.menulink,
.menulinkactive {
    display: block;
    padding: 5px var(--space-4);
    border-left: 2px solid transparent;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menulink:hover,
.menulinkactive:hover {
    background: var(--accent-soft);
    text-decoration: none;
}

.menulinkactive {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

/* ---- Content ---- */

.main {
    min-width: 0;
    padding: calc(var(--topbar-height) + var(--space-6)) var(--space-8) var(--space-8);
    margin-left: var(--sidebar-width);
}

.main h1 {
    margin: 0 0 var(--space-1);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.remark {
    max-width: 72ch;
    margin: 0 0 var(--space-6);
    color: var(--text-muted);
}

.main h1:empty,
.remark:empty { display: none; }

/* Charts pages put their own h1 inside .overview. */
.overview > h1 { margin-bottom: var(--space-6); }

/* Graph entries are a list separated by rules, not cards. */
.panel,
.panel-no-border {
    max-width: 760px;
    padding: var(--space-4) 0;
    border-top: 1px solid var(--border);
}

.panel-heading h2,
.panel-heading-no-border h2 {
    margin: 0 0 var(--space-2);
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.panel-body img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    filter: var(--graph-filter);
}

/* The navigator crop maps screen pixels to time, so the zoom graph keeps its
   intrinsic size and scrolls horizontally instead of scaling. */
.panel-body:has(#zoom) { overflow-x: auto; }
.panel-body #zoom { max-width: none; }

/* Navigator time-range form rendered by the CGI. */
#range_form p {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-3) 0 0;
    color: var(--text-muted);
}

#range_form input[type="text"],
#range_form input[type="submit"] {
    height: 32px;
    padding: 0 var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

#range_form input[type="submit"] { cursor: pointer; }
#range_form input[type="submit"]:hover { background: var(--accent-soft); }

.footer {
    max-width: 760px;
    margin-top: var(--space-8);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
}

/* ---- Sidebar visibility ----
   Wide screens: sidebar shown, button hides it. Narrow: hidden, button overlays it. */

@media (min-width: 900px) {
    body.nav-toggled .sidebar { display: none; }
    body.nav-toggled .main { margin-left: 0; }
}

@media (max-width: 899px) {
    .sidebar { display: none; width: min(var(--sidebar-width), 85vw); }
    body.nav-toggled .sidebar { display: block; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.35); }
    .main {
        margin-left: 0;
        padding: calc(var(--topbar-height) + var(--space-4)) var(--space-4) var(--space-6);
    }
}
