/* ==========================================================================
   FCBQbot web — experience layer (loaded after app.css)
   Fluid sizing, mobile-first shell (tab bar in the thumb zone), touch targets, container-query tiles, skeletons,
   data-viz components, motion that respects the user's settings, and accessibility modes.
   No inline styles anywhere (strict CSP): JS sets CSS custom properties through the CSSOM.
   ========================================================================== */

:root {
  /* fluid type + space: no breakpoints needed, everything scales smoothly between a 320px phone and a 4K screen */
  --step-0: clamp(0.94rem, 0.9rem + 0.2vw, 1.06rem);
  --step-1: clamp(1.1rem, 1.03rem + 0.35vw, 1.3rem);
  --step-2: clamp(1.3rem, 1.15rem + 0.75vw, 1.7rem);
  --step-3: clamp(1.7rem, 1.3rem + 2vw, 2.6rem);
  --step-4: clamp(2.1rem, 1.5rem + 3vw, 3.4rem);
  --gap: clamp(12px, 1.2vw + 8px, 22px);
  --pad: clamp(14px, 1vw + 10px, 24px);
  --tap: 44px;                                   /* minimum touch target (WCAG 2.5.5 / Apple HIG) */
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);            /* entering / feedback: starts fast, feels instant */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);        /* things that move on screen */
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);         /* sheets and drawers */
  --z-tabbar: 40; --z-sheet: 60; --z-toast: 80; --z-ball: 90;
}
html { scroll-padding-top: 16px; scroll-behavior: smooth; }
body { font-size: var(--step-0); overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }
h1 { font-size: var(--step-4); } h2 { font-size: var(--step-2); } h3 { font-size: var(--step-1); }
main { padding: clamp(18px, 3vw, 40px) clamp(14px, 4vw, 56px) 80px; scroll-margin-top: 0; }
main:focus { outline: none; }

/* long identifiers, paths and commands must wrap instead of pushing the page sideways on a 320px phone */
p .mono, li .mono, dd.mono, dd .mono, td .mono, .banner .mono, .muted .mono, .kv dd { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ accessibility basics */
.skip-link {
  position: fixed; left: 12px; top: -80px; z-index: 200; padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--paper);
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: calc(12px + var(--safe-t)); outline: 3px solid var(--court); outline-offset: 2px; color: var(--paper); }
:focus-visible { outline: 3px solid var(--court); outline-offset: 3px; border-radius: 8px; }
/* form controls too (app.css removes the outline on :focus for mouse clicks; keyboard users must still see where they are) */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--court); outline-offset: 2px; }
.card :focus-visible, .tile :focus-visible { outline-offset: 2px; }
kbd { font: 600 .72rem var(--font-mono); padding: 2px 6px; border: 1.5px solid var(--rule); border-bottom-width: 3px; border-radius: 6px; background: var(--sheet-2); color: var(--ink-2); }
@media (forced-colors: active) {
  .btn, .card, .tile, .badge, .nav a[aria-current="page"], .tabbar a[aria-current="page"] { border: 2px solid CanvasText; }
  .nav a[aria-current="page"], .tabbar a[aria-current="page"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}
@media (prefers-contrast: more) {
  :root { --rule: color-mix(in srgb, var(--ink) 55%, transparent); --ink-2: var(--ink); --ink-3: color-mix(in srgb, var(--ink) 80%, var(--paper)); }
  .card, .btn, select, input, textarea { border-width: 2.5px; }
}

/* ------------------------------------------------------------------ the shell: rail (desktop) / top bar + tab bar (phones, tablets) */
.topbar, .tabbar { display: none; }
.rail { gap: 20px; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--rule); background: var(--sheet); color: var(--ink-2); font: 500 .9rem var(--font-ui); text-align: left;
  transition: border-color .15s;
}
.search-trigger svg { width: 17px; height: 17px; flex: none; } .search-trigger span { flex: 1; } .search-trigger:hover { border-color: var(--ink); color: var(--ink); }
.nav a { position: relative; transition: background-color .15s, color .15s, transform .16s var(--ease-out); }
.nav a:active { transform: scale(.98); }
.dot { position: absolute; top: 8px; right: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--court-btn); color: var(--court-ink);
  font: 700 .68rem/18px var(--font-mono); text-align: center; font-style: normal; }
