/* SGC VM Auswertung — design foundation (TASK-021).
   Taken from fsta-auswertung's app.css so the sister applications look alike:
   the same tokens, header, navigation, card, form, alert and button blocks.
   Plain, high-contrast, no framework, no build step. Later pages reuse these
   blocks instead of adding page-specific CSS; what FSTA has beyond them
   (tables, tabs, help pages) comes over with the task that first needs it. */

/* ---------------------------------------------------------------- tokens */
:root {
    /* Accent: FSTA's dark red, so the two applications read as one family.
       One token to change if this one should get a colour of its own. */
    --color-accent: #8b0000;
    --color-accent-dark: #6d0000;
    --color-accent-soft: #f7ecec;

    --color-text: #1a1a1a;
    --color-text-muted: #5c5c5c;
    --color-bg: #ffffff;
    --color-bg-subtle: #f5f4f3;
    --color-border: #cfcbc8;
    --color-border-strong: #9a9490;

    --color-error: #8b0000;
    --color-error-bg: #fbeaea;
    --color-success: #1e6b32;
    --color-success-bg: #e9f4ec;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;

    --radius: 3px;
    --border: 1px solid var(--color-border);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);

    /* Comfortable hit area for touch use during result entry. */
    --touch-target: 2.75rem;
    --content-width: 74rem;
}

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

/* overflow-anchor: none is deliberate and global (CLAUDE.md, lessons from the
   sister projects). When an HTMX swap removes the element that has the focus,
   Chrome corrects the scroll position against an anchor that no longer exists
   and lands at the bottom of the page. Switched off rather than raced with a
   scroll of our own. */
html {
    font-family: var(--font-sans);
    font-size: 100%;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-subtle);
    -webkit-text-size-adjust: 100%;
    overflow-anchor: none;
}

/* Not a flex column: there is no footer to push down. If one is added, read
   FSTA's note first — a flex child with auto margins shrinks to fit, and
   .app-main then needs width: 100% (CLAUDE.md). min-height uses dvh, not vh,
   so a phone's address bar does not make a page that fits scroll. */
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
}

h1,
h2,
h3 {
    line-height: 1.25;
    margin: 0 0 var(--space-4);
    font-weight: 600;
}

h1 {
    font-size: var(--font-size-2xl);
}

h2 {
    font-size: var(--font-size-xl);
}

h3 {
    font-size: var(--font-size-lg);
}

p {
    margin: 0 0 var(--space-4);
}

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

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

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

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

/* ---------------------------------------------------------------- header */
.app-header {
    background: var(--color-bg);
    border-bottom: 3px solid var(--color-accent);
    box-shadow: var(--shadow);
}

/* Two rows on purpose, unlike FSTA's one: brand and session above, the
   navigation as a full row below. Nine entries, the brand and "angemeldet als …"
   need some 1380px against the 1152px of the content width, so one row was never
   going to hold — and left to flex-wrap, the session block broke onto a second
   row at the left edge, under the brand, where it read as an accident. Looked at
   in Chrome at 1280px and 390px (TASK-021). */
.app-header__bar {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4) 0;
    display: flex;
    align-items: center;
    gap: var(--space-2) var(--space-5);
    flex-wrap: wrap;
}

/* No bottom padding above, so the current entry's underline sits on the
   header's border. Without a navigation (the login page) the brand would then
   touch the border, so it gets the padding back. */
.app-header__bar:not(:has(.nav)) {
    padding-bottom: var(--space-3);
}

.app-header__brand {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--color-text);
}

.app-header__title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.02em;
}

.app-header__subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ------------------------------------------------------------------- nav */
/* Its own row (order and flex-basis), whatever its place in the markup. The
   negative margin lines the first label up with the brand above it, which the
   link's own padding would otherwise push in. */
.nav {
    order: 1;
    flex-basis: 100%;
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
    margin-left: calc(-1 * var(--space-3));
}

/* No box in any state (TASK-038). A grey background on hover or on the current
   entry belonged neither to the white header nor to the content below it. */
.nav__link {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target);
    padding: 0 var(--space-3);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
}

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

/* The current entry: dark red and bold, nothing else — no box, no bar, no
   underline (Patrick's decision, TASK-038). Hover is dark red but not bold, so
   the two stay distinct. The layout sets aria-current="page" as well, which is
   what a screen reader announces; the class is only the paint. */
.nav__link--active {
    color: var(--color-accent);
    font-weight: 700;
}

/* --------------------------------------------------------- session block */
/* Who is logged in, and the logout button beside it — last in the header bar.
   The logout is a form (POST /logout), so the block keeps the form from adding
   a margin of its own. */
