/* cc-facebook dashboard styling. Pulls every color, motion, and size from
   hellozoey tokens (theme/theme/hellozoey/tokens.light.css). Layout is
   math-driven: golden-ratio (φ=1.618) progressions for section heights,
   container queries for column counts, fluid type via clamp(). */

@import url('/theme/theme/hellozoey/tokens.light.css');
@import url('/theme/theme/hellozoey/tokens.dark.css');

/* Reset + base ----------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* overflow-x: clip prevents any descendant from leaking horizontal scroll up
   to the document. Components that legitimately need horizontal scrolling
   (tables, the canvas charts) provide their own .scroll-x wrapper. */
html, body { overflow-x: clip; max-width: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }

:root {
  /* hellozoey theme activation */
}
/* Activate the brand+kind selectors that hellozoey's tokens.light.css scopes
   under. The exported css file gates color tokens on
   :root[data-brand="hellozoey"][data-kind="light"], so we set those here. */
html[data-brand="hellozoey"][data-kind="light"] { color-scheme: light; }
html[data-brand="hellozoey"][data-kind="dark"]  { color-scheme: dark; }

body {
  font-family: "Inter Tight", system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-fg);
  font-weight: 400;
  line-height: 1.45;
  font-feature-settings: "ss01", "cv05";
  min-height: 100vh;
}

/* Fluid type: clamp(min, lerp, max) — pre-computed slopes via util/math.js
   would be ideal, but inlining a few hand-tuned ramps keeps CSS standalone. */
:root {
  --t-xs:  clamp(11px, 0.71vw + 8.8px, 13px);
  --t-sm:  clamp(13px, 0.71vw + 10.8px, 15px);
  --t-md:  clamp(15px, 0.71vw + 12.8px, 17px);
  --t-lg:  clamp(20px, 1.07vw + 16.6px, 24px);
  --t-xl:  clamp(28px, 2.13vw + 21.3px, 38px);
  --t-2xl: clamp(40px, 3.55vw + 28.7px, 64px);

  /* φ-based vertical rhythm */
  --rh-1: 0.5rem;
  --rh-2: 0.809rem;     /* 0.5 × φ */
  --rh-3: 1.309rem;     /* 0.809 × φ */
  --rh-4: 2.118rem;
  --rh-5: 3.427rem;
  --rh-6: 5.545rem;

  --rad-sm: 6px;
  --rad-md: 12px;
  --rad-lg: 18px;
}

/* Layout shell ---------------------------------------------------------- */

cc-shell { display: block; max-width: 100%; }
.shell {
  max-width: 1280px;
  margin: 0 auto;
  /* Mobile padding tightens to 14px on each side so the cards sit a finger's
     width inside the safe area, but never zero. Top/bottom padding scales
     with viewport too. */
  padding: clamp(18px, 4vw, var(--rh-4)) clamp(14px, 3vw, 32px) clamp(28px, 6vw, var(--rh-6));
}
/* Mobile-only: reduce card padding so content has more horizontal room. */
@media (max-width: 599px) {
  .card { padding: var(--rh-3); }
  .kpi  { padding: var(--rh-3); min-height: 112px; }
  .region-card { padding: var(--rh-3); }
}

/* Hero ------------------------------------------------------------------ */
/* Mobile: lockup stacks above the copy. Desktop: copy left, lockup right. */

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--rh-4);
  align-items: center;
  padding-block: var(--rh-3) var(--rh-5);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--rh-4);
}
@container shell (width >= 768px) {
  .hero { grid-template-columns: 1fr auto; }
}
.hero h1 {
  font-size: var(--t-2xl);
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0;
  line-height: 1.02;
  color: var(--color-fg);
}
.hero .lede {
  color: var(--color-fg-muted);
  font-size: var(--t-md);
  margin-top: var(--rh-2);
  max-width: 56ch;
}
.hero .period {
  display: inline-flex;
  gap: 0.6em;
  font-size: var(--t-sm);
  color: var(--color-fg-subtle);
  margin-top: var(--rh-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
/* Logo lockup = orbit mark stacked over the helloZoey wordmark. */
.hero-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rh-2);
  /* On mobile, sit above the copy and roughly half the desktop size. */
  order: -1;
}
@container shell (width >= 768px) {
  .hero-lockup { order: 0; }
}
.hero-lockup .hero-mark {
  width: clamp(120px, 16vw, 200px);
  height: clamp(120px, 16vw, 200px);
}
.hero-lockup .hero-wordmark {
  width: clamp(140px, 16vw, 220px);
  height: clamp(28px, 3vw, 44px);
}

/* Section primitives --------------------------------------------------- */

.section {
  margin-block: var(--rh-5);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--rh-3);
  margin-bottom: var(--rh-3);
}
.section-head h2 {
  margin: 0;
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-head .meta {
  color: var(--color-fg-subtle);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--rad-lg);
  padding: var(--rh-3) var(--rh-4);
  box-shadow: var(--shadow-sm);
}

