/*
 * BdS Oberstenfeld - application styles.
 *
 * Design direction: draft 6 in design/mockups/look-and-feel.html. Three themes,
 * chosen per user with the dots in the top bar (data-theme on <html>):
 *   bds    club colors, the default: lime band with a slanted edge, purple box,
 *          lively motion
 *   light  refined: no colored band, hairlines, one deep petrol box, calm motion
 *   dark   the same refinement on charcoal
 * Typography: Nunito Sans only, self-hosted (static/fonts/README.md). Every color
 * comes from a token, so a theme swaps values only. Text colors are checked for
 * WCAG 2.2 AA in all three themes by bds/core/tests/test_contrast.py; add a pair
 * there when you put a new token combination on screen.
 *
 * Shared vocabulary - templates in every module use these classes:
 *   layout     .page-head .page-title .page-lead .page-actions .stack .cluster .grid-2
 *              .button-stack (buttons below each other, full width)
 *   surfaces   .card .card-title .panel
 *   tables     .table-wrap (scrolls wide tables on phones) .data-table (th, td,
 *              tfoot .sum-row, td.num for amounts, td small for a second line)
 *   forms      .form-grid .form-stack .field .field-check (checkbox row) .field-help
 *              .field-error .form-actions; Django's .errorlist and .helptext work too
 *   buttons    .btn (secondary) .btn-primary .btn-quiet .btn-danger .btn-small
 *   status     .status[data-status="ok|pending|warn|neutral"] (dot plus text)
 *              .badge[data-status="ok|pending|warn|neutral"] (pill; dot plus text
 *              in light and dark)
 *   feedback   .messages .alert .alert-success|info|warning|error .empty-state
 *   details    .facts (dl with dt/dd pairs) .pagination (links, aria-current="page")
 *   misc       .muted .num .search .toolbar .skip-link .visually-hidden .rule (hr)
 *              .icon (see templates/core/icon.html) .htmx-indicator
 *
 * Blocks of templates/base.html: title, body_class, extra_head, nav_extra (more links
 * at the end of the main navigation), masthead (area on the band under the top bar,
 * the start page puts its greeting there), layout (wraps content; the allauth
 * layouts use it), content, extra_body.
 *
 * Motion: entrance animations are CSS only and every animation honors
 * prefers-reduced-motion (bottom of this file). htmx swaps can opt into a view
 * transition with hx-swap="innerHTML transition:true".
 */

/* ---------- Fonts ---------- */