.app-header__session {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 0 auto;
}

.app-header__user {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ------------------------------------------------------------------ main */
.app-main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-6) var(--space-4) var(--space-7);
}

/* ------------------------------------------------------------------ card */
.card {
    background: var(--color-bg);
    border: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

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

/* Narrow card for focused forms such as the login page. */
.card--narrow {
    max-width: 26rem;
    margin-left: auto;
    margin-right: auto;
}

/* ----------------------------------------------------------------- forms */
.form__row {
    margin-bottom: var(--space-4);
}

label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: 600;
    font-size: var(--font-size-sm);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: var(--touch-target);
    padding: var(--space-2) var(--space-3);
    font: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
}

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

/* A field the server refused (TASK-030, the admin-page pattern). */
input[aria-invalid="true"],
.is-invalid {
    border-color: var(--color-error);
    background: var(--color-error-bg);
}

.form__hint {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* A field shown but not editable — a competition's code on its edit form
   (TASK-031). The span carries the label's look without being a <label>, which
   would point at an input that is not there. */
.label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.readonly-value {
    margin: 0;
    padding: var(--space-2) 0;
}

/* The message under a refused field. */
.field-error {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-error);
}

/* Form- or page-level messages. */
.alert {
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-bg-subtle);
    margin-bottom: var(--space-4);
}

.alert--error {
    border-left-color: var(--color-error);
    background: var(--color-error-bg);
    color: var(--color-error);
}

.alert--success {
    border-left-color: var(--color-success);
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* --------------------------------------------------------------- buttons */
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch-target);
    padding: 0 var(--space-4);
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
}

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

.button--secondary {
    color: var(--color-text);
    background: var(--color-bg);
    border-color: var(--color-border-strong);
}

.button--secondary:hover {
    background: var(--color-bg-subtle);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* The glyph inside a button, stroked in currentColor so it follows the label
   through :hover and :focus-visible. flex-shrink: 0 because an inline svg has
   no intrinsic width and is the first thing a cramped flex row squeezes away;
   the svg elements carry width/height attributes for the same reason. */
.button svg,
button svg {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.button-row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-5);
}

/* Beside a page heading (the season's actions). */
.button-row--tight {
    margin-top: 0;
}

/* A POST action inside a table row (TASK-032: "Aktivieren"): a form, because
   it changes state and carries the CSRF token, painted like the row's links. */
.inline-form {
    display: inline;
    margin: 0;
}

.button--link,
.button--link:hover {
    display: inline;
    min-height: 0;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-accent);
    font-weight: inherit;
    text-decoration: underline;
}

.button--link:hover {
    color: var(--color-accent-dark);
}

/* Result entry (TASK-040): a score field wide enough for 4 digits, nothing
   more, so 30 rows stay one screen wide on a phone. */
input.input--score {
    width: 4.5rem;
}

table.entry select {
    width: auto;
    min-width: 5.5rem;
}

table.entry td.vm {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* An inactive competitor under "alle" (TASK-036): still listed, quieter. */
.row--inactive td {
    color: var(--color-text-muted);
}

/* Status words in a heading or a cell — abgeschlossen, aktiv. From fsta-auswertung. */
.badge {
    display: inline-block;
    padding: 0 var(--space-2);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

.badge--accent {
    color: #fff;
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.plain-list {
    margin: 0 0 var(--space-4);
    padding-left: var(--space-5);
}

/* The state of a season competition's 100er Limiten on the season detail page. */
.limits--incomplete {
    color: var(--color-error);
    font-weight: 600;
}

.limits--notNeeded {
    color: var(--color-text-muted);
}

section + section {
    margin-top: var(--space-6);
}

/* ------------------------------------------------- whole-table forms (TASK-033) */
/* A label beside a checkbox or in a table cell: the row's text, not a field
   caption above an input. */
.label--plain {
    display: inline;
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

/* A number in a table or a short row of fields — a maximum, a column. Narrow
   enough that a phone keeps the competition's name readable beside it. */
input.input--narrow {
    width: 5.5rem;
}

/* The 100er Limiten grids (TASK-034): four equal columns, so the three age
   groups line up from one competition to the next. */
table.limiten {
    table-layout: fixed;
}

table.limiten input.input--narrow {
    width: 100%;
    max-width: 5.5rem;
}

input.input--column {
    width: 3.5rem;
    min-height: 2.25rem;
    margin-right: var(--space-2);
    text-align: center;
}

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--color-accent);
}

/* The three Feld maxima side by side, wrapping on a phone. */
.form__inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-5);
}

