/* La Banqueta — sistema "Gespa i calç" (redisseny 2026-08-14).
   La marca és el verd fosc de la gespa (capçalera = el camp); el fons és
   blanc calç; els títols i els números parlen amb una condensada de dorsal
   (Barlow Condensed) i les dades amb Inter. Groc or per a l'estrella de
   preferit, vermell targeta per a les alertes: semàntica de futbol, no
   decoració. Firma: la línia de calç sota cada títol de pàgina. */

:root {
  --bg: #F4F7F2;
  --surface: #FFFFFF;
  --ink: #16211A;
  --ink-2: #55665B;
  --ink-3: #84948A;
  --line: #E1E8E0;
  --line-strong: #C9D4CA;
  --accent: #0E6A38;          /* gespa */
  --accent-soft: #E4F1E7;
  --topbar-a: #0C5A2E;        /* el camp: degradat de la capçalera */
  --topbar-b: #094A26;
  --or: #C9950B;              /* estrella de preferit */
  --alert: #C63A21;           /* vermell targeta: comptadors i no-llegits */
  --up: #1B7A42;
  --down: #A83B2A;
  --grana: #C63A21;           /* llegat: qualsevol ús antic cau a l'alerta */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(12, 44, 26, .05);
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0C110E;
  --surface: #141B16;
  --ink: #E8EEE9;
  --ink-2: #9FB0A5;
  --ink-3: #6E7F74;
  --line: #242E27;
  --line-strong: #36443B;
  --accent: #43B471;
  --accent-soft: #17301F;
  --topbar-a: #0E2818;
  --topbar-b: #0A2013;
  --or: #E5B62F;
  --alert: #E0583D;
  --up: #4FBE7E;
  --down: #E07A63;
  --grana: #E0583D;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0C110E; --surface: #141B16; --ink: #E8EEE9; --ink-2: #9FB0A5;
    --ink-3: #6E7F74; --line: #242E27; --line-strong: #36443B;
    --accent: #43B471; --accent-soft: #17301F;
    --topbar-a: #0E2818; --topbar-b: #0A2013;
    --or: #E5B62F; --alert: #E0583D; --up: #4FBE7E; --down: #E07A63;
    --grana: #E0583D; --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14.5px/1.45 var(--font-body);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.num { font-variant-numeric: tabular-nums; }

/* ---------- topbar: el camp ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, var(--topbar-a), var(--topbar-b));
  color: #fff;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 9px;
  background: rgba(255, 255, 255, .14);
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700; letter-spacing: .045em;
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text span { font-size: 11px; color: rgba(255, 255, 255, .72); }

.search { position: relative; flex: 1; min-width: 0; }
.search input {
  width: 100%; padding: 8px 12px;
  background: rgba(255, 255, 255, .13); color: #fff;
  border: 1px solid rgba(255, 255, 255, .22); border-radius: 9px;
  font-size: 14px;
}
.search input::placeholder { color: rgba(255, 255, 255, .6); }
.search input:focus { background: rgba(255, 255, 255, .2); outline: none; border-color: rgba(255, 255, 255, .5); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(10, 30, 18, .18);
  max-height: 60vh; overflow-y: auto;
}
.search-hit {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  width: 100%; text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.search-hit:last-child { border-bottom: 0; }
.search-hit:hover, .search-hit:focus-visible { background: var(--accent-soft); outline: none; }
.search-hit .h-name { font-weight: 600; font-size: 13.5px; }
.search-hit .h-team { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.search-empty { padding: 12px; font-size: 13px; color: var(--ink-2); }

.theme-btn {
  flex: none; width: 31px; height: 31px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
  display: grid; place-items: center;
}
.theme-btn:hover { background: rgba(255, 255, 255, .12); }
.theme-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(90deg, #fff 50%, transparent 50%);
  border: 1px solid #fff;
}

/* ---------- layout ---------- */
.view { max-width: 1080px; margin: 0 auto; padding: 18px 14px 40px; }
.foot { max-width: 1080px; margin: 0 auto; padding: 0 14px 28px; color: var(--ink-3); font-size: 11.5px; }
.foot p { margin: 2px 0; }

.state { padding: 48px 0; text-align: center; color: var(--ink-2); font-size: 14px; }
.state strong { color: var(--ink); }

.notice {
  margin: 0 0 14px; padding: 9px 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px; color: var(--ink-2);
}
.notice b { color: var(--ink); font-weight: 600; }

/* ---------- títols: la línia de calç ---------- */
.page-title {
  margin: 2px 0 12px;
  font-family: var(--font-display);
  font-size: 21px; font-weight: 700; letter-spacing: .012em;
  line-height: 1.15;
}
h1.page-title::after {
  content: ""; display: block;
  width: 36px; height: 3px; border-radius: 2px;
  margin-top: 7px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 35%, transparent));
}
h2.page-title, h3.page-title { font-size: 17px; }

