/* =========================================================================
   Buzzbuild — styles.css
   Outfit-only, type-led, theme-aware via [data-theme] custom properties.
   Cutting-edge primitives (light-dark, color-mix, container queries,
   text-wrap) are layered as progressive enhancement on a robust base.
   ========================================================================= */

/* ----- Font (self-hosted Outfit variable, latin subset) ---------------- */
@font-face {
  font-family: "Outfit";
  src: url("/fonts/outfit-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ----- Design tokens --------------------------------------------------- */
:root {
  /* Brand */
  --yellow: #d7d72e;
  --ink: #231e1e;
  --near-black: #0a0a0a;
  --white: #ffffff;

  /* Spacing rhythm (8px base) */
  --s-1: 0.5rem;   /* 8  */
  --s-2: 1rem;     /* 16 */
  --s-3: 1.5rem;   /* 24 */
  --s-4: 2rem;     /* 32 */
  --s-5: 3rem;     /* 48 */
  --s-6: 4rem;     /* 64 */
  --s-7: 6rem;     /* 96 */
  --s-8: 8rem;     /* 128 */

  /* Layout */
  --content: 76rem;        /* ~1216px content width */
  --gutter: clamp(1.25rem, 0.5rem + 2.5vw, 2.5rem);
  --radius: 16px;
  --radius-sm: 8px;

  /* Type */
  --font-sans: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.6s;
  --dur-fast: 0.18s;

  /* Theme fallbacks: light defaults so the page renders correctly with NO JS
     (before theme.js sets [data-theme]). [data-theme] blocks override these. */
  --bg: #fcfbf7;
  --bg-elev: var(--white);
  --fg: var(--ink);
  --fg-muted: color-mix(in srgb, var(--fg) 72%, transparent);
  --border: color-mix(in srgb, var(--fg) 11%, transparent);
  --hero-bg: var(--yellow);
  --hero-fg: var(--ink);
  --hero-bee: var(--ink);
  --hero-btn-bg: var(--ink);
  --hero-btn-fg: var(--yellow);
  --lockup: var(--ink);
  --focus-ring: var(--ink);
  --btn-outline: color-mix(in srgb, var(--fg) 45%, transparent);
  --card-accent: var(--ink);
  --comb: color-mix(in srgb, var(--ink) 6%, transparent);

  color-scheme: light dark;
}

/* Theme tokens. [data-theme] is the source of truth (set pre-paint by theme.js).
   light-dark() mirrors the same values as progressive enhancement. */
[data-theme="light"] {
  /* Theme tokens inherit the :root light defaults; this opt-in fixes color-scheme. */
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: var(--near-black);
  --bg-elev: #171717;
  --fg: #f5f2e8;
  --fg-muted: color-mix(in srgb, var(--fg) 72%, transparent);
  --border: color-mix(in srgb, var(--fg) 10%, transparent);
  --hero-bg: var(--near-black);
  --hero-fg: var(--fg);
  --hero-bee: var(--yellow);
  --hero-btn-bg: var(--yellow);
  --hero-btn-fg: var(--ink);
  --lockup: var(--yellow);
  --focus-ring: var(--fg);
  --btn-outline: color-mix(in srgb, var(--fg) 45%, transparent);
  --card-accent: var(--yellow);
  color-scheme: dark;
}

/* ----- Reset & base ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; overflow-x: clip; }
body {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--fg);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.18em; }
button { font: inherit; color: inherit; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }
:target { scroll-margin-top: 6rem; }
::selection { background: var(--yellow); color: var(--ink); }

/* Fluid type */
h1, h2, h3 { text-wrap: balance; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.6rem, 1.4rem + 5.2vw, 4.9rem); font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.85rem, 1.3rem + 2.4vw, 2.9rem); }
h3 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
p { text-wrap: pretty; }

/* ----- Layout helpers -------------------------------------------------- */
.wrap { width: 100%; max-width: var(--content); margin-inline: auto; padding-inline: var(--gutter); }

/* Inline SVG symbol sprite. Hidden via class because CSP style-src 'self'
   forbids inline style= attributes. */
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
  position: absolute; left: var(--s-2); top: -120%; z-index: 100;
  background: var(--ink); color: var(--yellow);
  padding: var(--s-1) var(--s-2); border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--s-2); }

