/* =========================================
   EarthTick – shared styles
   ========================================= */
:root {
  --bg: #070b18;
  --bg-2: #0d1530;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --surface-strong: #111a33;
  --text: #eef2ff;
  --muted: #9aa5c4;
  --primary: #38bdf8;
  --accent: #34d399;
  --red: #f87171;
  --orange: #fb923c;
  --yellow: #facc15;
  --violet: #a78bfa;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 16px;
  --since-h: 64px;
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg) 60%) fixed, var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); }
ul { list-style: none; }
[id] { scroll-margin-top: 90px; }
button { font: inherit; }
.container { width: min(1280px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.green { color: var(--accent); }
.red { color: var(--red); }
.blue { color: var(--primary); }
.violet { color: var(--violet); }
.num { font-variant-numeric: tabular-nums; }
.accent {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-width: 0;
}
.card__head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.card__head h2 { font-size: 1.05rem; font-weight: 700; }

.tag {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.tag--estimate { border-color: var(--yellow); color: var(--yellow); }
.tag--live { border-color: var(--red); color: var(--red); }

.source { color: var(--muted); font-size: 0.8rem; }
.error { color: var(--red); }

/* ---- Header ---- */
.header {
  position: sticky; top: 0; z-index: 1100;
  background: rgba(7, 11, 24, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header__inner { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { font-size: 1.35rem; font-weight: 800; color: var(--text); text-decoration: none; flex: none; }
.logo span { color: var(--primary); }
.nav { display: flex; gap: 0.25rem; }
.nav__link {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 0.4rem 0.8rem; border-radius: 999px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.nav__link:hover { color: var(--text); background: var(--surface-hover); }
.nav__link.active { color: var(--text); background: rgba(56, 189, 248, 0.15); }
.header__live { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.9rem; flex: none; }
.header__clock { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 0.25rem; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: livepulse 2s infinite; }
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.7); }
  70%, 100% { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0); }
}

/* ---- Page ---- */
.page { display: grid; gap: 1rem; padding: 1.75rem 0 1rem; }
.page-head { margin-bottom: 0.5rem; }
.page-head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 0.4rem; max-width: 720px; }
.breadcrumb { font-size: 0.85rem; margin-bottom: 0.4rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }

/* ---- Home: hero + category cards ---- */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.hero p { color: var(--muted); font-size: clamp(1rem, 2.5vw, 1.15rem); max-width: 560px; margin: 1rem auto 0; }

.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.cat {
  position: relative;
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
  min-width: 0;
}
.cat::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--cat-color, var(--primary));
}
.cat:hover { transform: translateY(-4px); border-color: var(--cat-color, var(--primary)); background: var(--surface-hover); }
.cat--pop { --cat-color: var(--accent); }
.cat--eq { --cat-color: var(--orange); }
.cat--ast { --cat-color: var(--violet); }
.cat__top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.cat__title { font-weight: 700; font-size: 1.05rem; }
.cat__label { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }
.cat__num { font-size: clamp(1.8rem, 3.4vw, 2.6rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.cat__sub { color: var(--muted); font-size: 0.9rem; min-height: 2.7em; }
.cat__sub strong { color: var(--text); }
.cat__more { margin-top: auto; padding-top: 0.5rem; font-weight: 700; color: var(--cat-color, var(--primary)); }

.info-row { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.updates li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.updates li:last-child { border-bottom: none; }
.updates span:last-child { color: var(--muted); text-align: right; }

/* ---- KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpis--3 { grid-template-columns: repeat(3, 1fr); }
.kpi { display: flex; flex-direction: column; gap: 0.35rem; }
.kpi__label { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.kpi__num { font-size: clamp(1.3rem, 2.4vw, 1.9rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.kpi__sub { color: var(--muted); font-size: 0.8rem; }

/* ---- Big counter ---- */
.big-counter { text-align: center; padding: 2rem 1.25rem; background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(52, 211, 153, 0.06)); border-color: rgba(56, 189, 248, 0.35); }
.big-counter__label { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; }
.big-counter__num { font-size: clamp(2.2rem, 8vw, 4.8rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.big-counter__sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; }

/* ---- Two/three column grids ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.rows { display: grid; }
.rows li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: none; }
.rows strong { font-variant-numeric: tabular-nums; font-size: 1.1rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
td.wrap { white-space: normal; min-width: 180px; }
td.right, th.right { text-align: right; }
tr.highlight td { background: rgba(167, 139, 250, 0.1); }
tbody tr:last-child td { border-bottom: none; }

/* ---- Segmented controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; }
.control { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.control__label { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 0.35rem 0.85rem; border-radius: 999px; font-weight: 600; font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--primary); color: #07101f; }

/* Highlighted main filters */
.controls--main {
  padding: 1.1rem 1.4rem;
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.12), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(251, 146, 60, 0.55);
  box-shadow: 0 8px 30px rgba(251, 146, 60, 0.1);
  gap: 1rem 2.5rem;
}
.controls--main .control__label { color: var(--text); font-size: 0.85rem; }
.controls--main .seg { background: rgba(7, 11, 24, 0.6); border-color: rgba(255, 255, 255, 0.18); }
.controls--main .seg button { padding: 0.5rem 1.05rem; font-size: 0.95rem; color: #c8d0e6; }
.controls--main .seg button.active { background: var(--orange); color: #1a0d02; box-shadow: 0 2px 10px rgba(251, 146, 60, 0.4); }

/* Pagination */
.pager-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.9rem; }
.pager { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.pager button {
  min-width: 36px; height: 36px; padding: 0 0.6rem;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.pager button:hover:not(:disabled) { border-color: var(--primary); }
.pager button.active { background: var(--primary); border-color: var(--primary); color: #07101f; }
.pager button:disabled { opacity: 0.35; cursor: default; }
.pager__gap { color: var(--muted); padding: 0 0.2rem; }

/* ---- Earthquakes ---- */
.map { height: 480px; border-radius: 12px; overflow: hidden; background: #0b1020; }
.map--small { height: 300px; }
.map-row { display: grid; grid-template-columns: 3fr 1fr; gap: 1rem; }
.map-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.75rem; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 0.35rem; }
.mag { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.mag--1 { background: var(--accent); }
.mag--2 { background: var(--yellow); }
.mag--3 { background: var(--orange); }
.mag--4 { background: var(--red); }

.badge { display: inline-block; min-width: 42px; font-weight: 800; text-align: center; border-radius: 8px; padding: 0.1rem 0.4rem; color: #0b1020; font-size: 0.85rem; }
.new { color: var(--primary); font-size: 0.65rem; font-weight: 800; margin-left: 0.4rem; cursor: help; }

.bars { display: grid; gap: 0.7rem; }
.bar__top { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.25rem; }
.bar__track { height: 8px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; transition: width 0.5s; }

.list-compact li { display: grid; grid-template-columns: 46px 1fr auto; gap: 0.7rem; align-items: center; padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.list-compact li:last-child { border-bottom: none; }
.list-compact .when { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* Leaflet */
.leaflet-container { font-family: inherit; background: #0b1020; }
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-strong); color: var(--text); }
.leaflet-popup-content { margin: 10px 14px; }
.leaflet-container a { color: var(--primary); }
.leaflet-control-attribution { background: rgba(7, 11, 24, 0.75) !important; color: var(--muted) !important; }

/* ---- Asteroids ---- */
.countdown { text-align: center; padding: 2rem 1.25rem; background: linear-gradient(135deg, rgba(167, 139, 250, 0.12), rgba(56, 189, 248, 0.06)); border-color: rgba(167, 139, 250, 0.4); }
.countdown__label { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; }
.countdown__time { font-size: clamp(2.2rem, 8vw, 4.5rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.15; }
.countdown__name { font-size: 1.2rem; font-weight: 700; margin-top: 0.5rem; }
.countdown__meta { color: var(--muted); margin-top: 0.25rem; }

/* ---- Floating "Since you arrived" panel ---- */
.since {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
  background: rgba(13, 21, 48, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
}
.since__inner {
  width: min(1280px, 100% - 32px); margin-inline: auto;
  min-height: var(--since-h);
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.6rem 0;
}
.since__title { display: flex; flex-direction: column; font-weight: 700; white-space: nowrap; }
.since__timer { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.since__timer strong { color: var(--primary); font-variant-numeric: tabular-nums; }
.since__items { flex: 1; display: flex; justify-content: space-around; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.since__items strong { color: var(--text); font-size: 1.25rem; font-variant-numeric: tabular-nums; margin-right: 0.2rem; }
.since__items em { font-style: normal; opacity: 0.7; font-size: 0.8rem; }
.since__toggle {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: none; color: var(--text);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.since__toggle:hover { border-color: var(--primary); }
.since.minimized .since__items { display: none; }
.since.minimized .since__inner { min-height: 0; }

/* ---- Toast ---- */
.toast {
  position: fixed; right: 16px; bottom: calc(var(--since-h) + 24px); z-index: 2000;
  max-width: min(360px, calc(100% - 32px));
  background: var(--surface-strong);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-weight: 500;
}

/* ---- Footer ---- */
.footer { margin-top: 2rem; padding: 1.5rem 0 calc(var(--since-h) + 2.5rem); border-top: 1px solid var(--border); font-size: 0.8rem; }
.footer__inner { display: grid; gap: 0.4rem; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .map-row { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpis--3 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .cats { grid-template-columns: 1fr; }
  .info-row, .grid-3 { grid-template-columns: 1fr; }
  .header__inner { height: auto; flex-wrap: wrap; padding: 0.6rem 0; gap: 0.4rem 1rem; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; margin: 0 -4px; }
}

@media (max-width: 760px) {
  :root { --since-h: 104px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis--3 { grid-template-columns: 1fr; }
  .map { height: 340px; }
  .controls--main { padding: 1rem; }
  .controls--main .seg button { padding: 0.45rem 0.8rem; font-size: 0.9rem; }
  .since__inner { flex-wrap: wrap; gap: 0.5rem 1rem; }
  .since__title { flex-direction: row; align-items: baseline; gap: 0.6rem; flex: 1; }
  .since__items { order: 3; flex-basis: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem 1rem; font-size: 0.8rem; }
  .since__items strong { font-size: 1.05rem; }
}

@media (max-width: 420px) {
  .kpis { gap: 0.6rem; }
  .header__clock { display: none; }
  .since__title { flex-direction: column; gap: 0; }
  .nav__link { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .cat { transition: none; }
}
