/* ============================================================
   Happy Variant Theme — Calm & Serene
   Sage green + warm gold on cream. No dark military aesthetic.
   Unlayered CSS — wins over main.css which is wrapped in
   @layer base by base-layer.css (@import ... layer(base)).
   ============================================================ */

/* ---------- Happy Light Mode (default + explicit light) ---------- */
:root[data-variant="happy"],
:root[data-variant="happy"][data-theme="light"] {
  /* Backgrounds */
  --bg: #FAFAF5;
  --bg-secondary: #F5F3EE;
  --surface: #FFFFFF;
  --surface-hover: #F5F2EC;
  --surface-active: #EDE9E0;

  /* Borders */
  --border: #DDD9CF;
  --border-strong: #C8C2B5;
  --border-subtle: #EBE8E0;

  /* Text */
  --text: #2D3A2E;
  --text-secondary: #4A5A4C;
  --text-dim: #6B7A6D;
  --text-muted: #8A9A8C;
  --text-faint: #A8B4AA;
  --text-ghost: #C0C8C2;
  --accent: #3D4A3E;

  /* Overlays & shadows */
  --overlay-subtle: rgba(107, 143, 94, 0.03);
  --overlay-light: rgba(107, 143, 94, 0.05);
  --overlay-medium: rgba(107, 143, 94, 0.08);
  --overlay-heavy: rgba(107, 143, 94, 0.12);
  --shadow-color: rgba(80, 70, 50, 0.08);
  --darken-light: rgba(80, 70, 50, 0.06);
  --darken-medium: rgba(80, 70, 50, 0.10);
  --darken-heavy: rgba(80, 70, 50, 0.15);

  /* Scrollbar */
  --scrollbar-thumb: #C8C2B5;
  --scrollbar-thumb-hover: #A8A298;

  /* Input */
  --input-bg: #F2EFE8;

  /* Panels */
  --panel-bg: #FFFFFF;
  --panel-border: #DDD9CF;

  /* Map */
  --map-bg: #D4E6EC;
  --map-grid: #C0D8D8;
  --map-country: #B9CDA8;
  --map-stroke: #C8C0B5;

  /* Typography — Nunito rounded sans-serif */
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;

  /* Panel border radius — soft rounded corners */
  --panel-radius: 14px;

  /* Severity levels — remapped to positive semantics */
  --semantic-critical: #C4A35A;
  --semantic-high: #6B8F5E;
  --semantic-elevated: #7BA5C4;
  --semantic-normal: #6B8F5E;
  --semantic-low: #C48B9F;
  --semantic-info: #7BA5C4;
  --semantic-positive: #6B8F5E;

  /* Threat levels — remapped to positive tones */
  --threat-critical: #C4A35A;
  --threat-high: #8BAF7A;
  --threat-medium: #7BA5C4;
  --threat-low: #6B8F5E;
  --threat-info: #7BA5C4;

  /* DEFCON levels — warm gradient instead of warning */
  --defcon-1: #C4A35A;
  --defcon-2: #A8B86B;
  --defcon-3: #7BA5C4;
  --defcon-4: #6B8F5E;
  --defcon-5: #8BAF7A;

  /* Status indicators */
  --status-live: #6B8F5E;
  --status-cached: #C4A35A;
  --status-unavailable: #C48B9F;

  /* Legacy color aliases */
  --red: #C48B9F;
  --green: #6B8F5E;
  --yellow: #C4A35A;
}

