/* The Local — staff area.
 *
 * MOBILE FIRST, like the public site: everything outside a media query is the
 * phone layout, and wider screens are additive via min-width only.
 *
 * Standalone rather than an add-on to style.css. The staff area shares none of
 * the public site's markup, and loading the public stylesheet to override two
 * thirds of it would be the slower, muddier option.
 *
 * ---------------------------------------------------------------------------
 * THE COMPONENTS ARE SHARED. THE PALETTE IS ONE OVERRIDABLE BLOCK.
 * ---------------------------------------------------------------------------
 *
 * The staff area is internal tooling, not client-facing brand, and its LAYOUT
 * should stay consistent across sites — a manager who works across two of these
 * should not have to learn two interfaces. So everything below the token block
 * is shared, finished, and not to be rewritten per site.
 *
 * The palette is the exception, because a staff area that looks like a
 * different company's website is its own kind of wrong. Every colour in this
 * file resolves through the tokens below, so a site reskins the whole staff
 * area by overriding THAT BLOCK ONLY and touching nothing else.
 *
 * THIS IS THE SITE'S COPY, so the token block below carries The Local's cream
 * and ink rather than the template's neutral greys. That is the one sanctioned
 * edit. Everything below it is the platform's shared staff-area CSS and should
 * stay byte-identical to innovators-platform/assets/css/admin.css, so a fix
 * made there can be dropped in here without a merge.
 *
 * TOKENS ARE ROLE-NAMED, NOT COLOUR-NAMED: --admin-bg says what it does, where
 * --cream stopped being true the moment another site went grey. Resist renaming
 * them back to the public site's colour names — that is what made the previous
 * version of this file impossible to share.
 *
 * Bump ASSET_VERSION in includes/site.php when you change this file — assets
 * are cached for a year by .htaccess.
 */

/* --- Tokens ---------------------------------------------------------------
 *
 * PER-SITE: override this block, and only this block, in the site's own copy.
 *
 * The three pairs each have a job, and they are separate because collapsing
 * them breaks a dark palette:
 *
 *   --admin-ink / --admin-bg          body text on the page
 *   --admin-bar-ink / --admin-bar-bg  the top bar, which may not follow the page
 *   --admin-on-accent / --admin-accent  anything filled in: buttons, pills, bars
 *
 * A light scheme can give all three the same two colours. A dark one cannot —
 * reusing the page ground as "text on a filled button" is what inverts the top
 * bar into a white slab. Keep them distinct.
 *
 * Every pair must clear WCAG AA (4.5:1) against its partner. These do — the
 * tightest is --admin-ink-soft on --admin-bg at 5.6:1.
 * ------------------------------------------------------------------------- */
:root {
    /* Page and surfaces, lightest-lifted to sunken. The Local's cream. */
    --admin-bg:          #e6d8c2;   /* the page itself */
    --admin-surface:     #f0e7d8;   /* panels, inputs, tables, stat tiles */
    --admin-surface-hi:  #ffffff;   /* an input sitting inside a panel */
    --admin-sunken:      #d8c8ac;   /* code, disabled fields, chart tracks */

    /* Text. */
    --admin-ink:         #010101;
    --admin-ink-soft:    #55504a;   /* 5.6:1 on --admin-bg */
    --admin-line:        rgba(1, 1, 1, 0.14);

    /* The top bar. Its own pair — see the note above. */
    --admin-bar-bg:      #010101;
    --admin-bar-ink:     #e6d8c2;
    --admin-line-invert: rgba(230, 216, 194, 0.22);   /* hairline ON the bar */

    /* Anything filled in. The ink pair, so the staff area stays monochrome
       against the cream — the public site's colour is the cream itself. */
    --admin-accent:      #010101;
    --admin-on-accent:   #e6d8c2;

    /* Status. --admin-error is used both as a fill and as text, so it has to
       work against --admin-on-error AND against --admin-bg. */
    --admin-error:       #8c2f27;
    --admin-on-error:    #ffffff;
    --admin-ok:          #4a5d3a;

    /* Type. Both are system stacks, matching style.css — the CSP forbids
       external origins, so there are no webfont links here either. The display
       stack must stay in step with style.css; previous serif stack recorded in
       CLAUDE.md. */
    --font-display: Optima, "Gill Sans", "Gill Sans MT", "Avenir Next", Avenir,
                    "Century Gothic", "Trebuchet MS", "Segoe UI", system-ui,
                    sans-serif;
    --font-body:    system-ui, -apple-system, "Segoe UI", Roboto,
                    "Helvetica Neue", Arial, sans-serif;

    /* Metrics. Not colours — a site should rarely need to touch these. */
    --gap:     1rem;
    --measure: 34rem;
    --shell:   64rem;
    --radius:  4px;
}

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

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