.dot:empty { min-width: 9px; width: 9px; height: 9px; padding: 0; top: 10px; }
.avatar-btn { padding: 0; }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: 12px; border: 0; background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; } .icon-btn:active { background: var(--sheet-2); }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: var(--z-tabbar);
    padding: calc(8px + var(--safe-t)) 14px 8px; background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--rule-strong);
  }
  .topbar .brand b { font-size: 1.5rem; } .topbar-actions { display: flex; gap: 4px; align-items: center; }
  .tabbar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: var(--z-tabbar); padding: 6px 6px calc(6px + var(--safe-b));
    background: color-mix(in srgb, var(--sheet) 92%, transparent); backdrop-filter: blur(14px); border-top: 2px solid var(--rule-strong);
  }
  .tabbar a, .tabbar button {
    flex: 1 1 0; min-width: 0; min-height: calc(var(--tabbar-h) - 12px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: transparent; color: var(--ink-2); font: 600 .72rem var(--font-ui); text-decoration: none; border-radius: 14px; cursor: pointer; position: relative;
    transition: color .15s, background-color .15s, transform .16s var(--ease-out);
  }
  .tabbar svg { width: 24px; height: 24px; } .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a:active, .tabbar button:active { transform: scale(.95); }
  .tabbar a[aria-current="page"] { color: var(--paper); background: var(--ink); }
  .tabbar .dot { top: 4px; right: calc(50% - 22px); }
  main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  #toasts { bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px) !important; }
  .map-layout { grid-template-columns: 1fr; } .venue-list { max-height: 260px; }
  .page-head { margin-bottom: 18px; }
}