/* ---------- Happy Dark Mode ---------- */
:root[data-variant="happy"][data-theme="dark"] {
  /* Backgrounds — deep navy, warm darks */
  --bg: #1A2332;
  --bg-secondary: #1E2838;
  --surface: #222E3E;
  --surface-hover: #2A3848;
  --surface-active: #2E3E50;

  /* Borders */
  --border: #344050;
  --border-strong: #445868;
  --border-subtle: #283545;

  /* Text — warm off-whites */
  --text: #E8E4DC;
  --text-secondary: #D0CCC4;
  --text-dim: #A0A098;
  --text-muted: #808880;
  --text-faint: #606860;
  --text-ghost: #485048;
  --accent: #E8E4DC;

  /* Overlays & shadows */
  --overlay-subtle: rgba(139, 175, 122, 0.03);
  --overlay-light: rgba(139, 175, 122, 0.06);
  --overlay-medium: rgba(139, 175, 122, 0.10);
  --overlay-heavy: rgba(139, 175, 122, 0.18);
  --shadow-color: rgba(0, 0, 0, 0.30);
  --darken-light: rgba(0, 0, 0, 0.15);
  --darken-medium: rgba(0, 0, 0, 0.20);
  --darken-heavy: rgba(0, 0, 0, 0.30);

  /* Scrollbar */
  --scrollbar-thumb: #445868;
  --scrollbar-thumb-hover: #5A6E80;

  /* Input */
  --input-bg: #283545;

  /* Panels */
  --panel-bg: #222E3E;
  --panel-border: #344050;

  /* Map */
  --map-bg: #16202E;
  --map-grid: #1E3040;
  --map-country: #2D4035;
  --map-stroke: #3D5045;

  /* Typography inherits from light variant selector */
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;

  /* Panel border radius */
  --panel-radius: 14px;

  /* Semantic — lighter variants for dark backgrounds */
  --semantic-critical: #D4B36A;
  --semantic-high: #8BAF7A;
  --semantic-elevated: #8BB5D4;
  --semantic-normal: #8BAF7A;
  --semantic-low: #D49BAF;
  --semantic-info: #8BB5D4;
  --semantic-positive: #8BAF7A;

  --threat-critical: #D4B36A;
  --threat-high: #9BBF8A;
  --threat-medium: #8BB5D4;
  --threat-low: #8BAF7A;
  --threat-info: #8BB5D4;

  --defcon-1: #D4B36A;
  --defcon-2: #B8C87B;
  --defcon-3: #8BB5D4;
  --defcon-4: #8BAF7A;
  --defcon-5: #9BBF8A;

  --status-live: #8BAF7A;
  --status-cached: #D4B36A;
  --status-unavailable: #D49BAF;

  --red: #D49BAF;
  --green: #8BAF7A;
  --yellow: #D4B36A;
}

/* ==========================================================
   Happy Panel Chrome — Rounded, Warm, Welcoming
   ========================================================== */

/* ---------- Panel border-radius & shadow (light) ---------- */
[data-variant="happy"] .panel {
  border-radius: var(--panel-radius, 14px);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(80, 70, 50, 0.06), 0 1px 2px rgba(80, 70, 50, 0.04);
}

[data-variant="happy"] .panel-header {
  border-radius: var(--panel-radius, 14px) var(--panel-radius, 14px) 0 0;
}

/* ---------- Panel shadow (dark mode) ---------- */
[data-variant="happy"][data-theme="dark"] .panel {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.20), 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* ---------- Panel title — softer casing ---------- */
[data-variant="happy"] .panel-title {
  text-transform: none;
  letter-spacing: 0.3px;
  font-weight: 700;
}

/* ---------- Panel count badge — rounded pill ---------- */
[data-variant="happy"] .panel-count {
  border-radius: 10px;
  padding: 2px 8px;
}

/* ---------- Panel resize handle — softer ---------- */
[data-variant="happy"] .panel-resize-handle {
  background: linear-gradient(to top, rgba(107, 143, 94, 0.10), transparent);
}

/* ---------- Map section — rounded ---------- */
[data-variant="happy"] .map-section {
  border-radius: var(--panel-radius, 14px);
  overflow: hidden;
}

/* ---------- Map controls — rounded ---------- */
[data-variant="happy"] .map-controls {
  gap: 6px;
}

[data-variant="happy"] .map-control-btn {
  border-radius: 8px;
}

/* ==========================================================
   Happy Empty States — Friendly nature-themed illustration
   ========================================================== */
[data-variant="happy"] .panel-empty,
[data-variant="happy"] .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
  gap: 12px;
  font-size: 13px;
}

[data-variant="happy"] .panel-empty::before,
[data-variant="happy"] .empty-state::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none'%3E%3Cpath d='M24 40V24M24 24C20 20 14 18 8 20C14 14 20 14 24 18C28 14 34 14 40 20C34 18 28 20 24 24Z' stroke='%236B8F5E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M18 38C18 38 20 34 24 34C28 34 30 38 30 38' stroke='%236B8F5E' stroke-width='1.5' stroke-linecap='round' opacity='0.4'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.6;
}

/* ==========================================================
   Happy Loading States — Gentle pulse instead of radar sweep
   ========================================================== */
[data-variant="happy"] .panel-loading-radar {
  border-color: rgba(107, 143, 94, 0.25);
}

[data-variant="happy"] .panel-radar-sweep {
  background: linear-gradient(90deg, transparent, var(--status-live));
  animation: happy-radar-sweep 3s linear infinite;
}

@keyframes happy-radar-sweep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

