/* portal.css, the interface for both modes.
 *
 * This is a business tool for photographers, technicians and tradespeople, not
 * a dashboard for engineers. So: generous type, buttons that look like buttons,
 * one column on a phone, and plenty of room. Nobody here has been trained on
 * any of it, and nobody is going to read a manual first.
 *
 * Bare elements are styled as well as classes. Views are written by several
 * hands, and a screen that only used h1, p, table, label and button should
 * still come out looking like the rest of the portal.
 *
 * Light and dark both come from prefers-color-scheme. There is no theme switch,
 * because a theme switch is a preference to store and a Partner already told
 * their operating system what they wanted.
 */

:root {
    color-scheme: light dark;

    --color-bg: #f6f6f3;
    --color-surface: #ffffff;
    --color-surface-sunk: #f0f0ec;
    --color-text: #1a1c1f;
    --color-text-muted: #585d64;
    --color-line: #e2e2dc;
    --color-line-strong: #c6c6be;

    --color-accent: #1f56c3;
    --color-accent-hover: #1a4aa8;
    --color-accent-text: #ffffff;
    --color-accent-soft: #e7eefb;

    --color-ok-text: #14563f;
    --color-ok-soft: #e0f2e9;
    --color-warn-text: #6f4602;
    --color-warn-soft: #fbeed3;
    --color-error-text: #86201f;
    --color-error-soft: #fae4e3;

    /* The impersonation banner keeps the same strong pair in both schemes. It
       is the one thing on the page that must not blend in anywhere. */
    --color-alert-bg: #8a1c1c;
    --color-alert-text: #ffffff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --shadow-card: 0 1px 2px rgba(20, 22, 26, .06), 0 6px 20px rgba(20, 22, 26, .05);

    --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --wrap: 64rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #13151a;
        --color-surface: #1b1e25;
        --color-surface-sunk: #23262e;
        --color-text: #e9e9e5;
        --color-text-muted: #a3a8b1;
        --color-line: #2b2f38;
        --color-line-strong: #3d424d;

        --color-accent: #7ba5f5;
        --color-accent-hover: #9dbcf8;
        --color-accent-text: #10161f;
        --color-accent-soft: #1d2941;

        --color-ok-text: #92dfbd;
        --color-ok-soft: #12281f;
        --color-warn-text: #f0c477;
        --color-warn-soft: #2c2313;
        --color-error-text: #f2a7a4;
        --color-error-soft: #2e1817;

        --shadow-card: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

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

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

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font: 400 17px/1.65 var(--font-body);
    -webkit-font-smoothing: antialiased;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ---- Skip link ------------------------------------------------------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: .75rem 1rem;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 0 0 var(--radius-md) 0;
    z-index: 20;
}

.skip-link:focus { left: 0; }

/* ---- Acting as somebody else ----------------------------------------- */

/* Sticky, so it is still there four screens down a long page. Scrolling past a
   warning is the ordinary way somebody stops seeing it. */
.impersonation {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-alert-bg);
    color: var(--color-alert-text);
    padding: .9rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid rgba(255, 255, 255, .35);
}

.impersonation p { margin: 0; }
.impersonation-text { max-width: 52rem; font-size: 1rem; }
.impersonation-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.impersonation .btn-quiet {
    background: var(--color-alert-text);
    color: var(--color-alert-bg);
    border-color: transparent;
}

.impersonation .btn-quiet:hover { background: #f0e6e6; }

.impersonation-back {
    color: var(--color-alert-text);
    text-decoration: underline;
    white-space: nowrap;
}

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

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-line);
}

.topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 2rem;
    min-height: 4.25rem;
    padding-top: .6rem;
    padding-bottom: .6rem;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -.015em;
    color: var(--color-text);
    text-decoration: none;
}

.brand:hover { color: var(--color-accent); }

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
    margin-left: auto;
}

.nav a {
    display: inline-block;
    padding: .55rem 0;
    color: var(--color-text-muted);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.nav a:hover { color: var(--color-text); }

.nav a.is-active {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
}

/* ---- The page -------------------------------------------------------- */

.page {
    padding-top: 2.5rem;
    padding-bottom: 4rem;
    min-height: 55vh;
}

h1, h2, h3 {
    line-height: 1.25;
    letter-spacing: -.015em;
    font-weight: 600;
    margin: 0 0 .75rem;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 2.25rem; }
h3 { font-size: 1.1rem; margin-top: 1.75rem; }

p { margin: 0 0 1.1rem; max-width: 42rem; }

.lead { font-size: 1.15rem; }
.muted { color: var(--color-text-muted); }
.small { font-size: .95rem; }

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

hr {
    border: 0;
    border-top: 1px solid var(--color-line);
    margin: 2.5rem 0;
}

/* Focus is never removed. Somebody keyboarding through a form has to be able
   to see where they are. */
:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ---- Cards ----------------------------------------------------------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.75rem;
    margin: 0 0 1.5rem;
}

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

.card-title { font-size: 1.2rem; margin-bottom: .35rem; }

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

.flash {
    max-width: none;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 500;
    margin-bottom: 2rem;
}

