/*
 * Sistema visual del panel (decisión 0010). Escenario es el estilo de Gesband;
 * Partitura y Festa son las alternativas que puede elegir cada asociación.
 *
 * <html data-style="escenario|partitura|festa" data-mode="system|light|dark"
 *       style="--brand:…; --brand-ink:…; --brand-text-light:…; …">
 * La marca llega ya corregida para leerse (apps/associations/branding.py).
 */

@font-face { font-family: "Big Shoulders Display"; src: url("fonts/BigShouldersDisplay-Variable.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/InstrumentSans-Variable.ttf") format("truetype"); font-weight: 400 700; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: "Libre Caslon Text"; src: url("fonts/LibreCaslonText-Variable.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Libre Caslon Text"; src: url("fonts/LibreCaslonText-Italic-Variable.ttf") format("truetype"); font-weight: 400 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("fonts/PublicSans-Variable.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/BricolageGrotesque-Variable.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/Figtree-Variable.ttf") format("truetype"); font-weight: 300 900; font-display: swap; }

/* ---------- Tokens: Escenario, claro ---------- */
:root {
  --font-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --display-weight: 800;
  --display-case: uppercase;
  --display-tracking: 0.01em;
  --display-leading: 0.95;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 22px;
  --pill: 999px;

  --bg: #F4F4F2;
  --surface: #FFFFFF;
  --surface-2: #ECECE9;
  --text: #111214;
  --muted: #5C5F66;
  --line: #DADBD8;
  --shadow: 0 1px 2px rgba(17, 18, 20, 0.06);
  --ok-bg: #DDF3E4; --ok-fg: #1D5A33;
  --warn-bg: #FBEFCF; --warn-fg: #6A4B0B;
  --bad-bg: #F8E0E0; --bad-fg: #7A2626;
  --info-bg: #E2EAF6; --info-fg: #1F3E66;
  --brand-text: var(--brand-text-light, #1B4965);
  --accent-text: var(--accent-text-light, #1B4965);
  --brand-edge: var(--brand-edge-light, transparent);
  color-scheme: light;
}

/* ---------- Escenario, oscuro ---------- */
:root[data-mode="dark"] {
  --bg: #0F1012;
  --surface: #1B1D21;
  --surface-2: #24272C;
  --text: #F2F2F0;
  --muted: #A3A6AD;
  --line: #2C2F35;
  --shadow: none;
  --ok-bg: #163A24; --ok-fg: #9BE3B1;
  --warn-bg: #3A2E10; --warn-fg: #F5D27A;
  --bad-bg: #3A1A1A; --bad-fg: #F2A7A7;
  --info-bg: #17263A; --info-fg: #A9C6F0;
  --brand-text: var(--brand-text-dark, #8FB0FF);
  --accent-text: var(--accent-text-dark, #8FB0FF);
  --brand-edge: var(--brand-edge-dark, transparent);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-mode="system"] {
    --bg: #0F1012;
    --surface: #1B1D21;
    --surface-2: #24272C;
    --text: #F2F2F0;
    --muted: #A3A6AD;
    --line: #2C2F35;
    --shadow: none;
    --ok-bg: #163A24; --ok-fg: #9BE3B1;
    --warn-bg: #3A2E10; --warn-fg: #F5D27A;
    --bad-bg: #3A1A1A; --bad-fg: #F2A7A7;
    --info-bg: #17263A; --info-fg: #A9C6F0;
    --brand-text: var(--brand-text-dark, #8FB0FF);
    --accent-text: var(--accent-text-dark, #8FB0FF);
    --brand-edge: var(--brand-edge-dark, transparent);
    color-scheme: dark;
  }
}

/* ---------- Partitura: clásica y editorial ---------- */
:root[data-style="partitura"] {
  --font-display: "Libre Caslon Text", Georgia, serif;
  --font-body: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --display-weight: 400;
  --display-case: none;
  --display-tracking: 0;
  --display-leading: 1.1;
  --radius-s: 8px;
  --radius-m: 10px;
  --radius-l: 14px;
}
:root[data-style="partitura"]:not([data-mode="dark"]) { --bg: #FBFAF7; --surface-2: #F3EFE6; --line: #E6E1D6; --muted: #6B645A; --text: #1E1B18; }
@media (prefers-color-scheme: dark) {
  :root[data-style="partitura"][data-mode="system"] { --bg: #15130F; --surface: #1F1C17; --surface-2: #29251F; --line: #36312A; --muted: #B3AA9C; --text: #F3EEE6; }
}
:root[data-style="partitura"][data-mode="dark"] { --bg: #15130F; --surface: #1F1C17; --surface-2: #29251F; --line: #36312A; --muted: #B3AA9C; --text: #F3EEE6; }

/* ---------- Festa: cálida y popular ---------- */
:root[data-style="festa"] {
  --font-display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --font-body: "Figtree", "Helvetica Neue", Arial, sans-serif;
  --display-weight: 800;
  --display-case: none;
  --display-tracking: -0.01em;
  --display-leading: 1.05;
  --radius-s: 14px;
  --radius-m: 18px;
  --radius-l: 24px;
}
:root[data-style="festa"]:not([data-mode="dark"]) { --bg: #F5F6FA; --surface-2: #ECEEF3; --line: #E1E4EB; --muted: #555A66; --text: #16181D; --shadow: 0 1px 2px rgba(22, 24, 29, 0.06), 0 8px 24px rgba(22, 24, 29, 0.05); }
@media (prefers-color-scheme: dark) {
  :root[data-style="festa"][data-mode="system"] { --bg: #111318; --surface: #1C1F26; --surface-2: #262A33; --line: #303541; --muted: #A9AFBC; --text: #F1F3F7; --shadow: none; }
}
:root[data-style="festa"][data-mode="dark"] { --bg: #111318; --surface: #1C1F26; --surface-2: #262A33; --line: #303541; --muted: #A9AFBC; --text: #F1F3F7; --shadow: none; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--brand-text); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand-text); outline-offset: 2px; }
img { max-width: 100%; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  text-transform: var(--display-case);
  letter-spacing: var(--display-tracking);
  line-height: var(--display-leading);
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: clamp(2.4rem, 5vw, 4rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 0.75rem; }
small, .muted { color: var(--muted); }
.eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

/* ---------- Estructura ---------- */
.shell-header { background: var(--bg); border-bottom: 1px solid var(--line); position: relative; }
.shell-bar {
  max-width: 1240px; margin: 0 auto; padding: 14px clamp(16px, 4vw, 40px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; flex: none; border-radius: var(--radius-s); overflow: hidden;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
  box-shadow: inset 0 0 0 1.5px var(--brand-edge);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name { font-family: var(--font-display); font-weight: var(--display-weight); text-transform: var(--display-case); font-size: 1.2rem; line-height: 1.05; max-width: 16ch; }
.brand-motto { display: block; font-size: 0.8rem; color: var(--muted); font-family: var(--font-body); text-transform: none; font-weight: 400; }

.main-nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; }
.main-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 11px;
  border-radius: var(--radius-s); text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.95rem;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

.shell-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.shell-tools form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.shell-tools select { min-height: 40px; padding: 0 6px; font-size: 0.9rem; }
.shell-tools .link-button { font-size: 0.9rem; }

.page { max-width: 1240px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 64px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head > div { display: flex; flex-direction: column; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---------- Superficies ---------- */
.card, .panel-section {
  background: var(--surface); border-radius: var(--radius-l); padding: clamp(16px, 2.5vw, 24px);
  box-shadow: var(--shadow); border: 1px solid transparent;
}
:root[data-style="partitura"] .card, :root[data-style="partitura"] .panel-section { border-color: var(--line); box-shadow: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; align-items: start; }
.card h2, .card h3 { margin-bottom: 8px; }

/* El cartel: la actividad que viene, con el color de la banda. */
.poster {
  position: relative; overflow: hidden; background: var(--brand); color: var(--brand-ink);
  border-radius: var(--radius-l); padding: clamp(20px, 3vw, 28px); min-height: 220px;
  box-shadow: inset 0 0 0 2px var(--brand-edge);
  display: flex; flex-direction: column; gap: 14px;
}
.poster a { color: inherit; }
.poster .eyebrow { color: inherit; opacity: 0.85; }
.poster-day {
  position: absolute; right: 8px; bottom: -0.25em; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(9rem, 16vw, 13rem); line-height: 1; opacity: 0.15; pointer-events: none;
}
.poster h2 { font-size: clamp(2rem, 3.4vw, 2.6rem); max-width: 22ch; position: relative; }
.poster > *:not(.poster-day) { position: relative; }
.poster h2 a { text-decoration: none; }
.poster h2 a:hover { text-decoration: underline; }

.meter { display: flex; height: 8px; border-radius: var(--pill); overflow: hidden; background: var(--surface-2); }
.meter > span { display: block; }
.meter .yes { background: #2F8F55; }
.meter .no { background: #B54848; }
.poster .meter { background: color-mix(in srgb, var(--brand-ink) 25%, transparent); }
.poster .meter .yes { background: var(--brand-ink); }
.poster .meter .no { background: color-mix(in srgb, var(--brand-ink) 55%, transparent); }

/* ---------- Botones ---------- */
.button, button.button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-m); border: 0;
  background: var(--brand); color: var(--brand-ink);
  font: 700 0.95rem/1 var(--font-body); text-decoration: none; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--brand-edge);
}
.button:hover { filter: brightness(1.08); }
.button.secondary { background: var(--accent); color: var(--accent-ink); }
.button.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.button.danger { background: var(--bad-fg); color: var(--bg); }
:root[data-style="festa"] .button { border-radius: var(--pill); }
.link-button { background: none; border: 0; padding: 0; color: var(--brand-text); font: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0; }
.actions form { margin: 0; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow); }
:root[data-style="partitura"] .table-wrap { border: 1px solid var(--line); box-shadow: none; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td select, td input { min-height: 40px; }

/* ---------- Formularios ---------- */
label { font-weight: 600; display: inline-block; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="datetime-local"],
input[type="number"], input[type="password"], input[type="search"], input[type="url"], input[type="color"],
input[type="file"], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  min-height: 44px; padding: 8px 12px; max-width: 100%;
}
textarea { min-height: 120px; width: 100%; }
input[type="color"] { padding: 4px; width: 64px; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--brand); vertical-align: middle; }
form p { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; }
form p:has(> input[type="checkbox"]) { flex-direction: row; align-items: center; gap: 10px; }
.helptext { color: var(--muted); font-size: 0.85rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 16px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.errorlist, .errors { color: var(--bad-fg); list-style: none; padding: 0; margin: 4px 0; font-weight: 600; }

/* ---------- Estados y mensajes ---------- */
.status {
  display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; border-radius: var(--pill);
  font-size: 0.78rem; font-weight: 700; background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.status.ok, .status.published, .status.accepted, .status.present { background: var(--ok-bg); color: var(--ok-fg); }
.status.warn, .status.pending, .status.draft { background: var(--warn-bg); color: var(--warn-fg); }
.status.bad, .status.cancelled, .status.declined, .status.absent { background: var(--bad-bg); color: var(--bad-fg); }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.message, .messages > li {
  padding: 12px 16px; border-radius: var(--radius-m); background: var(--info-bg); color: var(--info-fg); font-weight: 600;
}
.message.success, .messages > .success { background: var(--ok-bg); color: var(--ok-fg); }
.message.warning, .messages > .warning { background: var(--warn-bg); color: var(--warn-fg); }
.message.error, .messages > .error { background: var(--bad-bg); color: var(--bad-fg); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 8px; }

/* ---------- Firmas de estilo ---------- */
/* Partitura: cinco líneas de pentagrama, la central del color de la banda. */
:root[data-style="partitura"] .staff {
  height: 13px; max-width: 220px;
  background:
    linear-gradient(var(--line), var(--line)) 0 0 / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 3px / 100% 1px no-repeat,
    linear-gradient(var(--brand), var(--brand)) 0 6px / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 9px / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 12px / 100% 1px no-repeat;
}
:root:not([data-style="partitura"]) .staff { display: none; }
:root[data-style="partitura"] .brand-mark { border-radius: 50%; box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--accent); }

/* Festa: la cabecera es del color de la banda y la cruza la faja. */
:root[data-style="festa"] .shell-header { background: var(--brand); color: var(--brand-ink); border-bottom: 0; padding-bottom: 34px; overflow: hidden; }
:root[data-style="festa"] .shell-header::before,
:root[data-style="festa"] .shell-header::after {
  content: ""; position: absolute; left: -60px; right: -60px; background: var(--accent); transform: rotate(-1.4deg);
}
:root[data-style="festa"] .shell-header::before { bottom: 12px; height: 16px; }
:root[data-style="festa"] .shell-header::after { bottom: 3px; height: 4px; opacity: 0.6; }
:root[data-style="festa"] .shell-header .brand-motto,
:root[data-style="festa"] .shell-header .main-nav a { color: var(--brand-ink); }
:root[data-style="festa"] .shell-header .main-nav a { border-radius: var(--pill); }
:root[data-style="festa"] .shell-header .main-nav a:hover { background: color-mix(in srgb, var(--brand-ink) 14%, transparent); }
:root[data-style="festa"] .shell-header .main-nav a[aria-current="page"] { background: var(--brand-ink); color: var(--brand); box-shadow: none; }
:root[data-style="festa"] .shell-header .brand-mark { background: var(--brand-ink); color: var(--brand); border-radius: 15px; }
:root[data-style="festa"] .shell-header .link-button,
:root[data-style="festa"] .shell-header label { color: var(--brand-ink); }

@media (prefers-reduced-motion: no-preference) {
  .button, .main-nav a { transition: background-color 120ms ease, filter 120ms ease; }
}

/* ---------- Utilidades ---------- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.logout, form.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; text-decoration: none; }
details { background: var(--surface); border-radius: var(--radius-m); padding: 12px 16px; }
summary { cursor: pointer; font-weight: 700; min-height: 32px; }
ol, ul { padding-left: 1.3rem; }
.page > h2 { margin-top: 12px; }
.status.open { background: var(--info-bg); color: var(--info-fg); }

/* ---------- Páginas sueltas: acceso, activación ---------- */
.plain-page { max-width: 30rem; margin: 0 auto; padding: clamp(32px, 10vh, 96px) 16px 48px; display: flex; flex-direction: column; gap: 24px; }
.plain-page .card h1 { font-size: clamp(2.2rem, 7vw, 3rem); }
.plain-page form p input, .plain-page form input[type="password"], .plain-page form input[type="text"], .plain-page form input[type="email"] { width: 100%; }
.plain-page .button[type="submit"] { width: 100%; min-height: 48px; }
