/*
 * The look of Gantry's human screens (lot 4, S14, decision 0019): one hand-written sheet,
 * fonts served by Gantry, no external resource, no JavaScript.
 */

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("../fonts/space-grotesk-latin-variable.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --ground: #f5f6f8;
    --surface: #ffffff;
    --ink: #15181e;
    --muted: #5a6170;
    --line: #e1e4ea;
    --line-soft: #eef0f4;
    --field: #c9ced8;
    --accent: #2450c8;
    --accent-dark: #1a3c99;
    --accent-soft: #e8eefc;
    --night: #15181e;
    --night-raised: #262b35;
    --night-ink: #e9ecf2;
    --night-muted: #c9cfdb;
    /* State colors, fixed across Gantry; a state always has a word too. */
    --waiting: #7a4a00;
    --waiting-soft: #fdf1dc;
    --waiting-badge: #f2b544;
    --healthy: #1f6b3a;
    --healthy-soft: #e3f3e8;
    --danger: #a12a2a;
    --danger-soft: #fbe7e7;
    --expired: #4f5563;
    --expired-soft: #eceef2;
    --radius: 12px;
    --radius-small: 8px;
    --font-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-title: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Liberation Mono", monospace;
}

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

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

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: 15px;
    line-height: 1.5;
}

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

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

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

h1, h2, h3, h4 {
    font-family: var(--font-title);
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 12px;
}

h1 {
    font-size: 32px;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 18px;
}

h3 {
    font-size: 17px;
}

h4 {
    font-size: 15px;
    margin-top: 20px;
}

p {
    margin: 0 0 12px;
}

code, .mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

.muted {
    color: var(--muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* The shell: the menu on the left, the content on the right; the menu goes above on a phone. */

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

.sidebar {
    flex: 1 1 232px;
    max-width: 100%;
    background: var(--night);
    color: var(--night-ink);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    color: var(--night-ink);
    text-decoration: none;
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 20px;
}

.brand:hover {
    color: #ffffff;
}

.brand svg {
    flex: none;
}

.nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--radius-small);
    color: var(--night-muted);
    text-decoration: none;
    font-size: 14px;
}

.nav a:hover {
    background: var(--night-raised);
    color: #ffffff;
}

.nav a[aria-current="page"] {
    background: var(--night-raised);
    color: #ffffff;
    font-weight: 600;
}

.nav :focus-visible,
.sidebar :focus-visible {
    outline-color: #7fa0f5;
}

.badge {
    background: var(--waiting-badge);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 8px;
}

.account {
    margin-top: auto;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: var(--night-muted);
}

.account form {
    margin: 0;
}

.account .button {
    background: transparent;
    border-color: #4a5160;
    color: var(--night-ink);
    min-height: 40px;
}

.account .button:hover {
    background: var(--night-raised);
}

.content {
    flex: 999 1 560px;
    min-width: 0;
    padding: 40px 48px;
    max-width: 1200px;
}

.content > main > p:first-of-type,
.content > main > h1 + p {
    color: var(--muted);
    max-width: 760px;
}