.flash-ok { background: var(--color-ok-soft); color: var(--color-ok-text); border-color: currentColor; }
.flash-warn { background: var(--color-warn-soft); color: var(--color-warn-text); border-color: currentColor; }
.flash-error { background: var(--color-error-soft); color: var(--color-error-text); border-color: currentColor; }

/* ---- Buttons --------------------------------------------------------- */

.btn,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 3rem;
    padding: .7rem 1.4rem;
    font: 600 1rem/1.3 var(--font-body);
    text-decoration: none;
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.btn:hover,
button:hover,
input[type="submit"]:hover { background: var(--color-surface-sunk); color: var(--color-text); }

.btn-primary,
button.btn-primary,
input[type="submit"] {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-text);
}

.btn-primary:hover,
button.btn-primary:hover,
input[type="submit"]:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: var(--color-accent-text);
}

.btn-danger {
    background: var(--color-error-soft);
    border-color: currentColor;
    color: var(--color-error-text);
}

.btn-quiet { background: transparent; }

.btn[disabled], button[disabled] { opacity: .5; cursor: not-allowed; }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    margin: 1.5rem 0 0;
}

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

form { margin: 0; }

.field { margin: 0 0 1.5rem; max-width: 32rem; }

.field label,
label.field-label {
    display: block;
    font-weight: 600;
    margin-bottom: .35rem;
}

.hint {
    display: block;
    margin: .35rem 0 0;
    color: var(--color-text-muted);
    font-size: .95rem;
    max-width: none;
}

.field-error {
    display: block;
    margin: .35rem 0 0;
    color: var(--color-error-text);
    font-weight: 500;
    font-size: .95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="search"],
select,
textarea {
    display: block;
    width: 100%;
    min-height: 3rem;
    padding: .65rem .85rem;
    font: 400 1.05rem/1.4 var(--font-body);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-sm);
}

textarea { min-height: 9rem; resize: vertical; }

input:focus, select:focus, textarea:focus { border-color: var(--color-accent); }

.field-invalid input,
.field-invalid select,
.field-invalid textarea { border-color: var(--color-error-text); }

.checkbox {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    margin: 0 0 1rem;
    max-width: 34rem;
}

.checkbox input[type="checkbox"] {
    width: 1.35rem;
    height: 1.35rem;
    margin-top: .15rem;
    flex: none;
    accent-color: var(--color-accent);
}

.checkbox label { font-weight: 500; }

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

/* Wrap a table in this on a screen that has more columns than a phone has
   room for. The page itself must never scroll sideways. */
.table-scroll { overflow-x: auto; margin: 0 0 1.5rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

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

th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: .9rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:hover { background: var(--color-surface-sunk); }

/* ---- Small pieces ---------------------------------------------------- */

.pill {
    display: inline-block;
    padding: .2rem .7rem;
    border-radius: var(--radius-full);
    background: var(--color-surface-sunk);
    color: var(--color-text-muted);
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill-ok { background: var(--color-ok-soft); color: var(--color-ok-text); }
.pill-warn { background: var(--color-warn-soft); color: var(--color-warn-text); }
.pill-error { background: var(--color-error-soft); color: var(--color-error-text); }

.token {
    display: block;
    padding: .85rem 1rem;
    background: var(--color-surface-sunk);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .95rem;
    word-break: break-all;
    max-width: none;
}

.empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-surface-sunk);
    border-radius: var(--radius-lg);
}

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

.site-footer {
    border-top: 1px solid var(--color-line);
    padding: 1.75rem 0;
    color: var(--color-text-muted);
    font-size: .95rem;
}

.site-footer p { margin: 0; max-width: none; }

/* ---- Phones ---------------------------------------------------------- */

@media (max-width: 40rem) {
    body { font-size: 16.5px; }

    .topbar-inner { align-items: flex-start; }
    .nav { margin-left: 0; width: 100%; gap: .25rem 1rem; }

    .page { padding-top: 1.75rem; }

    h1 { font-size: 1.6rem; }

    .card { padding: 1.25rem; border-radius: var(--radius-md); }

    .field { max-width: none; }

    /* A button that fills the row is a button nobody misses with a thumb. */
    .btn-row { flex-direction: column; align-items: stretch; }
    .btn-row .btn, .btn-row button { width: 100%; }

    /* It stays sticky on a phone too, so it is tightened rather than dropped.
       A quarter of a small screen is a fair price for knowing whose account
       this is. */
    .impersonation { padding: .7rem 1.25rem; gap: .5rem 1rem; }
    .impersonation-text { font-size: .95rem; }
    .impersonation .btn { min-height: 2.6rem; padding: .5rem 1rem; font-size: .95rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* The standalone fallback page shown when a form is refused for a bad token.
   It is served without the shell, so it styles itself off the tokens above. */
.fallback-page {
    max-width: 34rem;
    margin: 4rem auto;
    padding: 0 1.25rem;
    color: var(--color-text);
}
.fallback-page h1 {
    font-size: 1.4rem;
    margin: 0 0 0.75rem;
}
.fallback-page p {
    margin: 0 0 0.75rem;
    color: var(--color-text-muted);
}