[data-variant="happy"] .panel-radar-dot {
  background: var(--status-live);
  box-shadow: 0 0 12px var(--status-live);
  animation: happy-pulse 2s ease-in-out infinite;
}

[data-variant="happy"] .status-dot {
  animation: happy-pulse 2.5s ease-in-out infinite;
}

@keyframes happy-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.08); }
}

[data-variant="happy"] .panel-loading-text {
  letter-spacing: 0.2px;
}

/* ==========================================================
   Happy Panel Error State — Softer error display
   ========================================================== */
[data-variant="happy"] .panel-header-error {
  background: rgba(196, 163, 90, 0.12);
  border-bottom-color: rgba(196, 163, 90, 0.30);
}

/* ==========================================================
   Happy Download Banner — Rounded and warm
   ========================================================== */
[data-variant="happy"] .wm-dl-panel {
  border-radius: 0 0 0 14px;
  border-left-color: var(--green);
}

/* ==========================================================
   Happy Data Badges — Rounded pills
   ========================================================== */
[data-variant="happy"] .panel-data-badge {
  border-radius: 10px;
}

/* ==========================================================
   Happy Tab Styles — Rounded boxed tabs (intentionally different)
   ========================================================== */
[data-variant="happy"] .panel-tab {
  border: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  border-radius: 8px;
}

[data-variant="happy"] .panel-tab.active {
  background: color-mix(in srgb, var(--semantic-high) 12%, transparent);
  border-color: var(--semantic-high);
  color: var(--semantic-high);
}

/* ==========================================================
   Happy Severity Badges — Warm tones
   ========================================================== */
[data-variant="happy"] .severity-extreme {
  background: color-mix(in srgb, var(--semantic-critical) 15%, transparent);
  color: var(--semantic-critical);
}

[data-variant="happy"] .severity-moderate {
  background: color-mix(in srgb, var(--semantic-high) 12%, transparent);
  color: var(--semantic-high);
}

/* ==========================================================
   Happy Posture Radar — Softer animation
   ========================================================== */
[data-variant="happy"] .posture-radar-sweep {
  animation: happy-radar-sweep 3s linear infinite;
}

/* ==========================================================
   Happy Positive News Feed — Filter Bar & Cards
   ========================================================== */

