/*
  Base layer and component classes. Components in this library render these class names;
  keeping the CSS here rather than in per-component isolated files means one stylesheet to
  reason about, and it can be previewed outside Blazor.
*/

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

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

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

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- shell ---- */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.shell__main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) 40px;
}

/* ---- top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-4);
  padding-top: calc(9px + env(safe-area-inset-top));
  background: var(--brand);
  color: var(--brand-contrast);
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}

.topbar__logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
  object-fit: contain;
}

.topbar__titles { flex: 1; min-width: 0; }
.topbar__title { font-size: 1.05rem; font-weight: 800; letter-spacing: .02em; line-height: 1.2; margin: 0; }
.topbar__subtitle { font-size: .78rem; opacity: .85; font-weight: 500; margin: 0; }

.topbar__action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .35);
  color: var(--brand-contrast);
  text-decoration: none;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.topbar__action:hover { background: rgba(255, 255, 255, .28); }

/* ---- nav tabs ---- */

.navtabs {
  position: sticky;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 9;
  display: flex;
  gap: var(--space-1);
  padding: 6px var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.navtab {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 700;
  font-size: .88rem;
  white-space: nowrap;
}

.navtab.is-active { background: var(--brand-wash); color: var(--brand-ink); }

/* ---- section title ---- */

.section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-soft);
  margin: var(--space-6) 0 var(--space-3);
}

/* ---- card ---- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.card--padded { padding: var(--space-4); }

.card--hero {
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: var(--brand-contrast);
  border: none;
  position: relative;
  overflow: hidden;
}

.card--hero a { color: var(--brand-contrast); }

/* ---- rows ---- */

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}

.row:last-child { border-bottom: none; }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 700; font-size: .95rem; }
.row__meta { font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }

/* ---- date block ---- */

.dateblock {
  flex-shrink: 0;
  width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 8px 0;
}

.dateblock__day { font-size: 1.3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dateblock__weekday { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--ink-soft); letter-spacing: .05em; }

/* ---- chip ---- */

.chip {
  padding: 7px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }

.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-1) 0 var(--space-4); }

/* ---- badge ---- */

.badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge--brand { background: var(--brand-wash); color: var(--brand-ink); }
.badge--neutral { background: rgba(85, 85, 90, .12); color: var(--ink-soft); }
.badge--ok { background: var(--ok-wash); color: var(--ok); }
.badge--warn { background: var(--warn-wash); color: var(--warn); }
.badge--danger { background: var(--danger-wash); color: var(--danger); }

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  /* Numbers inside a button line up too: "Maak uitbetaling (7 - 122,50)" jitters every
     time the selection changes otherwise. */
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, background .15s, border-color .15s;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--brand); color: var(--brand-contrast); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-ink); }

.btn--ghost { background: transparent; color: var(--brand-ink); }
.btn--ghost:hover:not(:disabled) { background: var(--brand-wash); }

.btn--danger { background: var(--danger); color: #fff; }

.btn--block { width: 100%; }

/* ---- fields ---- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }

.field__label { font-size: .82rem; font-weight: 700; color: var(--ink-soft); }
.field__label .field__required { color: var(--danger); margin-left: 2px; }

.field__control {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

/* 16px minimum on the control above stops iOS Safari zooming the page on focus. */

.field__control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.field__control[aria-invalid="true"] { border-color: var(--danger); }

.field__hint { font-size: .78rem; color: var(--ink-soft); }
.field__error { font-size: .78rem; color: var(--danger); font-weight: 600; }

.field__suffix { display: flex; align-items: center; gap: 8px; }
.field__suffix .field__control { flex: 1; }
.field__unit { font-size: .85rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }

/* ---- stat tiles ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* The 1px gap above is the divider: each tile paints its own surface and the grid's
   background shows through between them. One rule instead of border-right plus a
   :last-child exception that breaks the moment the row wraps. */
.stat { padding: var(--space-3) var(--space-4); background: var(--surface); }

.stat__label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.stat__value {
  font-size: 1.45rem;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.stat--ok .stat__value { color: var(--ok); }
.stat--danger .stat__value { color: var(--danger); }

/* ---- sheet ---- */

.sheet__backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  max-width: var(--content-width);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  max-height: 85dvh;
  overflow-y: auto;
  animation: sheet-in .18s ease-out;
}

@keyframes sheet-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet__handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto var(--space-4); }
.sheet__title { font-size: 1.1rem; font-weight: 800; margin: 0 0 var(--space-3); }

@media (min-width: 640px) {
  .sheet__backdrop { align-items: center; }
  .sheet { border-radius: var(--radius); max-width: 480px; margin: 0 var(--space-4); }
}

/* ---- empty state & spinner ---- */

