/* Daily Macro Briefing — "voice vs data": editorial serif over precise mono, on calm ink.
   Accent is driven by the current regime (set on <html data-regime>). */

:root {
  color-scheme: dark;

  --bg: #0b0c0e;
  --bg-2: #0e0f12;
  --surface: rgba(255, 255, 255, 0.026);
  --surface-2: rgba(255, 255, 255, 0.05);
  --hairline: rgba(255, 255, 255, 0.085);
  --hairline-soft: rgba(255, 255, 255, 0.05);

  --text: #e9e6df;
  --text-dim: #b3b2ab;
  --text-mute: #7c7f86;

  --up: #79b98a;
  --down: #d98d7c;
  --amber: #e0b15e;

  /* regime accent (overridden per data-regime) */
  --accent: #6fc2a6;
  --accent-weak: rgba(111, 194, 166, 0.14);
  --accent-glow: rgba(111, 194, 166, 0.20);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --maxw: 30rem;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html[data-regime="soft_landing"]        { --accent: #6fc2a6; --accent-weak: rgba(111,194,166,.14); --accent-glow: rgba(111,194,166,.20); }
html[data-regime="late_cycle_expansion"]{ --accent: #d8b25a; --accent-weak: rgba(216,178,90,.14);  --accent-glow: rgba(216,178,90,.20); }
html[data-regime="stagflation_risk"]     { --accent: #e0875e; --accent-weak: rgba(224,135,94,.15);  --accent-glow: rgba(224,135,94,.22); }
html[data-regime="recovery"]             { --accent: #6fa8d8; --accent-weak: rgba(111,168,216,.14); --accent-glow: rgba(111,168,216,.20); }
html[data-regime="slowdown"]             { --accent: #cf9a6b; --accent-weak: rgba(207,154,107,.14); --accent-glow: rgba(207,154,107,.20); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); }

body {
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: max(1.1rem, env(safe-area-inset-top)) 1.1rem max(1.6rem, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

/* ambient atmosphere — a faint accent glow + a grain wash, both calm */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 55% at 50% -8%, var(--accent-glow), transparent 60%),
    radial-gradient(90% 40% at 100% 0%, rgba(255,255,255,.03), transparent 55%);
  transition: background .8s var(--ease);
}
.ambient::after {
  content: "";
  position: absolute; inset: 0;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
}

/* ── eyebrow ─────────────────────────────────────────── */
.eyebrow {
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: .55em;
  margin-bottom: .9rem;
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ── briefing card ───────────────────────────────────── */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.4rem 1.35rem 1.5rem;
  overflow: hidden;
  isolation: isolate;
  animation: rise .7s var(--ease) both;
}
.card__bar {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 78%);
}
.card::after { /* faint accent wash inside the card */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120% 80% at 0% 0%, var(--accent-weak), transparent 55%);
}

.headline {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 6.2vw, 1.95rem);
  line-height: 1.16;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}

.quotes { list-style: none; margin: 1.15rem 0 0; display: grid; gap: .6rem; }
.quote {
  position: relative;
  padding-left: 1.15rem;
  font-size: .93rem;
  line-height: 1.45;
  color: var(--text-dim);
}
.quote::before {
  content: ""; position: absolute; left: 0; top: .58em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}
.quote b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.conds { margin-top: 1.15rem; display: grid; gap: .55rem; }
.cond {
  font-size: .8rem;
  line-height: 1.4;
  color: var(--text-dim);
  padding-left: .85rem;
  border-left: 2px solid var(--accent-weak);
}
.cond .tag {
  font-weight: 600; color: var(--accent);
  letter-spacing: .02em;
}
.cond--change { font-family: var(--serif); font-style: italic; font-size: .92rem; color: var(--text-dim); }

/* fallback (state 4): plain template, no flourish */
.fallback {
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── indicator rows (Apple-Stocks) ───────────────────── */
.rows { list-style: none; margin: 1.5rem 0 0; }
.row {
  display: grid;
  /* fixed value column → every sparkline lands in the same place (Apple-Stocks alignment),
     instead of the value auto-sizing per row and shoving wide rows' sparks left. */
  grid-template-columns: 1fr 64px 6rem;
  align-items: center;
  gap: 1rem;
  padding: .72rem .2rem;
  border-top: 1px solid var(--hairline-soft);
  animation: fade .6s var(--ease) both;
}
.row:first-child { border-top: none; }
.row__name { font-size: .9rem; color: var(--text-dim); letter-spacing: -0.01em; }
.row__spark { width: 64px; height: 26px; opacity: .9; }
.row__val {
  display: flex;
  flex-direction: column;
  align-items: flex-end;          /* value + chip stack vertically, right-aligned (Apple Stocks) */
  gap: .26rem;
  color: var(--text);
}
.row__num {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: .96rem;
  line-height: 1.05;
}
/* Apple-Stocks change chip — a filled rounded badge under the value; tap to cycle %/points/raw level. */
.row__val .chip {
  display: inline-block;
  padding: .06rem .42rem .1rem;
  border-radius: .45rem;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .005em;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: filter .15s var(--ease);
}
.row__val .chip:empty { display: none; }
.row__val .chip.up   { background: var(--up);   color: #0b1410; }
.row__val .chip.down { background: var(--down); color: #1a0f0c; }
.row__val .chip.flat { background: rgba(255, 255, 255, .08); color: var(--text-mute); }
.row__val .chip:hover { filter: brightness(1.08); }
.row__val .chip:active { filter: brightness(.93); }
.row__val .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row[data-stale="true"] .row__val { color: var(--text-mute); }

/* ── regime snapshot (V2 Tier 0) ─────────────────────── */
.regime {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.4rem;
  padding: .68rem .9rem;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--accent-weak);
  animation: fade .6s var(--ease) both;
}
.regime__eyebrow {
  font-size: .62rem; font-weight: 500; letter-spacing: .24em;
  text-transform: uppercase; color: var(--text-mute);
}
.regime__value {
  font-family: var(--serif); font-size: 1.05rem; color: var(--text);
  display: inline-flex; align-items: center; gap: .5em;
}
.regime__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent-glow);
}

/* ── more-indicators drawer (V2 Tier 2) ──────────────── */
.drawer { margin-top: .2rem; }
.drawer__summary {
  list-style: none; cursor: pointer;
  padding: .72rem .2rem;
  font-size: .8rem; letter-spacing: .02em; color: var(--text-mute);
  display: flex; align-items: center; gap: .5em;
  border-top: 1px solid var(--hairline-soft);
}
.drawer__summary::-webkit-details-marker { display: none; }
.drawer__summary::before {
  content: "+"; font-family: var(--mono); color: var(--accent); font-size: .95rem; line-height: 1;
}
.drawer[open] .drawer__summary::before { content: "–"; }
.drawer__summary:hover { color: var(--text-dim); }
.rows--drawer { margin-top: 0; }
.rows--drawer .row:first-child { border-top: 1px solid var(--hairline-soft); }

/* ── markets strip (V2 Tier 3 — display-only) ────────── */
.markets { margin-top: 1rem; }
.markets__head {
  font-size: .8rem; letter-spacing: .02em; color: var(--text-mute);
  padding: .72rem .2rem .1rem; border-top: 1px solid var(--hairline-soft);
}
.rows--markets { margin-top: 0; }
.markets__note {
  margin-top: .35rem; padding: 0 .2rem;
  font-size: .68rem; letter-spacing: .02em; color: var(--text-mute); font-style: italic;
}

/* ── footer ──────────────────────────────────────────── */
.rule { border: none; border-top: 1px solid var(--hairline); margin: 1rem 0 .85rem; }
.footer {
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--text-mute);
}
.footer .run { color: var(--text-dim); }
html[data-state="stale"] .footer { color: var(--amber); }
html[data-state="stale"] .footer .run { color: var(--amber); }

/* ── states ──────────────────────────────────────────── */
/* error: card collapses silently, rows still render (the invariant) */
html[data-state="error"] .card { display: none; }

/* loading skeletons */
.skeleton {
  border-radius: 7px;
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--headline { height: 1.7rem; width: 86%; margin-bottom: .9rem; }
.skeleton--line { height: .9rem; width: 70%; margin-bottom: .5rem; }
.skeleton--line.short { width: 52%; }
.row--skeleton { height: 1.45rem; }
.row--skeleton::after {
  content: ""; display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, ::after, ::before { animation: none !important; transition: none !important; }
}

@media (min-width: 32rem) {
  body { align-items: center; padding-top: 3rem; }
}

/* ── tappable rows (open the detail sheet) ───────────── */
.row { cursor: pointer; }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }

/* ── detail sheet (V2 Tier 4 — Apple-Stocks-style) ───── */
/* iOS scroll lock: overflow:hidden alone is ignored by iOS Safari, so position:fixed the body
   (JS sets `top: -scrollY` on open and restores scroll on close). */
body.sheet-open { overflow: hidden; position: fixed; left: 0; right: 0; width: 100%; }
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet__backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 1;                                   /* rest opaque; entrance fades in, close fades out */
  transition: opacity .28s var(--ease);
  animation: sheetfade .28s var(--ease);        /* auto-plays the fade-in on show (no JS/rAF) */
  touch-action: none;                           /* a drag on the backdrop can't scroll the page behind */
  will-change: opacity;
}
.sheet__panel {
  position: relative; z-index: 1;
  width: 100%; max-width: var(--maxw);
  max-height: 92vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;                 /* don't chain scroll to the body behind */
  background: var(--bg-2);
  border: 1px solid var(--hairline); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.4rem 1.25rem calc(1.4rem + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5);
  transform: translateY(0);                     /* resting OPEN position (visible) */
  transition: transform .3s var(--ease);        /* drives drag spring-back + slide-down close */
  animation: sheetup .32s var(--ease);          /* auto-plays the slide-up on show (no JS/rAF) */
  will-change: transform;
}
.sheet__close {
  position: absolute; top: .9rem; right: .95rem;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  border: none; background: var(--surface-2); color: var(--text-dim);
  font-size: .78rem; line-height: 1; cursor: pointer;
}
.sheet__close:hover { color: var(--text); background: var(--hairline); }
.sheet__head { margin-bottom: 1rem; padding-right: 2rem; }
.sheet__name { font-size: .78rem; letter-spacing: .04em; color: var(--text-mute); text-transform: uppercase; }
.sheet__val { font-size: 1.95rem; font-weight: 600; margin-top: .18rem; font-variant-numeric: tabular-nums; }
.sheet__sub { display: flex; align-items: center; gap: .55rem; margin-top: .4rem; }
.sheet__sub .chip { margin-top: 0; }
.sheet__period { font-size: .76rem; color: var(--text-mute); }
.sheet__tf { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tf {
  flex: 1 1 auto; min-width: 2.3rem;
  padding: .36rem .2rem; border: none; border-radius: .5rem;
  background: var(--surface-2); color: var(--text-mute);
  font-family: var(--mono); font-size: .72rem; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tf:hover { color: var(--text-dim); }
.tf--on { background: var(--accent-weak); color: var(--accent); }
.tf:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sheet__chart { margin-bottom: 1rem; min-height: 120px; }
.chart { width: 100%; height: auto; display: block; }
.chart__grid { stroke: var(--hairline-soft); stroke-width: .5; }
.chart__ylab, .chart__xlab { fill: var(--text-mute); font-family: var(--mono); font-size: 7px; }
.chart__line { stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.chart__area { opacity: .09; stroke: none; }
.sheet__empty { color: var(--text-mute); font-size: .82rem; text-align: center; padding: 2.2rem 0; }
.sheet__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; margin-bottom: 1.1rem; }
.stat { display: flex; justify-content: space-between; gap: .5rem; padding: .44rem 0; border-bottom: 1px solid var(--hairline-soft); }
.stat dt { font-size: .76rem; color: var(--text-mute); }
.stat dd { font-size: .78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; text-align: right; }
.sheet__links { display: flex; gap: .6rem; }
.sheet__link {
  flex: 1; text-align: center; padding: .62rem; border-radius: .6rem;
  background: var(--surface-2); border: 1px solid var(--hairline);
  color: var(--text-dim); text-decoration: none; font-size: .8rem;
}
.sheet__link:hover { color: var(--text); border-color: var(--accent); }

/* ── detail-sheet motion: grab handle + drag/open/close states ───────────── */
.sheet__handle {
  position: absolute; top: .55rem; left: 50%;
  width: 36px; height: 4px; margin-left: -18px;
  border-radius: 999px;
  background: var(--text-mute); opacity: .35;
  z-index: 2; cursor: grab; touch-action: none;
}
.sheet__handle:active { cursor: grabbing; }
/* nudge the close button + header down so they clear the handle */
.sheet__close { top: 1.1rem; }
.sheet__head  { padding-top: .35rem; touch-action: none; }  /* header is a drag-start zone → own the gesture */
/* entrance animations (auto-play when the sheet goes display:none → flex) */
@keyframes sheetup   { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheetfade { from { opacity: 0; } to { opacity: 1; } }
/* finger down → kill transition + entrance animation so the panel tracks the finger 1:1
   (JS writes inline transform/opacity each pointermove) */
.sheet--dragging .sheet__panel,
.sheet--dragging .sheet__backdrop { transition: none; animation: none; }