/* ----- Focus (visible in both themes) ---------------------------------- */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ----- Buttons & links ------------------------------------------------- */
.btn {
  --btn-fg: var(--ink);
  --btn-bg: transparent;
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 0.7rem 1.25rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-weight: 600; font-size: 1rem; line-height: 1;
  text-decoration: none; white-space: nowrap;
  background: var(--btn-bg); color: var(--btn-fg);
  min-height: 44px;
}
.btn-primary { --btn-fg: var(--ink); --btn-bg: var(--yellow); position: relative; isolation: isolate; border: 0; background: var(--btn-bg); color: var(--btn-fg); box-shadow: none; transition: transform 0.18s var(--ease); }
.btn-primary::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--btn-outline); border-radius: inherit; transform: translate(2px, 2px); pointer-events: none; z-index: 1; }
.btn-primary:hover { transform: scale(1.04); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn-lg { padding: 0.95rem 1.6rem; font-size: 1.15rem; }
/* Header CTA shows a short label on compact/mobile layouts. */
.btn-primary .w-short { display: none; }

/* Hero CTA must stay solid + high-contrast on the yellow (light) / near-black (dark) field. */
.hero .btn-primary { --btn-bg: var(--hero-btn-bg); --btn-fg: var(--hero-btn-fg); }

.link-arrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 600; text-decoration: none;
  border-bottom: 2px solid currentColor;
  padding-bottom: 2px;
}
.link-arrow span { transition: transform var(--dur-fast) var(--ease); display: inline-block; }
.link-arrow:hover span { transform: translateX(0.2em); }

.eyebrow {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-muted);
}

/* ----- Header ---------------------------------------------------------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--bg-elev); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: var(--s-3); min-height: 72px; }
.brand { display: inline-flex; color: var(--lockup); text-decoration: none; }
.brand-lockup { height: clamp(30px, 1.8rem + 1.4vw, 44px); width: auto; }
.site-nav { display: flex; gap: var(--s-3); margin-inline-start: var(--s-2); }
.site-nav a { position: relative; font-weight: 500; font-size: 0.97rem; color: var(--fg-muted); text-decoration: none; padding: var(--s-1) 0; transition: color 0.2s; }
.site-nav a:hover { color: var(--fg); }
.site-nav a::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--fg); transform: scaleX(0); transform-origin: left; transition: transform 0.28s var(--ease); }
.site-nav a:hover::after { transform: scaleX(1); }
[data-theme="dark"] .site-nav a::after { background: var(--yellow); }
.header-actions { display: flex; align-items: center; gap: var(--s-2); margin-inline-start: auto; }

.theme-toggle {
  display: none; place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--btn-outline); border-radius: 999px;
  background: var(--bg-elev); color: var(--fg);
  transition: transform var(--dur-fast) var(--ease);
}
/* Theme toggle is JS-driven: hidden until theme.js opts in via html.js. */
html.js .theme-toggle { display: inline-grid; }
.theme-toggle:hover { transform: scale(1.04); }
.theme-toggle svg { width: 20px; height: 20px; grid-area: 1 / 1; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ----- Hero ------------------------------------------------------------ */
.hero {
  position: relative; isolation: isolate;
  background: var(--hero-bg);
  color: var(--hero-fg);
  border-bottom: 1px solid var(--border);
}
/* Hero honeycomb texture. ONE svg supplies the comb shape as an alpha mask; the
   visible color is the --comb variable, so a single asset recolors per theme —
   faint ink lines on the yellow field, faint white lines on black. */
[data-theme="light"] { --comb: color-mix(in srgb, var(--ink) 6%, transparent); }
[data-theme="dark"] { --comb: color-mix(in srgb, var(--white) 4%, transparent); }
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background-color: var(--comb);
  -webkit-mask-image: url("/honeycomb.svg");
  -webkit-mask-size: 56px;
  -webkit-mask-repeat: repeat;
  mask-image: url("/honeycomb.svg");
  mask-size: 56px;
  mask-repeat: repeat;
  mask-mode: alpha;
  pointer-events: none;
  z-index: -1;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: center;
  gap: clamp(2rem, 1rem + 4vw, 4rem);
  padding-block: clamp(1.5rem, 1rem + 1.5vw, 2.25rem);
}
.hero-content .eyebrow { color: color-mix(in srgb, var(--hero-fg) 78%, transparent); }
.hero h1 { margin-block: var(--s-2) var(--s-3); }
/* Dark hero: accent the brand word so the headline keeps color variation. */
[data-theme="dark"] .hero .hl { color: var(--yellow); }
[data-theme="light"] .hero .hl { text-decoration: underline; text-decoration-thickness: 0.05em; text-underline-offset: 0.16em; text-decoration-color: color-mix(in srgb, currentColor 55%, transparent); }
.lede { font-size: clamp(1.1rem, 1rem + 0.55vw, 1.4rem); font-weight: 400; line-height: 1.5; max-width: 33rem; color: color-mix(in srgb, var(--hero-fg) 88%, transparent); }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-5); }
.hero-cta .link-arrow { color: var(--hero-fg); }

