/* HearthDAoC's one stylesheet (#237 design 5): theme A, the client splash's night and gold. Our own files only (the
   font is static/cinzel.ttf), and no inline style anywhere. Pages use the tokens on :root and no colour of their own.

   Dark is the page's own (#237 design 5.1). The server marks <html> with a logged-in account's Appearance:
   data-theme="light", or "system" (light only under a light preference); the pages before a login carry none, so they
   are dark. Each token is light-dark(light, dark), so its two values are written once and color-scheme picks one. A
   browser without light-dark() (before 2024) leaves the tokens out and shows its own dark colours, still readable. */

@font-face {
    font-family: "Cinzel";
    src: url("/static/cinzel.ttf");
    font-weight: 400 900;
    font-display: swap;
}

/* The tokens (#237 design 5's table; ThemeTests checks every pair the pages use for contrast). Two moved a small step
   for it: --edge in light (#8a93a2 to #7b8493, 3:1 on the open row) and --warn in light (#8a6a12 to #82620a). */
:root {
    color-scheme: dark;
    --bg: light-dark(#eef0f3, #151a24);         /* the page: cool stone, night */
    --card: light-dark(#ffffff, #1d2431);       /* notices, the invite form */
    --field: light-dark(#ffffff, #121620);      /* inside inputs and selects */
    --line: light-dark(#d3d8e0, #2a3242);       /* table and section rules: decorative */
    --edge: light-dark(#7b8493, #646f86);       /* the borders of inputs, selects and outlined buttons */
    --fg: light-dark(#1b2130, #ebe5d8);         /* text: night ink, parchment */
    --muted: light-dark(#5b6475, #a29a8a);      /* secondary text, table heads */
    --title: light-dark(#6e5112, #d6ad55);      /* page titles, the open row's edge: gold */
    --link: light-dark(#a8481a, #e9a15f);       /* links, summaries */
    --btn: light-dark(#b8501c, #d9662a);        /* the main button: ember */
    --onbtn: light-dark(#ffffff, #1a1208);
    --bad: light-dark(#a3261f, #ef8a7f);        /* errors, danger buttons */
    --onbad: light-dark(#ffffff, #1a0d0b);
    --ok: light-dark(#2f6b3f, #86c495);
    --warn: light-dark(#82620a, #e0b04a);
    --sel: light-dark(#d6ad5526, #d6ad5514);    /* the open row and its strip: gold at 15%, 8% */
    --focus: light-dark(#b8501c, #d6ad55);      /* the focus ring: ember, gold */
    /* The header, the same in both themes: night and gold. */
    --head: #0f131b;
    --head-gold: #d6ad55;
    --head-rule: #d6ad5566;
    --head-fg: #c9c1b1;
    --head-name: #ebe5d8;
    --head-link: #e9b26f;
}
:root[data-theme=light] { color-scheme: light; }
@media (prefers-color-scheme: light) {
    :root[data-theme=system] { color-scheme: light; }
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* The header: the mark and the wordmark, a link home, then the nav; a thin gold rule under it. */
header {
    color-scheme: dark;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--head);
    color: var(--head-fg);
    border-bottom: 1px solid var(--head-rule);
}
header .brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--head-gold);
    text-decoration: none;
    font-family: "Cinzel", serif;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.05em;
}
header .mark { display: block; flex: none; }
header nav { font-size: 12.5px; }
header nav b { color: var(--head-name); }
/* Each link on one line: the nav wraps only between them (at 360 px it broke "Site settings" in two). */
header nav a, header nav form.inline button { color: var(--head-link); white-space: nowrap; }
header :focus-visible { outline-color: var(--head-gold); }

main, footer { max-width: 54rem; margin: 0 auto; }
main { padding: 14px 16px 18px; }
footer { padding: 0 16px 16px; font-size: 12.5px; color: var(--muted); }
footer p { margin: 0; }

h1 {
    font-family: "Cinzel", serif;
    font-weight: 600;
    font-size: 22px;
    letter-spacing: 0.03em;
    color: var(--title);
    margin: 2px 0 12px;
}
h2 { font-size: 15px; margin: 20px 0 6px; }
a { color: var(--link); }
/* A ring on every control and link that has the keyboard's focus. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.small { font-size: 12.5px; color: var(--muted); }
code { overflow-wrap: anywhere; }
/* A time never breaks inside itself ("Nov 28, 12:56 / PM"): it goes to the next line whole. */
time { white-space: nowrap; }

form { margin: 12px 0; }
form.inline { display: inline; margin: 0; }
label { display: block; margin: 8px 0; }
label.check { display: flex; gap: 8px; align-items: center; }
form.filter { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
form.filter label { margin: 0; }

/* One compact size: buttons, inputs and selects 30 px high, 13.5 px text; a link that looks like a button
   (a.button: it only opens a page state, #237 design 8.4) takes the button's rules by their selectors. */
button, a.button, input, select { font: inherit; font-size: 13.5px; }
button, a.button, select, input:not([type=checkbox]):not([type=hidden]) { height: 30px; border-radius: 3px; }
input:not([type=checkbox]):not([type=hidden]), select {
    display: block;
    width: 100%;
    max-width: 22rem;
    margin-top: 3px;
    padding: 0 8px;
    border: 1px solid var(--edge);
    background: var(--field);
    color: var(--fg);
}
input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--btn); }
/* The button kinds: the main action (ember, filled); .second, outlined and quiet; .danger, a red outline; .danger.go,
   filled red, the question's own button when it takes something away (#237 design 8.3). */
button, a.button {
    padding: 0 12px;
    border: 1px solid var(--btn);
    background: var(--btn);
    color: var(--onbtn);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
button.second, a.button.second { border-color: var(--edge); background: transparent; color: var(--fg); }
button.danger, a.button.danger { border-color: var(--bad); background: transparent; color: var(--bad); }
button.danger.go { background: var(--bad); color: var(--onbad); }
a.button { display: inline-flex; align-items: center; text-decoration: none; }
/* The open row's Change, drawn pressed: following it again closes the row (#237 design 7). */
a.button[aria-expanded=true] { border-color: var(--title); color: var(--title); }
/* A form's button that reads as a link (Log out). */
form.inline button {
    height: auto;
    padding: 0;
    border: none;
    background: none;
    color: var(--link);
    font: inherit;
    text-decoration: underline;
}
/* A phone zooms in on a field whose text is under 16 px. */
@media (max-width: 40rem) {
    input:not([type=checkbox]):not([type=hidden]), select { font-size: 16px; }
}

/* A line of same-size controls (the open row's strip, a question's form), wrapping on a narrow screen; .push goes to
   the right, last. */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.bar label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.bar input:not([type=checkbox]):not([type=hidden]), .bar select { width: auto; margin-top: 0; }
.bar .push { margin-left: auto; }
/* A question (#237 design 8.3): the question in bold and what follows muted, on one line; under it the fields, each
   label over its field, then the confirm button and Keep. The invite form (.bar.card, #237 design 9) is such a line
   too, on a card. */
.question > p { margin: 2px 0 8px; }
.question > p span { color: var(--muted); }
.question .bar, .bar.card { align-items: end; }
.question .bar label, .bar.card label {
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    font-size: 12.5px;
    color: var(--muted);
}
.card { margin: 12px 0; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.bar.card input[type=email] { width: 15rem; }
.bar.card input[type=password] { width: 8rem; }
.bar.card input[name=code] { width: 6.5rem; }
/* The confirm button and Keep, one item of the line (Question.Html's span.answer): they wrap together, so Keep never
   sits alone on a line, and side by side; on a line too narrow for both, Keep goes under the button, its text (no
   padding before it) at the fields' edge. CSS alone can't keep two items of a wrapping line together: reserving
   Keep's room with a negative margin needs a fixed width, and on a phone sent Keep off the line's left edge. */
.question .answer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
a.keep { display: inline-flex; align-items: center; height: 30px; }
/* On a narrow screen those fields take the full width, one to a line, the button after them (side by side they came
   out of uneven widths). As specific as the invite form's widths above, and later, so it wins. */
@media (max-width: 40rem) {
    .question .bar label, .bar.card label { flex: 1 1 100%; }
    .question .bar input:not([type=checkbox]):not([type=hidden]), .question .bar select,
    .bar.card input:not([type=checkbox]):not([type=hidden]), .bar.card select { width: 100%; max-width: none; }
}

/* Tables: a muted, ruled head and ruled rows. One wider than the screen scrolls sideways in its own box (.wide), so
   the page never does. */
.wide { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 10px;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
/* The open row (the one being changed, #237 design 7) and the strip under it, highlighted alike, a gold edge left. */
tr.open td { background: var(--sel); border-bottom-color: transparent; }
tr.open td:first-child, tr.strip td { box-shadow: inset 3px 0 0 var(--title); }
tr.strip td { background: var(--sel); padding: 4px 10px 12px 14px; }
table.accounts td, table.invites td { vertical-align: middle; }
td.end { width: 1%; white-space: nowrap; text-align: right; }
/* The open and past invites line up when wide: one fixed layout, the same widths for Email, Role and Sent in both
   tables, the rest to what follows them. Role fits "Administrator" and Cancel's column its button (88 and 71 px in
   Chromium's Noto Sans, with room to spare); at 41rem the badge still fits beside them. An email may break before its
   @ (the page's <wbr>), else anywhere (a long one). On a phone each table lays itself out (below). */
@media (width > 40rem) {
    table.invites { table-layout: fixed; }
    .invites th:nth-child(1) { width: 27%; }
    .invites th:nth-child(2) { width: 7.5rem; }
    .invites th:nth-child(3) { width: 20%; }
    .invites th:nth-child(5) { width: 6.5rem; }
}
.invites tr:not(.strip) td:first-child { overflow-wrap: anywhere; }
/* The owner's pick A (#237 design 7): on a phone the Accounts table fits the screen, its Email and Authenticator
   columns hidden (.wide-only), and the open strip shows them first on a muted line (.narrow-only). The Invites tables
   the same way (#237 design 9): Role and Sent hide and show again under the email, which may break (above). */
.facts { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.narrow-only { display: none; }
@media (max-width: 40rem) {
    .wide-only { display: none; }
    .narrow-only { display: block; }
    .accounts th, .accounts tr:not(.strip) td, .invites th, .invites tr:not(.strip) td {
        padding-left: 6px;
        padding-right: 6px;
    }
}

/* Notices: a note, a warning, an error. */
.note, .warn, .error { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--title); background: var(--card); }
.warn { border-left-color: var(--warn); }
.error { border-left-color: var(--bad); color: var(--bad); }

/* The status page: two lights (part D1 design 13). */
.state { font-weight: 600; }
.state.up { color: var(--ok); }
.state.starting, .state.stuck { color: var(--warn); }
.state.down { color: var(--bad); }
.state.none, .state.unknown { color: var(--muted); }
dl.status .since { font-size: 12.5px; color: var(--muted); }
dl.status { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 6px 0 12px; }
dl.status dt { color: var(--muted); }
dl.status dd { margin: 0; }

/* The settings page's rows, and the set-up's pieces. */
.row {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 4px 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.row h2 { margin: 0; font-size: 14px; }
.row > div > p:first-child { margin-top: 0; }
@media (max-width: 30rem) { .row { grid-template-columns: 1fr; } }
.key { font-family: ui-monospace, monospace; font-size: 15px; letter-spacing: 0.05em; }
.qr svg { display: block; width: 12rem; height: 12rem; margin: 8px 0; }
.codes { font-family: ui-monospace, monospace; columns: 2; }
.once { margin: 16px 0; }
.hint { display: block; font-size: 12.5px; margin: -4px 0 8px; color: var(--muted); }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--bad); }
details > summary { cursor: pointer; color: var(--link); }
/* The Invites page (#237 design 9): its past invites folded under a summary, and each state one badge, a small rounded
   outline in its own colour: gold while open, green used, muted cancelled or ran out. */
main > details > summary { margin: 20px 0 6px; font-weight: 600; }
.badge {
    display: inline-block;
    padding: 0 8px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge.open { color: var(--title); }
.badge.used { color: var(--ok); }
.badge.gone { color: var(--muted); border-color: var(--edge); }
/* The set-up that covers a page when the account must set up an authenticator now (live.js). */
.cover {
    position: fixed;
    inset: 0;
    overflow: auto;
    background: var(--bg);
    padding: 16px;
}