/* ---------- Filter bar ---------- */
[data-variant="happy"] .positive-feed-filters {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  mask-image: linear-gradient(to right, black 90%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
}
[data-variant="happy"] .positive-feed-filters::-webkit-scrollbar { display: none; }

[data-variant="happy"] .positive-filter-btn {
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-family: var(--font-body);
  flex-shrink: 0;
}
[data-variant="happy"] .positive-filter-btn:hover {
  border-color: var(--yellow);
  color: var(--text);
}
[data-variant="happy"] .positive-filter-btn.active {
  background: var(--yellow);
  color: var(--bg);
  border-color: var(--yellow);
}

/* ---------- Card styles ---------- */
[data-variant="happy"] .positive-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
[data-variant="happy"] .positive-card:hover {
  background: var(--bg-secondary);
}
[data-variant="happy"] .positive-card-image {
  flex-shrink: 0;
  width: 72px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
}
[data-variant="happy"] .positive-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
[data-variant="happy"] .positive-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}
[data-variant="happy"] .positive-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}
[data-variant="happy"] .positive-card-source {
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
[data-variant="happy"] .positive-card-category {
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 600;
  background: var(--green);
  color: white;
}
[data-variant="happy"] .positive-card-category.cat-science-health { background: var(--semantic-info); }
[data-variant="happy"] .positive-card-category.cat-nature-wildlife { background: var(--green); }
[data-variant="happy"] .positive-card-category.cat-humanity-kindness { background: var(--red); }
[data-variant="happy"] .positive-card-category.cat-innovation-tech { background: var(--yellow); color: var(--bg); }
[data-variant="happy"] .positive-card-category.cat-climate-wins { background: #2d9a4e; }
[data-variant="happy"] .positive-card-category.cat-culture-community { background: #8b5cf6; }

[data-variant="happy"] .positive-card-title {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
  color: var(--text);
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
[data-variant="happy"] .positive-card-time {
  font-size: 10px;
  color: var(--text-dim);
}

/* ---------- Share button ---------- */
[data-variant="happy"] .positive-card-share {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  transition: opacity 0.2s, background 0.2s;
  padding: 0;
}
[data-variant="happy"] .positive-card:hover .positive-card-share {
  opacity: 1;
}
[data-variant="happy"] .positive-card-share:hover {
  background: rgba(255, 255, 255, 1);
  color: var(--yellow);
}
[data-variant="happy"] .positive-card-share.shared {
  color: var(--green);
  transform: scale(1.1);
  transition: color 0.15s, transform 0.15s;
}
[data-variant="happy"][data-theme="dark"] .positive-card-share {
  background: rgba(30, 30, 30, 0.8);
}
[data-variant="happy"][data-theme="dark"] .positive-card-share:hover {
  background: rgba(50, 50, 50, 1);
}

/* ---------- Empty state ---------- */
[data-variant="happy"] .positive-feed-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ==========================================================
   Happy Counters Panel — Ticking positive metrics grid
   ========================================================== */

/* ---------- Counters grid layout (auto-fit to container) ---------- */
[data-variant='happy'] .counters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  padding: 10px;
}

/* ---------- Counter card ---------- */
[data-variant='happy'] .counter-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius, 14px);
  padding: 10px 8px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

[data-variant='happy'] .counter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-variant='happy'] .counter-icon {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

[data-variant='happy'] .counter-value {
  font-size: clamp(0.85rem, 1.8vw, 1.3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.2;
  min-height: 1.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: break-word;
}

[data-variant='happy'] .counter-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

[data-variant='happy'] .counter-source {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ==========================================================
   Happy Progress Charts Panel — D3 area chart containers
   ========================================================== */

/* ---------- Progress chart container ---------- */
[data-variant='happy'] .progress-chart-container {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

[data-variant='happy'] .progress-chart-container:last-child {
  border-bottom: none;
}

[data-variant='happy'] .progress-chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

[data-variant='happy'] .progress-chart-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

[data-variant='happy'] .progress-chart-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--green);
  color: white;
}

[data-variant='happy'] .progress-chart-unit {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: 6px;
}

/* ---------- D3 chart SVG styling ---------- */
[data-variant='happy'] .progress-chart-container svg {
  overflow: visible;
}

[data-variant='happy'] .progress-chart-container .tick text {
  fill: var(--text-secondary);
  font-size: 0.65rem;
}

[data-variant='happy'] .progress-chart-container .tick line,
[data-variant='happy'] .progress-chart-container .domain {
  stroke: var(--border);
}

[data-variant='happy'] .progress-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  white-space: nowrap;
}

/* ---------- Dark mode adjustments ---------- */
[data-variant='happy'][data-theme='dark'] .counter-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

[data-variant='happy'][data-theme='dark'] .progress-chart-tooltip {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================================
   Phase 6 — Breakthroughs Ticker
   ========================================================== */

@keyframes happy-ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

[data-variant="happy"] .breakthroughs-ticker-wrapper {
  overflow: hidden;
  position: relative;
  padding: 0.5rem 0;
}

[data-variant="happy"] .breakthroughs-ticker-track {
  display: flex;
  width: max-content;
  gap: 2rem;
  animation: happy-ticker-scroll 120s linear infinite;
}

[data-variant="happy"] .breakthroughs-ticker-wrapper:hover .breakthroughs-ticker-track {
  animation-play-state: paused;
}

[data-variant="happy"] .ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  background: var(--bg-secondary);
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  transition: background 0.2s;
}

[data-variant="happy"] .ticker-item:hover {
  background: var(--surface-hover);
}

[data-variant="happy"] .ticker-item-source {
  color: var(--yellow);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

[data-variant="happy"] .ticker-item-title {
  color: var(--text);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================
   Phase 6 — Hero Spotlight Card
   ========================================================== */

[data-variant="happy"] .hero-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: var(--panel-radius, 14px);
  overflow: hidden;
  background: var(--bg-secondary);
}

[data-variant="happy"] .hero-card-image {
  width: 100%;
  max-height: 200px;
  overflow: hidden;
}

[data-variant="happy"] .hero-card-image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

[data-variant="happy"] .hero-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

[data-variant="happy"] .hero-card-source {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--yellow);
}

[data-variant="happy"] .hero-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

[data-variant="happy"] .hero-card-title a {
  color: var(--text);
  text-decoration: none;
}

[data-variant="happy"] .hero-card-title a:hover {
  text-decoration: underline;
}

[data-variant="happy"] .hero-card-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.7;
}

[data-variant="happy"] .hero-card-location-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: transparent;
  color: var(--green);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  align-self: flex-start;
}

[data-variant="happy"] .hero-card-location-btn:hover {
  background: var(--green);
  color: var(--bg);
}