body {
    margin: 0;
    font: 400 1rem/1.6 var(--font-body);
    color: var(--admin-ink);
    background: var(--admin-bg);
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.12;
    margin: 0 0 var(--gap);
}

/* Optical tracking, same reasoning as the public site — see style.css. Staff
   headings run smaller throughout, so only h1 keeps the negative value. */
h1 { font-size: clamp(1.875rem, 7vw, 2.75rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.375rem, 5vw, 1.875rem); margin-top: 2.5rem; letter-spacing: 0; }
h3 { font-size: 1.125rem; letter-spacing: 0.01em; }

p { margin: 0 0 var(--gap); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.25em; }
a:hover { text-decoration-color: var(--admin-ink-soft); }

/* One focus style everywhere, and it must stay visible. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: 2px;
}

/* --- Utilities ---------------------------------------------------------- */
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 100;
    padding: 0.75rem 1rem;
    background: var(--admin-accent);
    color: var(--admin-on-accent);
    text-decoration: none;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Honeypot: a class, never an inline style — the CSP forbids those. Moved
 * off-screen rather than display:none, which some bots detect. */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px; height: 1px;
    overflow: hidden;
}

.eyebrow {
    margin: 0 0 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--admin-ink-soft);
}

.measure { max-width: var(--measure); }
.muted   { color: var(--admin-ink-soft); }
.lede    { font-size: 1.0625rem; color: var(--admin-ink-soft); }

code {
    padding: 0.1em 0.35em;
    font-size: 0.875em;
    background: var(--admin-sunken);
    border-radius: 3px;
    word-break: break-word;
}

/* --- Top bar ------------------------------------------------------------ */
.admin-bar {
    color: var(--admin-bar-ink);
    background: var(--admin-bar-bg);
}

.admin-bar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0.875rem 1.25rem;
}

.admin-bar__brand {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.25rem;
}
/* The logotype leaves the staff area for the public site, so it underlines on
   hover — it is the one link in the bar that does not go where it is. */
.admin-bar__brand a { text-decoration: none; }
.admin-bar__brand a:hover { text-decoration: underline; }
.admin-bar__brand span {
    display: block;
    font-family: var(--font-body);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    opacity: 0.65;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    width: 100%;
}

.admin-nav__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-nav__list a {
    display: inline-block;
    /* 44px touch target, which is why the padding looks generous. */
    padding: 0.7rem 0;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
}
.admin-nav__list a:hover { text-decoration: underline; }
.admin-nav__list a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.35em;
}

.admin-nav__out { margin-left: auto; }
.admin-nav__out .btn { margin-top: 0; width: auto; }

.admin-who {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0.75rem 1.25rem 0;
    font-size: 0.8125rem;
    color: var(--admin-ink-soft);
}

