/* Sistema de diseño — Elecciones CTH */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Poppins:wght@700;800;900&display=swap');

:root{
  --navy: #101a3d;
  --navy-deep: #0a1230;
  --indigo: #2f3f9e;
  --indigo-light: #4f5fc9;
  --gold: #f0ad00;
  --gold-deep: #c98700;
  --gold-light: #ffe28a;
  --maroon: #7a1730;
  --maroon-light: #b8455f;
  --emerald: #17a367;
  --emerald-light: #22c67f;
  --sky: #2196d8;
  --amber-soft: #fff4d9;
  --bg: #f6f4ec;
  --card: #ffffff;
  --ink: #16193d;
  --ink-soft: #5b5f82;
  --line: #e9e4d6;

  /* fondos de sección, para dar "carácter" pastel-vibrante a cada bloque de grado */
  --tint-pre: #fff3d6;
  --tint-pre-line: #f5d788;
  --tint-pri: #dbeafe;
  --tint-pri-line: #a8cdf5;
  --tint-bac: #fbdfe1;
  --tint-bac-line: #f2b3b8;

  --grad-hero: linear-gradient(135deg, var(--navy-deep), #1c2861 55%, #3a2a80 100%);
  --grad-gold: linear-gradient(135deg, var(--gold), #ffd23f);
  --grad-indigo: linear-gradient(135deg, var(--indigo), var(--indigo-light));
  --grad-maroon: linear-gradient(135deg, var(--maroon), var(--maroon-light));
  --grad-emerald: linear-gradient(135deg, #0d8f6b, var(--emerald-light));
  --grad-sky: linear-gradient(135deg, #1476ad, var(--sky));

  --shadow: 0 10px 30px -12px rgba(16, 26, 61, 0.18);
  --shadow-sm: 0 4px 14px -6px rgba(16, 26, 61, 0.14);
  --shadow-lg: 0 24px 48px -20px rgba(16, 26, 61, 0.28);
  --glow-gold: 0 8px 22px -6px rgba(240, 173, 0, 0.45);
  --glow-indigo: 0 8px 22px -6px rgba(47, 63, 158, 0.4);
  /* sombra tipo "sticker": bloque sólido desplazado, look juguetón */
  --sticker: 5px 5px 0 0 var(--ink);
  --sticker-sm: 3px 3px 0 0 var(--ink);

  --radius: 22px;
  --radius-sm: 16px;
  --radius-lg: 28px;
  --ease: cubic-bezier(.22,1,.36,1);
  --bounce: cubic-bezier(.34,1.56,.64,1);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;overflow-x:hidden;}
body{
  background:
    radial-gradient(1200px 560px at 12% -10%, rgba(47,63,158,.10), transparent 60%),
    radial-gradient(1000px 560px at 105% 0%, rgba(240,173,0,.14), transparent 55%),
    radial-gradient(800px 500px at 50% 120%, rgba(23,163,103,.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
h1,h2,h3,.font-display{ font-family:'Baloo 2', 'Plus Jakarta Sans', sans-serif; letter-spacing:-.005em; }

a{ color: inherit; }

.container{ max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header{
  background: var(--grad-hero);
  color: #fff;
  padding: 46px 0 48px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.site-header::before{
  content:"";
  position:absolute; inset:0;
  background-image: radial-gradient(rgba(255,255,255,.16) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  mask-image: radial-gradient(760px 340px at 50% 0%, #000 0%, transparent 75%);
  opacity:.55;
  pointer-events:none;
}
.site-header::after{
  content:"";
  position:absolute; inset:0;
  background:
    radial-gradient(680px 320px at 92% -20%, rgba(240,173,0,.5), transparent 60%),
    radial-gradient(560px 300px at 4% 115%, rgba(23,163,103,.35), transparent 60%),
    radial-gradient(420px 260px at 50% -30%, rgba(255,255,255,.15), transparent 60%);
  pointer-events:none;
}
.site-header .top-hairline{ position:absolute; left:0; right:0; top:0; height:6px; background: linear-gradient(90deg, var(--gold) 25%, var(--emerald-light) 50%, var(--indigo-light) 75%, var(--maroon-light)); }
.site-header .header-mascot{
  position:absolute; right:3%; bottom:-34px; height:230px; width:auto; z-index:2;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.3)); pointer-events:none; display:none;
}
@media (min-width:820px){ .site-header .header-mascot{ display:block; } }
.site-header .container{ position:relative; display:flex; flex-direction:column; align-items:center; gap:12px; text-align:center; min-width:0; }
.site-header img.logo{
  height: 72px; width:auto; max-width:100%; filter: drop-shadow(0 10px 18px rgba(0,0,0,.35));
  transform: rotate(-3deg); transition: transform .3s var(--bounce);
}
.site-header img.logo.logo-lg{ height: 230px; }
.site-header img.logo:hover{ transform: rotate(0deg) scale(1.04); }
.site-header h1{
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); font-weight: 800; margin: 8px 0 0; line-height:1.05;
  background: linear-gradient(120deg, #fff 25%, var(--gold-light) 60%, #fff 90%);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.site-header p.subtitle{ margin:0; opacity:.85; font-size: 1.02rem; letter-spacing:.01em; font-weight:600; }

.live-badge{
  display:inline-flex; align-items:center; gap:8px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.28);
  padding: 6px 14px; border-radius: 999px; font-size:.78rem; font-weight:700;
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}
.live-dot{ width:8px; height:8px; border-radius:50%; background:#39e07a; box-shadow: 0 0 0 0 rgba(57,224,122,.6); animation: pulse 1.8s infinite; }
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(57,224,122,.55); }
  70%{ box-shadow: 0 0 0 9px rgba(57,224,122,0); }
  100%{ box-shadow: 0 0 0 0 rgba(57,224,122,0); }
}

.top-actions{ display:flex; gap:12px; flex-wrap:wrap; justify-content:center; margin-top:14px; }
.btn-hero{
  padding: 12px 24px; border-radius: 999px; font-weight:800; font-size:.94rem;
  background: rgba(255,255,255,.12); color:#fff; border:2px solid rgba(255,255,255,.4);
  cursor:pointer; transition: .18s var(--bounce); backdrop-filter: blur(6px);
  display:inline-flex; align-items:center; gap:7px; min-height:46px;
}
.btn-hero:hover{ background: rgba(255,255,255,.22); transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 22px -10px rgba(0,0,0,.4); }
.btn-hero:active{ transform: translateY(-1px) scale(1); }
.btn-hero.gold{ background: var(--grad-gold); color:#3d2400; border-color: #fff; box-shadow: var(--glow-gold); }
.btn-hero.gold:hover{ filter: brightness(1.06); box-shadow: 0 14px 28px -8px rgba(240,173,0,.6); }

/* ---------- Sections ---------- */
main{ padding: 44px 0 70px; }
.section-block{
  margin-bottom: 36px; padding: 24px 22px 26px; border-radius: var(--radius-lg);
  background: var(--tint-bg, var(--bg)); border: 2px solid var(--tint-line, var(--line));
}
.section-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom: 18px; flex-wrap: wrap;}
.section-head h2{ font-size: 1.55rem; font-weight:700; margin:0; display:flex; align-items:center; gap:12px; }

.grade-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(155px,1fr)); gap: 12px; }
.grade-card{
  background: var(--card); border: 2.5px solid var(--ink); border-radius: var(--radius-sm);
  padding: 16px 17px; text-align:left; cursor:pointer; box-shadow: var(--sticker);
  transition: transform .16s var(--bounce), box-shadow .16s var(--bounce), filter .2s ease;
  position: relative; overflow:hidden;
}
.grade-card::before{
  content:""; position:absolute; left:-2.5px; top:-2.5px; right:-2.5px; height:6px; background: var(--bar-color, var(--indigo));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.grade-card:hover{ transform: translate(-2px,-2px); box-shadow: 7px 7px 0 0 var(--ink); }
.grade-card:active{ transform: translate(1px,1px); box-shadow: 2px 2px 0 0 var(--ink); }
.grade-card .name{ font-weight:700; font-size: 1.08rem; font-family:'Baloo 2',sans-serif; margin-top:4px; }
.grade-card .meta{ font-size:.78rem; color: var(--ink-soft); margin-top:4px; font-weight:600; }
.grade-card.pending{ opacity:.75; }
.grade-card.pending:hover{ opacity:1; }
.grade-card.done .meta{ color: var(--emerald); font-weight:800; }
.grade-card.done .meta::before{ content:"● "; }

.section-actions{ display:flex; flex-wrap:wrap; justify-content:center; gap: 12px; margin-top:16px; }
.section-actions .action-card{ flex: 0 1 240px; }
.action-card{
  display:flex; align-items:center; gap:13px; text-align:left;
  background: var(--card); border: 2.5px solid var(--ink); border-radius: var(--radius-sm);
  padding: 13px 16px; cursor:pointer; box-shadow: var(--sticker);
  transition: transform .16s var(--bounce), box-shadow .16s var(--bounce), filter .2s ease;
  position: relative; overflow:hidden;
}
.action-card:hover{ transform: translate(-2px,-2px); box-shadow: 7px 7px 0 0 var(--ink); }
.section-block.preescolar :is(.grade-card,.action-card):hover{ background:#fff3c4; border-color:#d89a00; box-shadow:7px 7px 0 0 #c78c00; }
.section-block.primaria :is(.grade-card,.action-card):hover{ background:#e1f3ff; border-color:#258fd1; box-shadow:7px 7px 0 0 #1979b8; }
.section-block.bachillerato :is(.grade-card,.action-card):hover{ background:#ffe1e4; border-color:#cc5260; box-shadow:7px 7px 0 0 #a93949; }
.action-card:active{ transform: translate(1px,1px); box-shadow: 2px 2px 0 0 var(--ink); }
.action-card .icon{
  flex-shrink:0; width:42px; height:42px; border-radius:13px; display:flex; align-items:center; justify-content:center;
  font-size:1.3rem; background: var(--grad-maroon); color:#fff; transform: rotate(-3deg);
}
.action-card .text{ min-width:0; }
.action-card .name{ font-weight:700; font-size: .96rem; font-family:'Baloo 2',sans-serif; line-height:1.25; }
.action-card .meta{ font-size:.78rem; color: var(--ink-soft); margin-top:2px; font-weight:600; }
.action-card.pending{ opacity:.75; }
.action-card.done .meta{ color: var(--emerald); font-weight:800; }
.action-card.done .meta::before{ content:"● "; }

.btn-outline{
  padding: 10px 18px; border-radius: 999px; font-weight:700; font-size:.85rem; min-height:44px;
  background:#fff; border:1.5px solid var(--line); color: var(--ink); cursor:pointer; box-shadow: var(--shadow-sm);
  transition: .18s var(--ease);
}
.btn-outline:hover{ border-color: var(--indigo-light); color: var(--indigo); transform: translateY(-2px); box-shadow: var(--shadow); }

.footnote{ font-size:.78rem; color: var(--ink-soft); margin-top:10px; }

/* ---------- Modal ---------- */
.modal-backdrop{ position:fixed; inset:0; background: rgba(9,12,32,.6); backdrop-filter: blur(3px); z-index:60; display:none; align-items:center; justify-content:center; padding:14px; }
.modal-backdrop.open{ display:flex; animation: fadeIn .18s ease; }
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }
.modal-card{
  background:#fff; border-radius: var(--radius-lg); width:100%; max-width: 760px; max-height: 90vh; overflow:auto;
  border: 3px solid var(--ink); box-shadow: 8px 8px 0 0 var(--ink);
  animation: modalIn .22s var(--bounce);
}
@keyframes modalIn{ from{ opacity:0; transform: translateY(10px) scale(.98); } to{ opacity:1; transform:none; } }
.modal-head{
  padding: 22px 24px; border-bottom:3px solid var(--ink); display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  background: linear-gradient(180deg, #fbfcff, #fff);
}
.modal-head h3{ margin:0; font-size:1.4rem; font-weight:700; font-family:'Baloo 2',sans-serif; }
.modal-head p{ margin:4px 0 0; color:var(--ink-soft); font-size:.85rem; font-weight:700; }
.modal-head .actions{ display:flex; gap:8px; flex-shrink:0; }
.icon-btn{ border:2px solid var(--ink); background: #fff; width:38px; height:38px; border-radius:11px; cursor:pointer; font-size:1rem; display:flex; align-items:center; justify-content:center; transition:.15s var(--bounce); }
.icon-btn:hover{ background:var(--bg); transform: translate(-1px,-1px); box-shadow: 2px 2px 0 0 var(--ink); }
.modal-body{ padding: 22px 24px 28px; }

/* ---------- Diálogo genérico (confirmar / alerta / texto) ---------- */
.dialog-card{ max-width: 420px; }
.dialog-card .modal-body{ padding: 24px; }
.dialog-message{ margin:0; font-weight:600; color:var(--ink); line-height:1.5; }
.dialog-input{
  width:100%; margin-top:14px; padding:11px 13px; border-radius:11px; border:1.5px solid var(--line);
  font-size:.95rem; font-family:inherit;
}
.dialog-input:focus{ border-color: var(--indigo-light); outline:none; }
.dialog-actions{ display:flex; gap:10px; justify-content:flex-end; margin-top:22px; }
.dialog-actions button{
  padding: 11px 22px; border-radius:999px; font-weight:800; cursor:pointer; border:none; transition:.16s var(--bounce);
  font-family:'Baloo 2',sans-serif;
}
.dialog-actions .dialog-cancel{ background:var(--bg); color:var(--ink); border:1.5px solid var(--line); }
.dialog-actions .dialog-cancel:hover{ background:var(--line); }
.dialog-actions .dialog-ok{ background: var(--grad-indigo); color:#fff; box-shadow: var(--sticker-sm); }
.dialog-actions .dialog-ok:hover{ transform: translate(-2px,-2px); box-shadow: 5px 5px 0 0 var(--ink); }
.dialog-actions .dialog-ok.danger{ background: linear-gradient(135deg,#c0392b,#e05656); }

.chip-row{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom: 16px; }
.chip{
  padding:7px 16px; border-radius:999px; font-size:.82rem; font-weight:700; cursor:pointer;
  background: var(--bg); color: var(--ink-soft); border:2px solid var(--line); transition: .15s var(--bounce);
}
.chip:hover{ border-color: var(--indigo-light); color: var(--indigo); transform: translateY(-1px); }
.chip.active{ background: var(--grad-indigo); color:#fff; border-color: var(--ink); box-shadow: 3px 3px 0 0 var(--ink); }

.chart-wrap{ position:relative; height: 300px; }

.winner-banner{
  margin-top: 18px; padding: 20px 22px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--amber-soft), #fff);
  border: 2.5px solid var(--gold); text-align:center;
  box-shadow: var(--sticker-sm);
}
.winner-banner .kicker{ font-size:.74rem; text-transform:uppercase; letter-spacing:.1em; color:#8a6d00; font-weight:800; }
.winner-banner .name{ font-size: 1.55rem; font-weight:700; margin-top:4px; font-family:'Baloo 2',sans-serif; }
.winner-banner .votes{ color: var(--ink-soft); margin-top:2px; font-size:.9rem; font-weight:700; }

.breakdown-table{ width:100%; border-collapse: collapse; margin-top:16px; font-size:.88rem; }
.breakdown-table td{ padding:9px 4px; border-bottom:1px solid var(--line); }
.breakdown-table td:last-child{ text-align:right; font-weight:800; }
.swatch{ display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:9px; }

.empty-state{ text-align:center; padding: 34px 10px; color: var(--ink-soft); font-weight:500; }

/* ---------- Focus & accessibility ---------- */
:focus-visible{ outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
button{ font-family: inherit; }

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

@media (max-width:640px){
  .container{ padding:0 16px; }
  .site-header{ padding:26px 0 30px; }
  .site-header .container{ gap:10px; }
  .site-header img.logo,
  .site-header img.logo.logo-lg{
    width:min(92vw, 360px); height:auto; max-height:150px; object-fit:contain; transform:none;
  }
  .site-header h1{ font-size:clamp(2rem, 8vw, 2.55rem); margin-top:2px; }
  .site-header h1 span{ display:block; }
  .site-header p.subtitle{ font-size:.95rem; line-height:1.4; max-width:34ch; }
  .top-actions{ display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); width:100%; gap:10px; margin-top:8px; }
  .top-actions .btn-hero{ width:100%; min-width:0; min-height:44px; justify-content:center; padding:9px 8px; font-size:.8rem; line-height:1.2; text-align:center; white-space:normal; overflow-wrap:anywhere; }
  .live-badge{ font-size:.74rem; }
  main{ padding:28px 0 54px; }
  .section-block{ margin-bottom:22px; padding:20px 16px 22px; }
  .section-head h2{ font-size:1.4rem; }
  .grade-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); gap:10px; }
  .grade-card{ padding:14px 12px; }
  .grade-card .name{ font-size:1rem; }
  .section-actions .action-card{ flex-basis:100%; }
  .chart-wrap{ height:260px; }
  .modal-backdrop{ padding:8px; }
  .modal-head,.modal-body{ padding-left:16px; padding-right:16px; }
}