/* ==========================================================
   Phase 6 — Good Things Digest
   ========================================================== */

[data-variant="happy"] .digest-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

[data-variant="happy"] .digest-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--bg-secondary);
  transition: background 0.2s;
}

[data-variant="happy"] .digest-card:hover {
  background: var(--surface-hover);
}

[data-variant="happy"] .digest-card-number {
  flex-shrink: 0;
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

[data-variant="happy"] .digest-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

[data-variant="happy"] .digest-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
}

[data-variant="happy"] .digest-card-title:hover {
  text-decoration: underline;
}

[data-variant="happy"] .digest-card-source {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

[data-variant="happy"] .digest-card-summary {
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0.85;
  line-height: 1.4;
  margin: 0.25rem 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

[data-variant="happy"] .digest-card-summary--loading {
  opacity: 0.5;
  font-style: italic;
}

/* ==========================================================
   Phase 6 — Dark Mode Overrides
   ========================================================== */

[data-variant="happy"][data-theme="dark"] .ticker-item {
  background: rgba(255, 255, 255, 0.06);
}

[data-variant="happy"][data-theme="dark"] .ticker-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

[data-variant="happy"][data-theme="dark"] .hero-card {
  background: rgba(255, 255, 255, 0.06);
}

[data-variant="happy"][data-theme="dark"] .digest-card {
  background: rgba(255, 255, 255, 0.06);
}

[data-variant="happy"][data-theme="dark"] .digest-card:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================
   Phase 7 — Species Comeback Panel
   ========================================================== */

[data-variant='happy'] .species-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
}

@media (max-width: 768px) {
  [data-variant='happy'] .species-grid {
    grid-template-columns: 1fr;
  }
}

[data-variant='happy'] .species-card {
  background: var(--bg-secondary);
  border-radius: var(--panel-radius, 14px);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

[data-variant='happy'] .species-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-variant='happy'] .species-photo {
  width: 100%;
  height: 120px;
  overflow: hidden;
}

[data-variant='happy'] .species-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[data-variant='happy'] .species-info {
  padding: 8px 12px;
}

[data-variant='happy'] .species-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}

[data-variant='happy'] .species-scientific {
  font-size: 11px;
  font-style: italic;
  color: var(--text-dim);
  display: block;
  margin-bottom: 6px;
}

[data-variant='happy'] .species-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

[data-variant='happy'] .species-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

[data-variant='happy'] .badge-recovered {
  background: rgba(107, 143, 94, 0.15);
  color: var(--green);
}

[data-variant='happy'] .badge-recovering {
  background: rgba(196, 163, 90, 0.15);
  color: var(--yellow);
}

[data-variant='happy'] .badge-stabilized {
  background: rgba(123, 165, 196, 0.15);
  color: var(--semantic-info);
}

[data-variant='happy'] .badge-iucn {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-dim);
}

