/* ── Birthday page layout ─────────────────────────────────────────── */

body.bd-page {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--page-bg);
  color: var(--txt);
  line-height: 1.45;
}

/* star field canvas — fixed behind all content */
#bdStars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

body.bd-page > .site-header,
body.bd-page > .bd-layout {
  position: relative;
  z-index: 1;
}

/* transparent header — nav chips float in the starfield */
body.bd-page .site-header {
  background: transparent;
  border-bottom: none;
  box-shadow: none;
  backdrop-filter: none;
}

.bd-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  overflow: hidden;
  min-height: 0;
  transition: grid-template-columns 0.25s ease;
}

.bd-layout.is-card-max {
  grid-template-columns: 1fr 0px;
}

.bd-layout.is-map-max {
  grid-template-columns: 0px 1fr;
}

/* ── Left column: birthday content ─────────────────────────────────── */

.bd-main {
  overflow-y: auto;
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
}

.bd-layout.is-map-max .bd-main {
  display: none;
}

/* ── Right column: sidebar (controls + map + next birthday) ─────────── */

.bd-sidebar {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--brd);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.bd-layout.is-card-max .bd-sidebar {
  display: none;
}

/* Controls bar */
.bd-sidebar-controls {
  display: flex;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--brd);
  flex-shrink: 0;
  background: var(--surf);
}

.bd-ctrl-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid var(--brd);
  border-radius: 999px;
  background: var(--surf2);
  color: var(--mut);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-ctrl-btn:hover {
  border-color: var(--control-hover-border);
  background: var(--control-hover-bg);
  color: var(--control-hover-text);
}

.bd-ctrl-btn.is-active {
  border-color: var(--acc);
  background: var(--accent-soft);
  color: var(--acc-strong);
}

/* Main-map iframe */
.bd-map-frame {
  flex: 1;
  min-height: 0;
  background: var(--bg);
  display: block;
  width: 100%;
  border: none;
}

/* Sidebar bottom: upcoming week list */
.bd-sidebar-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--brd);
  background: var(--surf);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 42vh;
}

/* ── Birthday celebration card ───────────────────────────────────────── */

.bd-card {
  background: var(--surf);
  border: 1px solid var(--brd);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

/* Hero banner */
.bd-hero {
  padding: 22px 24px 20px;
  background: linear-gradient(140deg, #041f13 0%, #0a1f42 55%, #061428 100%);
  position: relative;
  overflow: hidden;
}

.bd-hero::before {
  content: "⚛";
  position: absolute;
  right: -28px;
  top: -28px;
  font-size: 140px;
  opacity: 0.07;
  animation: bdAtomSpin 16s linear infinite;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.bd-hero::after {
  content: "⚛";
  position: absolute;
  left: -30px;
  bottom: -40px;
  font-size: 100px;
  opacity: 0.04;
  animation: bdAtomSpin 24s linear infinite reverse;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

@keyframes bdAtomSpin {
  to { transform: rotate(360deg); }
}

/* Tag pill */
.bd-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 13px 4px 9px;
  border: 1px solid rgba(134, 239, 172, 0.35);
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.1);
  color: #86efac;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.bd-tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: bdPulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes bdPulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50% { opacity: 0.7; transform: scale(0.75); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}

/* Age display */
.bd-age-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.bd-age-number {
  font-size: 80px;
  font-weight: 900;
  line-height: 0.9;
  color: #4ade80;
  letter-spacing: -3px;
  text-shadow: 0 0 60px rgba(74, 222, 128, 0.35), 0 0 20px rgba(74, 222, 128, 0.2);
}

.bd-age-label {
  font-size: 24px;
  font-weight: 700;
  color: #a7f3d0;
  letter-spacing: 0.01em;
}

/* Unit & plant info */
.bd-unit-name {
  font-size: 26px;
  font-weight: 800;
  color: #f0f9ff;
  margin-bottom: 6px;
  line-height: 1.15;
}

.bd-plant-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 13px;
  color: rgba(186, 230, 253, 0.75);
  margin-bottom: 2px;
}

.bd-country-flag {
  font-size: 17px;
  line-height: 1;
}

/* Status pill */
.bd-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bd-status-pill.is-operating {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.bd-status-pill.is-shutdown,
.bd-status-pill.is-decommissioned {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.bd-status-pill.is-construction {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.bd-status-pill.is-suspended {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

/* Date/btype info row */
.bd-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.bd-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(186, 230, 253, 0.85);
}

/* ── Metrics grid ──────────────────────────────────────────────────── */

.bd-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--brd);
  border-top: 1px solid var(--brd);
}

.bd-metric {
  background: var(--surf);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bd-metric-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 5px;
}

.bd-metric-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--txt);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

/* bigger values for the most impactful metrics */
[data-metric-id="age"] .bd-metric-value      { font-size: 40px; letter-spacing: -1px; }
[data-metric-id="generation"] .bd-metric-value,
[data-metric-id="co2"] .bd-metric-value      { font-size: 30px; }
[data-metric-id="capacity"] .bd-metric-value,
[data-metric-id="thermal"] .bd-metric-value  { font-size: 26px; }

.bd-metric-value.is-green { color: var(--op); }
.bd-metric-value.is-accent { color: var(--acc); }

.bd-metric-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mut);
  margin-top: 1px;
}

.bd-metric-slogan {
  font-size: 11px;
  color: var(--mut);
  line-height: 1.35;
  margin-top: 3px;
}