/* bottom sheets + palette (native <dialog>: focus trap, Esc, inert background for free) */
dialog.sheet {
  margin: auto 0 0; width: 100%; max-width: 560px; inset-inline: 0; margin-inline: auto; border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--safe-b));
  display: none; gap: 12px; border-bottom: 0; max-height: 86dvh; overflow: auto; overscroll-behavior: contain;
}
dialog.sheet[open] { display: grid; animation: sheet-in .26s var(--ease-drawer); }
dialog.sheet::backdrop { background: rgba(10, 8, 5, .5); backdrop-filter: blur(3px); animation: fade-in .2s; }
.sheet-grip { width: 44px; height: 5px; border-radius: 99px; background: var(--rule); margin: 0 auto 4px; }
.sheet h2 { font-size: var(--step-1); }
.sheet-list { display: grid; gap: 4px; }
.sheet-list a { position: relative; display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 12px; border-radius: 14px; text-decoration: none; font-weight: 600; }
.sheet-list a svg { width: 22px; height: 22px; flex: none; } .sheet-list a:active { background: var(--sheet-2); }
.sheet-list a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.sheet .who { display: flex; align-items: center; gap: 12px; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
dialog.palette { margin: min(14vh, 120px) auto auto; width: min(640px, 94vw); padding: 0; border-radius: 18px; overflow: hidden; }
/* the palette is a keyboard tool used many times a day: it opens instantly */
.palette-box { display: grid; }
.palette-box input { border: 0; border-bottom: 2px solid var(--rule); border-radius: 0; min-height: 56px; padding: 14px 20px; font-size: 1.05rem; background: transparent; width: 100%; }
.palette-box input:focus { border-color: var(--court); outline: none; }
#palette-list { list-style: none; margin: 0; padding: 8px; max-height: min(52dvh, 420px); overflow: auto; display: grid; gap: 2px; }
#palette-list li { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; }
#palette-list li svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); } #palette-list li small { margin-left: auto; color: var(--ink-3); font: 500 .75rem var(--font-mono); }
#palette-list li[aria-selected="true"] { background: var(--ink); color: var(--paper); } #palette-list li[aria-selected="true"] svg, #palette-list li[aria-selected="true"] small { color: inherit; }
#palette-list .palette-empty { color: var(--ink-3); cursor: default; font-weight: 500; }
.palette-hint { margin: 0; padding: 10px 16px; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: .78rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ touch-first controls */
.btn { transition: transform .16s var(--ease-out), background-color .15s, color .15s, border-color .15s; }
.btn:active { transform: scale(.97); }
@media (pointer: coarse) {
  .btn, .btn.small, select, input[type=text], input[type=search], input[type=number], input[type=password], .seg button, .tabs a, .pager .btn,
  table.data th button, .venue-item, .announce-item, [data-table-toggle] { min-height: var(--tap); }
  .btn, .btn.small { padding-inline: 18px; justify-content: center; }
  .seg button { min-width: var(--tap); }
  table.data th button { display: inline-flex; align-items: center; padding-block: 6px; min-width: var(--tap); }
  .nav a, .sheet-list a { min-height: var(--tap); }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .form-grid label.check { min-height: var(--tap); }
  .leaflet-bar a { width: var(--tap) !important; height: var(--tap) !important; line-height: var(--tap) !important; }
}
select { background-image: none; padding-right: 14px; }

/* ------------------------------------------------------------------ KPI tiles (container queries: numbers never overflow) */
main { container-type: inline-size; container-name: page; }
.kpis { display: grid; gap: var(--gap); grid-template-columns: 1fr 1fr; }
.kpis > .wide { grid-column: 1 / -1; }
@container page (min-width: 640px) { .kpis.six { grid-template-columns: repeat(3, 1fr); } }
@container page (min-width: 880px) {
  .kpis.six { grid-template-columns: repeat(6, 1fr); }
  .kpis.user { grid-template-columns: 1.1fr 1fr 1fr 1.8fr; } .kpis.user > .wide { grid-column: auto; }
}
.charts { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.charts.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
@media (max-width: 600px) { .kpis { gap: 10px; } }
.tile { container-type: inline-size; padding: var(--pad); }
.tile .label { font-size: clamp(.64rem, 4.4cqi, .74rem); }
.tile .value { font-size: clamp(1.5rem, calc(150cqi / var(--chars, 6)), 3.4rem); white-space: nowrap; overflow: hidden; text-overflow: clip; line-height: 1.05; }
.tile .delta { font-size: clamp(.74rem, 5cqi, .85rem); }
.tile.link { text-decoration: none; display: block; color: inherit; transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.tile.link:active { transform: scale(.985); }
.card { transition: box-shadow .2s, transform .2s var(--ease-out); }
.card > header { flex-wrap: wrap; }
.card:has(> .chart-box) { display: flex; flex-direction: column; }
.chart-box { flex: 1 1 auto; height: auto; min-height: var(--chart-h, 240px); }
.chart-box.tall { min-height: var(--chart-h, 340px); }
.chart-box canvas { display: block; }
.chart-note { margin: 10px 0 0; color: var(--ink-3); font-size: .8rem; }

/* skeletons: what you see while data loads (no layout jump, no blank card) */
.skeleton, .chart-box:not([data-state="ready"]), .value[data-loading] {
  position: relative; overflow: hidden; border-radius: 10px;
  background: linear-gradient(100deg, var(--sheet-2) 30%, color-mix(in srgb, var(--rule) 55%, var(--sheet-2)) 50%, var(--sheet-2) 70%) 0 0 / 220% 100%;
}
.value[data-loading] { color: transparent !important; min-width: 3ch; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton, .chart-box:not([data-state="ready"]), .value[data-loading] { animation: shimmer 1.4s linear infinite; }
}
@keyframes shimmer { to { background-position: -120% 0; } }
[aria-busy="true"] { cursor: progress; }

/* ------------------------------------------------------------------ tables: scroll on desktop, cards on phones */
.table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
@media (max-width: 700px) {
  .table-wrap:not(.keep):has(> table.data:not(.mini-table)) { border: 0; background: transparent; overflow: visible; }
  table.data:not(.mini-table):not(.chart-table), table.data:not(.mini-table) tbody { display: block; }
  table.data:not(.mini-table) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data:not(.mini-table) tbody tr { display: grid; gap: 4px 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--sheet); border: 2px solid var(--rule-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
  table.data:not(.mini-table) td { display: grid; grid-template-columns: minmax(84px, 34%) 1fr; gap: 10px; padding: 3px 0; border: 0; max-width: none; text-align: left !important; overflow: visible; white-space: normal !important; word-break: break-word; }
  table.data:not(.mini-table) td::before { content: attr(data-label); font: 600 .68rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); align-self: center; }
  table.data:not(.mini-table) td:nth-child(n+7):not(:last-child) { display: none; }
  table.data:not(.mini-table) td:empty { display: none; }
  table.data:not(.mini-table) td:not([data-label])::before { content: none; }
  table.data:not(.mini-table) td:not([data-label]) { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ toasts + live feedback */
#toasts { position: fixed; z-index: var(--z-toast); right: 18px; bottom: 18px; display: grid; gap: 8px; max-width: min(92vw, 380px); pointer-events: none; }
#toasts .toast { position: static; animation: none; pointer-events: auto; opacity: 1; transform: none; transition: opacity .22s var(--ease-out), transform .22s var(--ease-out); }
@starting-style { #toasts .toast { opacity: 0; transform: translateY(12px) scale(.97); } }
#toasts .toast.leaving { opacity: 0; transform: translateY(6px); transition-duration: .16s; }
@media (max-width: 900px) { #toasts { left: 14px; right: 14px; max-width: none; } }

/* pull to refresh (touch screens) */
.ptr { position: fixed; z-index: var(--z-toast); left: 50%; top: calc(var(--safe-t) + 4px); transform: translate(-50%, -140%); display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-radius: 999px; background: var(--ink); color: var(--paper); font: 600 .82rem var(--font-ui); box-shadow: var(--shadow); pointer-events: none; transition: transform .2s var(--ease-out); }
.ptr.pulling { transition: none; } .ptr.ready .ptr-text::after { content: " ✓"; }
.ptr-ball { display: inline-block; } .ptr.loading .ptr-ball { animation: dribble .7s ease-in-out infinite; }
@keyframes dribble { 0%, 100% { transform: translateY(-3px); } 50% { transform: translateY(5px) scaleY(.88); } }

/* ------------------------------------------------------------------ data-viz: heat maps, funnel, calendar */
.heat { display: grid; gap: 4px; --cell: clamp(10px, 2.4vw, 22px); font: 500 .68rem var(--font-mono); color: var(--ink-3); }
.heat-grid { display: grid; grid-template-columns: auto repeat(24, minmax(var(--cell), 1fr)); gap: 3px; align-items: center; }
.heat-grid .row-label { padding-right: 8px; text-align: right; white-space: nowrap; }
.heat-cell { aspect-ratio: 1; min-height: 12px; border-radius: 4px; background: var(--seq-0, color-mix(in srgb, var(--rule) 55%, transparent)); position: relative; }
.heat-cell[data-l="1"] { background: var(--seq-1); } .heat-cell[data-l="2"] { background: var(--seq-2); } .heat-cell[data-l="3"] { background: var(--seq-3); } .heat-cell[data-l="4"] { background: var(--seq-4); }
.heat-cell:hover, .heat-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 1; }
.heat-hours { display: grid; grid-template-columns: auto repeat(24, minmax(var(--cell), 1fr)); gap: 3px; }
.heat-hours span { text-align: center; font-size: .62rem; } .heat-hours span:not(:nth-child(3n+2)) { visibility: hidden; }
.heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.heat-legend i { width: 14px; height: 14px; border-radius: 4px; display: block; }
.heat-scroll { overflow-x: auto; padding-bottom: 4px; } .heat-scroll > .heat-grid { min-width: 520px; }
.cal-wrap { --cell: clamp(12px, 1.7vw, 18px); }
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--cell)); gap: 3px; grid-auto-columns: var(--cell); }
.cal .heat-cell { width: var(--cell); height: var(--cell); aspect-ratio: auto; min-height: 0; }
.cal-months { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell, 14px); gap: 3px; font: 500 .66rem var(--font-mono); color: var(--ink-3); margin-bottom: 4px; }
.cal-months span { overflow: visible; white-space: nowrap; }
.cal-wrap { overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.funnel { display: grid; gap: 10px; }
.funnel-step { display: grid; gap: 4px; }
.funnel-step .row { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; font-size: .9rem; }
.funnel-step .row b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.funnel-bar { height: 14px; border-radius: 99px; background: var(--sheet-2); overflow: hidden; }
.funnel-bar > i { display: block; height: 100%; width: var(--w, 0%); background: var(--series-1); border-radius: 99px; transform-origin: left; }
.funnel-step:nth-child(2) .funnel-bar > i { background: var(--series-3); } .funnel-step:nth-child(3) .funnel-bar > i { background: var(--series-4); } .funnel-step:nth-child(4) .funnel-bar > i { background: var(--series-2); }
.funnel-step small { color: var(--ink-3); font-size: .76rem; }
@media (prefers-reduced-motion: no-preference) { .funnel-bar > i { animation: grow .9s var(--ease-out) both; } }
@keyframes grow { from { transform: scaleX(0); } }

/* ------------------------------------------------------------------ scroll reveal + page transitions */
@media (prefers-reduced-motion: no-preference) {
  html.js [data-reveal] { opacity: 0; transform: translateY(12px); transition: opacity .38s var(--ease-out), transform .38s var(--ease-out); }
  .reveal > * { animation-duration: .38s; animation-timing-function: var(--ease-out); }
  .reveal > *:nth-child(2) { animation-delay: .045s; } .reveal > *:nth-child(3) { animation-delay: .09s; } .reveal > *:nth-child(4) { animation-delay: .135s; }
  .reveal > *:nth-child(5) { animation-delay: .18s; } .reveal > *:nth-child(6) { animation-delay: .225s; }
  html.js [data-reveal].in { opacity: 1; transform: none; }
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: .12s var(--ease-out) both fade-out; }
  ::view-transition-new(root) { animation: .22s var(--ease-out) both fade-in; }
}
@keyframes fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ easter eggs (all of them off when motion is reduced) */
.egg-ball { position: fixed; left: 0; top: 0; width: 64px; height: 64px; z-index: var(--z-ball); pointer-events: none; will-change: transform; }
.egg-ball svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 10px 6px rgba(0,0,0,.25)); }
.egg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-ball); overflow: hidden; }
.egg-confetti i { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; background: var(--c, var(--court)); left: var(--x); animation: confetti 2.6s var(--d, 0s) ease-in forwards; }
@keyframes confetti { to { transform: translate(var(--dx, 0), 110vh) rotate(var(--r, 540deg)); opacity: .9; } }
html.all-star-mode { --court: #f1d500; --court-ink: #15110c; }
html.all-star-mode .brand b i { animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { text-shadow: 0 0 14px var(--court); } }

.next-skel { height: 76px; } .cal-skel { height: 120px; }
/* login / error pages */
.center-stage { padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
.auth-card { padding: clamp(18px, 4vw, 30px); }
.auth-card .btn { width: 100%; }
@media print { .rail, .topbar, .tabbar, .ptr, #toasts, .skip-link { display: none !important; } main { padding: 0; } }


/* ==========================================================================
   Polish pass (Emil Kowalski's motion rules, Impeccable's craft floor)
   ========================================================================== */

/* hover effects only where hover exists: on touch screens a tap must not leave a button stuck in its hover state */
@media (hover: hover) and (pointer: fine) {
  .card:hover { box-shadow: 0 2px 0 rgba(21,17,12,.06), 0 16px 32px -16px rgba(21,17,12,.32); }
  .tile.link:hover { transform: translateY(-2px); color: inherit; box-shadow: 0 2px 0 rgba(21,17,12,.06), 0 14px 28px -14px rgba(21,17,12,.35); }
  .search-trigger:hover { border-color: var(--ink); color: var(--ink); }
}
@media (hover: none) {
  .btn:hover { background: transparent; color: var(--ink); transform: none; }
  .btn.primary:hover { background: var(--court); border-color: var(--court); color: var(--court-ink); }
  .btn.danger:hover { background: transparent; color: var(--bad); }
  .nav a:hover, .sheet-list a:hover { background: transparent; color: inherit; }
  .nav a[aria-current="page"]:hover { background: var(--ink); color: var(--paper); }
  .tile.link:hover { box-shadow: var(--shadow); color: inherit; }
  .venue-item:hover, .announce-item:hover { border-color: var(--rule); }
  .search-trigger:hover { border-color: var(--rule); color: var(--ink-2); }
}

/* drawn icons: one family, one stroke weight, inherits the text colour and size */
svg.i { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.btn svg.i, .badge svg.i { width: 1.1em; height: 1.1em; vertical-align: -0.16em; }
.task-title { display: inline-flex; align-items: center; gap: 10px; }
.task-title svg.i { color: var(--court); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.back-link:hover { color: var(--court); }
.ptr-ball svg.i { width: 18px; height: 18px; vertical-align: middle; }
.page-head h1 { margin: 0; text-wrap: balance; }
.page-head > div > .muted { margin: 8px 0 0; }

/* the parts of the page the browser draws by default belong to the design too */
::selection { background: color-mix(in srgb, var(--court) 32%, transparent); color: inherit; }
html { caret-color: var(--court); accent-color: var(--court); scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 28%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 26%, transparent); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--ink) 42%, transparent); background-clip: content-box; }
a { text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
table.data td, .chart-table td, .kv dd, .num, .badge { font-variant-numeric: tabular-nums; }
h1, h2, h3 { text-wrap: balance; } p, li { text-wrap: pretty; }
.card p, .banner, main > p, .muted { max-width: 72ch; }           /* readable measure for prose */
.card > header { gap: 8px 12px; }
.card > header h2, .card > header h3 { font-size: var(--step-1); line-height: 1.15; }
.sheet h2 { font-size: var(--step-1); }
.card > header h3 { margin-right: auto; }

/* touch targets the tests found: brand link, links inside table cards, back link, landing navigation */
@media (pointer: coarse) {
  .brand { min-height: var(--tap); justify-content: center; }
  .topbar .brand { display: inline-flex; flex-direction: row; align-items: center; }
  .back-link { min-height: var(--tap); }
  table.data td a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: var(--tap); }
  .sort-picker select { min-height: var(--tap); }
}

/* phones: the table header is hidden, so sorting moves into a native select above the cards */
.sort-picker { display: none; }
@media (max-width: 700px) {
  .sort-picker { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .sort-picker label { font: 600 .72rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
  .sort-picker select { flex: 1; }
}


/* switches: a real toggle (still a native checkbox for keyboards and screen readers), with a thumb-sized label */
label.check, label:has(> input[type=checkbox]) { display: inline-flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; font-weight: 600; }
input[type=checkbox][role=switch] {
  appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; margin: 0; border-radius: 99px; cursor: pointer; position: relative;
  background: var(--rule); border: 2px solid var(--ink-3); transition: background-color .18s var(--ease-out), border-color .18s var(--ease-out);
}
input[type=checkbox][role=switch]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink);
  transition: transform .18s var(--ease-out), background-color .18s var(--ease-out);
}
input[type=checkbox][role=switch]:checked { background: var(--court-btn); border-color: var(--court-btn); }
input[type=checkbox][role=switch]:checked::before { transform: translateX(18px); background: #fff; }
input[type=checkbox][role=switch]:disabled { opacity: .5; cursor: progress; }

/* documentation: a jump bar, readable measure, and anchors that clear the sticky header */
.doc-toc ul { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.doc-toc a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border: 1.5px solid var(--rule); border-radius: 999px; text-decoration: none; font-weight: 600; }
.doc-toc a:hover { border-color: var(--ink); }
[id^="d-"] { scroll-margin-top: 84px; }
.steps li { max-width: 75ch; }

/* pull to refresh only exists on small (touch) layouts; this must come AFTER the base .ptr rule or display:flex wins */
@media (min-width: 901px) { .ptr { display: none; } }

/* toggle buttons (map heat layer, chart "Taula"): the pressed state must be visible without relying on colour alone (filled + a dot, not a ring) */
.btn[aria-pressed] { display: inline-flex; align-items: center; gap: 8px; }
.btn[aria-pressed]::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid currentColor; box-sizing: border-box;
  transition: background-color .15s var(--ease-out), transform .15s var(--ease-out);
}
.btn[aria-pressed="true"], .btn[aria-pressed="true"]:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn[aria-pressed="true"]::before { background: currentColor; }
.btn[aria-pressed="true"]:active::before { transform: scale(.8); }


/* ------------------------------------------------------------------ preferences panel */
.pref-section { display: grid; gap: 4px; }
.pref-row { display: grid; gap: 4px; padding: 14px 0; border-top: 1.5px dashed var(--rule); }
.pref-section > header + .pref-row { border-top: 0; }
.pref-label { display: flex; align-items: center; gap: 14px; min-height: var(--tap); font-weight: 600; margin: 0; padding: 0; border: 0; cursor: pointer; }
.pref-label.stacked { flex-direction: column; align-items: stretch; gap: 8px; cursor: default; }
.pref-label legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.pref-label select { max-width: 420px; min-height: var(--tap); }
.pref-help { margin: 0; max-width: 70ch; font-size: .9rem; }
/* locked rows are not faded (text contrast): the disabled control and the plan badge say it */
.pref-row.is-locked input:disabled, .pref-row.is-locked select:disabled { cursor: not-allowed; }
.pref-saved { color: var(--good); font-weight: 600; opacity: 0; transition: opacity .2s var(--ease-out); }
.pref-saved.on { opacity: 1; }
.pref-multi { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border: 1.5px solid var(--rule); border-radius: 999px; cursor: pointer; font-weight: 600; gap: 8px; }
.chip input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.chip:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:has(input:disabled) { cursor: not-allowed; }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus, var(--court)); outline-offset: 2px; }
.activity-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.activity-list li { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 0; border-top: 1.5px dashed var(--rule); flex-wrap: wrap; }
.activity-list li:first-child { border-top: 0; }
.activity-list li.is-undone { opacity: .6; }
.sk-block { height: 120px; }


