﻿:root {
  color-scheme: dark;
  --bg: #111c34;
  --bg-card: #152243;
  --bg-card-light: rgba(21, 34, 67, 0.95);
  --text: #e9f1ff;
  --text-muted: #9fb4d8;
  --accent: #0f766e;
  --accent-strong: #155e75;
  --border: rgba(148, 163, 184, 0.2);
  /* Respect safe areas on mobile */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
img, canvas, svg, video { max-width: 100%; height: auto; }

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

html, body {
  max-width: 100%;
}

/* Headline insight bar (mobile truncation) */
#headlineBar { display: block; }
@media (max-width: 600px) {
  #headlineBar {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; /* clamp to 2 lines on small screens */
    overflow: hidden;
  }
}

/* Headline magnitude styles */
#headlineCard.headline-hot {
  border-color: #ff49e1 !important; /* neon pink */
  box-shadow: 0 0 0 1px rgba(255, 73, 225, 0.22);
}
#headlineCard.headline-cool {
  border-color: #60a5fa !important; /* cool blue */
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.18);
}

/* Hide Date column on small screens */
@media (max-width: 600px) {
  .data-table th.col-date,
  .data-table td.col-date { display: none; }
}

a {
  color: inherit;
}

a:hover {
  color: #f8fafc;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 200;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.5rem 0.75rem;
  background: #1f2937;
  color: #f8fafc;
  border-radius: 0.5rem;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(17, 28, 52, 0.9), var(--bg) 55%);
}

.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

/* Fluid container variant for admin pages when wide tables are desired */
.container.container--fluid {
  width: 98vw;
  max-width: none;
}

/* Shared table styling */
.table, .data-table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td,
.data-table th, .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* Responsive tables: horizontal scroll on small screens */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table { width: 100%; min-width: 640px; border-collapse: collapse; }
/* Unified responsive table wrapper */
.responsive-table { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.responsive-table > table { width: 100%; min-width: 640px; border-collapse: collapse; }

/* Add safe side padding on small screens so borders/shadows don't clip */
@media (max-width: 600px) {
  .container {
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }
  .container.container--fluid {
    width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(17, 28, 52, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  transition: transform 0.22s ease;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1.5rem;
}

.brand {
  color: #f8fafc;
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav-list li {
  position: relative;
}

.nav-link,
.nav-trigger {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 0.75rem;
  padding: 0.45rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.nav-link.active,
.nav-link:hover,
.nav-trigger:hover,
.nav-trigger:focus {
  color: #0f172a;
  background: #cbd5f5;
}

.menu > summary {
  list-style: none;
}

.menu[open] > summary {
  color: #0f172a;
  background: #cbd5f5;
}

.menu .dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  background: #152243;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 24px rgba(8, 11, 24, 0.45);
  padding: 10px;
  display: none;
  min-width: 200px;
  max-width: min(240px, 92vw);
  flex-direction: column;
  gap: 8px;
  z-index: 40;
}

.menu[open] .dropdown {
  display: flex;
}

.menu .dropdown a {
  padding: 0.5rem 0.75rem;
  border-radius: 0.65rem;
  color: #e2e8f0;
  text-decoration: none;
  background: transparent;
}

.menu .dropdown a:hover {
  background: rgba(148, 163, 184, 0.2);
}

.header-cta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #ecfeff;
  box-shadow: 0 10px 25px rgba(15, 118, 110, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.32);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

.btn-ghost:hover {
  background: rgba(148, 163, 184, 0.12);
}

.micro {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stack {
  display: grid;
  gap: 32px;
  padding: 48px 0 72px;
}

.page-intro {
  display: grid;
  gap: 0.75rem;
}

.page-intro h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2vw + 1rem, 2.4rem);
}

.data-updated {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.section-group {
  display: grid;
  gap: 24px;
}

.card {
  min-width: 0; /* allow shrink inside grid/flex */
  background: rgba(21, 34, 67, 0.93);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(123, 148, 196, 0.22);
}

.card header {
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  color: #e2e8f0;
}

.card p {
  margin: 0;
  color: rgba(200, 214, 244, 0.82);
}

.chart-frame {
  position: relative;
  min-height: 320px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: auto;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table thead th {
  font-weight: 600;
  color: var(--text-muted);
}

.data-table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

/* Wider container option for data-heavy pages */
.container-wide {
  max-width: 1200px;
}

.data-table td a {
  word-break: break-word;
}

canvas {
  width: 100% !important;
  height: auto !important;
  max-height: 420px;
}

/* Guard against wide elements overflowing viewport */
img, canvas, table {
  max-width: 100%;
}

.contribute {
  display: grid;
  gap: 0.75rem;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(14, 116, 144, 0.26));
  border: 1px solid rgba(45, 212, 191, 0.35);
}

.contribute-head .muted {
  color: rgba(200, 214, 244, 0.82);
}

.contribute-points {
  margin: 0;
  padding-left: 1.1rem;
  color: rgba(241, 245, 249, 0.9);
}

.contribute-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.contribute-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  font-size: 0.85rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 999px;
  color: rgba(228, 236, 255, 0.95);
  background: rgba(22, 49, 94, 0.6);
}

.tight {
  margin-bottom: 0.25rem;
}

.usage-list {
  margin: 0;
  padding-left: 1.1rem;
  color: rgba(226, 232, 240, 0.85);
}

footer {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding: 32px 0;
  background: rgba(17, 28, 52, 0.9);
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  color: rgba(200, 214, 244, 0.82);
}

.footer-nav a {
  text-decoration: none;
  color: rgba(94, 234, 212, 0.85);
}

.footer-nav a:hover {
  color: #f0fdfa;
}

.nudge {
  position: fixed;
  inset: auto 1rem 1rem auto;
  max-width: 22rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card-light);
  color: #f0fdfa;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 0.6rem;
  z-index: 60;
}

.nudge-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nudge .btn-primary {
  box-shadow: none;
}

@media (max-width: 768px) {
  .site-header .container {
    flex-wrap: wrap;
    justify-content: center;
  }

  .site-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-list {
    flex-wrap: wrap;
    justify-content: center;
  }

  .header-cta {
    align-items: center;
  }

  .nudge {
    inset: auto 0.75rem 0.75rem 0.75rem;
  }
}

/* Hide header when body has header-hidden (on scroll down) */
.header-hidden .site-header {
  transform: translateY(-110%);
}

/* On small devices in landscape, hide header to free vertical space */
@media (max-width: 900px) and (orientation: landscape) {
  .site-header { display: none; }
  /* Reduce chart footprint in landscape on small screens */
  .chart-frame { min-height: 180px; }
  canvas { max-height: 220px !important; }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #111c34;
    --bg-card: #152243;
    --text: #e9f1ff;
    --text-muted: #9fb4d8;
    --border: rgba(203, 213, 225, 0.6);
  }

  body {
    color: var(--text);
  }

  .card {
    box-shadow: 0 12px 40px rgba(148, 163, 184, 0.28);
  }

  .contribute {
    color: #0f172a;
  }

  .pill {
    color: #0f172a;
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.4);
  }

  .btn-ghost {
    color: #111827;
    border-color: rgba(148, 163, 184, 0.5);
  }

  .btn-ghost:hover {
    background: rgba(148, 163, 184, 0.18);
  }

  .nudge {
    background: #ffffff;
    color: #0f172a;
  }
}



