/* Padel2Morrow — court blue, glass walls, one optic-yellow ball per taken spot. */
@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --court: #1b5c8f;
  --court-deep: #0f3d61;
  --court-line: #ffffff;
  --ball: #dceb3a;
  --ball-edge: #9fab1c;
  --glass: #edf2f5;
  --surface: #ffffff;
  --ink: #102030;
  --muted: #4e6274;
  --line: #c9d5de;
  --ok: #1e7a4c;
  --ok-bg: #e3f3ea;
  --warn: #9a4a0b;
  --warn-bg: #fdf0e1;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --focus: #0b6bcb;
  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 20px;
  --shadow: 0 1px 2px rgb(16 32 48 / 8%), 0 4px 16px rgb(16 32 48 / 6%);
  --font-display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --court: #3f86c2;
    --court-deep: #1d4a70;
    --glass: #0d1a26;
    --surface: #152737;
    --ink: #e6eef4;
    --muted: #a3b5c4;
    --line: #2b4256;
    --ok: #6fd3a0;
    --ok-bg: #12382a;
    --warn: #f3b26b;
    --warn-bg: #3a2814;
    --danger: #ff8a80;
    --danger-bg: #3d1a17;
    --focus: #7cc0ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--glass);
  color: var(--ink);
  font: 1rem/1.5 var(--font-body);
  min-height: 100dvh;
  padding-bottom: calc(76px + var(--safe-bottom));
}
body.no-nav { padding-bottom: 0; }
img, svg { display: block; max-width: 100%; }
a { color: var(--court); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { a { color: #8cc4f0; } }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; } /* buttons set their own display, which would otherwise win */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: var(--radius-s); }
.skip-link:focus { top: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--court-deep);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
}
.topbar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark { font-family: var(--font-display); font-stretch: 75%; font-weight: 800; font-size: 1.45rem; letter-spacing: -0.01em; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.wordmark .two { color: var(--ball); }
.wordmark svg { width: 26px; height: 26px; }
.topbar .who { font-size: .9rem; opacity: .9; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-family: var(--font-display); font-stretch: 80%; font-weight: 750; font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 28px 0 10px; }
h3 { font-size: 1rem; font-weight: 650; }
h1:focus { outline: none; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin: 4px 0 16px; }

/* ---------- buttons & inputs ---------- */
button, .button {
  font: inherit; font-weight: 600;
  min-height: 48px; padding: 10px 18px;
  border-radius: var(--radius-m); border: 2px solid transparent;
  background: var(--court); color: #fff;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  touch-action: manipulation;
}
button:hover, .button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button[disabled] { opacity: .55; cursor: not-allowed; }
button.secondary, .button.secondary { background: transparent; color: var(--court); border-color: var(--court); }
@media (prefers-color-scheme: dark) { button.secondary, .button.secondary { color: #8cc4f0; border-color: #8cc4f0; } }
button.quiet, .button.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { background: var(--danger); color: #fff; }
button.danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: var(--court); padding: 8px 0; min-height: 44px; text-decoration: underline; font-weight: 500; }
@media (prefers-color-scheme: dark) { button.link { color: #8cc4f0; } }
button.block, .button.block { width: 100%; }
button.small, .button.small { min-height: 40px; padding: 6px 12px; font-size: .9rem; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: .875rem; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  font: inherit; font-size: 1rem; /* 16px avoids iOS zoom */
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; }
input[aria-invalid='true'] { border-color: var(--danger); }
.code-input { font-family: var(--font-display); font-size: 2rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: flex-start; gap: 12px; font-weight: 500; min-height: 44px; padding: 8px 0; }
.check input { width: 24px; height: 24px; min-height: 0; margin: 2px 0 0; accent-color: var(--court); flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error-text { color: var(--danger); font-weight: 600; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border-radius: var(--radius-m); padding: 16px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 12px; }
.notice { border-radius: var(--radius-m); padding: 12px 14px; margin-bottom: 16px; background: var(--warn-bg); color: var(--warn); font-weight: 500; }
.notice.info { background: var(--surface); color: var(--ink); border-left: 4px solid var(--court); box-shadow: var(--shadow); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- event list ---------- */
.day-label { font-weight: 650; color: var(--muted); font-size: .95rem; margin: 22px 0 8px; }
.event-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.event-card {
  display: grid; grid-template-columns: 64px 1fr; gap: 14px;
  background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow);
  padding: 14px; color: inherit; text-decoration: none; position: relative;
  border-left: 6px solid transparent;
}
.event-card.mine { border-left-color: var(--ball-edge); }
.event-card.cancelled { opacity: .7; }
.event-card:hover { box-shadow: 0 0 0 2px var(--court), var(--shadow); }
.date-block { text-align: center; font-family: var(--font-display); font-stretch: 70%; line-height: 1; color: var(--court-deep); padding-top: 2px; }
@media (prefers-color-scheme: dark) { .date-block { color: #cfe3f3; } }
.date-block .dow { font-size: .95rem; font-weight: 600; }
.date-block .dom { font-size: 2.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.date-block .mon { font-size: .95rem; font-weight: 600; }
.event-card h3 { font-size: 1.1rem; margin-bottom: 2px; }
.event-meta { color: var(--muted); font-size: .92rem; }
.event-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.spots-count { font-family: var(--font-display); font-stretch: 75%; font-weight: 750; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.spots-count.full { color: var(--warn); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--glass); color: var(--ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- the signature: courts with spots ---------- */
.courts { display: flex; flex-wrap: wrap; gap: 6px; }
.court {
  position: relative; width: 52px; height: 30px; border-radius: 5px;
  background: var(--court); border: 2px solid var(--court-line);
  outline: 1px solid var(--court); display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  place-items: center; padding: 2px 4px;
}
.court::after { content: ''; position: absolute; left: 50%; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: rgb(255 255 255 / 85%); }
.spot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgb(255 255 255 / 90%); background: transparent; }
.spot.taken { background: var(--ball); border-color: var(--ball-edge); box-shadow: inset -2px -2px 0 rgb(0 0 0 / 12%); }
.courts.large { gap: 12px; }
.court-card { background: var(--court); border-radius: var(--radius-m); padding: 12px; color: #fff; position: relative; }
.court-card .court-title { font-family: var(--font-display); font-stretch: 75%; font-weight: 700; font-size: 1rem; margin-bottom: 8px; opacity: .95; }
.court-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; position: relative; }
.court-slots::before { content: ''; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: rgb(255 255 255 / 70%); }
.slot { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 8px; border-radius: var(--radius-s); background: rgb(255 255 255 / 10%); font-weight: 600; overflow-wrap: anywhere; }
.slot .spot { flex: none; width: 14px; height: 14px; }
.slot.free { color: #fff; font-weight: 500; font-style: italic; }
.slot.me { background: rgb(220 235 58 / 25%); }
.slot button { margin-left: auto; min-height: 32px; padding: 2px 8px; font-size: .8rem; background: rgb(255 255 255 / 15%); }
.court-grid { display: grid; gap: 10px; }
/* numbered mini courts on the dashboard */
.court-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.court-no { font-size: .72rem; font-weight: 700; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
/* court booker (event page) */
.court-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.court-head .court-title { margin-bottom: 2px; }
.court-booker { font-size: .85rem; font-weight: 600; }
.court-booker.missing { font-weight: 500; font-style: italic; opacity: .9; }
.slot-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.booker-badge { flex: none; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 999px; background: var(--ball); color: #102030; }
.court-card .court-btn { flex: none; min-height: 36px; padding: 4px 10px; font-size: .85rem; background: rgb(255 255 255 / 16%); color: #fff; border-color: rgb(255 255 255 / 55%); }
@media (min-width: 560px) { .court-grid { grid-template-columns: 1fr 1fr; } }

.waitlist { margin: 0; padding-left: 1.6em; }
.waitlist li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* sticky action bar on the event page */
.action-bar {
  position: sticky; bottom: calc(68px + var(--safe-bottom)); z-index: 5;
  background: var(--surface); border-radius: var(--radius-l); box-shadow: 0 -2px 18px rgb(16 32 48 / 18%);
  padding: 12px; margin-top: 20px; display: grid; gap: 8px;
}
.act-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.act-row .who { font-weight: 600; }

/* ---------- bottom navigation ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 640px; display: flex; }
.bottom-nav li { flex: 1; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; min-height: 60px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; }
.bottom-nav a[aria-current='page'] { color: var(--court); }
@media (prefers-color-scheme: dark) { .bottom-nav a[aria-current='page'] { color: #8cc4f0; } }
.bottom-nav svg { width: 24px; height: 24px; }

/* ---------- tabs (admin) ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--surface); font-weight: 600; font-size: .92rem; min-height: 40px; display: inline-flex; align-items: center; }
.tabs a[aria-current='page'] { background: var(--court-deep); color: #fff; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.list > li { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list button.row-button { all: unset; display: block; width: 100%; cursor: pointer; box-sizing: border-box; }
.list button.row-button:focus-visible { outline: 3px solid var(--focus); }
.member-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- dialogs & toasts ---------- */
dialog {
  border: 0; border-radius: var(--radius-l); padding: 20px; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); max-height: 90dvh; overflow: auto;
}
dialog::backdrop { background: rgb(10 25 40 / 55%); }
dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.qr { background: #fff; padding: 12px; border-radius: var(--radius-m); max-width: 260px; margin: 8px auto; }
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(84px + var(--safe-bottom)); z-index: 50; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: var(--radius-m); box-shadow: var(--shadow); max-width: 560px; display: flex; gap: 12px; align-items: center; }
.toast button { min-height: 36px; padding: 4px 12px; background: var(--ball); color: #102030; }
.toast.error { background: var(--danger); color: #fff; }
.offline-bar { background: var(--warn-bg); color: var(--warn); text-align: center; padding: 6px; font-weight: 600; font-size: .9rem; }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 0 auto; padding-top: 6vh; }
.login-hero { background: var(--court-deep); color: #fff; border-radius: var(--radius-l); padding: 22px 20px; margin-bottom: 20px; }
.login-hero .wordmark { font-size: 2.1rem; }
.login-hero p { margin: 8px 0 0; opacity: .9; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 20px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; background: var(--surface); border-radius: var(--radius-m); padding: 14px 14px 14px 56px; position: relative; margin-bottom: 10px; box-shadow: var(--shadow); }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--court); color: #fff; display: grid; place-items: center; font-weight: 700; }
.steps li.done::before { content: '✓'; background: var(--ok); }

/* numbered how-to steps (passkey set-up, notification helper) */
.howto { margin: 0; padding-left: 1.4em; }
.howto li { padding: 3px 0; }
.howto li + li { margin-top: 4px; }
details summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
details[open] summary { margin-bottom: 8px; }
dialog h3 { margin: 4px 0 6px; }
.code-show { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; letter-spacing: .12em; text-align: center; font-variant-numeric: tabular-nums; margin: 8px 0 16px; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--court); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.just-changed { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .spot.taken { forced-color-adjust: none; background: CanvasText; }
  .court { border-color: CanvasText; }
  .booker-badge { border: 1px solid CanvasText; }
}

/* spacing utilities (inline styles are blocked by the Content-Security-Policy) */
.mt-xs { margin-top: 8px; }
.mt-s { margin-top: 12px; }
.mt-m { margin-top: 16px; }
.mb-xs { margin-bottom: 8px; }
.mb-0 { margin-bottom: 0; }
.pre-line { white-space: pre-line; }

.slot .icon-btn { margin-left: auto; flex: none; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: rgb(255 255 255 / 14%); color: #fff; font-size: 1rem; }
.waitlist li button { min-height: 40px; }