/* ------------------------------------------------------------------ Dribbler, the mascot */
.mascot { display: block; flex: none; overflow: visible; }
.auth-card > .mascot { margin: 0 auto 4px; }
.empty .mascot { margin: 0 auto 10px; }
.with-mascot { display: flex; align-items: center; gap: 14px; }
.with-mascot p { margin: 4px 0 0; }
.with-mascot > div { min-width: 0; }                                  /* lets a long title wrap next to the mascot instead of overflowing a 320px phone */
.with-mascot h1 { overflow-wrap: anywhere; }
@media (prefers-reduced-motion: no-preference) {
  .mascot.bob { animation: dribbler-bob 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
  .mascot.hop { animation: dribbler-hop .8s cubic-bezier(.3, 0, .6, 1) infinite; transform-origin: 50% 90%; }
}
@keyframes dribbler-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes dribbler-hop { 0%, 100% { transform: translateY(0) scale(1.08, .92); } 50% { transform: translateY(-18px) scale(.96, 1.04); } }


/* ------------------------------------------------------------------ designation upload */
.dropzone { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2.5px dashed var(--rule); border-radius: 18px; cursor: pointer;
  transition: border-color .15s var(--ease-out), background-color .15s var(--ease-out), transform .15s var(--ease-out); }
.dropzone strong { font: 700 1.1rem var(--font-display); }
.dropzone span { color: var(--ink-2); }
.dropzone:hover, .dropzone.over { border-color: var(--ink); background: var(--sheet-2, transparent); }
.dropzone.over { transform: scale(1.01); }
.dz-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.dz-input:focus-visible + .dropzone, .dropzone:has(+ .dz-input:focus-visible) { outline: 3px solid var(--focus, var(--court)); outline-offset: 3px; border-color: var(--ink); }
#upload-status.error { color: var(--bad); font-weight: 600; }
.note { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--rule); border-radius: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.note p { margin: 0; flex: 1 1 220px; }
.note ul { margin: 6px 0 0; padding-left: 18px; }
.note.warn { border-color: var(--warn); }


/* ------------------------------------------------------------------ Dribbler moves (only when motion is welcome; reduced motion = he stays still) */
@media (prefers-reduced-motion: no-preference) {
  .mascot { transition: transform .2s var(--ease-out); }
  .mascot.breathe { animation: dribbler-breathe 3.8s ease-in-out infinite; transform-origin: 50% 90%; }
  .mascot.pop { animation: dribbler-pop .6s cubic-bezier(.34, 1.56, .64, 1) both; transform-origin: 50% 90%; }
  .mascot.shake { animation: dribbler-shake .55s ease-in-out 1; transform-origin: 50% 90%; }
  .mascot.hop-once { animation: dribbler-jump .7s cubic-bezier(.3, 0, .6, 1) 1; transform-origin: 50% 90%; }
  @media (hover: hover) and (pointer: fine) { .mascot:hover { transform: rotate(-4deg) scale(1.05); } }
}
@keyframes dribbler-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes dribbler-pop { 0% { transform: scale(.55) translateY(8px); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes dribbler-shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 45% { transform: rotate(7deg); } 70% { transform: rotate(-4deg); } }
@keyframes dribbler-jump { 0% { transform: none; } 35% { transform: translateY(-16px) scale(.97, 1.05); } 65% { transform: translateY(0) scale(1.06, .94); } 100% { transform: none; } }

/* "how to read this": a collapsible note, native <details> (keyboard and screen reader friendly with no script) */
.help { border: 1.5px dashed var(--rule); border-radius: 14px; padding: 4px 16px; }
.help summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.help[open] summary { margin-bottom: 4px; }
.help ul { margin: 0 0 12px; padding-left: 20px; max-width: 75ch; display: grid; gap: 6px; }

/* the Wrapped button while it works: it cannot be pressed again, and it shows something is happening */
.btn[aria-busy="true"] { pointer-events: none; cursor: progress; }
.btn .btn-icon { display: inline-flex; align-items: center; }
.btn .mascot { width: 30px; height: 30px; margin-block: -6px; }

/* ------------------------------------------------------------------ calendar verification (code from the invitation) */
.verify-form { display: grid; gap: 10px; }
.verify-form .verify-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.verify-form input { width: 9ch; letter-spacing: .15em; text-align: center; }

/* ------------------------------------------------------------------ public pages: legal texts, footer links, contact button */
.site-head { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: center;
  padding: calc(18px + var(--safe-t)) clamp(16px, 4vw, 56px) 18px; border-bottom: 2px solid var(--rule-strong); }
.lang-switch { display: flex; gap: 6px; }
.lang-switch a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border: 1.5px solid var(--rule);
  border-radius: 999px; font-weight: 600; text-decoration: none; color: var(--ink-2); }
.lang-switch a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.legal-main { padding-bottom: 120px; }
/* prose: one readable column (~75 characters), centred; tables scroll inside themselves instead of widening the page */
.prose { max-width: 75ch; margin-inline: auto; line-height: 1.65; overflow-wrap: break-word; }
.prose h1 { margin: 0 0 .6em; text-wrap: balance; }
.prose h2 { margin: 2em 0 .5em; } .prose h3 { margin: 1.6em 0 .4em; }
.prose p, .prose ul, .prose ol, .prose blockquote { max-width: none; margin: 0 0 1em; }
.prose li + li { margin-top: .35em; }
.prose a { color: var(--court-text); text-underline-offset: 3px; }
.prose code { font: .9em var(--font-mono); background: var(--sheet-2); padding: 1px 5px; border-radius: 4px; }
.prose blockquote { border-left: 4px solid var(--court); padding: 12px 18px; background: var(--sheet); border-radius: 0 10px 10px 0; }
.table-scroll { overflow-x: auto; margin: 0 0 1.2em; border-radius: 6px; }   /* focusable (tabindex=0): keyboard users can scroll it */
.prose table { border-collapse: collapse; width: 100%; font-size: .92em; }
.prose th, .prose td { border: 1px solid var(--rule); padding: 8px 10px; text-align: left; vertical-align: top; min-width: 9em; }
.prose th { background: var(--sheet-2); }
.site-foot { display: grid; gap: 10px; justify-items: center; text-align: center;
  padding: 28px clamp(16px, 4vw, 56px) calc(96px + var(--safe-b)); border-top: 1px solid var(--rule); }
.legal-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; }
.legal-nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 8px; color: var(--ink-2); text-underline-offset: 3px; }
.legal-nav a:hover { color: var(--ink); }
.rail-legal ul { justify-content: flex-start; } .rail-legal a { min-height: 28px; font-size: .78rem; padding: 0 6px 0 0; }   /* desktop rail only (mouse) */
.profile-legal { margin-top: 28px; } .profile-legal .legal-nav ul { justify-content: flex-start; } .profile-legal .legal-nav a { padding-left: 0; }
/* floating contact: a SECONDARY action (outlined, never the brand colour of the primary call to action) */
.contact-fab { position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + var(--safe-b)); z-index: var(--z-toast);
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.contact-fab a { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 999px;
  border: 2px solid var(--rule-strong); background: var(--sheet); color: var(--ink); font-weight: 700; text-decoration: none; box-shadow: var(--shadow); }