/* KPI strip ------------------------------------------------------------ */
/* 1 column on mobile, 2 on tablet, 3 across × 2 rows on desktop. The grid
   is keyed off the shell container so the dashboard reflows inside flex
   parents (sidebars, modals) too, not just the viewport. */

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--rh-3);
}
@container shell (width >= 640px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container shell (width >= 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.kpi {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--rh-2);
  padding: var(--rh-3) var(--rh-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--rad-lg);
  min-height: 132px;
}
.kpi .label {
  color: var(--color-fg-subtle);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  /* Allow up to two label lines without pushing the value down. */
  line-height: 1.25;
}
.kpi .value {
  font-size: var(--t-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  /* Keep $X,XXX.XX on one line — shrink type with container width if needed. */
  white-space: nowrap;
}
.kpi .delta { color: var(--color-fg-muted); font-size: var(--t-xs); line-height: 1.3; }

/* Region card row ------------------------------------------------------ */

.region-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--rh-3);
}
@container shell (width >= 1024px) {
  .region-row { grid-template-columns: 1fr 1fr; }
}
.region-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--rh-2);
  padding: var(--rh-3) var(--rh-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--rad-lg);
}
.region-card .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.region-card .pill {
  font-size: var(--t-xs);
  background: var(--color-surface-hover);
  color: var(--color-accent);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.region-card h3 { margin: 0; font-size: var(--t-md); font-weight: 600; }
.region-card .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--rh-2);
}
.region-card .stats > div { display: flex; flex-direction: column; gap: 2px; }
.region-card .stats .v { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.01em; }
.region-card .stats .l { font-size: var(--t-xs); color: var(--color-fg-subtle); text-transform: uppercase; letter-spacing: 0.08em; }

.video-bars {
  display: grid;
  gap: 4px;
  margin-top: var(--rh-1);
}
.video-bars .row { display: grid; grid-template-columns: 60px 1fr 60px; gap: 8px; align-items: center; }
.video-bars .row .lbl { font-size: var(--t-xs); color: var(--color-fg-subtle); }
.video-bars .row .bar {
  background: var(--color-surface-hover);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.video-bars .row .bar > span {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: inherit;
}
.video-bars .row .val { font-size: var(--t-xs); color: var(--color-fg); text-align: right; }

/* Tables -------------------------------------------------------------- */

.tbl {
  width: 100%;
  /* Keep columns legible on narrow screens — fall through to horizontal
     scroll on the .scroll-x wrapper instead of crushing the text. */
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--t-sm);
}
.tbl thead th {
  text-align: left;
  font-weight: 500;
  color: var(--color-fg-subtle);
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: var(--rh-1) var(--rh-2);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
}
.tbl tbody td {
  padding: var(--rh-2);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--color-surface-hover); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.dim { color: var(--color-fg-subtle); }
.tbl .badge {
  display: inline-block;
  font-size: var(--t-xs);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-surface-hover);
  color: var(--color-fg);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--color-border);
}
/* Region badges — borders use the actual token colours so they retint with the theme. */
.tbl .badge.il    { color: var(--color-accent);  border-color: color-mix(in srgb, var(--color-accent)  35%, transparent); }
.tbl .badge.mi_in { color: var(--color-primary); border-color: color-mix(in srgb, var(--color-primary) 35%, transparent); }

/* .scroll-x: the canonical "this thing is wider than the page" wrapper.
   Forces a horizontal scrollbar on the component (not the page) for tables
   and other column-heavy content. */
.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  /* On iOS-Safari WebKit, momentum scrolling makes horizontal table scroll usable. */
  -webkit-overflow-scrolling: touch;
  /* Shadow hint that there's more to scroll: subtle right-edge gradient. */
  background:
    linear-gradient(to right, var(--color-surface) 30%, transparent),
    linear-gradient(to right, transparent, var(--color-surface) 70%) right / 24px 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--color-fg) 12%, transparent), transparent),
    radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--color-fg) 12%, transparent), transparent) right / 12px 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}
/* The card already supplies the visible surface, so when .scroll-x lives
   inside .card we drop the gradient hints — otherwise they double up. */
.card > .scroll-x {
  background: none;
}
/* Card itself must not let oversized children blow out the viewport. */
.card { overflow: hidden; max-width: 100%; }

/* Two-col layouts — φ-weighted golden ratio split, even split when .even is set.
   Stacks on mobile/tablet, splits on desktop. */

.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--rh-4);
}
@container shell (width >= 1024px) {
  .two-col      { grid-template-columns: minmax(0, 1.618fr) minmax(0, 1fr); }
  .two-col.even { grid-template-columns: 1fr 1fr; }
}

/* Empty / loading states ---------------------------------------------- */

.skel {
  background: linear-gradient(90deg,
    var(--color-surface-hover) 0%,
    var(--color-bg) 50%,
    var(--color-surface-hover) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s var(--color-primary, linear) infinite;
  border-radius: var(--rad-sm);
  color: transparent;
  display: inline-block;
  min-height: 1em;
  min-width: 4em;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Footer -------------------------------------------------------------- */

footer.sig {
  margin-top: var(--rh-6);
  padding-top: var(--rh-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-fg-subtle);
  font-size: var(--t-xs);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--rh-3);
  flex-wrap: wrap;
}
footer.sig .tag { letter-spacing: 0.06em; text-transform: uppercase; }

/* Container query host: the shell element acts as the container for the
   two-col / region-row queries above, so the page reflows around its own
   width rather than the viewport (handles sidebars, modals, etc). */
cc-shell { container-name: shell; container-type: inline-size; display: block; }
