/* PowaOn live map: a night view of Nigeria where light glows and darkness is deep.
   Glass materials and sheet behaviour follow iOS/Android conventions. */
:root {
  --bg: #04060c;
  --glass: rgba(14, 18, 30, 0.62);
  --glass-strong: rgba(14, 18, 30, 0.82);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-hi: rgba(255, 255, 255, 0.16);
  --text: #f2f4f8;
  --muted: #8d97ab;
  --lit: #ffc94d;
  --lit-2: #ff9f1c;
  --lit-glow: rgba(255, 186, 64, 0.55);
  --dark: #0a0f1f;
  --dark-edge: #2b3e6b;
  --cool: #7f97d8;
  --tg: #2aabee;
  --r-lg: 22px;
  --r-md: 14px;
  --spring: cubic-bezier(0.32, 0.72, 0, 1); /* iOS sheet curve */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* Set from innerHeight by map.js: Android WebView resolves vh against its first, tiny layout. */
  --vh: 1vh;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Google Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}

#map, #fx, .vignette { position: fixed; inset: 0; }
#fx { pointer-events: none; z-index: 1; }
.vignette {
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: saturate(160%) blur(22px);
  -webkit-backdrop-filter: saturate(160%) blur(22px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.muted { color: var(--muted); margin: 0; }
.small { font-size: 12.5px; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  z-index: 3;
  top: calc(var(--safe-t) + 12px);
  left: 12px;
  right: 72px;
  max-width: 440px;
  height: 50px;
  border-radius: 25px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 14px;
}
.logo {
  flex: none;
  width: 24px; height: 24px;
  fill: var(--lit);
  filter: drop-shadow(0 0 7px var(--lit-glow));
  animation: hum 3.4s ease-in-out infinite;
}
#search {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* no iOS zoom-on-focus */
}
#search::placeholder { color: var(--muted); }
#search::-webkit-search-cancel-button { filter: invert(0.7); }
.live {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 201, 77, 0.12);
  color: var(--lit);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--lit); box-shadow: 0 0 0 0 var(--lit-glow); animation: ping 2s var(--ease-out) infinite; }

.results {
  position: absolute;
  top: 58px; left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  max-height: calc(var(--vh) * 50);
  overflow: auto;
  animation: drop 0.25s var(--ease-out);
}
.results li {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px;
}
.results li small { color: var(--muted); }
.results li[aria-selected="true"], .results li:hover { background: rgba(255, 255, 255, 0.07); }

/* ---------- floating buttons ---------- */
.fabs {
  position: fixed;
  z-index: 3;
  top: calc(var(--safe-t) + 12px);
  right: 12px;
  display: grid;
  gap: 10px;
}
.fab {
  width: 50px; height: 50px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.25s var(--spring), background 0.2s;
}
.fab svg { width: 22px; height: 22px; fill: currentColor; }
.fab:active { transform: scale(0.92); }
.fab.busy svg { animation: spin 1s linear infinite; }

/* ---------- sheet ---------- */
.sheet {
  position: fixed;
  z-index: 4;
  left: 0; right: 0; bottom: 0;
  height: min(calc(var(--vh) * 78), 560px);
  padding: 0 18px calc(var(--safe-b) + 18px);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 0;
  background: var(--glass-strong);
  transform: translateY(calc(100% - var(--peek, 168px)));
  transition: transform 0.5s var(--spring);
  touch-action: none;
  overflow: hidden;
}
.sheet[data-snap="half"] { transform: translateY(calc(100% - min(calc(var(--vh) * 56), 430px))); }
.sheet[data-snap="full"] { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet[data-snap="full"] .more, .sheet[data-snap="half"] .more { overflow: auto; }

.grabber { display: grid; place-items: center; height: 26px; cursor: grab; margin: 0 -18px; }
.grabber span { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.28); }