.contact-fab a:hover { background: var(--ink); color: var(--paper); }
.contact-fab svg { width: 20px; height: 20px; flex: none; }
@media print { .contact-fab, .lang-switch { display: none !important; } }
@media (min-width: 901px) and (max-height: 760px) { .rail .rail-legal { display: none; } }   /* still on the profile page */
/* anti-spam honeypot: off screen (not display:none, which simple robots skip), hidden from assistive technology in the markup */
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
/* cookie consent banner (only rendered while WEB/app/consent.py has a category): accept and reject look the same on purpose */
.consent-banner { position: fixed; z-index: calc(var(--z-toast) + 1); left: 16px; right: 16px; bottom: calc(16px + var(--safe-b));
  max-width: 640px; margin-inline: auto; padding: 18px; display: grid; gap: 12px; background: var(--sheet); color: var(--ink);
  border: 2px solid var(--rule-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
.consent-title { margin: 0; font-size: var(--step-1); } .consent-text { margin: 0; }
.consent-options { border: 1px solid var(--rule); border-radius: 10px; padding: 10px 14px; display: grid; gap: 10px; }
.consent-option { display: flex; gap: 10px; align-items: flex-start; } .consent-option small { display: block; color: var(--ink-2); }
.consent-option input { width: 22px; height: 22px; margin-top: 2px; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.consent-btn { min-height: var(--tap); padding: 0 18px; border-radius: 999px; border: 2px solid var(--rule-strong); background: var(--sheet);
  color: var(--ink); font: 700 .95rem var(--font-ui); cursor: pointer; }
.consent-link { border-color: transparent; text-decoration: underline; }
.link-btn { background: none; border: 0; padding: 0 8px; min-height: var(--tap); color: var(--ink-2); font: inherit; text-decoration: underline; cursor: pointer; }

/* ------------------------------------------------------------------ legal pages: the scoresheet look of the app */
.legal-main { --content-max: 1200px; padding-top: clamp(24px, 4vw, 56px); }
.legal-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end;
  padding-bottom: clamp(20px, 3vw, 32px); margin-bottom: clamp(24px, 4vw, 44px); border-bottom: 2px solid var(--rule-strong); }
.legal-hero .eyebrow { margin: 0 0 10px; font: 600 .75rem var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--court-text); }
.legal-hero h1 { margin: 0; font-size: var(--step-4); line-height: 1.05; letter-spacing: -.02em; text-wrap: balance; }
.legal-lead { margin: 14px 0 18px; max-width: 62ch; font-size: var(--step-1); color: var(--ink-2); }
.legal-meta { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.legal-meta li { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border: 1.5px solid var(--rule); border-radius: 999px;
  background: var(--sheet); font: 600 .8rem var(--font-mono); font-variant-numeric: tabular-nums; }
.legal-meta li span { font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-size: .7rem; }
.legal-hero-pet { line-height: 0; }
.legal-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }   /* minmax(0): the wide table scrolls, the page does not */
@media (min-width: 1100px) { .legal-layout { grid-template-columns: 250px minmax(0, 1fr); } .legal-toc { position: sticky; top: 24px; } }
@media (max-width: 600px) { .legal-hero { grid-template-columns: minmax(0, 1fr); } .legal-hero-pet { display: none; } }
/* table of contents: numbered like the sections */
.legal-toc details { border: 2px solid var(--rule-strong); border-radius: var(--radius); background: var(--sheet); padding: 6px 8px; }
.legal-toc summary { min-height: var(--tap); display: flex; align-items: center; padding: 0 8px; cursor: pointer;
  font: 600 .75rem var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.legal-toc ol { list-style: none; margin: 0; padding: 0 0 6px; display: grid; gap: 2px; }
.legal-toc a { display: grid; grid-template-columns: 2.4em 1fr; align-items: baseline; padding: 8px; min-height: var(--tap); box-sizing: border-box;
  border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: .9rem; line-height: 1.35; }
.legal-toc a:hover { background: var(--sheet-2); color: var(--ink); }
.legal-toc .num, .legal-card .num { font: 600 .78rem var(--font-mono); color: var(--court-text); font-variant-numeric: tabular-nums; }
/* the document itself: a sheet of the scoresheet */
.legal-sheet { max-width: none; margin: 0; padding: clamp(20px, 4vw, 48px); background: var(--sheet); border: 2px solid var(--rule-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.legal-sheet > :first-child { margin-top: 0; }
.legal-sheet h2 { display: flex; gap: 14px; align-items: baseline; margin: 2.2em 0 .7em; padding-top: 1.1em; border-top: 1px dashed var(--rule);
  font-size: var(--step-2); scroll-margin-top: 20px; }
.legal-sheet h2:first-of-type { margin-top: 1.4em; }
.legal-sheet > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.legal-sheet h2[data-n]::before { content: attr(data-n); flex: none; font: 600 .8rem var(--font-mono); color: var(--court-text);
  border: 1.5px solid currentColor; border-radius: 6px; padding: 3px 7px; transform: translateY(-3px); }
.legal-sheet th { font: 600 .72rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.legal-sheet td, .legal-sheet th { border-color: var(--rule); }
.legal-sheet tr:nth-child(even) td { background: color-mix(in srgb, var(--sheet-2) 60%, transparent); }
.legal-sheet ul li::marker { color: var(--court); }
/* other documents */
.legal-related { margin-top: clamp(32px, 5vw, 64px); }
.legal-related h2 { margin: 0 0 16px; font-size: var(--step-2); }
.legal-related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.legal-card { display: grid; gap: 6px; height: 100%; box-sizing: border-box; padding: 18px 20px; border: 2px solid var(--rule-strong);
  border-radius: var(--radius); background: var(--sheet); color: var(--ink); text-decoration: none; }
.legal-card b { font: 600 1.15rem/1.2 var(--font-display); } .legal-card small { color: var(--ink-2); font-size: .85rem; line-height: 1.45; }
.legal-card:hover { background: var(--ink); color: var(--paper); } .legal-card:hover small, .legal-card:hover .num { color: inherit; }
@media (prefers-reduced-motion: no-preference) {
  .legal-card { transition: transform .2s var(--ease-out), background-color .2s; } .legal-card:hover { transform: translateY(-3px); }
}