.empty { text-align: center; padding: 40px var(--space-5); color: var(--ink-soft); }
.empty__icon { font-size: 2.2rem; line-height: 1; margin-bottom: var(--space-3); }
.empty__title { font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.empty__text { font-size: .9rem; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner--centred { display: block; margin: 40px auto; }

/* ============================================================================
   Desk layout.

   The referee app is used standing in a sports hall on a phone; the admin
   portal is used sitting at a desk with a real screen and a lot more data on
   it. Same components, different shape: a sidebar and a wide content column
   above 960px, falling back to the phone layout below it.

   One markup, two presentations. Nothing here is admin-specific except that
   the admin app opts in with .shell--desk.
   ============================================================================ */

.shell--desk .shell__main { max-width: 1180px; }

@media (min-width: 960px) {
    .shell--desk {
        display: grid;
        grid-template-columns: 248px minmax(0, 1fr);
        grid-template-areas: "side main";
        min-height: 100dvh;
    }

    .shell--desk .sidebar { grid-area: side; display: flex; }
    .shell--desk .shell__main { grid-area: main; padding: 32px 40px 64px; }

    /* The phone chrome is redundant once the sidebar carries the same information. */
    .shell--desk .topbar,
    .shell--desk .navtabs { display: none; }
}

.sidebar {
    display: none;
    flex-direction: column;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
}

.sidebar__brand { display: flex; align-items: center; gap: 12px; }

.sidebar__mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand);
    color: var(--brand-contrast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar__club { font-weight: 800; font-size: .95rem; line-height: 1.2; }
.sidebar__section { font-size: .74rem; color: var(--ink-soft); font-weight: 600; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar__label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    padding: 0 12px;
    margin-bottom: 6px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 600;
}

.sidebar__link:hover { background: var(--bg); }

.sidebar__link.is-active { background: var(--brand-wash); color: var(--brand-ink); }

.sidebar__icon { width: 20px; text-align: center; flex-shrink: 0; }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.sidebar__user { font-size: .82rem; color: var(--ink-soft); padding: 0 12px; }

/* ---- data table ---- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-raised);
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

table.data th {
    text-align: left;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--ink-soft);
    padding: 9px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--ink-soft);
    white-space: nowrap;
}

table.data td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg); }

table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .is-muted td { opacity: .55; }

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}

.table-empty { padding: 32px 16px; text-align: center; color: var(--ink-soft); font-size: .92rem; }

/* Buttons inside a dense table should not be phone-sized. */
table.data .btn { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
table.data .actions .btn + .btn { margin-left: 6px; }

/* Selection checkboxes, as on the payout list. Big enough to hit, in the club's colour. */
table.data input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    cursor: pointer;
}

/* ---- dashboard ---- */

.dash { display: grid; gap: var(--space-6); align-items: start; }

/* Two columns only once the content column is genuinely wide: at 1280px the sidebar has
   taken 248px and each half is still around 460px, which a table survives. Below that they
   stack, which is also what a phone gets. */
@media (min-width: 1280px) {
    .dash--split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

.dash__note { margin: var(--space-4) 0 0; font-size: .88rem; color: var(--ink-soft); max-width: 66ch; }
.dash__note--warn { color: var(--warn); font-weight: 600; }
.dash__sub { font-size: .76rem; color: var(--ink-soft); font-weight: 400; }

.alerts { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }

.alert {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
}

.alert__body { flex: 1; min-width: 220px; }
.alert__title { font-weight: 700; font-size: .95rem; }
.alert__text { font-size: .85rem; color: var(--ink-soft); margin-top: 2px; }

.alert__mark {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .95rem;
}

/* The wash tokens are defined for both themes, so these hold on either ground. */
.alert--blocking { border-color: var(--danger); background: var(--danger-wash); }
.alert--blocking .alert__mark { background: var(--danger); color: #fff; }

.alert--advice { border-color: var(--warn); background: var(--warn-wash); }
.alert--advice .alert__mark { background: var(--warn); color: #fff; }

/* A club logo where the initials would otherwise be. Same footprint, so nothing shifts the
   day one is uploaded. */
.sidebar__logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
    object-fit: contain;
    background: var(--surface);
}

/* ---- brand ---- */

/* The stroke is set here rather than in the SVG so the mark follows currentColor and can
   be tuned in one place. 3 of 40 holds up from 16px favicon to a 512px app icon. */
.brandmark {
    display: block;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linejoin: round;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: .32em;
    color: var(--brand);
    line-height: 1;
}

/* The name at the mark's own weight. Plex 600 with a touch of negative tracking: heavier
   and the counters of the b, d and e close at the sizes this appears at. */
.wordmark__text {
    font-weight: 600;
    letter-spacing: -.025em;
    font-size: 1em;
}

/* The platform's own mark in the sidebar slot, where a club's initials would otherwise be.
   Same footprint as .sidebar__mark. */
.sidebar__mark--brand { padding: 4px; }

/* And in the top bar, the mark on a white tile: the bar itself is the brand colour, and
   orange on orange would vanish. */
.topbar__mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #fff;
    color: var(--brand);
    padding: 4px;
    flex-shrink: 0;
}

/* A club-branded portal still says whose platform it runs on, in the smallest voice. */
.sidebar__platform {
    margin-top: var(--space-3);
    font-size: .74rem;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar__platform .wordmark { color: inherit; font-size: .8rem; }

/* ---- sponsor slides ---- */

/* The board's own aspect ratio, 896 x 512, so the thumbnail crops nothing and what is too
   small to read here is too small to read from the stands either. */
.slide-thumb {
    display: block;
    width: 112px;
    height: 64px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    object-fit: cover;
    background: #000;
}

.slide-meta { font-size: .78rem; color: var(--ink-soft); margin-top: 2px; }

/* Shown once and copied by hand onto a Pi, so it wraps rather than scrolls: a command that
   runs off the edge of the box is one somebody transcribes wrongly. */
.board-token {
    margin: 0 0 var(--space-2);
    padding: var(--space-3);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    user-select: all;
}

/* The slide as it will appear, inside the editing sheet. Wider than the thumbnail because
   this is where somebody decides whether the artwork is right. */
.slide-preview {
    display: block;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 896 / 512;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    object-fit: cover;
    background: #000;
    margin-bottom: var(--space-2);
}
