/* HayLuzEnPR. A public-service status board: answer first ("¿hay luz?"), then regions, load
   shedding, history and the neighborhood lookup. Light by default with a matching dark mode.
   Status colors carry meaning (green = with power, red = outages, violet = load shedding,
   blue = planned work); the amber "luz" accent is reserved for the brand and highlights. */
:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --line: #e2e5e0;
  --line-strong: #cfd4cc;
  --text: #151a17;
  --muted: #5d665f;
  --faint: #8a928b;
  --luz: #f2b200;
  --luz-ink: #8a6200;
  --luz-soft: #fff5d6;
  --ok: #15803d;
  --ok-soft: #e4f4e9;
  --bad: #d92d20;
  --bad-soft: #fde8e6;
  --shed: #7c3aed;
  --shed-soft: #efe7fd;
  --plan: #2563eb;
  --plan-soft: #e6eefd;
  --focus: #2563eb;
  --ink-btn: #151a17;
  --ink-btn-text: #ffffff;
  --f-head: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 10px;
  --pad: max(16px, 4vw);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1210;
    --surface: #161a17;
    --surface-2: #1b201c;
    --line: #2a302b;
    --line-strong: #3a423b;
    --text: #e9ece8;
    --muted: #a1aaa2;
    --faint: #7b847c;
    --luz: #ffc72c;
    --luz-ink: #ffd666;
    --luz-soft: #3a3010;
    --ok: #4ade80;
    --ok-soft: #133321;
    --bad: #ff6b5e;
    --bad-soft: #3d1714;
    --shed: #b794ff;
    --shed-soft: #2a1d47;
    --plan: #7aa7ff;
    --plan-soft: #18264a;
    --focus: #7aa7ff;
    --ink-btn: #e9ece8;
    --ink-btn-text: #101311;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--f-head); text-wrap: balance; letter-spacing: -0.01em; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: var(--pad); }
.eyebrow { font: 600 12px/1.2 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* header */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; }
.site-head .wrap { display: flex; align-items: center; gap: 8px 20px; padding-block: 10px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 700 21px/1 var(--f-head); letter-spacing: -0.02em; }
.logo b { color: var(--luz-ink); font-weight: 700; }
.logo svg { width: 24px; height: 24px; }
.logo .bulb { fill: var(--luz); } .logo .bolt { fill: var(--text); }
.nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { position: relative; white-space: nowrap; text-decoration: none; padding: 8px 11px; font-weight: 600; font-size: 15px; color: var(--muted); }
.nav a::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: 0; height: 2px; border-radius: 2px; background: var(--luz); transform: scaleX(0); transform-origin: left; transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.nav a:hover { color: var(--text); }
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }
.nav a[aria-current="page"] { color: var(--text); }
@media (max-width: 640px) { .site-head { position: static; } .nav { margin-left: 0; flex-basis: 100%; } }

/* page */
.page { display: grid; gap: 22px; padding-block: 26px 56px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 24px; }
.panel > h2, .section-head h2 { font-size: 24px; font-weight: 700; }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.section-head p { color: var(--muted); font-size: 15px; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }

/* the answer */
.answer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 28px; align-items: center; padding: 28px; position: relative; overflow: hidden; }
.answer h1 { font-size: clamp(28px, 4.4vw, 44px); line-height: 1.05; font-weight: 750; font-stretch: 90%; }
.answer .verdict { margin-top: 10px; font: 700 clamp(20px, 2.6vw, 26px)/1.2 var(--f-head); }
.answer .verdict[data-tone="ok"] { color: var(--ok); }
.answer .verdict[data-tone="warn"] { color: var(--luz-ink); }
.answer .verdict[data-tone="bad"] { color: var(--bad); }
.answer .sub { color: var(--muted); margin-top: 6px; }
.big { text-align: right; }
.big .pct { font: 800 clamp(48px, 8vw, 84px)/0.95 var(--f-head); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.big .pct small { font-size: .42em; font-weight: 700; margin-left: 2px; }
.big .lbl { color: var(--muted); font-weight: 600; margin-top: 4px; }
.meter { grid-column: 1 / -1; height: 12px; border-radius: 6px; background: var(--ok-soft); overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; }
.meter .m-out { background: var(--bad); } .meter .m-plan { background: var(--plan); } .meter .m-shed { background: var(--shed); }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; }
.chip b { font-variant-numeric: tabular-nums; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.out { background: var(--bad); } .dot.plan { background: var(--plan); } .dot.shed { background: var(--shed); } .dot.ok { background: var(--ok); }
.updated { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 14px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: live 1.8s ease-out infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
@media (max-width: 640px) { .answer { grid-template-columns: 1fr; padding: 22px 20px; } .big { text-align: left; } }

/* load-shedding banner */
.shed-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 16px 20px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.shed-banner[data-active="1"] { background: var(--shed-soft); border-color: color-mix(in srgb, var(--shed) 40%, transparent); }
.shed-banner .ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); flex: none; font-weight: 800; }
.shed-banner[data-active="1"] .ic { background: var(--shed); color: #fff; }
.shed-banner strong { font-family: var(--f-head); font-size: 18px; }
.shed-banner p { color: var(--muted); font-size: 15px; }
.shed-banner .towns { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.shed-banner .towns a { text-decoration: none; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--shed) 35%, transparent); font-size: 14px; font-weight: 600; }