/* Bee: a deliberate, full-ink mascot in its own column — never behind text. */
.hero-bee { display: grid; place-items: center; }
.hero-bee .bee {
  width: min(100%, 36rem);
  height: auto;
  color: var(--hero-bee);
}

@media (max-width: 44rem) {
  .hero-grid { grid-template-columns: 1fr; gap: var(--s-3); padding-block: clamp(1.25rem, 1rem + 1vw, 1.75rem); }
  .hero-bee { order: -1; }
  .hero-bee .bee { width: min(46vw, 15rem); }
}
/* Tablet (44–64rem): cap the bee so the two-column hero never crowds the copy. */
@media (min-width: 44rem) and (max-width: 64rem) {
  .hero-bee .bee { width: min(100%, 26rem); }
}

/* ----- Sections -------------------------------------------------------- */
.section { padding-block: clamp(3rem, 2.25rem + 4vw, 5.5rem); }
.section-head { margin-bottom: var(--s-4); }
.section-head .eyebrow { display: block; margin-bottom: var(--s-1); }
.how { padding-block-start: 0; }
.explainer { background: var(--bg-elev); border-block: 1px solid var(--border); padding-block: clamp(4rem, 3rem + 4vw, 6.5rem); }
.explainer .big { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.6rem); line-height: 1.45; font-weight: 500; margin-block: var(--s-2) var(--s-3); }
.explainer h2 { margin-bottom: var(--s-1); }

/* Community rules */
.rules-page { padding-block-start: clamp(3.5rem, 2.5rem + 4vw, 6rem); }
.rules-page .section-head { max-width: none; }
.rules-page h1 { margin-bottom: var(--s-2); }
.rules-intro { max-width: none; font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.6rem); line-height: 1.45; color: var(--fg-muted); }
.rules-context { max-width: none; margin-block: var(--s-3) var(--s-5); }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.rules-group { padding: var(--s-3); }
.rules-group h2 { margin-bottom: var(--s-2); font-size: clamp(1.5rem, 1.25rem + 1vw, 2.2rem); }
.rules-lead { margin-block: calc(var(--s-1) * -1) var(--s-2); color: var(--fg-muted); }
.rules-list { list-style: disc; padding-inline-start: 1.35rem; }
.rules-list li { padding-inline-start: 0.25rem; }
.rules-list li + li { margin-top: var(--s-1); }
.rules-list li::marker { color: var(--card-accent); }
.rules-note { margin-top: var(--s-5); padding-top: var(--s-3); border-top: 1px solid var(--border); color: var(--fg-muted); }
.rules-note p { max-width: none; }
@media (max-width: 44rem) {
  .rules-grid { grid-template-columns: 1fr; }
}


/* Cards */
.card-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); counter-reset: card; }
/* Balanced 2-column band so the four cards never orphan into 3+1 at mid widths;
   below 44rem they stack, above 74rem all four fit on one row. */
@media (min-width: 44rem) and (max-width: 74rem) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s-3); counter-increment: card;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--fg-muted); }
.card h3 { margin-bottom: var(--s-1); }
.card h3::before { content: counter(card, decimal-leading-zero); display: block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; color: var(--card-accent); margin-bottom: var(--s-2); }

/* Steps */
.steps { display: grid; gap: var(--s-3); margin-block: var(--s-4); counter-reset: step; }
.steps li { display: grid; grid-template-columns: auto 1fr; gap: var(--s-4); align-items: center; padding: var(--s-3) var(--s-4); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); }
.step-num { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 1px solid var(--btn-outline); border-radius: 999px; background: var(--yellow); color: var(--ink); font-weight: 700; font-size: 1rem; }
.steps em { font-style: normal; font-weight: 600; color: var(--ink); background: var(--yellow); padding: 0 0.3em; border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.step-body { display: grid; grid-template-columns: minmax(0, 26rem) 1fr; gap: var(--s-4); align-items: center; }
.step-body h3 { margin-bottom: 0; }
/* Step-1 highlight doubles as the invite link. */
.step-link { text-decoration: none; border-radius: 4px; }
.step-link:hover em { background: color-mix(in srgb, var(--yellow) 88%, var(--ink)); }
@media (max-width: 56rem) {
  .step-body { grid-template-columns: 1fr; gap: var(--s-1); align-items: start; }
}
.step-link:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* ----- Footer ---------------------------------------------------------- */
.site-footer { background: var(--bg-elev); border-top: 1px solid var(--border); padding-block: var(--s-5); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); }
.footer-brand { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-1); color: var(--lockup); }
.brand-lockup.sm { height: 38px; }
.tagline { color: var(--fg-muted); font-weight: 500; }
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-inline-start: auto; }
.footer-nav a { font-weight: 500; text-decoration: none; color: var(--fg-muted); transition: color var(--dur-fast) var(--ease); }
.footer-nav a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 0.18em; }
.fineprint { width: 100%; color: var(--fg-muted); font-size: 0.85rem; border-top: 1px solid var(--border); padding-top: var(--s-3); margin-top: var(--s-1); }