@media (max-width: 720px) {
    .content {
        padding: 24px 16px;
    }

    .sidebar {
        padding: 16px;
        gap: 12px;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .account {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        margin-top: 0;
    }

    h1 {
        font-size: 26px;
    }
}

/* The sign-in screens: a panel that says what Gantry is for, then the form. */

.auth {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
}

.auth__panel {
    flex: 1 1 380px;
    background: var(--night);
    color: var(--night-ink);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
}

.auth__panel h2 {
    font-size: 36px;
    letter-spacing: -0.02em;
    max-width: 440px;
}

.auth__panel p {
    color: #b7becc;
    max-width: 440px;
}

.auth__main {
    flex: 999 1 420px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
}

.auth__main > .flashes {
    width: 100%;
    max-width: 420px;
}

.auth__main > main {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 32px;
}

.auth__step {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth__form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.auth__form .button {
    margin-top: 12px;
}

.auth__backup {
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .auth__panel {
        padding: 24px 16px;
        gap: 16px;
    }

    .auth__panel h2 {
        font-size: 24px;
    }

    .auth__main > .flashes {
    width: 100%;
    max-width: 420px;
}

.auth__main > main {
        padding: 24px 16px;
    }
}

/* Cards, tables, lists of facts. */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin: 0 0 24px;
}

.card > :last-child {
    margin-bottom: 0;
}

article {
    border-top: 1px solid var(--line-soft);
    padding-top: 20px;
    margin-top: 20px;
}

.table-scroll {
    /* Positioned, so the hidden headers stay inside the box instead of widening the page. */
    position: relative;
    overflow-x: auto;
    margin: 0 -24px;
    padding: 0 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    font-weight: 500;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}

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

td form {
    margin: 0 0 6px;
}

dl {
    display: grid;
    grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
    gap: 10px 24px;
    margin: 0 0 16px;
    font-size: 14px;
}

dt {
    color: var(--muted);
}

dd {
    margin: 0;
    min-width: 0;
}

@media (max-width: 520px) {
    dl {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }

    dd {
        margin-bottom: 10px;
    }
}

ul {
    padding-left: 20px;
}

.backup-codes {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    padding: 24px;
}

.secrets-changed {
    margin: 0 0 4px;
}

/* State pills: color and word. */

.pill {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 10px;
    background: var(--expired-soft);
    color: var(--expired);
    white-space: nowrap;
}

.pill--info {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.pill--waiting {
    background: var(--waiting-soft);
    color: var(--waiting);
}

.pill--healthy {
    background: var(--healthy-soft);
    color: var(--healthy);
}

.pill--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

/* The live health of an environment (lot 5, S16): the age of its read, after its pill. */

.health-read {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.health-read--stale {
    color: var(--waiting);
}

/* A card whose title has an action next to it. */

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-header h2,
.card-header form {
    margin: 0;
}

/* Flash messages and alerts. */

.flashes {
    margin: 0 0 24px;
}

.flashes p,
main p[role="alert"],
main p[role="status"] {
    border-radius: var(--radius-small);
    padding: 12px 16px;
}

.flashes p[role="status"] {
    background: var(--healthy-soft);
    color: var(--healthy);
}

.flashes p[role="alert"],
main p[role="alert"] {
    background: var(--waiting-soft);
    color: #5a3700;
}

main p[role="status"] {
    background: var(--expired-soft);
    color: var(--ink);
}

/* Forms: a label above its field, 44 px targets. */

label {
    font-size: 14px;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    display: block;
    width: 100%;
    max-width: 420px;
    min-height: 44px;
    margin-top: 6px;
    padding: 0 12px;
    border: 1px solid var(--field);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 400;
}

input[type="number"] {
    max-width: 160px;
}

#_auth_code,
#code {
    font-family: var(--font-title);
    font-size: 22px;
    letter-spacing: 0.2em;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0 8px 0 0;
    vertical-align: -3px;
    accent-color: var(--accent);
}

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    padding: 16px;
    margin: 0 0 16px;
    min-width: 0;
}

fieldset > label {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-weight: 400;
}

legend {
    font-weight: 600;
    padding: 0 6px;
}

form p label {
    display: block;
}

form p label:has(input) {
    display: inline;
}

details summary {
    cursor: pointer;
    color: var(--accent);
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* Buttons: primary, secondary, destructive; a bare button is secondary. */

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--field);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--ground);
    color: var(--ink);
}

.button--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.button--primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #ffffff;
}

.button--danger {
    color: var(--danger);
}

.button--danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 16px 0 0;
}

.actions form {
    margin: 0;
}

.back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 14px;
}

/* Lot 6, S18: a one-button form inside a description (the automatic rollback rule). */
.inline-form {
    display: inline;
    margin-left: 0.5rem;
}