/* search */
.search { display: grid; gap: 10px; }
.search label { font: 700 20px/1.2 var(--f-head); }
.search p { color: var(--muted); font-size: 15px; }
.search input { width: 100%; padding: 14px 16px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--surface); font-size: 18px; }
.search input:focus { outline: none; border-color: var(--luz); box-shadow: 0 0 0 4px color-mix(in srgb, var(--luz) 25%, transparent); }
.results { list-style: none; margin: 0; padding: 0; display: grid; }
.results li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 4px; border-top: 1px solid var(--line); text-decoration: none; }
.results li:first-child a { border-top: 0; }
.results li a:hover { background: var(--surface-2); }
.results .r-name { font-weight: 700; }
.results .r-town { color: var(--muted); font-size: 14px; grid-column: 1; }
.results .r-empty { padding: 10px 4px; color: var(--muted); }
.stage { display: inline-flex; align-items: center; justify-content: center; grid-row: 1 / span 2; grid-column: 2; align-self: center; padding: 4px 10px; border-radius: 999px; font: 700 13px/1 var(--f-body); background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.stage.s1 { background: var(--shed-soft); color: var(--shed); border-color: transparent; }
.stage.s2 { background: var(--plan-soft); color: var(--plan); border-color: transparent; }
.stage.s3 { background: var(--luz-soft); color: var(--luz-ink); border-color: transparent; }
.stage.sc { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.stage.off { background: var(--shed); color: #fff; }

/* regions */
.regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.region { display: grid; gap: 8px; padding: 16px 18px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); text-decoration: none; }
.region:hover { border-color: var(--line-strong); }
.region h3 { font-size: 19px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.region h3 span { font-variant-numeric: tabular-nums; }
.region h3 span[data-tone="ok"] { color: var(--ok); } .region h3 span[data-tone="warn"] { color: var(--luz-ink); } .region h3 span[data-tone="bad"] { color: var(--bad); }
.region .bar { height: 6px; border-radius: 3px; background: var(--ok-soft); overflow: hidden; display: flex; }
.region .bar i { height: 100%; }
.region p { color: var(--muted); font-size: 14px; }

/* chart */
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 5px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink-btn); color: var(--ink-btn-text); }
.chart { margin-top: 14px; }
.chart svg { display: block; width: 100%; height: 220px; }
.chart .area { fill: color-mix(in srgb, var(--bad) 18%, transparent); }
.chart .line { fill: none; stroke: var(--bad); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .ticks { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.chart .note { color: var(--muted); font-size: 14px; margin-top: 8px; }
.chart .peak { font-weight: 700; color: var(--text); }

/* towns */
.towns-by-region { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px 24px; }
.towns-by-region h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.towns-by-region ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.towns-by-region a { text-decoration: none; font-size: 15px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.towns-by-region a:hover { border-color: var(--luz); }

/* town page */
.stage-groups { display: grid; gap: 18px; }
.stage-group h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.stage-group > p { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.feeder { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 4px 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.feeder:first-of-type { border-top: 0; }
.feeder .f-id { font: 600 14px/1.3 var(--f-body); color: var(--muted); font-variant-numeric: tabular-nums; }
.feeder .f-id small { display: block; font-weight: 400; }
.feeder .f-places { font-size: 15px; }
.feeder .f-state { grid-column: 2; font-size: 13px; font-weight: 700; color: var(--shed); }
.feeder.is-off { background: var(--shed-soft); border-radius: 8px; padding-inline: 10px; }
@media (max-width: 560px) { .feeder { grid-template-columns: 1fr; } .feeder .f-state { grid-column: 1; } }

/* prose */
.prose { display: grid; gap: 10px; max-width: 74ch; }
.prose h2 { font-size: 22px; font-weight: 700; }
.prose p, .prose li { color: var(--muted); }
.prose strong { color: var(--text); }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }

/* footer */
.site-foot { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px; }
.site-foot .wrap { display: grid; gap: 6px; padding-block: 22px calc(22px + env(safe-area-inset-bottom, 0px)); }
.site-foot a { color: var(--muted); }

.skeleton { color: var(--faint); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* town page: live region box */
.town-live { display: grid; gap: 10px; }