/* Acordió de categories a Competicions (Juvenil, Cadet S16…). */
.cat-acc { border-bottom: 1px solid var(--line); }
.cat-acc > .cat-title {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 2px;
  font-family: var(--font-display);
  font-size: 16.5px; font-weight: 600; letter-spacing: .03em;
}
.cat-acc > .cat-title::-webkit-details-marker { display: none; }
.cat-acc > .cat-title::after {
  content: ""; width: 8px; height: 8px; margin-right: 4px; flex: none;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg); transition: transform .15s ease;
}
.cat-acc[open] > .cat-title::after { transform: rotate(45deg); }
.cat-acc > .grid { margin: 2px 0 16px; }

.grid {
  display: grid; gap: 8px;
  grid-template-columns: 1fr;
}
/* Un nom llarg no pot forçar scroll lateral: els items poden encongir. */
.grid > * { min-width: 0; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid { grid-template-columns: 1fr 1fr 1fr 1fr; } }

.card {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left; width: 100%;
  transition: border-color .12s ease, transform .12s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .pos {
  flex: none; width: 30px;
  font-family: var(--font-display);
  font-size: 23px; font-weight: 700;
  color: var(--ink-3); text-align: center;
  font-variant-numeric: tabular-nums;
}
/* Cap de taula: posicions d'ascens en verd gespa. */
.card[data-top="1"] { box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.card[data-top="1"] .pos { color: var(--accent); }
.crest {
  flex: none; width: 36px; height: 36px; object-fit: contain;
}
.crest-fallback {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--accent-soft);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--accent);
}
.card .c-body { min-width: 0; flex: 1; }
.card .c-name {
  display: block; /* els spans inline ignoren overflow/ellipsis */
  font-size: 13.5px; font-weight: 620; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .c-stats {
  display: flex; gap: 8px; margin-top: 3px;
  font-size: 11.5px; color: var(--ink-2);
}
.card .c-stats b { color: var(--ink); font-weight: 650; }

/* ---------- vista equipo ---------- */
.crumb { font-size: 12.5px; color: var(--ink-2); margin-bottom: 12px; display: inline-block; }
.crumb::before { content: "← "; }
.crumb:hover { color: var(--accent); }

.team-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.team-head .crest, .team-head .crest-fallback { width: 54px; height: 54px; }
.team-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; line-height: 1.1; letter-spacing: .01em;
}
.team-line { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-2); }
.team-line b { color: var(--ink); }

.table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0;
  background: var(--surface);
  text-align: right; padding: 8px 10px;
  font-size: 10.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2); border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th.col-name { text-align: left; }
thead th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
thead th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
tbody td {
  padding: 7px 10px; text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: 0; }
tbody td.col-name { text-align: left; font-weight: 600; max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
td .muted, .muted { color: var(--ink-3); }
td .sub { display: block; font-size: 11px; color: var(--ink-2); font-weight: 400; }

.badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  border: 1px solid var(--accent); border-radius: 99px;
  color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .04em;
  vertical-align: 1px;
}

/* ---------- ficha jugador (overlay) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, #07130B 45%, transparent);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay[hidden] { display: none; }
@media (min-width: 700px) { .overlay { align-items: center; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 18px 18px 24px;
}
@media (min-width: 700px) { .sheet { border-radius: 16px; } }
.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; line-height: 1.15; letter-spacing: .01em;
}
.sheet .p-meta { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); }
.close-btn {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line-strong); font-size: 15px; line-height: 1;
  color: var(--ink-2);
}

.tabs { display: flex; gap: 4px; margin: 16px 0 12px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 7px 14px; font-size: 13.5px; font-weight: 650; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.season-ctx {
  font-size: 12.5px; color: var(--ink-2); margin: 0 0 12px;
}
.season-ctx b { color: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px 9px;
}
.tile .t-label {
  font-size: 10px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-2);
}
.tile .t-value {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tile .t-value .nodata { font-size: 18px; color: var(--ink-3); font-weight: 500; }
.tile .t-delta { font-size: 11.5px; margin-top: 1px; color: var(--ink-2); }
.tile .t-delta.up { color: var(--up); }
.tile .t-delta.down { color: var(--down); }

.tab-empty {
  padding: 26px 14px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--ink-2); font-size: 13px;
}
.tab-empty strong { color: var(--ink); display: block; margin-bottom: 4px; font-size: 14px; }

/* ---------- navegació inferior ---------- */
body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-3);
}
.bottomnav button svg { width: 22px; height: 22px; }
.bottomnav button[aria-current="page"] { color: var(--accent); }
.bottomnav button[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%;
  width: 22px; height: 3px; border-radius: 0 0 3px 3px;
  transform: translateX(-50%);
  background: var(--accent);
}
.nav-badge {
  position: absolute; top: 4px; left: calc(50% + 8px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--alert); color: #fff;
  border-radius: 99px;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ---------- preferits: l'estrella és d'or ---------- */
.star {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--ink-3); vertical-align: -8px;
}
.star:hover { color: var(--ink-2); }
.star.on { color: var(--or); }
.team-head-body { min-width: 0; }
.fav-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 22px; }
.fav-head .page-title { margin: 0; }
.tabs-inline { margin: 0; border-bottom: 0; }
.fav-head + .grid, .fav-head + .tab-empty { margin-top: 10px; }

