/* ─── Custom properties ───────────────────────────────── */
:root {
  --bg-deep:   #071b2f;
  --bg-mid:    #0f2d4b;
  --panel-bg:  rgba(15, 41, 75, 0.92);
  --border:    rgba(148, 163, 184, 0.15);
  --text:      #f8fafc;
  --muted:     #94a3b8;
  --accent:    #ff7f50;
  --radius-lg: 24px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 1rem;
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Header ──────────────────────────────────────────── */
header {
  padding: 1.1rem 1.5rem 0.75rem;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

header p {
  margin: 0.4rem auto 0;
  max-width: 40rem;
  color: #cbd5e1;
  font-size: clamp(0.88rem, 2vw, 1rem);
}

/* ─── Main layout ─────────────────────────────────────── */
main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
  gap: 1rem;
  padding: 0.75rem 1rem 0.75rem;
  min-height: 72vh;
}

/* ─── Globe container ─────────────────────────────────── */
#globe-container {
  position: relative;
  min-height: 520px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.15), transparent 40%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.18), transparent 35%),
    var(--bg-deep);
}

.globe-status {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  color: #dbeafe;
  font-size: 0.88rem;
  background: rgba(7, 27, 47, 0.72);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  pointer-events: none;
  transition: opacity 0.3s;
}

.retry-btn {
  position: absolute;
  left: 1rem;
  bottom: 3.5rem;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.retry-btn:hover  { opacity: 0.85; }
.retry-btn:active { transform: scale(0.97); }

.zoom-controls {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.zoom-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(7, 27, 47, 0.72);
  color: #dbeafe;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  user-select: none;
}
.zoom-btn:hover  { background: rgba(56, 189, 248, 0.25); }
.zoom-btn:active { transform: scale(0.93); }

/* ─── Info panel ──────────────────────────────────────── */
#info-panel {
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 8rem);
  overflow: hidden;
}

#info-panel h2 {
  margin: 0;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ─── Controls ────────────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.controls input[type="search"],
.controls select {
  flex: 1 1 140px;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.controls input[type="search"]:focus,
.controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 127, 80, 0.25);
}

.controls select {
  flex: 1 1 160px;
  cursor: pointer;
}

.controls select option {
  background: #0f2d4b;
  color: #f8fafc;
}

.controls button#clear-filters {
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.1s;
}
.controls button#clear-filters:hover  { opacity: 0.85; }
.controls button#clear-filters:active { transform: scale(0.97); }

.howto {
  width: 100%;
}
.howto summary {
  cursor: pointer;
  color: #cbd5e1;
  font-size: 0.88rem;
  user-select: none;
}
.howto ol {
  margin: 0.45rem 0 0;
  padding-left: 1.4rem;
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.95;
}

/* ─── Colour legend ───────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.legend-item--active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Details pane ────────────────────────────────────── */
#details {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}
#details::-webkit-scrollbar        { width: 4px; }
#details::-webkit-scrollbar-track  { background: transparent; }
#details::-webkit-scrollbar-thumb  { background: rgba(148,163,184,0.3); border-radius: 2px; }

/* Welcome state */
.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1rem 1rem;
  gap: 0.75rem;
}
.welcome-emoji {
  font-size: 3rem;
  line-height: 1;
}
.welcome-text {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.65;
  font-size: 0.97rem;
}

/* Event card */
.event-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.event-type-emoji {
  font-size: 2.4rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.event-title-block {
  flex: 1;
  min-width: 0;
}

.event-title-block h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  line-height: 1.35;
}

.event-badge {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.event-info-row {
  font-size: 0.95rem;
  color: #e2e8f0;
  line-height: 1.5;
}

.event-description-box {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 0.85rem;
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.65;
}

.event-description-box strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Learn-more expandable panel ────────────────────── */
.learn-more-panel {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0 0.85rem;
}

.learn-more-panel summary {
  cursor: pointer;
  padding: 0.6rem 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.learn-more-panel summary::-webkit-details-marker { display: none; }

.learn-more-panel summary::after {
  content: '▸';
  margin-left: auto;
  transition: transform 0.2s;
  font-size: 0.8rem;
  color: var(--muted);
}

.learn-more-panel[open] summary::after {
  transform: rotate(90deg);
}

.learn-more-panel p {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.65;
}

/* ─── 30-day dashboard ────────────────────────────────── */
#dashboard {
  margin: 0 1rem 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

#dashboard h2 {
  margin: 0 0 1.1rem;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  text-align: center;
}

#dashboard-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.dash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-color, var(--accent));
  border-radius: var(--radius-sm);
  padding: 0.9rem 0.6rem 0.75rem;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.dash-emoji {
  font-size: 2rem;
  line-height: 1;
}

.dash-count {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.dash-label {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.dash-phrase {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  line-height: 1.5;
  margin-top: 0.15rem;
}

.dash-bar-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  margin-top: 0.45rem;
  overflow: hidden;
}

.dash-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 900px) {
  #dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  #dashboard {
    margin: 0 0.5rem 1rem;
    padding: 1rem;
  }

  #dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-count {
    font-size: 2rem;
  }
}

/* ─── Learn floating button ───────────────────────────── */
.learn-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 127, 80, 0.45);
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}
.learn-btn:hover  { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 6px 24px rgba(255, 127, 80, 0.55); }
.learn-btn:active { transform: scale(0.97); }

/* ─── Learn modal overlay ─────────────────────────────── */
.learn-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(7, 27, 47, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.learn-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.learn-modal-box {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.learn-modal.open .learn-modal-box {
  transform: none;
}

.learn-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.learn-modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}
.learn-modal-close {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}
.learn-modal-close:hover { background: rgba(255,255,255,0.14); color: var(--text); }

/* ─── Modal tabs ──────────────────────────────────────── */
.learn-tabs {
  display: flex;
  padding: 0.75rem 1.5rem 0;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.learn-tab {
  flex: 1;
  padding: 0.5rem 0.5rem 0.65rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}
.learn-tab:hover { color: var(--text); }
.learn-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Modal panels ────────────────────────────────────── */
.learn-panels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}
.learn-panels::-webkit-scrollbar       { width: 4px; }
.learn-panels::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.3); border-radius: 2px; }

.learn-panel {
  padding: 1.25rem 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.learn-panel--hidden { display: none; }

.learn-intro {
  margin: 0;
  font-size: 1.05rem;
}
.learn-panel p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.7;
  font-size: 0.95rem;
}
.learn-calm {
  background: rgba(56, 189, 248, 0.08);
  border-left: 3px solid #38bdf8;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.65rem 0.9rem !important;
  color: #e2e8f0 !important;
  font-size: 0.92rem !important;
}

.safety-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.safety-list li {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.93rem;
  color: #e2e8f0;
  line-height: 1.55;
}

/* ─── Glossary grid ───────────────────────────────────── */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
.glossary-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.glossary-word {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
}
.glossary-def {
  font-size: 0.84rem;
  color: #cbd5e1;
  line-height: 1.55;
}

@media (max-width: 480px) {
  .learn-btn { bottom: 1rem; right: 1rem; padding: 0.55rem 1rem; font-size: 0.88rem; }
  .glossary-grid { grid-template-columns: 1fr; }
  .learn-modal-box { border-radius: var(--radius-sm); }
}

/* ─── Footer ──────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 0.6rem 1.5rem 1.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    min-height: unset;
  }

  #globe-container {
    min-height: 380px;
  }

  #info-panel {
    max-height: 55vh;
  }
}