/* --- Layout ------------------------------------------------------------- */
.admin-main {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

/* Signed-out screens are a single narrow column, centred. */
.admin--bare .admin-main {
    max-width: calc(var(--measure) + 2.5rem);
    padding-top: 2.5rem;
}

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { margin-bottom: 0.5rem; }

.panel {
    padding: 1.25rem;
    background: var(--admin-surface);
    border: 1px solid var(--admin-line);
    border-radius: var(--radius);
}
.panel + .panel { margin-top: 1.25rem; }
.panel > :last-child { margin-bottom: 0; }

.stack > * + * { margin-top: 1.25rem; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.7rem 1.5rem;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--admin-on-accent);
    background: var(--admin-accent);
    border: 1px solid var(--admin-accent);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.btn:hover { background: transparent; color: var(--admin-accent); }

.btn--ghost {
    color: var(--admin-bar-ink);
    background: transparent;
    border-color: var(--admin-line-invert);
}
.btn--ghost:hover { background: var(--admin-bar-ink); color: var(--admin-bar-bg); border-color: var(--admin-bar-ink); }

.btn--quiet {
    color: var(--admin-ink);
    background: transparent;
    border-color: var(--admin-line);
}
.btn--quiet:hover { background: var(--admin-sunken); border-color: var(--admin-sunken); color: var(--admin-ink); }

.btn--danger { background: var(--admin-error); border-color: var(--admin-error); color: var(--admin-on-error); }
.btn--danger:hover { background: transparent; color: var(--admin-error); }

.btn--small {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.75rem;
}
.btn-row .btn { margin-top: 0; width: auto; }

/* --- Forms -------------------------------------------------------------- */
label {
    display: block;
    margin: 1.5rem 0 0.4rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hint {
    display: block;
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--admin-ink-soft);
}

input, select {
    width: 100%;
    padding: 0.85rem;
    font: inherit;
    color: inherit;
    background: var(--admin-surface);
    border: 1px solid var(--admin-line);
    border-radius: var(--radius);
    /* 16px minimum stops iOS Safari zooming on focus. */
    font-size: max(1rem, 16px);
}
.panel input, .panel select { background: var(--admin-surface-hi); }
input:hover, select:hover { border-color: var(--admin-ink); }
input:disabled, select:disabled {
    color: var(--admin-ink-soft);
    background: var(--admin-sunken);
    cursor: not-allowed;
}

/* Tick boxes are not text fields — the 100% width above would stretch one into
 * a stripe across the page. The label sits beside it, in sentence case, and the
 * whole pair is at least 44px tall so it is a comfortable touch target. */
input[type="checkbox"], input[type="radio"] {
    width: auto;
    min-width: 1.375rem;
    min-height: 1.375rem;
    margin: 0;
    accent-color: var(--admin-accent);
}

.checkline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    margin-top: 1.5rem;
}
.checkline label {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

form .btn { margin-top: 1.75rem; width: 100%; }

.form-aside {
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

.privacy {
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: var(--admin-ink-soft);
}

/* Search / filter row above the user list. */
.filters {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.filters label { margin-top: 0; }
.filters .btn { margin-top: 0; width: 100%; }

/* --- Notices ------------------------------------------------------------ */
.notice {
    margin: var(--gap) 0;
    padding: var(--gap);
    border-left: 3px solid;
    background: var(--admin-surface);
}
.notice ul { margin: 0; padding-left: 1.25rem; }
.notice li + li { margin-top: 0.35rem; }
.notice > :last-child { margin-bottom: 0; }
.notice--error { border-color: var(--admin-error); }
.notice--ok    { border-color: var(--admin-ok); }
.notice--warn  { border-color: var(--admin-sunken); }

/* --- The user list ------------------------------------------------------
 * A real table, because it is real tabular data and a screen reader should be
 * told so. On a phone it scrolls sideways inside its own box rather than
 * squeezing the page — tabbable and labelled so that is discoverable.
 */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--admin-line);
    border-radius: var(--radius);
    background: var(--admin-surface);
}

table {
    width: 100%;
    min-width: 40rem;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

caption {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8125rem;
    color: var(--admin-ink-soft);
    border-bottom: 1px solid var(--admin-line);
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--admin-line);
}

thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:last-child th,
tbody tr:last-child td { border-bottom: 0; }

td .row-actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.row-name { font-weight: 600; }
.row-email { font-size: 0.875rem; color: var(--admin-ink-soft); word-break: break-word; }

/* --- Small labels ------------------------------------------------------- */
.pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    border: 1px solid var(--admin-line);
    border-radius: 999px;
}
.pill--admin      { color: var(--admin-on-accent); background: var(--admin-accent); border-color: var(--admin-accent); }
.pill--management { background: var(--admin-sunken); }
.pill--suspended  { color: var(--admin-on-error); background: var(--admin-error); border-color: var(--admin-error); }

/* --- Definition pairs on the dashboard ---------------------------------- */
.facts { margin: 0; }
.facts dt {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--admin-ink-soft);
}
.facts dd {
    margin: 0.25rem 0 1rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
}
.facts dd:last-child { margin-bottom: 0; }

/* --- Metrics: headline figures ------------------------------------------
 * Four tiles. On a phone they are two by two rather than a single column —
 * these are numbers to compare at a glance, and a column makes that a scroll.
 */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 0 0 0.75rem;
}

.stat {
    padding: 1rem;
    background: var(--admin-surface);
    border: 1px solid var(--admin-line);
    border-radius: var(--radius);
}

.stat dt {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--admin-ink-soft);
}

.stat dd {
    margin: 0.35rem 0 0;
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 8vw, 2.5rem);
    line-height: 1.05;
    /* Tabular figures so the four tiles line up rather than shuffling about. */
    font-variant-numeric: tabular-nums;
}