[data-variant='happy'] .species-region {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

[data-variant='happy'] .species-sparkline {
  padding: 0 8px;
}

[data-variant='happy'] .species-sparkline svg {
  width: 100%;
  display: block;
}

[data-variant='happy'] .species-sparkline text {
  font-size: 9px;
  fill: var(--text-dim);
}

[data-variant='happy'] .species-summary {
  padding: 4px 12px 10px;
}

[data-variant='happy'] .species-summary p {
  font-size: 12px;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

[data-variant='happy'] .species-source {
  font-size: 10px;
  color: var(--text-dim);
  font-style: normal;
}

/* ==========================================================
   Phase 7 — Renewable Energy Panel
   ========================================================== */

[data-variant='happy'] .renewable-container {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

[data-variant='happy'] .renewable-gauge-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

[data-variant='happy'] .renewable-gauge-section svg {
  max-width: 180px;
  width: 100%;
}

[data-variant='happy'] .gauge-value {
  font-size: 28px;
  font-weight: 700;
  fill: var(--text);
  font-variant-numeric: tabular-nums;
}

[data-variant='happy'] .gauge-label {
  font-size: 12px;
  fill: var(--text-dim);
}

[data-variant='happy'] .gauge-year {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 4px;
}

/* Historical trend sparkline below gauge */
[data-variant='happy'] .renewable-history {
  padding: 0 16px;
}

[data-variant='happy'] .renewable-history svg {
  width: 100%;
  display: block;
}

/* Regional breakdown */
[data-variant='happy'] .renewable-regions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

[data-variant='happy'] .region-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

@media (max-width: 768px) {
  [data-variant='happy'] .region-row {
    grid-template-columns: 100px 1fr 40px;
    font-size: 11px;
  }
}

[data-variant='happy'] .region-name {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-variant='happy'] .region-bar-container {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

[data-variant='happy'] .region-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease-out;
}

[data-variant='happy'] .region-value {
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- EIA Installed Capacity Chart ---------- */
[data-variant='happy'] .capacity-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

[data-variant='happy'] .capacity-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: center;
}

[data-variant='happy'] .capacity-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-dim);
}

[data-variant='happy'] .capacity-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

[data-variant='happy'] .capacity-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ==========================================================
   Phase 7 — Dark Mode Overrides
   ========================================================== */

[data-variant='happy'][data-theme='dark'] .species-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-variant='happy'][data-theme='dark'] .badge-iucn {
  background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================
   Phase 9 — TV Mode (Ambient Fullscreen Panel Cycling)
   Driven by data-tv-mode attribute on <html>
   ========================================================== */

/* ---------- 1. Panel cycling transitions ---------- */
[data-tv-mode] .panel {
  transition: opacity 0.8s ease, transform 0.5s ease;
}
[data-tv-mode] .panel.tv-hidden {
  opacity: 0;
  position: absolute;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}
[data-tv-mode] .panel.tv-active {
  opacity: 1;
  width: 100%;
  max-width: 100%;
}

/* ---------- 2. Larger typography (TV-02) ---------- */
[data-tv-mode] .panel-title { font-size: 1.6rem; }
[data-tv-mode] .panel-content { font-size: 1.15rem; line-height: 1.7; }
[data-tv-mode] .positive-card-title { font-size: 1.3rem; }
[data-tv-mode] .counter-value { font-size: 2.4rem; }
[data-tv-mode] .counter-label { font-size: 1.1rem; }

/* ---------- 3. Suppressed interactive elements (TV-02) ---------- */
[data-tv-mode] .positive-filter-bar,
[data-tv-mode] .positive-feed-filters,
[data-tv-mode] .map-resize-handle,
[data-tv-mode] .positive-card-share,
[data-tv-mode] .panel-header button,
[data-tv-mode] .settings-btn,
[data-tv-mode] .sources-btn,
[data-tv-mode] .search-btn,
[data-tv-mode] .copy-link-btn,
[data-tv-mode] .fullscreen-btn,
[data-tv-mode] .tv-mode-btn,
[data-tv-mode] #regionSelect,
[data-tv-mode] #langSelect {
  display: none !important;
}

/* ---------- 4. Layout overrides for single-panel display ---------- */
[data-tv-mode] #panelsGrid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
[data-tv-mode] .panel.tv-active {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}
[data-tv-mode] .panel.tv-active .panel-content {
  flex: 1;
  overflow: auto;
}

/* ---------- 5. Ambient floating particles (TV-03) — CSS-only ---------- */
[data-tv-mode]::before,
[data-tv-mode]::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
}
[data-tv-mode]::before {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--yellow) 0%, transparent 70%);
  top: 10%;
  left: 5%;
  animation: tv-float-a 25s ease-in-out infinite alternate;
}
[data-tv-mode]::after {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, var(--green) 0%, transparent 70%);
  bottom: 15%;
  right: 8%;
  animation: tv-float-b 30s ease-in-out infinite alternate;
}
@keyframes tv-float-a {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.2); }
  100% { transform: translate(-30px, 80px) scale(0.9); }
}
@keyframes tv-float-b {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -30px) scale(1.15); }
  100% { transform: translate(40px, -60px) scale(0.95); }
}

/* ---------- 6. Reduced motion support ---------- */
@media (prefers-reduced-motion: reduce) {
  [data-tv-mode]::before,
  [data-tv-mode]::after {
    animation: none;
  }
  [data-tv-mode] .panel {
    transition: none;
  }
}

/* ---------- 7. TV mode exit button ---------- */
[data-tv-mode] .tv-exit-btn {
  display: flex !important;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s;
}
[data-tv-mode]:hover .tv-exit-btn {
  opacity: 1;
}
.tv-exit-btn {
  display: none !important;
}

/* ---------- 8. TV mode header button ---------- */
[data-variant="happy"] .tv-mode-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
[data-variant="happy"] .tv-mode-btn:hover {
  border-color: var(--yellow);
  color: var(--text);
}
[data-variant="happy"] .tv-mode-btn.active {
  color: var(--yellow);
  border-color: var(--yellow);
  background: rgba(196, 163, 90, 0.12);
}
