/* Jay Content Engine — brand tokens, single source of truth.
 *
 * Load this AFTER each page's inline <style>. Every page used to define its own
 * :root palette, which had drifted to a generic slate teal on off-white and had
 * no [data-theme] rules at all, so the Auto/Light/Dark toggle set an attribute
 * that nothing listened to. Two problems, one file.
 *
 * Brand source: CLAUDE.md and memory/jayowenlive-brand.md
 *   kraft paper #ece5d3 · warm ink #0e0c0a · flame red #e8431b
 *   display Bricolage Grotesque · body Inter
 *
 * Accent variants are measured, not eyeballed. Flame red on kraft is 3.18:1,
 * which is fine for large type and fails for body text, so small text uses
 * --accent-ink instead (4.71:1 light, 5.37:1 dark).
 */

/* ---- light: the brand as specified ---- */
:root,
:root[data-theme="light"] {
  --bg: #ece5d3;
  --panel: #f5f1e6;
  --panel-2: #e0d8c3;
  --ink: #0e0c0a;
  --ink-dim: #6b6355;
  --line: rgba(14, 12, 10, 0.14);
  --accent: #e8431b;
  --accent-ink: #b93313;
  --accent-soft: rgba(232, 67, 27, 0.10);
  --display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --brand-jay: #e8431b;
  color-scheme: light;
}

/* ---- dark: ink ground, same flame ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0c0a;
    --panel: #17140f;
    --panel-2: #221d16;
    --ink: #ece5d3;
    --ink-dim: #948a78;
    --line: rgba(236, 229, 211, 0.14);
    --accent: #e8431b;
    --accent-ink: #ea532f;
    --accent-soft: rgba(232, 67, 27, 0.14);
    --brand-jay: #e8431b;
    color-scheme: dark;
  }
}

/* An explicit choice always beats the OS preference. This is the rule the
   toggle was missing, which is why it did nothing before. */
:root[data-theme="dark"] {
  --bg: #0e0c0a;
  --panel: #17140f;
  --panel-2: #221d16;
  --ink: #ece5d3;
  --ink-dim: #948a78;
  --line: rgba(236, 229, 211, 0.14);
  --accent: #e8431b;
  --accent-ink: #ea532f;
  --accent-soft: rgba(232, 67, 27, 0.14);
  --brand-jay: #e8431b;
  color-scheme: dark;
}

/* ---- display type ---- */
h1, h2, h3,
.week h3,
header.hero h1 {
  font-family: var(--display);
  letter-spacing: -0.02em;
}

/* Small accent text needs the accessible variant, not the graphic one. */
.eyebrow,
header.hero .eyebrow,
.goal-strip .label,
a.accent,
.status.drafted,
.week .live-cap {
  color: var(--accent-ink);
}

/* The wordmark period is flame red. It is the one mark that carries the brand. */
header.hero h1 .dot,
h1 .dot {
  color: var(--accent);
}

/* Visible focus everywhere. The portal had none. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip link for keyboard users. */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100000;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  border-radius: 0 0 8px 0;
}
.skip-to-content:focus {
  left: 0;
}

/* ---- mobile ----
 * The sticky header's brand tab strip is wider than a phone, so the whole page
 * scrolled sideways by a few pixels and the last brand tab was unreachable.
 * portal-enh-mobile.js already provides a bottom tab bar, but the strip still
 * has to be usable on pages that do not load it, so let it scroll on its own
 * instead of dragging the document with it.
 */
@media (max-width: 640px) {
  .pcui-header {
    max-width: 100vw;
    overflow: hidden;
  }
  .pcui-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .pcui-tabs::-webkit-scrollbar { display: none; }
  .pcui-tab { flex: 0 0 auto; }
  /* The bottom nav from portal-enh-mobile.js is the primary brand switcher on
     a phone, so the duplicate strip in the header just costs vertical space. */
  body:has(.pem-bottom-nav) .pcui-tabs { display: none; }
}

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

@media print {
  :root { --bg: #fff; --ink: #000; --panel: #fff; }
}
