/* ═══════════════════════════════════════════════
   core.css — shared stylesheet for every page in the core module
   (login popup, sign-up page, and whatever comes next).
   Served from core/static/core/ via STATICFILES_DIRS ("core" prefix).

   Sections: green ramp → font → standalone page shell → frame → fields →
   actions → buttons → errors

   The .modal-* skeleton mirrors the staff subscription popup (staff.css
   §modal frames): <dialog|section class="modal-frame"> → .modal-box →
   .modal-title / .modal-fields / .modal-actions. Differences: a tighter
   vertical rhythm (these forms are short) and the green button ramp
   instead of the blue one. The sign-up PAGE reuses the same skeleton in a
   <section>, so the dedicated page and the popup read as one component.

   Token fallbacks are inline (var(--x, #hex)) so these rules still render
   correctly on a page that does not load the public shell stylesheet
   (library/main.css) — the sign-up page is exactly that case.
   ═══════════════════════════════════════════════ */

/* ════ 1. Green ramp — base #28a745 ════════════
   Redeclared here rather than imported: same values as the public shell,
   but this file must stand alone on pages that only need the dialog. */
:root {
    --color-green:        #28a745;
    --color-green-hover:  #2fbf52;
    --color-green-active: #1e7e34;
    --color-green-ring:   rgba(40,167,69,0.30);
    --color-error:        #d93025;
}

/* ════ 1b. Night mode ══════════════════════════
   Almost nothing is needed here: every colour in this file already reads a
   --color-* token, and library/library.css — which base_public always loads —
   redefines the whole set under [data-theme="night"]. Only the three places
   where the day value does not simply invert are corrected.

   The green ramp deliberately does NOT change: green means "confirm" in both
   themes, and #28a745 holds its contrast on the dark surface. */
[data-theme="night"] {
    /* #d93025 on the night surface falls to about 3:1. This is the same hue
       lifted until it clears 4.5:1, so the error line stays red without
       becoming the brightest thing on the page. */
    --color-error: #ff7a6b;
}

/* --color-text-light is the *page* light tone, and at night it is the dark
   navy — correct everywhere except here, where it is the label on a green
   fill that did not change. Pinned, or the confirm button reads dark-on-green. */
[data-theme="night"] .action-green {
    color: #ffffff;
}

/* Both are day-tinted literals that vanish against a dark ground. */
[data-theme="night"] .modal-frame {
    box-shadow: 0 3px 0 rgba(0,0,0,0.8), 0 24px 60px rgba(0,0,0,0.65);
}
[data-theme="night"] .modal-frame::backdrop {
    background-color: rgba(0,10,18,0.72);
}

/* ════ 2. Font + standalone page shell ═════════
   A core page that is NOT the public main page (sign-up) loads only this
   file, so it needs the brand font and a page background of its own. Both
   are scoped to body.core-page so nothing here can fight library/main.css
   on the root page, which loads both stylesheets. */
