/*
 * The site's colours are the application's colours, taken from Theming/ThemePalette.cs in the
 * DutyAllocator repository rather than picked to look similar. If the application's palette
 * changes, change these to match: the point of the site looking like the software is that a
 * customer recognises what they are buying when they open it.
 *
 * Theming has three states, the same three the application has. No choice made follows the
 * visitor's system setting; a choice made overrides it and is remembered. That is why the dark
 * values appear twice: once under the media query for "no choice made and the system is dark",
 * and once under the attribute for "dark was chosen". The light block has to win back from the
 * media query when light is chosen explicitly, which is what the :not() guard is for.
 */

:root,
html[data-theme="light"] {
    --page: #F4F5F7;
    --surface: #FFFFFF;
    --surface-alt: #F9FAFB;
    --border: #E1E4E8;
    --border-strong: #C7CED6;

    --text: #1B2733;
    --text-secondary: #5A6875;
    --text-muted: #8A95A1;

    --accent: #1264A3;
    --accent-hover: #0E5084;
    --accent-soft: #E4EEF7;
    --on-accent: #FFFFFF;

    --danger: #B42D2D;
    --danger-soft: #FBE9E9;
    --ok: #1F7A44;
    --ok-soft: #E6F4EC;

    --rail: #FFFFFF;
    --shadow: 0 1px 2px rgba(27, 39, 51, .06), 0 8px 24px rgba(27, 39, 51, .06);

    --measure: 1120px;
    --radius: 10px;

    color-scheme: light;
}

html[data-theme="dark"] {
    --page: #16191D;
    --surface: #1E2228;
    --surface-alt: #23282F;
    --border: #2E343C;
    --border-strong: #3D444E;

    --text: #E6EAEF;
    --text-secondary: #A2ACB8;
    --text-muted: #78828E;

    --accent: #4C9AFF;
    --accent-hover: #6FB2FF;
    --accent-soft: #1B2A3D;
    --on-accent: #0B1622;

    --danger: #F0736A;
    --danger-soft: #331D1C;
    --ok: #5FCB8B;
    --ok-soft: #16281E;

    --rail: #1A1D22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --page: #16191D;
        --surface: #1E2228;
        --surface-alt: #23282F;
        --border: #2E343C;
        --border-strong: #3D444E;

        --text: #E6EAEF;
        --text-secondary: #A2ACB8;
        --text-muted: #78828E;

        --accent: #4C9AFF;
        --accent-hover: #6FB2FF;
        --accent-soft: #1B2A3D;
        --on-accent: #0B1622;

        --danger: #F0736A;
        --danger-soft: #331D1C;
        --ok: #5FCB8B;
        --ok-soft: #16281E;

        --rail: #1A1D22;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);

        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    /* Segoe UI first, because that is what the application itself draws in. */
    font: 16px/1.6 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 24px; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 600; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { margin: 0 0 1em; }

.lead { font-size: 1.15rem; color: var(--text-secondary); max-width: 60ch; }
.muted { color: var(--text-muted); }
.small { font-size: .9rem; }

/* --- Header, styled after the application's own rail and header ------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--rail);
    border-bottom: 1px solid var(--border);
}

.site-header .wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.brand svg { width: 26px; height: 26px; color: var(--accent); flex: none; }

.site-nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }

.site-nav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .95rem;
}

.site-nav a:hover { background: var(--surface-alt); color: var(--text); }
.site-nav a.current { background: var(--accent-soft); color: var(--accent); }

/* --- The theme switch ------------------------------------------------------------------ */

.theme-switch {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-alt);
}

.theme-switch button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button:hover { color: var(--text); }

.theme-switch button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

/* --- Buttons, matching AppButton ------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-secondary:hover { background: var(--surface-alt); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 7px 12px; font-size: .875rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* --- Sections -------------------------------------------------------------------------- */

section { padding: 72px 0; }
section + section { border-top: 1px solid var(--border); }

.hero { padding-top: 80px; padding-bottom: 40px; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    margin-bottom: 18px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .8rem;
    font-weight: 600;
}

/* --- Cards, matching the Card control -------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* --- Screenshots ----------------------------------------------------------------------- */

.shot {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
}

/* Only the image matching the current theme is shown, in all three theme states. */
.shot-dark { display: none; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .shot-light { display: none; }
    html:not([data-theme="light"]) .shot-dark { display: block; }
}

html[data-theme="dark"] .shot-light { display: none; }
html[data-theme="dark"] .shot-dark { display: block; }
html[data-theme="light"] .shot-light { display: block; }
html[data-theme="light"] .shot-dark { display: none; }

figure { margin: 0; }
figcaption { margin-top: 12px; color: var(--text-secondary); font-size: .95rem; }

/* --- The pipeline, which is how the product is explained in the README ----------------- */

.pipeline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 28px; padding: 0; list-style: none; }

.pipeline li {
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
}

.pipeline li.feeds { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.pipeline .arrow { color: var(--text-muted); font-weight: 400; }

/* --- Forms ----------------------------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

textarea { min-height: 160px; resize: vertical; }
.field { margin-bottom: 18px; }
.field .hint { font-weight: 400; color: var(--text-muted); font-size: .875rem; margin-top: 4px; }

/* --- Messages -------------------------------------------------------------------------- */

.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 22px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

.notice {
    border-left: 3px solid var(--danger);
    background: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 18px 22px;
}

.notice h3 { color: var(--danger); }

/* --- Tables ---------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }

table.data th, table.data td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

table.data th { color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-alt); }

/* --- Admin ----------------------------------------------------------------------------- */

.admin-shell { display: flex; min-height: 100vh; }

.admin-rail {
    width: 220px;
    flex: none;
    background: var(--rail);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
}

.admin-rail a {
    display: block;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .95rem;
}

.admin-rail a:hover { background: var(--surface-alt); color: var(--text); }
.admin-rail a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.admin-main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.admin-main h1 { font-size: 1.75rem; }

.stat { padding: 18px 20px; }
.stat .n { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stat .k { color: var(--text-muted); font-size: .875rem; }

.unread { font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill-new { background: var(--accent-soft); color: var(--accent); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-off { background: var(--danger-soft); color: var(--danger); }

/* --- Footer ---------------------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--rail);
    padding: 40px 0;
    color: var(--text-muted);
    font-size: .9rem;
}

.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }

@media (max-width: 860px) {
    section { padding: 48px 0; }
    .site-nav a:not(.btn) { display: none; }
    .admin-shell { display: block; }
    .admin-rail { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .admin-rail a { display: inline-block; }
    .admin-main { padding: 20px; }
}