.stats__note {
    max-width: var(--measure);
    margin-bottom: 2rem;
    font-size: 0.8125rem;
    color: var(--admin-ink-soft);
}

/* --- Metrics: date range ------------------------------------------------- */
.range-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.range-presets .btn { width: auto; }
.range-presets [aria-current="true"] {
    color: var(--admin-on-accent);
    background: var(--admin-accent);
    border-color: var(--admin-accent);
}

.range-said {
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
}

/* --- Metrics: charts -----------------------------------------------------
 * The drawings are inline SVG with percentage geometry and no viewBox, so they
 * fill whatever box these rules give them while their rounded corners stay in
 * real pixels. See includes/chart.php. Nothing here may become an inline style:
 * the CSP forbids those, which is the whole reason the geometry lives in SVG
 * attributes in the first place.
 */
.chart-block { margin-bottom: 2.5rem; }
.chart-block h2 { margin-bottom: 0.35rem; }

.chart__note {
    max-width: var(--measure);
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    color: var(--admin-ink-soft);
}

/* The rule the columns stand on, so a day with no traffic reads as a zero
   rather than as a missing bar. */
.chart {
    height: 9rem;
    padding-bottom: 1px;
    border-bottom: 1px solid var(--admin-line);
}
.chart--short { height: 6rem; }

.chart__svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.chart__col { fill: var(--admin-accent); }

.chart__axis {
    display: flex;
    justify-content: space-between;
    margin: 0.4rem 0 1rem;
    font-size: 0.75rem;
    color: var(--admin-ink-soft);
}

.chart__bar {
    display: block;
    width: 100%;
    height: 0.625rem;
}
.chart__track { fill: var(--admin-sunken); }
.chart__fill  { fill: var(--admin-accent); }
/* Machines, in the one chart that shows them beside people. The label carries
   the meaning; this only stops the eye reading four identical bars as one
   quantity. Never colour alone. */
.chart__fill--muted { fill: var(--admin-ink-soft); }

.chart__data {
    margin-top: 1rem;
    font-size: 0.875rem;
}
.chart__data summary {
    padding: 0.5rem 0;
    cursor: pointer;
    font-weight: 600;
}
.chart__data .table-wrap { margin-top: 0.5rem; }

.cell-bar { width: 40%; min-width: 6rem; vertical-align: middle; }

/* --- Metrics: labelled bars ---------------------------------------------
 * Label, bar, value. The bar is aria-hidden — the number is right there as
 * text, so announcing the drawing would read the row twice.
 */
.meters {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.meter {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.25rem 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--admin-line);
}
.meter:last-child { border-bottom: 0; }

.meter__label { font-size: 0.9375rem; }

.meter__value {
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* The bar drops to its own full-width row on a phone, where a three-column
   layout would leave it a few millimetres wide and useless. */
.meter__track { grid-column: 1 / -1; }

.plain-list {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}
.plain-list--split { columns: 2; }

/* --- Footer ------------------------------------------------------------- */
.admin-foot {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
    border-top: 1px solid var(--admin-line);
    font-size: 0.8125rem;
    color: var(--admin-ink-soft);
}
.admin-foot p { margin: 0 0 0.5rem; }
.admin-foot__note { max-width: var(--measure); }

/* Provenance, not a message to anybody: quieter than the note above it. */
.admin-foot__version {
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    opacity: 0.7;
}

/* --- Wider screens ------------------------------------------------------ */
@media (min-width: 40rem) {
    form .btn { width: auto; }

    .filters {
        grid-template-columns: 2fr 1fr 1fr auto;
        align-items: end;
    }
    .filters .btn { width: auto; }

    /* Two dates and a button, not the user list's four columns. */
    .filters--range { grid-template-columns: 1fr 1fr auto; }

    .panel { padding: 1.75rem; }

    .stats { grid-template-columns: repeat(4, 1fr); }

    /* Enough width for the bar to sit between the label and the value. */
    .meter {
        grid-template-columns: 10rem 1fr 8rem;
        gap: 0.75rem 1rem;
    }
    .meter__track { grid-column: auto; }
}

@media (min-width: 52rem) {
    .admin-bar__inner { flex-wrap: nowrap; padding-block: 1rem; }
    .admin-nav { width: auto; flex-wrap: nowrap; }
    .admin-nav__out { margin-left: 1rem; }

    .facts--grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0 1.5rem;
    }
}

/* --- Respect user preferences ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