.row--invalid td {
    background: var(--color-error-bg);
}

/* One combination of the combinations form. */
.combination {
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg);
    border: var(--border);
    border-radius: var(--radius);
}

.combination legend {
    padding: 0 var(--space-1);
    font-weight: 600;
}

.combination--invalid {
    border-color: var(--color-error);
}

.member-list {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2 16rem;
    column-gap: var(--space-5);
}

.member-list li {
    display: flex;
    align-items: center;
    padding: var(--space-1) 0;
    break-inside: avoid;
}

/* A link back above a page's first section, below its heading. */
.back-link--top {
    margin-top: calc(-1 * var(--space-3));
}

/* A link back to the list, below a page's last table — not glued to it. */
.back-link {
    margin-top: var(--space-5);
}

/* A page heading with an action beside it — "Waffen" and "Neue Waffe". */
.card__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

/* ---------------------------------------------------------------- tables */
/* From fsta-auswertung (TASK-030 is the first list): dense but readable, and a
   wide table scrolls inside its wrapper instead of widening the page. */
/* position: relative contains the .visually-hidden column headings: absolutely
   positioned with no positioned ancestor, they escaped this frame's clipping
   and widened the whole page on a phone (seen in TASK-031, 463px of 390). */
.table-wrap {
    position: relative;
    overflow-x: auto;
    background: var(--color-bg);
    border: var(--border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

th,
td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

thead th {
    background: var(--color-bg-subtle);
    border-bottom: 2px solid var(--color-border-strong);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--color-accent-soft);
}

.row-actions {
    text-align: right;
    white-space: nowrap;
}

/* A code such as stgw57-02 stays on one line; a browser would break it at the
   hyphen, and half a short name reads as two. */
.nowrap {
    white-space: nowrap;
}

/* A number column — the order of the competitions. */
.num {
    text-align: right;
    white-space: nowrap;
}

/* A competition code (TASK-031) stays whole in its column. */
td.code {
    white-space: nowrap;
}

/* What a narrow screen shows under a row's main value instead of in columns of
   its own — a competition's code and type (TASK-031). Hidden on wide screens,
   where those columns exist. */
.cell-detail {
    display: none;
}

/* Shown instead of an empty table. */
.empty-state {
    padding: var(--space-6);
    text-align: center;
    color: var(--color-text-muted);
}

/* Read by a screen reader, not painted — a column heading for the action column. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------------------------------------------------------------- status */
/* The status box on the home page: label and value pairs, loaded by HTMX. */
.status {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-5);
    margin: 0;
}

.status dt {
    font-weight: 600;
}

.status dd {
    margin: 0;
}

.status__ok {
    color: var(--color-success);
    font-weight: 600;
}

.status__fault {
    color: var(--color-error);
    font-weight: 600;
}

/* ------------------------------------------------------- narrow screens */
/* FSTA's breakpoint, and for FSTA's reason: it is about vertical space. The
   width arm catches a phone held upright, the height arm the same phone turned
   sideways. The brand block goes — the LINK goes, not just its text, so no
   empty link is left behind; the page <title> still names the application. */
@media (max-width: 48rem), (max-height: 30rem) {
    .app-header__brand {
        display: none;
    }
}

/* Tables on a phone (TASK-030): a header like KURZBEZEICHNUNG must not hold its
   column at full width, or the action column is pushed out of the frame and
   the edit link is cut off — seen at 390px. Headers may wrap, cells pad less;
   a table that still does not fit scrolls inside .table-wrap. */
@media (max-width: 48rem) {
    th,
    td {
        padding: var(--space-2);
    }

    thead th {
        white-space: normal;
    }

    /* Columns a phone has no room for; their content moves into .cell-detail. */
    .wide-only {
        display: none;
    }

    .cell-detail {
        display: block;
        margin-top: var(--space-1);
        font-size: var(--font-size-sm);
        color: var(--color-text-muted);
        /* A long code may break here, in a secondary line, rather than widen the table. */
        overflow-wrap: anywhere;
    }

    /* Two actions in one row (TASK-036: Bearbeiten, Deaktivieren) stack instead of
       side by side — beside each other they pushed the competitor table to 450px. */
    .row-actions .inline-form {
        display: block;
        margin-top: var(--space-1);
    }

    /* Result entry (TASK-040) on a phone: name, weapon, score and VM-Punkte must
       fit 390px for a 30-row sheet — at desktop widths the score column fell off
       the screen. The category moves under the name (.cell-detail). */
    table.entry select {
        min-width: 0;
        max-width: 5.5rem;
    }

    table.entry input.input--score {
        width: 3.25rem;
    }
}