.hero { display: flex; align-items: center; gap: 14px; }
.hero h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.ring { position: relative; width: 58px; height: 58px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring .track { stroke: var(--dark); }
.ring .arc {
  stroke: url(#none) var(--lit);
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 119.4;
  filter: drop-shadow(0 0 4px var(--lit-glow));
  transition: stroke-dashoffset 1s var(--ease-out);
}
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 14px; }

.stats { display: flex; gap: 10px; margin-top: 14px; }
.stat {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
}
.stat b { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.stat small { grid-column: 2; color: var(--muted); font-size: 12px; margin-top: -2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; grid-row: span 2; }
.dot.lit { background: var(--lit); box-shadow: 0 0 10px var(--lit-glow); }
.dot.dark { background: var(--dark); border: 1px solid var(--dark-edge); }

/* area card */
#area { animation: rise 0.4s var(--spring); }
.area-head { display: flex; justify-content: space-between; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.badge.lit { background: rgba(255, 201, 77, 0.14); color: var(--lit); }
.badge.dark { background: rgba(127, 151, 216, 0.13); color: var(--cool); }
.badge.mixed { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.close {
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.08); color: var(--text);
  font-size: 20px; line-height: 1; cursor: pointer;
}
#area h2 { margin: 10px 0 2px; font-size: 26px; letter-spacing: -0.02em; }
#area h2.lit { color: var(--lit); text-shadow: 0 0 18px var(--lit-glow); }
#area h2.dark { color: #c3cff0; }
.actions { display: grid; gap: 8px; margin-top: 14px; }

.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .row .btn + .btn { margin-top: 0; }

/* area report */
#area { height: calc(100% - 26px); overflow-y: auto; overscroll-behavior: contain; margin: 0 -18px; padding: 0 18px 24px; }
#area-body { display: grid; gap: 12px; margin-top: 16px; }
.card {
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
}
.card header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.card h3 { margin: 0; font-size: 15px; font-weight: 650; }

.timeline {
  position: relative;
  height: 26px;
  border-radius: 8px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 6px, transparent 6px 12px);
  overflow: hidden;
}
.timeline i { position: absolute; top: 0; bottom: 0; }
.timeline i.lit { background: linear-gradient(180deg, #ffd56b, var(--lit-2)); box-shadow: 0 0 14px var(--lit-glow); }
.timeline i.dark { background: var(--dark); box-shadow: inset 0 0 0 1px var(--dark-edge); }
.timeline .now { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: #fff; border-radius: 1px; box-shadow: 0 0 8px #fff; }
.ticks { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 11px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  display: grid;
}
.tile b { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.tile small { color: var(--muted); font-size: 12px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 104px; }
.day { display: grid; grid-template-rows: 1fr auto; gap: 4px; text-align: center; }
.day small { color: var(--muted); font-size: 11px; }
.col { display: flex; flex-direction: column-reverse; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.03); }
.col i { display: block; transition: height 0.8s var(--ease-out); }
.col i.lit { background: linear-gradient(0deg, var(--lit-2), #ffd56b); box-shadow: 0 0 10px var(--lit-glow); }
.col i.dark { background: var(--dark); }

.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 34px; }
.hours i {
  border-radius: 3px;
  background: rgb(255 201 77 / calc(0.08 + var(--a) * 0.92));
  box-shadow: 0 0 calc(var(--a) * 10px) rgb(255 186 64 / calc(var(--a) * 0.6));
}

/* Arabic: the page flows right to left, but time still runs left to right on charts. */
[dir="rtl"] .timeline, [dir="rtl"] .ticks, [dir="rtl"] .week, [dir="rtl"] .hours { direction: ltr; }
[dir="rtl"] .grabber { margin: 0 -18px; }

.nearby { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.nearby .dot { width: 8px; height: 8px; }

.skeleton {
  height: 56px; border-radius: var(--r-md);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skeleton.short { height: 80px; }
.skeleton.tall { height: 130px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* "You are here": the iOS/Android blue dot */
.me { width: 16px; height: 16px; border-radius: 50%; background: #3d8bff; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(61, 139, 255, 0.5); animation: me 2s infinite; }
@keyframes me { 0% { box-shadow: 0 0 0 0 rgba(61, 139, 255, 0.5); } 100% { box-shadow: 0 0 0 18px rgba(61, 139, 255, 0); } }

.more { margin-top: 16px; max-height: calc(100% - 150px); }
#area:not([hidden]) ~ .more { display: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit; font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s var(--spring), background 0.2s;
}
.chip:active { transform: scale(0.95); }
.chip:hover { background: rgba(255, 255, 255, 0.1); }

/* Light league */
.league { margin-bottom: 16px; }
.league ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.league li button {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 26px 1fr 72px 42px;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.league li button:hover { background: rgba(255, 255, 255, 0.05); }
.league .rank { color: var(--muted); font-size: 13px; text-align: center; }
.league li:first-child .rank { color: var(--lit); font-weight: 700; }
.league .flag { font-size: 18px; line-height: 1; }
.league .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.league .lbar { height: 6px; border-radius: 3px; background: var(--dark); overflow: hidden; }
.league .lbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--lit-2), var(--lit)); box-shadow: 0 0 8px var(--lit-glow); transition: width 0.8s var(--ease-out); }
.league b { text-align: end; font-size: 14px; }
.linkish { margin-top: 6px; border: 0; background: none; color: var(--lit); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 16px 0; font-size: 13px; color: var(--muted); }
.sw { display: inline-block; width: 16px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.lit { background: var(--lit); box-shadow: 0 0 10px var(--lit-glow); }
.sw.mixed { background: linear-gradient(90deg, var(--lit) 50%, var(--dark) 50%); }
.sw.dark { background: var(--dark); border: 1px solid var(--dark-edge); }
.sw.none { border: 1px dashed #4a5368; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--stroke-hi);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--spring), filter 0.2s;
}
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.12); }
.btn.telegram { background: var(--tg); border-color: transparent; color: #fff; box-shadow: 0 8px 24px rgba(42, 171, 238, 0.3); }
.btn.ghost { background: transparent; border-color: rgba(255, 201, 77, 0.45); color: var(--lit); margin-top: 8px; }
.btn.whatsapp { background: #25d366; border-color: transparent; color: #04210f; box-shadow: 0 8px 24px rgba(37, 211, 102, 0.25); }
.btn:focus-visible, .chip:focus-visible, .fab:focus-visible, .grabber:focus-visible { outline: 2px solid var(--lit); outline-offset: 2px; }
.foot { margin-top: 14px; text-align: center; }
.foot a { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  top: calc(var(--safe-t) + 72px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: drop 0.35s var(--spring);
}

/* ---------- MapLibre chrome ---------- */
.maplibregl-ctrl-attrib { background: rgba(4, 6, 12, 0.55) !important; color: var(--muted); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-bottom-right { bottom: calc(var(--peek, 168px) - 4px); transition: bottom 0.5s var(--spring); }

/* ---------- wide screens: the sheet becomes a floating side card (Apple Maps on iPad/Mac) ---------- */
@media (min-width: 900px) {
  .topbar { left: 20px; right: auto; width: 380px; top: 20px; }
  .fabs { top: 20px; right: 20px; }
  .sheet {
    left: 20px; right: auto; bottom: auto;
    top: 82px;
    width: 380px;
    height: auto;
    max-height: calc(var(--vh) * 100 - 110px);
    border-radius: var(--r-lg);
    border-bottom: 1px solid var(--stroke);
    padding: 18px;
    transform: none !important;
    overflow: auto;
  }
  .grabber { display: none; }
  .more { max-height: none; }
  .maplibregl-ctrl-bottom-right { bottom: 0; }
}

@keyframes hum { 0%, 100% { filter: drop-shadow(0 0 5px var(--lit-glow)); } 50% { filter: drop-shadow(0 0 12px var(--lit-glow)); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255, 201, 77, 0.6); } 80%, 100% { box-shadow: 0 0 0 8px rgba(255, 201, 77, 0); } }
@keyframes drop { from { opacity: 0; transform: translate(var(--tx, 0), -6px); } to { opacity: 1; transform: translate(var(--tx, 0), 0); } }
.toast { --tx: -50%; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}

/* "Usually back in about 2h" under an outage's title. */
.eta {
  display: inline-block;
  margin: 8px 0 0;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lit);
  background: rgba(255, 201, 77, 0.1);
  border: 1px solid rgba(255, 201, 77, 0.25);
}
.eta[hidden] { display: none; }
/* National grid collapse banner: under the search bar, impossible to miss, still calm. */
.grid-alert {
  position: fixed;
  top: calc(var(--safe-t) + 74px);
  left: 12px;
  right: 76px; /* clear of the round buttons on the right */
  z-index: 3;
  max-width: 560px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 107, 97, 0.45);
  background: rgba(60, 12, 10, 0.82);
  color: #ffd9d5;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}
.grid-alert[hidden] { display: none; }