/* ---------- bústia ---------- */
.events {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.event-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; line-height: 1.4;
}
.event-item:last-child { border-bottom: 0; }
.event-item:hover { background: var(--accent-soft); }
.ev-dot {
  flex: none; width: 7px; height: 7px; border-radius: 50%;
  margin-top: 6px; background: transparent;
}
.event-item.unseen .ev-dot { background: var(--alert); }
.ev-body { min-width: 0; }
.ev-date { display: block; margin-top: 2px; font-size: 11px; color: var(--ink-3); }

/* ---------- cerca a pantalla ---------- */
.search-page input {
  font-size: 16px; padding: 11px 14px;
  background: var(--surface); color: var(--ink);
  border-color: var(--line-strong);
}
.search-page input::placeholder { color: var(--ink-3); }
.search-page input:focus { border-color: var(--accent); background: var(--surface); }
@media (max-width: 700px) { .search-top { display: none; } }

/* ---------- avís legal ---------- */
.prose { max-width: 620px; font-size: 14px; }
.prose p { margin: 0 0 12px; }
.prose b { font-weight: 650; }
.foot-link { text-decoration: underline; }

/* ---------- v1.1: campana ---------- */
.bell-btn { position: relative; }
.bell-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--alert); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 5px; border-radius: 999px;
  border: 2px solid var(--topbar-a);
}

/* ---------- v1.1: inici ordenable ---------- */
.comp-row { touch-action: pan-y; }
.comp-row .drag-handle {
  flex: none; width: 40px; height: 40px;
  display: grid; place-items: center;
  color: var(--ink-3); font-size: 18px;
  cursor: grab; touch-action: none;
}
.comp-row.dragging { opacity: .65; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.comp-row.no-nav { cursor: default; }

/* ---------- v1.1: partits ---------- */
.match-row {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 6px;
}
.m-team { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.m-team.right { text-align: right; }
.m-score {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.m-time { color: var(--ink-2); font-size: 13px; }
.date-sep {
  margin: 14px 0 8px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); text-transform: capitalize;
  letter-spacing: .02em;
}
details.jornada { border-top: 1px solid var(--line); padding: 4px 0; }
details.jornada summary {
  cursor: pointer; padding: 8px 2px; font-weight: 600; font-size: 13.5px;
  color: var(--ink-2); list-style: none;
}
details.jornada summary::-webkit-details-marker { display: none; }
details.jornada summary::after { content: "▾"; float: right; color: var(--ink-3); }
details.jornada[open] summary::after { content: "▴"; }

/* ---------- v1.1: T/S últims 10 ---------- */
.ts {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 5px;
  font-size: 11px; font-weight: 700;
}
.ts-T { background: var(--accent); color: #fff; }
.ts-S { background: var(--accent-soft); color: var(--accent); }
details.p10 summary { list-style: none; cursor: pointer; }
details.p10 summary::-webkit-details-marker { display: none; }
details.p10 > .p-meta { padding: 4px 12px 10px; }

/* ---------- v1.1.1: capçalera de plantilla en dos nivells + compacte ---------- */
.th-season {
  text-align: center; color: var(--ink-2);
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
  padding: 5px 6px;
}
.th-season.th-prev { border-left: 1px solid var(--line-strong); }
.table-wrap td:nth-child(3), .table-wrap th[data-sort="prevTeam"] {
  border-left: 1px solid var(--line-strong);  /* separa 26/27 de 25/26 */
}
@media (max-width: 640px) {
  .table-wrap table { font-size: 12px; }
  .table-wrap th, .table-wrap td { padding: 6px 5px; }
  .table-wrap .col-name { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- v1.2: compte ---------- */
.acc-dot {
  position: absolute; top: 2px; right: 2px;
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--or);
  border: 1.5px solid var(--topbar-a);
}
#account { position: relative; }
.acc-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.acc-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); }
.acc-form input {
  padding: 9px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.acc-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.acc-submit { align-self: flex-start; background: var(--accent); color: #fff; border-radius: 8px; padding: 9px 18px; }
.acc-submit:hover { filter: brightness(1.08); }
.acc-error { color: var(--down); font-size: 13px; margin: 0; }
.acc-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.acc-section .page-title { margin-bottom: 6px; }
.acc-section .tab { margin-right: 8px; }
.acc-danger { color: var(--down); border: 1px solid var(--down); border-radius: 8px; }