@font-face {
    font-family: 'Arsenal';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/arsenal-400-latin.654e88b7cee2.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
    font-family: 'Arsenal';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/arsenal-400-cyrillic.b4c9feb05cb7.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Arsenal';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/arsenal-700-latin.91b43c5422cd.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
    font-family: 'Arsenal';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/arsenal-700-cyrillic.529460ada88a.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

body.core-page {
    font-family: var(--font-family, 'Arsenal', Arial, sans-serif);
    background-color: var(--color-bg, #fffdf0);
    color: var(--color-text, #001624);
    margin: 0;
    padding: 0;
}

/* Centers the card the way ::backdrop centers the popup, with room to
   scroll on a short viewport instead of clipping the form. */
body.core-page .page-centered {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg, 24px) var(--space-md, 16px);
    box-sizing: border-box;
}

/* ════ 3. Frame ════════════════════════════════ */
.modal-frame {
    border: none;
    border-radius: var(--radius-lg, 12px);
    padding: 0;
    /* narrower than the staff popup's 520px — two fields need less room */
    width: min(400px, 92vw);
    box-shadow: 0 12px 32px rgba(0,22,36,0.3);
    background-color: var(--color-surface, #ffffff);
}
.modal-frame::backdrop {
    background-color: rgba(0,22,36,0.55);
}

/* Page variant: the same frame rendered as a <section> on a dedicated page
   instead of a <dialog>. A dialog gets margin:auto from the UA stylesheet;
   a section does not. Slightly wider — six labelled fields, and a page has
   room a popup does not. */
.modal-frame-page {
    margin: 0 auto;
    width: min(460px, 92vw);
}

.modal-box {
    /* staff popup uses --space-lg (24px); the compact form drops to 20px/16px */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md, 16px);
    margin: 0;
    width: auto;
}

.modal-title {
    margin: 0;
    font-size: var(--font-size-lg, 22px);
    font-weight: 700;
    color: var(--color-primary, #00548a);
    text-align: center;
}

/* ════ 4. Fields ═══════════════════════════════ */
.modal-fields {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs, 4px);
}
.modal-fields label {
    font-size: var(--font-size-xs, 14px);
    font-weight: 700;
    color: var(--color-text-muted, #5b7284);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
/* second and later labels need air above them; the first sits right under
   the title, which already has the box gap */
.modal-fields label + input {
    margin-bottom: var(--space-sm, 8px);
}
.modal-fields input {
    padding: 8px 12px;
    border: 1px solid var(--color-border, #d6e5f0);
    border-radius: var(--radius-md, 8px);
    font-size: var(--font-size-sm, 17px);
    font-family: var(--font-family, 'Arsenal', Arial, sans-serif);
    color: var(--color-text, #001624);
    background-color: var(--color-surface, #ffffff);
    box-sizing: border-box;
    width: 100%;
}
.modal-fields input:focus {
    outline: none;
    border-color: var(--color-green);
    box-shadow: 0 0 0 3px var(--color-green-ring);
}

/* A field that failed its HTML constraint on blur. Only ever set by
   core.js — :invalid on its own would paint every required field red
   before the visitor has typed a character. */
.modal-fields input.field-invalid {
    border-color: var(--color-error);
}
.modal-fields input.field-invalid:focus {
    box-shadow: 0 0 0 3px rgba(217,48,37,0.20);
}

/* ── Grouped fields (sign-up page) ──────────────
   The popup's two fields sit flat in .modal-fields; a form with six fields
   and a per-field error line needs each label/input/error kept together, or
   the error reads as belonging to the next field down. */
.modal-fields .field-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs, 4px);
}
.modal-fields .field-group + .field-group {
    margin-top: var(--space-sm, 8px);
}
/* the flat-layout spacing rule must not apply inside a group */
.modal-fields .field-group label + input {
    margin-bottom: 0;
}

/* ════ 5. Actions — Cancel left, confirm right, one line ═
   space-between pins the pair to the two edges; nowrap keeps them on the
   same line at every width, and the flex-basis lets them shrink instead
   of stacking on a narrow phone. */
.modal-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm, 8px);
}
.modal-actions .action-button {
    flex: 0 1 auto;
    min-width: 108px;
}

.action-button {
    display: block;
    padding: 9px var(--space-md, 16px);
    /* transparent border, not none: .action-neutral draws a real 1px border and
       without this the two buttons in the same row differ by 2px in height */
    border: 1px solid transparent;
    border-radius: var(--radius-md, 8px);
    font-family: var(--font-family, 'Arsenal', Arial, sans-serif);
    font-size: var(--font-size-base, 19px);
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.2s, box-shadow 0.2s;
}
.action-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-green-ring);
}

.action-green {
    background-color: var(--color-green);
    color: var(--color-text-light, #ffffff);
}
.action-green:hover {
    background-color: var(--color-green-hover);
}
.action-green:active {
    background-color: var(--color-green-active);
}
.action-green[disabled],
.action-green[disabled]:hover {
    background-color: var(--color-border, #d6e5f0);
    color: var(--color-text-muted, #5b7284);
    cursor: default;
}

.action-neutral {
    background-color: transparent;
    color: var(--color-primary, #00548a);
    border: 1px solid var(--color-border, #d6e5f0);
}
.action-neutral:hover {
    background-color: rgba(40,167,69,0.10);
}
.action-neutral:active {
    background-color: rgba(40,167,69,0.18);
}

/* ════ 6. Errors ═══════════════════════════════
   Same red, same regular weight in both places; they differ only in
   alignment, because a per-field message belongs to the field above it
   while the form-level one is centred under the button row. */
.modal-error,
.field-error {
    margin: 0;
    color: var(--color-error);
    font-size: var(--font-size-sm, 17px);
    font-weight: 400;
}
.modal-error {
    text-align: center;
}
.field-error {
    text-align: left;
    /* 17px under a 14px label is loud for an inline hint, but the two error
       kinds were specified to share a style — only the size steps down */
    font-size: var(--font-size-xs, 14px);
}