/* ── Other birthday units ──────────────────────────────────────────── */

.bd-others {
  padding: 14px 20px 12px;
  border-top: 1px solid var(--brd);
}

.bd-others-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mut);
  margin-bottom: 8px;
}

.bd-other-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--brd);
  font-size: 13px;
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.bd-other-item:hover { background: var(--subtle-hover-bg); }

.bd-other-item:first-of-type { border-top: none; }

.bd-other-flag { font-size: 14px; line-height: 1; }
.bd-other-name { font-weight: 600; color: var(--txt); min-width: 0; }
.bd-other-country { font-size: 11px; color: var(--mut); }
.bd-other-age { margin-left: auto; font-size: 12px; color: var(--mut); white-space: nowrap; padding-left: 8px; }
.bd-other-status { font-size: 10px; color: var(--op); font-weight: 600; }

/* ── Next birthday hint (left column footer) ───────────────────────── */

.bd-next-hint {
  background: var(--surf2);
  border: 1px solid var(--brd);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.bd-next-hint-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mut);
  flex-shrink: 0;
}

.bd-next-hint-text {
  font-size: 13px;
  color: var(--txt);
  min-width: 0;
}

.bd-next-hint-countdown {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--control-hover-border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--acc-strong);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Upcoming week list (sidebar bottom) ───────────────────────────── */

.bd-week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px 7px;
  border-bottom: 1px solid var(--brd);
  flex-shrink: 0;
}

.bd-week-header-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mut);
}

.bd-week-header-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--acc);
}

.bd-week-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.bd-week-group {
  border-bottom: 1px solid var(--brd);
}

.bd-week-group:last-child { border-bottom: none; }

.bd-week-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px 4px;
  background: var(--surf2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.bd-week-group-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--txt);
}

.bd-week-group-when {
  font-size: 10px;
  color: var(--acc);
  font-weight: 600;
}

.bd-week-units {
  padding: 2px 0 6px;
}

.bd-week-unit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  font-size: 12px;
  line-height: 1.3;
}

button.bd-week-unit-link {
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.bd-week-unit-row:hover { background: var(--subtle-hover-bg); }

.bd-week-op-dot {
  font-size: 8px;
  color: var(--op);
  flex-shrink: 0;
  line-height: 1;
}

.bd-week-unit-flag { font-size: 13px; flex-shrink: 0; }

.bd-week-unit-name {
  font-weight: 600;
  color: var(--txt);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-week-unit-meta {
  margin-left: auto;
  font-size: 10px;
  color: var(--mut);
  white-space: nowrap;
  padding-left: 6px;
  flex-shrink: 0;
}

/* ── Sim-date banner (inserted as first child of .bd-main) ──────────── */

.bd-sim-banner {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 10px;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  flex-shrink: 0;
}

/* ── Hero links ──────────────────────────────────────────────────────── */

.bd-hero-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(167, 243, 208, 0.3);
  transition: border-color 0.12s, color 0.12s;
}

.bd-hero-link:hover {
  color: #86efac;
  border-bottom-color: rgba(167, 243, 208, 0.8);
}

.bd-hero-link-country {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-bottom: none;
  text-decoration: underline;
  text-decoration-color: rgba(167, 243, 208, 0.25);
  text-underline-offset: 3px;
}

.bd-hero-link-country:hover {
  color: #86efac;
  text-decoration-color: rgba(167, 243, 208, 0.7);
}

/* Meta chips that are links */
.bd-meta-chip-link {
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
  cursor: pointer;
}

.bd-meta-chip-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.28);
  color: #f0f9ff;
}

/* ── Linked metric cells ─────────────────────────────────────────────── */

a.bd-metric-link {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surf);
  position: relative;
}

a.bd-metric-link .bd-metric {
  background: transparent;
  height: 100%;
}

a.bd-metric-link::after {
  content: "↗";
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  color: var(--mut);
  opacity: 0;
  transition: opacity 0.12s;
}

a.bd-metric-link:hover .bd-metric {
  background: var(--subtle-hover-bg);
}

a.bd-metric-link:hover::after {
  opacity: 1;
}

/* ── Loading / error ────────────────────────────────────────────────── */

.bd-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 60px 20px;
  color: var(--mut);
  text-align: center;
  background: var(--surf);
  border: 1px solid var(--brd);
  border-radius: 18px;
  box-shadow: var(--shadow-panel);
}

.bd-spinner {
  font-size: 40px;
  animation: bdAtomSpin 2s linear infinite;
  display: block;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */

@media (max-width: 780px) {
  .bd-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .bd-layout.is-card-max { grid-template-rows: 1fr 0px; }
  .bd-layout.is-map-max  { grid-template-rows: 0px 1fr; }

  .bd-sidebar {
    border-left: none;
    border-top: 1px solid var(--brd);
    max-height: 38vh;
  }

  .bd-layout.is-card-max .bd-sidebar,
  .bd-layout.is-map-max .bd-main {
    display: none;
  }

  .bd-age-number { font-size: 56px; }
  .bd-unit-name  { font-size: 20px; }
  .bd-age-label  { font-size: 18px; }

  .bd-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .bd-metric-value { font-size: 18px; }
}

@media (max-width: 420px) {
  .bd-metrics { grid-template-columns: 1fr 1fr; }
  .bd-hero { padding: 18px 16px 16px; }
  .bd-age-number { font-size: 48px; }
}