/* ----- Status pages (404 / 503) ---------------------------------------- */
.page-status main { min-height: 100svh; display: grid; place-items: center; padding: var(--gutter); text-align: center; }
.page-status main > div { max-width: 34rem; }
.page-status .bee { height: clamp(80px, 8vw, 140px); width: auto; margin-inline: auto; color: var(--ink); }
[data-theme="dark"] .page-status .bee { color: var(--yellow); }
.page-status h1 { margin-top: var(--s-3); }
.page-status .lede { color: var(--fg-muted); margin-block: var(--s-2) var(--s-4); }
.page-status .actions { display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; }

/* ----- Reveal animations (progressive; disabled under reduced motion) -- */
[data-reveal] { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
/* Only hide-then-reveal when JS has opted in via html.reveal — no-JS keeps content visible. */
@media screen { html.reveal [data-reveal]:not(.is-visible) { opacity: 0; transform: translateY(16px); } }

@keyframes hero-rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
.hero-content > * { animation: hero-rise var(--dur) var(--ease) both; }
.hero-content > *:nth-child(1) { animation-delay: 0.05s; }
.hero-content > *:nth-child(2) { animation-delay: 0.12s; }
.hero-content > *:nth-child(3) { animation-delay: 0.19s; }
.hero-content > *:nth-child(4) { animation-delay: 0.26s; }
.hero-bee { animation: hero-rise var(--dur) var(--ease) both; animation-delay: 0.18s; }

/* ----- Responsive ------------------------------------------------------ */
@media (max-width: 760px) {
  .site-nav { display: none; }
  /* Keep the primary CTA prominent on mobile — compact pill, short label. */
  .header-actions .btn-primary { padding: 0.55rem 0.95rem; font-size: 0.92rem; }
  .header-actions .btn-primary .w-full { display: none; }
  .header-actions .btn-primary .w-short { display: inline; }
}

/* Touch layouts: enlarge inline link targets to the 44px minimum (SPEC §8). */
@media (pointer: coarse) {
  .site-nav a,
  .footer-nav a,
  .link-arrow,
  .step-link,
  .brand,
  .fineprint a { min-height: 44px; display: inline-flex; align-items: center; }
  .footer-nav a { padding-inline: 0.25rem; }
  .link-arrow { padding-block: 0.4rem; }
}

/* ----- Reduced motion / forced colors / increased contrast ------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
  .hero-content > *, .hero-bee { animation: none; }
}
@media (prefers-contrast: more) {
  :root { --border: currentColor; --fg-muted: var(--fg); }
  .card, .steps li { border-width: 2px; }
}
@media (forced-colors: active) {
  /* Canvas/CanvasText take over (SPEC §4.3): remap tokens so no author-color
     surface can trap system text at 1:1. Brand marks stay legible as LinkText. */
  :root {
    --bg: Canvas; --bg-elev: Canvas; --hero-bg: Canvas;
    --fg: CanvasText; --fg-muted: CanvasText; --hero-fg: CanvasText;
    --border: CanvasText; --card-accent: CanvasText;
    --yellow: CanvasText; --ink: CanvasText; --lockup: LinkText;
    --hero-btn-bg: ButtonFace; --hero-btn-fg: ButtonText;
    --btn-outline: ButtonText; --comb: transparent;
  }
  .btn-primary { --btn-bg: ButtonFace; --btn-fg: ButtonText; }
  .brand-lockup, .hero-bee .bee, .footer-brand { color: LinkText; }
  .step-num { background: Canvas; color: CanvasText; border-color: CanvasText; }
  .step-link em { background: Canvas; color: LinkText; text-decoration: underline; }
  .skip-link { background: ButtonFace; color: ButtonText; }
  ::selection { background: Highlight; color: HighlightText; }
}

/* ----- View Transitions (theme switch, reduced-motion guarded in JS) --- */
@supports (view-transition-name: root) {
  ::view-transition-old(root), ::view-transition-new(root) {
    animation-duration: 0.5s; animation-timing-function: var(--ease);
    mix-blend-mode: normal;
  }
}