/* Light theme (admin-friendly) */
body.theme-light {
  --bg: #f9fbfd;
  --bg-card: #ffffff;
  --bg-card-light: #ffffff;
  --text: #0f172a;
  --text-muted: #334155;
  --accent: #0a56c2;
  --accent-strong: #0a4aa8;
  --border: #e6eef8;
  color-scheme: light;
}

/* Shared table styling */
.table, .data-table { width: 100%; border-collapse: collapse; }
.table th, .table td,
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* Sticky headers inside scroll container */
.table thead th, .data-table thead th { position: sticky; top: 0; background: var(--bg-card); z-index: 1; }

/* Responsive tables: horizontal scroll on small screens */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table { min-width: 720px; }

/*
  Responsive foundation additions
  These override or extend earlier rules to meet new mobile-first requirements.
*/

html { font-size: 16px; }
body { line-height: 1.5; }
img { max-width: 100%; height: auto; display: block; }

/* Container breakpoints */
.container{margin:0 auto;padding:0 1rem;}
@media (min-width:640px){.container{max-width:640px}}
@media (min-width:768px){.container{max-width:768px}}
@media (min-width:1024px){.container{max-width:960px}}
@media (min-width:1280px){.container{max-width:1120px}}

/* Table scroll for admin/public tables */
.table-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
.table-scroll table{border-collapse:collapse;width:100%;min-width:640px}
thead th{position:sticky;top:0;z-index:2;background:var(--bg-card,#fff);border-bottom:1px solid rgba(0,0,0,.08)}
tbody tr:nth-child(odd){background:rgba(0,0,0,.02)}
td,th{padding:.5rem .75rem;text-align:left;white-space:nowrap}

/* Charts */
.chart-wrap{position:relative;width:100%;aspect-ratio:4/3;overflow:hidden}
@media (min-width:768px){.chart-wrap{aspect-ratio:16/7}}
.chart-wrap canvas{position:absolute;inset:0;width:100% !important;height:100% !important}

/* Grids */
.grid { display: grid; gap: 1rem; }
.grid-responsive { grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid-responsive { grid-template-columns: repeat(2, minmax(0,1fr)); } }
/* Ensure grid children can shrink to avoid overflow */
.grid > * { min-width: 0; }
.flex > * { min-width: 0; }

/* Forms */
.form { display: grid; gap: 1.25rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 768px){ .form-grid { grid-template-columns: 1fr 1fr; } .form-wide { grid-column: 1 / -1; } }
.form-group { display: grid; gap: 0.5rem; }
.form input[type=text], .form input[type=date], .form input[type=number], .form input[type=email], .form textarea {
  width: 100%; padding: 0.9rem 1rem; border-radius: 0.75rem; border: 1px solid rgba(164,189,235,0.45);
  background: rgba(29,44,78,0.78); color: #f3f7ff; font-size: 1rem;
}
.form textarea { min-height: 220px; resize: vertical; }
.form input:focus, .form textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.checkbox { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: flex-start; }
.checkbox input { width: 22px; height: 22px; }
.form-actions { display: flex; gap: 0.75rem; }
.form-inline { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* LinkedIn follow CTA */
.follow-link { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: inherit; font-weight: 600; }
.follow-link .icon { width: 20px; height: 20px; display: inline-block; }
.follow-link:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { .follow-link .icon { filter: invert(1) brightness(1.1); } }

/* Compact follow card near page header */
.follow-card {
  margin: 12px 0 10px;
  display: flex;
  justify-content: flex-start;
}
.follow-card__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #ff49e1; /* default: neon pink */
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  line-height: 1;
  color: hsl(0 0% 98%);
  background: hsl(210 12% 14%);
  transition: background .2s ease, border-color .2s ease, transform .06s ease;
}
.follow-card__link:hover {
  background: hsl(210 12% 17%);
  border-color: #ff49e1;
}
.follow-card__link:active { transform: translateY(1px); }
.follow-card__link:focus-visible {
  outline: 2px solid hsl(203 89% 53% / .5);
  outline-offset: 2px;
  border-radius: 10px;
}
.follow-card__link--gold { border-color: #d4af37; }
.follow-card__link--gold:hover { border-color: #d4af37; }
.follow-card__icon { inline-size: 18px; block-size: 18px; filter: brightness(1.2); }
.follow-card__text {
  font-size: 14px;
  white-space: nowrap;
}
@media (max-width: 420px) { .follow-card__text { white-space: normal; } }

/* Tighter spacing when follow card appears in the intro block */
.page-intro .follow-card { margin-top: 4px; margin-bottom: 8px; }

/* === Responsive baseline utilities (additions) === */
/* Global safe defaults for media elements */
img, svg, canvas, video { max-width: 100%; height: auto; }

/* Charts: responsive container with stable aspect ratio */
.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0; /* critical for flex/grid */
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.chart-wrap > canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Horizontal scroll wrapper for wide tables */
.h-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable both-edges; }
.h-scroll::-webkit-scrollbar { height: 10px; }

/* Set a practical minimum table width so columns don’t crush */
.table--min { min-width: 640px; table-layout: fixed; }
/* Prevent content overlapping adjacent cells: clip overflow within the cell */
.table--min th, .table--min td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sticky table header for better context while scrolling */
.table--sticky thead th { position: sticky; top: 0; z-index: 1; background: hsl(210 12% 14% / 1); }

/* Prevent body-level horizontal scrolling from accidental overflow */
/* Removed global overflow-x hidden; addressed true overflow causes instead */

/* Safe container padding so content doesn’t touch edges on mobile */
.container, main { padding-inline: clamp(12px, 3vw, 24px); }

/* Mobile portrait polish */
@media (max-width: 480px) {
  .h-scroll { padding-bottom: 4px; margin-right: -8px; padding-right: 8px; }
  .chart-wrap { margin-inline: 0; }
}

/* Slim footnote near page end */
.footnote { margin: 8px 0 0; color: var(--text-muted); font-size: 0.9rem; }

/* Ensure container never overflows viewport on narrow desktop windows */
@media (max-width: 900px) {
  .container { width: auto; max-width: 100%; }
}
@media (max-width: 600px) {
  .container { width: auto; max-width: 100%; }
}

/* Prevent any card from extending beyond container */
.card { max-width: 100%; }

/* Form alignment refinements (fix misaligned email input) */
.form-grid { align-items: start; }
.form-group .hint { display: block; margin-top: 0.25rem; color: var(--text-muted); font-size: 0.9rem; }

/* Compact mode */
body.compact .table th, body.compact .table td,
body.compact .data-table th, body.compact .data-table td { padding: 4px 6px; }

/* TEMP: highlight horizontal overflow in dev
body { outline: 2px dashed transparent; }
@media (max-width: 420px) {
  body { outline-color: red; }
}
*/