@font-face {
  font-family: "Nunito Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("../fonts/nunito-sans-latin-wght-normal.e010923d59d4.woff2") format("woff2-variations"),
       url("../fonts/nunito-sans-latin-wght-normal.e010923d59d4.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("../fonts/nunito-sans-latin-ext-wght-normal.9359f35055cf.woff2") format("woff2-variations"),
       url("../fonts/nunito-sans-latin-ext-wght-normal.9359f35055cf.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */

/* Club colors from the website (brand/README.md). Also the fallback without a theme. */
:root,
[data-theme="bds"] {
  --chrome: #C7D301;
  --page: #F7F8F3; --surface: #FFFFFF; --surface-2: #F1F3EA; --field: #FFFFFF; --field-border: #2C2C2C;
  --ink: #2C2C2C; --muted: #5D5D66; --line: #E2E4DA; --line-strong: #D6DBA6;
  --heading: #00756C; --th-ink: #00756C; --th-rule: #C7D301; --decor: #C7D301;
  --band: #C7D301; --band-ink: #2C2C2C; --band-hover: rgba(255, 255, 255, .45);
  --band-current: #59358C; --band-current-ink: #FFFFFF;
  --task-bg: #FFFFFF; --task-border: #FFFFFF;
  --accent: #59358C; --accent-hover: #462A70; --accent-ink: #FFFFFF; --accent-soft: #ECE6F5; --accent-text: #59358C;
  --btn-ink: #59358C; --btn-border: #59358C; --btn-hover-bg: #ECE6F5;
  --hero: #59358C; --hero-ink: #FFFFFF; --hero-muted: rgba(255, 255, 255, .9); --hero-line: rgba(255, 255, 255, .35);
  --hero-border: #59358C; --hero-focus: #C7D301; --hero-btn-bg: #C7D301; --hero-btn-ink: #2C2C2C;
  --signal: #C7D301; --signal-ink: #2C2C2C;
  --highlight: #F3F6CF;
  --ok: #00756C; --ok-soft: #DDF1EF; --ok-text: #00756C;
  --pending: #59358C; --pending-soft: #ECE6F5; --pending-text: #59358C;
  --warn: #C63368; --warn-soft: #FBE6ED; --warn-text: #A3204F;
  --neutral-soft: #EFEFF1; --focus: #59358C;
  --sky: #583F99; --town-filter: none; --people: #C7D301;
  --shadow-card: 0 1px 3px rgba(60, 64, 0, .18); --shadow-pop: 0 18px 40px rgba(40, 44, 0, .2);
  --hero-shadow: 0 10px 30px rgba(89, 53, 140, .25);

  --r: 4px; --r-sm: 4px; --r-lg: 12px; --r-field: 4px; --r-badge: 3px; --slant: 52px;
  --display-weight: 800; --display-track: .02em; --h-weight: 800; --strong: 800;
  --nav-weight: 700; --nav-track: .06em; --btn-weight: 800; --label-weight: 700;
  --th-weight: 700; --th-track: .04em; --th-rule-width: 2px; --border-strong: 2px;
  --greet-size: 34px; --hero-size: 26px; --total-size: 30px; --title-size: clamp(26px, 3vw, 34px);
  --masthead-pad: 88px; --hero-shift: -62px; --entrance-shift: -184px;
  --rise: 14px; --reveal: 650ms; --ease-reveal: cubic-bezier(.34, 1.4, .64, 1);

  --container: 1240px;
  --gutter: clamp(16px, 4vw, 40px);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
  accent-color: var(--accent);
}

/* Light: porcelain and white, one deep petrol box, ivory type and a pale lime signal. */
[data-theme="light"] {
  --chrome: #F5F6F4;
  --page: #F5F6F4; --surface: #FFFFFF; --surface-2: #F0F2EF; --field: #FFFFFF; --field-border: #8F9590;
  --ink: #1A1D1C; --muted: #6A706D; --line: #E5E7E3; --line-strong: #D3D7D2;
  --heading: #1A1D1C; --th-ink: #6A706D; --th-rule: #D3D7D2; --decor: #D3D7D2;
  --band: transparent; --band-ink: #1A1D1C; --band-hover: transparent;
  --band-current: transparent; --band-current-ink: #1A1D1C;
  --task-bg: #FFFFFF; --task-border: #E5E7E3;
  --accent: #1A1D1C; --accent-hover: #343A37; --accent-ink: #FFFFFF; --accent-soft: #F0F2EF; --accent-text: #0E5E57;
  --btn-ink: #1A1D1C; --btn-border: #D3D7D2; --btn-hover-bg: #F0F2EF;
  --hero: #10302D; --hero-ink: #F4F1E8; --hero-muted: rgba(244, 241, 232, .7); --hero-line: rgba(244, 241, 232, .16);
  --hero-border: #10302D; --hero-focus: #DCE29A; --hero-btn-bg: #F4F1E8; --hero-btn-ink: #10302D;
  --signal: #DCE29A; --signal-ink: #10302D;
  --highlight: #F4F6F3;
  --ok: #2F8F84; --ok-soft: #E6F2EF; --ok-text: #1F6E66;
  --pending: #5E4E9A; --pending-soft: #EFECF8; --pending-text: #5E4E9A;
  --warn: #C2456E; --warn-soft: #FBF0F3; --warn-text: #A0325A;
  --neutral-soft: #F0F2EF; --focus: #0E5E57;
  --sky: #59358C; --town-filter: none; --people: #DCE29A;
  --shadow-card: none; --shadow-pop: 0 28px 60px -16px rgba(20, 24, 22, .2);
  --hero-shadow: 0 34px 60px -30px rgba(16, 48, 45, .6);
  color-scheme: light;
}

/* Dark: charcoal with a hint of green, the same petrol box, ivory primary buttons. */
[data-theme="dark"] {
  --chrome: #0F1211;
  --page: #0F1211; --surface: #151918; --surface-2: #1B201E; --field: #121615; --field-border: #5E6662;
  --ink: #ECEEEA; --muted: #8E9692; --line: #232927; --line-strong: #333A37;
  --heading: #ECEEEA; --th-ink: #8E9692; --th-rule: #333A37; --decor: #333A37;
  --band: transparent; --band-ink: #ECEEEA; --band-hover: transparent;
  --band-current: transparent; --band-current-ink: #ECEEEA;
  --task-bg: #151918; --task-border: #232927;
  --accent: #ECEEEA; --accent-hover: #FFFFFF; --accent-ink: #0F1211; --accent-soft: #1E2422; --accent-text: #A8D8CF;
  --btn-ink: #ECEEEA; --btn-border: #333A37; --btn-hover-bg: #1B201E;
  --hero: #132523; --hero-ink: #ECEEEA; --hero-muted: rgba(236, 238, 234, .66); --hero-line: rgba(236, 238, 234, .13);
  --hero-border: #21403C; --hero-focus: #D9DE9E; --hero-btn-bg: #ECEEEA; --hero-btn-ink: #132523;
  --signal: #D9DE9E; --signal-ink: #132523;
  --highlight: #181D1B;
  --ok: #5BBFB2; --ok-soft: rgba(91, 191, 178, .12); --ok-text: #8FD3C8;
  --pending: #A796E0; --pending-soft: rgba(167, 150, 224, .14); --pending-text: #C3B7EE;
  --warn: #E57A9E; --warn-soft: rgba(229, 122, 158, .1); --warn-text: #F0A3BD;
  --neutral-soft: rgba(255, 255, 255, .06); --focus: #A8D8CF;
  --sky: #A99BDB; --town-filter: brightness(0) invert(.88); --people: #D9DE9E;
  --shadow-card: none; --shadow-pop: 0 28px 60px rgba(0, 0, 0, .6);
  --hero-shadow: 0 34px 60px -26px rgba(0, 0, 0, .75);
  color-scheme: dark;
}

/* Refined shape, type and motion shared by light and dark: lighter weights, round shapes, slower and smaller moves.
   Component rules below wrap this theme prefix in :where(), so they win by source order only and stay easy to override. */
:root:is([data-theme="light"], [data-theme="dark"]) {
  --r: 20px; --r-sm: 999px; --r-lg: 16px; --r-field: 12px; --r-badge: 999px; --slant: 0px;
  --display-weight: 600; --display-track: -.02em; --h-weight: 600; --strong: 600;
  --nav-weight: 500; --nav-track: 0; --btn-weight: 600; --label-weight: 600;
  --th-weight: 600; --th-track: 0; --th-rule-width: 1px; --border-strong: 1px;
  --greet-size: 40px; --hero-size: 28px; --total-size: 34px; --title-size: clamp(28px, 3.4vw, 38px);
  --masthead-pad: 40px; --hero-shift: 0px; --entrance-shift: 16px;
  --rise: 6px; --reveal: 900ms; --ease-reveal: var(--ease-out);
}

/* ---------- Base ---------- */

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-weight: var(--h-weight); line-height: 1.2; }
a { color: var(--accent-text); text-underline-offset: .2em; text-decoration-thickness: 1px; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; }
::selection { background: var(--signal); color: var(--signal-ink); }

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

.skip-link { position: absolute; left: -9999px; top: 12px; z-index: 20; padding: 10px 16px; border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-weight: var(--strong); box-shadow: var(--shadow-pop); }
.skip-link:focus { left: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .icon { stroke-width: 1.5; }

/* ---------- Frame: top bar, band, content, footer ---------- */

.app-bar, .masthead-inner, .app-content { width: min(var(--container), 100% - 2 * var(--gutter)); margin-inline: auto; }

.app-head { background: var(--band); color: var(--band-ink); }
.app-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 16px; }
.brand { display: block; height: 56px; flex: none; border-radius: var(--r-sm); }
.logo { display: block; height: 100%; width: auto; aspect-ratio: 1900 / 420; overflow: visible; }
.logo-sky { stroke: var(--sky); }
.logo-sky path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.logo-town { filter: var(--town-filter); }

.app-nav { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.app-nav a { color: var(--band-ink); text-decoration: none; font-weight: var(--nav-weight); font-size: 14px; letter-spacing: var(--nav-track); padding: 7px 10px; border-radius: var(--r-sm); white-space: nowrap; transition: background-color .2s, color .2s, box-shadow .25s; }
.app-nav a:hover { background: var(--band-hover); }
.app-nav a[aria-current] { background: var(--band-current); color: var(--band-current-ink); }

.app-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
.app-user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; border-radius: var(--r-sm); }
.app-user-name:hover { text-decoration: underline; }
.app-user form { margin: 0; }
.app-logout .btn { padding: 6px 10px; font-size: 14px; }
.app-logout .btn:hover { background: var(--band-hover); }

.theme-switch { display: flex; gap: 6px; }
.theme-dot { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--chrome); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--band-ink) 28%, transparent); cursor: pointer; transition: box-shadow .2s, transform .25s var(--ease-pop); }
.theme-dot:hover { transform: scale(1.1); }
.theme-dot[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--band-ink); }
/* The dots preview the other themes, so their colors are fixed. */
.theme-dot[value="bds"] { background: conic-gradient(from 225deg, #C7D301 0 50%, #59358C 0); }
.theme-dot[value="light"] { background: conic-gradient(from 225deg, #F5F6F4 0 50%, #10302D 0); }
.theme-dot[value="dark"] { background: conic-gradient(from 225deg, #0F1211 0 50%, #D9DE9E 0); }

/* The band ends in the slanted edge of the website; the start page draws it under its greeting instead. */
.band-tail { height: calc(var(--slant) + 12px); background: var(--band); clip-path: polygon(0 0, 100% 0, 100% 12px, 0 100%); }
.band-tail-tall { height: calc(var(--slant) + 150px); clip-path: polygon(0 0, 100% 0, 100% 150px, 0 100%); }

.app-main { flex: 1; }
.app-main:focus { outline: none; }
.app-content { padding-block: 32px 64px; }

.app-foot { padding: 20px var(--gutter) 28px; text-align: center; font-size: 11px; color: var(--muted); }
.deploy-info { margin: 0; font-variant-numeric: tabular-nums; }

/* Refined layer: no colored band, a hairline under the bar, underlined navigation. */
:where(:root:is([data-theme="light"], [data-theme="dark"])) .app-bar { border-bottom: 1px solid var(--line); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .band-tail { display: none; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav { gap: 26px; margin-left: 12px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav a { padding: 6px 0; border-radius: 0; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav a:hover { box-shadow: inset 0 -1px 0 var(--line-strong); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav a[aria-current] { font-weight: 600; box-shadow: inset 0 -1.5px 0 currentColor; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .app-user-name { color: var(--muted); font-weight: 500; }

/* ---------- Layout vocabulary ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; margin: 0 0 24px; }
.page-title { margin: 0; font-weight: var(--h-weight); color: var(--heading); font-size: var(--title-size); line-height: 1.15; letter-spacing: var(--display-track); }
.page-lead { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.stack > * + * { margin-top: 16px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.button-stack { display: grid; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 24px; }
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* ---------- Surfaces ---------- */

.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 24px; box-shadow: var(--shadow-card); }
.card-title { margin: 0 0 12px; font-size: 18px; font-weight: var(--h-weight); color: var(--heading); letter-spacing: var(--display-track); }
.card > p, .panel > p { margin: 0 0 12px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) :is(.card, .panel) { padding: 28px 30px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .card-title { font-size: 20px; }

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

.table-wrap { max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 15px; }
.data-table th { text-align: left; font-size: 13px; font-weight: var(--th-weight); letter-spacing: var(--th-track); color: var(--th-ink); padding: 10px 12px; border-bottom: var(--th-rule-width) solid var(--th-rule); white-space: nowrap; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; transition: background-color .2s; }
.data-table tbody tr:hover td { background: var(--highlight); }
.data-table td small { display: block; color: var(--muted); font-size: 13.5px; }
.data-table td.num, .data-table th.num { text-align: right; white-space: nowrap; }
.data-table tfoot .sum-row td { font-weight: var(--strong); border-top: var(--th-rule-width) solid var(--th-rule); border-bottom: 0; }

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

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px 20px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 14px; font-weight: var(--label-weight); }
:where(.field, .form-grid, .form-stack) :is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"]), select, textarea) {
  width: 100%; min-height: 44px; color: var(--ink); background: var(--field);
  border: 1.5px solid var(--field-border); border-radius: var(--r-field); padding: 9px 12px;
  transition: border-color .2s, box-shadow .2s;
}
:where(.field, .form-grid, .form-stack) :is(input, select, textarea):focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
:where(.field, .form-grid, .form-stack) :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--warn); }
:where(.field, .form-grid, .form-stack) :is(input, textarea):is([readonly], [disabled]) { background: var(--surface-2); }
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: 20px; height: 20px; margin: 0; flex: none; }
.field-check > label { font-weight: 400; }
.field-help, .helptext { font-size: 13px; color: var(--muted); }
.field-help ul { margin: 4px 0 0; padding-left: 18px; }
.field-error, .errorlist { font-size: 13px; font-weight: 600; color: var(--warn-text); }
.field-error { margin: 0; }
.errorlist { list-style: none; margin: 0; padding: 0; }
.errorlist.nonfield { padding: 12px 16px; border-radius: var(--r-field); background: var(--warn-soft); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 0; }
.form-stack > .form-actions { margin-top: 4px; }

.search input { width: 100%; font-size: 17px; padding: 11px 16px; border: var(--border-strong) solid var(--field-border); border-radius: var(--r-lg); background: var(--field); color: var(--ink); }
.search input::placeholder { color: var(--muted); opacity: 1; }

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

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px; font-weight: var(--btn-weight); font-size: 15px; line-height: 1.3; border-radius: var(--r-sm); border: var(--border-strong) solid var(--btn-border); background: var(--surface); color: var(--btn-ink); cursor: pointer; text-decoration: none; transition: background-color .2s, border-color .2s, color .2s, box-shadow .2s, transform .2s var(--ease-pop); }
.btn:hover { background: var(--btn-hover-bg); }
.btn:active { transform: scale(.97); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: inherit; }
.btn-quiet:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.btn-danger { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-text); }
.btn-danger:hover { background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn); }
.btn-small { min-height: 32px; padding: 4px 12px; font-size: 13.5px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .btn { min-height: 44px; padding: 10px 22px; font-size: 15.5px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .btn:active { transform: none; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .btn-small { min-height: 32px; padding: 4px 14px; font-size: 13.5px; }

/* ---------- Status ---------- */

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-status="ok"]::before { background: var(--ok); }
.status[data-status="pending"]::before { background: var(--pending); }
.status[data-status="warn"]::before { background: var(--warn); }

.badge { display: inline-flex; align-items: center; gap: 8px; padding: 2px 10px; border-radius: var(--r-badge); font-size: 13px; font-weight: 700; white-space: nowrap; background: var(--neutral-soft); color: var(--ink); }
.badge[data-status="ok"] { background: var(--ok-soft); color: var(--ok-text); }
.badge[data-status="pending"] { background: var(--pending-soft); color: var(--pending-text); }
.badge[data-status="warn"] { background: var(--warn-soft); color: var(--warn-text); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) :is(.badge, .badge[data-status]) { padding: 0; background: none; font-weight: 600; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Feedback ---------- */

.messages { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 8px; }
.alert { padding: 12px 16px; border-radius: var(--r-sm); border-left: 4px solid currentColor; background: var(--neutral-soft); color: var(--ink); }
.alert > p { margin: 0; }
.alert > p + p { margin-top: 4px; }
.alert-success { background: var(--ok-soft); color: var(--ok-text); }
.alert-info { background: var(--pending-soft); color: var(--pending-text); }
.alert-warning, .alert-error { background: var(--warn-soft); color: var(--warn-text); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .alert { border-left: 0; border-radius: 12px; box-shadow: inset 2px 0 0 currentColor; }

.empty-state { margin: 0; padding: 40px 24px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r); }

.facts { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; font-size: 14px; }
.pagination a, .pagination span { min-width: 36px; padding: 6px 12px; border-radius: var(--r-sm); text-align: center; }
.pagination a { color: var(--ink); text-decoration: none; border: 1px solid var(--line); background: var(--surface); }
.pagination a:hover { background: var(--btn-hover-bg); }
.pagination [aria-current] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Start page ---------- */

.masthead { background: var(--band); color: var(--band-ink); padding-bottom: var(--masthead-pad); clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--slant)), 0 100%); }
.masthead-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px 48px; align-items: end; padding-top: 12px; }
.greeting { margin: 0 0 18px; font-size: var(--greet-size); line-height: 1.12; font-weight: var(--display-weight); letter-spacing: var(--display-track); color: inherit; }
.greeting-question { display: block; }

.finder { display: flex; align-items: center; gap: 8px; background: var(--field); color: var(--ink); border: var(--border-strong) solid var(--field-border); border-radius: var(--r-lg); padding: 6px 6px 6px 16px; transition: box-shadow .3s; }
.finder:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.finder-field { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.finder-field .icon { width: 24px; height: 24px; color: var(--muted); }
.finder input { flex: 1; min-width: 0; padding: 8px 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 18px; }
.finder input::placeholder { color: var(--muted); opacity: 1; }
.finder input::-webkit-search-cancel-button { cursor: pointer; }
.finder-submit { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: calc(var(--r-lg) - 4px); background: var(--accent); color: var(--accent-ink); cursor: pointer; transition: background-color .2s, transform .25s var(--ease-pop); }
.finder-submit:hover { background: var(--accent-hover); }
.finder-submit:hover .icon { transform: translateX(2px); }
.finder-submit .icon { transition: transform .25s var(--ease-pop); }

.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.shortcut { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px; align-items: center; align-content: center; padding: 11px 14px; background: var(--task-bg); color: var(--ink); border: var(--border-strong) solid var(--task-border); border-radius: var(--r-lg); box-shadow: var(--shadow-card); text-decoration: none; transition: border-color .2s, background-color .2s, transform .25s var(--ease-pop), box-shadow .25s; }
.shortcut:hover { border-color: var(--accent); transform: translateY(-2px); }
.shortcut-icon { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.shortcut strong { font-size: 15.5px; line-height: 1.25; font-weight: var(--h-weight); }
.shortcut > span:last-child { font-size: 13.5px; color: var(--muted); }

.page-home .app-content { padding-top: 0; }
.hero { position: relative; z-index: 1; margin-top: var(--hero-shift); display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.page-home .messages { position: relative; z-index: 2; margin-top: var(--hero-shift); }
.page-home .messages + .hero { margin-top: 0; }
.hero-card { background: var(--hero); color: var(--hero-ink); border: 1px solid var(--hero-border); border-radius: var(--r); padding: 26px 30px 30px; box-shadow: var(--hero-shadow); }
.hero-card :focus-visible { outline-color: var(--hero-focus); }
.hero-title { margin: 0; font-size: var(--hero-size); line-height: 1.1; font-weight: var(--display-weight); letter-spacing: var(--display-track); }
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 22px 0 26px; }
.figure::before { content: ""; display: block; height: 3px; margin-bottom: 12px; background: var(--signal); transform-origin: left center; }
.figure dt { font-size: 14px; font-weight: 600; color: var(--hero-muted); }
.figure dd { margin: 6px 0 0; font-size: clamp(34px, 5vw, 48px); line-height: 1; font-weight: var(--display-weight); letter-spacing: var(--display-track); }
.hero-actions { margin: 0; }
.hero-btn { background: var(--hero-btn-bg); border-color: var(--hero-btn-bg); color: var(--hero-btn-ink); }
.hero-btn:hover { background: var(--hero-btn-bg); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hero-btn-bg) 30%, transparent); }
.hero-btn:hover .icon { transform: translateX(3px); }
.hero-btn .icon { transition: transform .25s var(--ease-pop); }

.fee-panel .muted { margin: 0; font-size: 14px; }
.fee-panel .fee-total { margin: 22px 0 0; }
.fee-total-num { position: relative; display: inline-block; padding-bottom: 10px; font-size: var(--total-size); font-weight: var(--display-weight); line-height: 1; letter-spacing: var(--display-track); }
/* The double rule under a total, as in a cash book. */
.fee-total-num::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; border-top: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform-origin: left center; }

:where(:root:is([data-theme="light"], [data-theme="dark"])) .masthead-inner { padding-top: 40px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .greeting { line-height: 1.15; margin-bottom: 24px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .finder { padding: 8px 8px 8px 18px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .shortcut { padding: 13px 16px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .shortcut:hover { border-color: var(--line-strong); background: var(--surface-2); transform: none; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .shortcut-icon { background: transparent; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--ink); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .hero-card { padding: 32px 36px 36px; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .figure::before { height: 1px; background: var(--hero-line); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .figure:first-child::before { background: var(--signal); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .figure dd { font-weight: 500; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .fee-total-num::after { height: 5px; border-width: 1px; }

/* ---------- Sign-in and account pages (allauth) ---------- */

.entrance { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); max-width: 980px; margin: var(--entrance-shift) auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop); overflow: hidden; }
.page-entrance .messages { position: relative; z-index: 2; max-width: 980px; margin: var(--entrance-shift) auto 24px; }
.page-entrance .messages + .entrance { margin-top: 0; }
.entrance-hero { display: flex; flex-direction: column; gap: 10px; padding: 36px 32px 0; background: var(--hero); color: var(--hero-ink); }
.entrance-hero > p { margin: 0; }
.entrance-kicker { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--signal); }
.entrance-welcome { font-size: 28px; line-height: 1.15; font-weight: var(--display-weight); letter-spacing: var(--display-track); }
.entrance-note { color: var(--hero-muted); font-size: 15px; }
.entrance-people { margin-top: auto; padding-top: 24px; aspect-ratio: 600 / 227; background: var(--people); -webkit-mask: url("../img/people-lime.ec576bc9f3e7.png") center bottom / contain no-repeat; mask: url("../img/people-lime.ec576bc9f3e7.png") center bottom / contain no-repeat; }
.entrance-body { display: flex; flex-direction: column; gap: 16px; padding: 36px 36px 32px; }
.entrance-body .page-head { margin: 0; }
.entrance-body .page-lead { margin: 0; }
.entrance-body p { margin: 0; }
.entrance-body .form-actions .btn, .entrance-body > .btn, .button-stack .btn { width: 100%; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
/* One-click demo sign-in, only with DEBUG on this machine (bds/accounts/demo.py). */
.demo-login { display: grid; gap: 6px; text-align: center; }
.demo-login .btn { width: 100%; justify-content: center; border-style: dashed; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .entrance-kicker { font-weight: 600; letter-spacing: .12em; }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .entrance-people { opacity: .5; }

.manage { display: grid; gap: 24px; max-width: 760px; }
.manage-body { display: flex; flex-direction: column; gap: 16px; }
.manage-body > p { margin: 0; }
.manage-body .page-head { margin: 0; }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; }
.subnav a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; transition: background-color .2s, border-color .2s; }
.subnav a:hover { background: var(--btn-hover-bg); }
.subnav a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.subnav .icon { width: 18px; height: 18px; }

/* QR codes need dark modules on white in every theme, or phones cannot read them. */
.qr { display: block; width: 200px; height: 200px; padding: 12px; background: #FFFFFF; border: 1px solid var(--line); border-radius: var(--r-field); }
.codes { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .08em; line-height: 1.7; }

/* ---------- Error pages ---------- */

.error-page { max-width: 640px; padding: 8px 0 32px; }
.error-code { margin: 0 0 8px; font-size: clamp(72px, 14vw, 132px); line-height: .9; font-weight: 900; letter-spacing: -.02em; color: var(--decor); }
:where(:root:is([data-theme="light"], [data-theme="dark"])) .error-code { font-weight: 300; }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(var(--rise)); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(18px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes logo-rise { from { opacity: 0; transform: translateY(60px); } }
@keyframes wipe { from { opacity: 0; clip-path: inset(0 100% 0 0); } }
@keyframes band-settle { from { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); } }

.page-head, .error-code, .messages .alert { animation: rise var(--reveal) var(--ease-reveal) both; }
.error-page .page-title { animation: rise var(--reveal) var(--ease-out) 80ms both; }

.page-home .greeting { animation: rise var(--reveal) var(--ease-reveal) 120ms both; }
.page-home .finder { animation: rise var(--reveal) var(--ease-reveal) 220ms both; }
.page-home .shortcut { animation: rise var(--reveal) var(--ease-reveal) 300ms both; }
.page-home .shortcut:nth-child(2) { animation-delay: 350ms; }
.page-home .shortcut:nth-child(3) { animation-delay: 400ms; }
.page-home .shortcut:nth-child(4) { animation-delay: 450ms; }
.page-home .shortcut:nth-child(5) { animation-delay: 500ms; }
.page-home .shortcut:nth-child(6) { animation-delay: 550ms; }
.hero-card { animation: rise calc(var(--reveal) + 200ms) var(--ease-out) 450ms both; }
.fee-panel { animation: slide-in calc(var(--reveal) + 100ms) var(--ease-out) 600ms both; }
.figure::before { animation: grow 700ms var(--ease-out) 800ms both; }
.figure:nth-child(2)::before { animation-delay: 920ms; }
.figure:nth-child(3)::before { animation-delay: 1040ms; }
.fee-total-num::after { animation: grow 700ms var(--ease-in-out) 1300ms both; }
/* The club band arrives flat and settles into its slanted edge, as on the website. */
[data-theme="bds"] .page-home .masthead { animation: band-settle 1000ms var(--ease-in-out) 150ms backwards; }

.entrance { animation: rise calc(var(--reveal) + 100ms) var(--ease-out) 100ms both; }
.entrance-people { animation: rise 900ms var(--ease-out) 500ms both; }
.page-entrance .logo-sky path { animation: draw 1500ms var(--ease-in-out) both; }
.page-entrance .logo-sky path + path { animation-delay: 300ms; }
.page-entrance .logo-letters { animation: logo-rise 800ms var(--ease-out) 450ms both; }
.page-entrance .logo-town { animation: wipe 900ms var(--ease-out) 850ms both; }

/* Page changes cross-fade; the top bar stays put. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
html:not(.theme-reveal) .app-head { view-transition-name: app-head; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 240ms; }
/* The theme switch reveals the new colors in a circle (app.js); the default cross-fade would fight it. */
html.theme-reveal::view-transition-old(root), html.theme-reveal::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* ---------- Small screens ---------- */

/* Seven sections, the user and the theme dots fit in one row only on wide screens. */
@media (max-width: 1359px) {
  .app-nav { order: 3; flex-basis: 100%; }
  :where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav { margin-left: 0; }
}

@media (max-width: 1100px) {
  .masthead-inner, .hero { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .entrance { grid-template-columns: minmax(0, 1fr); }
  .entrance-hero { padding: 24px 22px 0; }
  .entrance-welcome { font-size: 22px; }
  .entrance-people { max-height: 96px; padding-top: 12px; }
  .entrance-body { padding: 26px 22px 24px; }
}

@media (max-width: 760px) {
  :root { --gutter: 16px; --greet-size: 26px; --hero-size: 22px; --total-size: 26px; --masthead-pad: 72px; --hero-shift: -56px; --entrance-shift: -170px; }
  :root:is([data-theme="light"], [data-theme="dark"]) { --greet-size: 30px; --hero-size: 24px; --total-size: 30px; --masthead-pad: 32px; --hero-shift: 0px; --entrance-shift: 8px; }
  .app-bar { gap: 12px; padding-block: 12px; }
  .brand { height: 40px; }
  .app-user { gap: 10px; }
  .app-user-name { display: none; }
  .app-logout .btn { padding: 6px 8px; }
  .app-logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .app-nav, :where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  :where(:root:is([data-theme="light"], [data-theme="dark"])) .app-nav { gap: 20px; }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-content { padding-block: 24px 48px; }
  .shortcut { grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
  .shortcut-icon { grid-row: auto; }
  .shortcut > span:last-child { display: none; }
  .hero-card, :where(:root:is([data-theme="light"], [data-theme="dark"])) .hero-card { padding: 22px 18px; }
  .figures { gap: 12px; }
  :is(.card, .panel), :where(:root:is([data-theme="light"], [data-theme="dark"])) :is(.card, .panel) { padding: 18px 16px; }
  .page-actions { margin-left: 0; }
  .data-table th, .data-table td { padding-inline: 8px; }
}

@media (max-width: 380px) {
  .brand { height: 34px; }
  .theme-switch { gap: 4px; }
  .theme-dot { width: 22px; height: 22px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
