/*
 * components.css — shared component design-system layer
 * (brief §17.4 Layout, §17.5 Cards, §17.6 Buttons, §19 Motion, §25.3 CSS rules)
 *
 * Loaded after tokens.css + base.css (see 01-head.html link order). Consumes
 * tokens only — no raw hex values duplicated here (brief §25.3).
 *
 * CROSS-AGENT CONTRACT: the class names below (.container, .section,
 * .section--dark/--light, .eyebrow, .section-title, .btn/.btn--primary/
 * .btn--secondary, .card, .card--principle, .card--venture-track, .badge,
 * .badge--track, .badge--experiment, .reveal) are consumed verbatim by other
 * partial-authoring agents. Do not rename without updating every consumer.
 */

/* ---------------------------------------------------------------------- */
/* .container / .eyebrow — already implemented in base.css                */
/* ---------------------------------------------------------------------- */
/* base.css already ships a `.container` (max-width var(--content-max-width)
   + responsive padding-inline at 768/1024) and a `.eyebrow` (Geist Mono,
   uppercase, letter-spacing per §17.3) that fully satisfy this contract.
   Redefining them here would just duplicate base.css and risks drifting out
   of sync — so this file intentionally does not redeclare them. Consumers:
   use `.container` / `.eyebrow` exactly as shipped by base.css. */

/* ---------------------------------------------------------------------- */
/* .section — class-based full-bleed section rhythm + surface modifiers    */
/* (brief §17.2: hero + footer dark, all other sections light)             */
/* ---------------------------------------------------------------------- */

.section {
  padding-block: var(--section-spacing-mobile);
}

@media (min-width: 1024px) {
  .section {
    padding-block: var(--section-spacing-desktop);
  }
}

/* NOTE: base.css already applies the same padding-block to the bare
   `<section>` element selector. This class exists so the same rhythm can be
   applied to a non-`<section>` wrapper, or so `--dark`/`--light` can be
   requested by class name (mirrors base.css's `.surface-dark`/`.surface-light`,
   which remain valid and are not replaced). */

.section--dark {
  background: var(--bg-dark);
  color: var(--text-on-dark);
}

.section--dark .text-muted {
  color: var(--text-on-dark-muted);
}

.section--light {
  background: var(--bg-light);
  color: var(--text-on-light);
}

.section--light .text-muted {
  color: var(--text-on-light-muted);
}

/* ---------------------------------------------------------------------- */
/* .section-title — H2 style for section headings                         */
/* ---------------------------------------------------------------------- */

.section-title {
  font-family: var(--font-display);
  font-weight: var(--fw-h2);
  font-size: var(--fs-h2-mobile);
  line-height: 1.14;
  max-width: 720px; /* brief §17.3: long lines capped at 720px */
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .section-title {
    font-size: var(--fs-h2-desktop);
    line-height: var(--lh-h2-desktop);
    margin-bottom: 24px;
  }
}

/* ---------------------------------------------------------------------- */
/* Buttons — brief §17.6                                                  */
/* Forbidden CTA copy ("Book a demo" / "Get started free" / "Start        */
/* building") is a content concern enforced by tools/banned-phrases.txt   */
/* (EVI-9 build gate), not something CSS can prevent.                     */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--button-height);
  padding-inline: 28px;
  border-radius: var(--radius-button);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-body-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-align: center;
  transition:
    background-color var(--transition-duration) var(--transition-easing),
    border-color var(--transition-duration) var(--transition-easing),
    color var(--transition-duration) var(--transition-easing);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface-white);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--secondary {
  background: transparent;
  border-color: currentColor;
  color: inherit;
}

.btn--secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Compact variant — same button, smaller footprint (e.g. the persistent
   mobile header CTA in 02-header.html, brief §6.1 "компактная кнопка").
   Still clears the 44px minimum tap target (brief §20). */
.btn--compact {
  height: 44px;
  padding-inline: 16px;
  font-size: var(--fs-small);
}

/* ---------------------------------------------------------------------- */
/* Cards — brief §17.5                                                    */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--card-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  padding: 28px;
  transition: border-color var(--transition-duration) var(--transition-easing);
}

.card:hover {
  border-color: var(--accent);
}

/* Cards only ever appear on light sections in the current content model
   (Thesis / Venture Tracks) — no dark-surface card variant exists yet. If a
   card ever lands inside .section--dark / .surface-dark, add a variant
   token-driven surface at that point rather than guessing one now. */

.card--principle {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Equal card height on desktop (brief §9.5) comes for free from CSS
     Grid's default `align-items: stretch` on the parent grid
     (`.thesis__principles`, src/styles/sections.css) — no extra height
     rule needed here. */
}

.card--venture-track {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------------------------------------------------------------------- */
/* Badges — status pills, mono uppercase (brief §17.5)                    */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-button);
  border: 1px solid var(--border-light);
  background: var(--card-surface);
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  font-weight: var(--fw-body-medium);
  line-height: 1;
  white-space: nowrap;
}

/* Generic venture-track status pill (brief §12.5: "статусы должны
   отображаться заметно"). Styles the pill only — text content ("ACTIVE
   VALIDATION" / "LIVE VALIDATION" / "IN DEVELOPMENT" / "RESEARCH TRACK")
   comes from content.json ventureTracks[].status and is not hardcoded here. */
.badge--track {
  border-color: var(--text-on-light);
  color: var(--text-on-light);
}

/* CommonTime "PUBLIC EXPERIMENT" eyebrow-as-badge (brief §13.1). Soft-accent
   treatment using the token already reserved for this purpose. */
.badge--experiment {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------------------------------------------------------------------- */
/* .reveal — fade/translate entrance animation (brief §19)                 */
/* Toggled by an IntersectionObserver in main.js adding .is-visible.       */
/*                                                                         */
/* The opacity:0 starting state is scoped to html.js-reveal (added by     */
/* main.js at the very start of its execution — same pattern as           */
/* evidence-flow.css's html.js-ef) so content is visible by DEFAULT and   */
/* only ever hidden once JS has actually confirmed it can run the reveal  */
/* sequence. Without this scope, .reveal was unconditionally opacity:0,   */
/* so any visitor without JS (blocked/disabled/failed to load) saw the    */
/* entire page below the hero permanently blank — a Critical bug found   */
/* by the Stage-5 verify oracle, and a direct violation of brief §19      */
/* "Не скрывать контент до загрузки JavaScript" / EVI-4 zero-JS-first.    */
/*                                                                         */
/* SECOND bug (found live in production, post-deploy, by real-browser     */
/* CDP inspection — none of the 5 verify-oracle text-only review rounds   */
/* caught it because nothing ever rendered the cascade): the show-state   */
/* rule below MUST prefix with the same `html.js-reveal` selector as the  */
/* hide-state rule, or its specificity (0,2,0) loses to the hide rule's   */
/* (0,2,1) — `.is-visible` was being added to the element correctly by    */
/* main.js, but the element stayed at computed opacity:0 regardless,      */
/* because the higher-specificity hide rule still won the cascade. This   */
/* is exactly the pattern evidence-flow.css already got right             */
/* (`html.js-ef .evidence-flow.is-visible .ef-node`, same prefix on both  */
/* rules) — .reveal just wasn't written to match it. Confirmed fixed via  */
/* getComputedStyle(...).opacity after adding .is-visible, not just by    */
/* checking the class list or reading the CSS text.                      */
/* ---------------------------------------------------------------------- */

html.js-reveal .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity var(--transition-duration) var(--transition-easing),
    transform var(--transition-duration) var(--transition-easing);
}

html.js-reveal .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  html.js-reveal .reveal {
    transform: none;
    transition: opacity var(--transition-duration) var(--transition-easing);
  }
}

/* ---------------------------------------------------------------------- */
/* Site header (component #1 of §25.2's 15-component list) — brief §6      */
/* ---------------------------------------------------------------------- */

:root {
  --header-height-mobile: 64px;   /* brief §6.3, exact value */
  --header-height-desktop: 76px;  /* brief §6.3 range 72–80px, midpoint */
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height-mobile);
  background: var(--bg-dark);
  color: var(--text-on-dark);
  border-bottom: 1px solid transparent;
  transition:
    background-color var(--transition-duration) var(--transition-easing),
    border-color var(--transition-duration) var(--transition-easing),
    color var(--transition-duration) var(--transition-easing);
}

@media (min-width: 1024px) {
  .site-header {
    height: var(--header-height-desktop);
  }
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-header__logo {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-weight: var(--fw-h3);
  font-size: 19px;
  letter-spacing: -0.01em;
  color: inherit;
}

/* Desktop inline nav (brief §6.1). Hidden below 1024px — the same links
   live in .site-header__drawer for mobile (see responsive.css). */
.site-header__nav {
  display: none;
}

@media (min-width: 1024px) {
  .site-header__nav {
    display: block;
  }
}

.site-header__nav-list {
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-header__nav-link {
  font-size: var(--fs-small);
  font-weight: var(--fw-body-medium);
  color: inherit;
  opacity: 0.85;
  transition: opacity var(--transition-duration) var(--transition-easing);
}

.site-header__nav-link:hover {
  opacity: 1;
}

.site-header__nav-link.is-active {
  opacity: 1;
}

/* Last nav item is "Bring us a hard problem" (content.json nav[5]) — brief
   §6.1 asks for it to render as a button, not a plain link. The template
   loop has no per-item "is this a CTA" flag (and content.json's schema is
   not owned by this file), so the button treatment is applied structurally
   to the last list item instead of via an extra class. */
.site-header__nav-list li:last-child .site-header__nav-link {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding-inline: 20px;
  border-radius: var(--radius-button);
  background: var(--accent);
  color: var(--surface-white);
  opacity: 1;
}

.site-header__nav-list li:last-child .site-header__nav-link:hover {
  background: var(--accent-hover);
}

/* Persistent compact mobile CTA + hamburger (brief §6.1). Hidden at desktop
   width once the inline nav takes over. */
.site-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (min-width: 1024px) {
  .site-header__mobile-cta,
  .site-header__hamburger {
    display: none;
  }
}

.site-header__hamburger {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--text-on-dark-muted);
  border-radius: var(--radius-button);
}

.site-header__hamburger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
}

/* Mobile drawer (brief §6.1/§6.3, §25.4 mobile nav via JS) */
.site-header__drawer {
  position: fixed;
  inset: var(--header-height-mobile) 0 0 0;
  z-index: 49;
  background: var(--bg-dark);
  color: var(--text-on-dark);
  overflow-y: auto;
  padding: 24px var(--side-padding-mobile) 40px;
}

.site-header__drawer[hidden] {
  display: none;
}

@media (min-width: 1024px) {
  .site-header__drawer {
    display: none !important; /* browser-specific override guard: prevents
      the drawer from ever being shown once JS removes [hidden] on a window
      that is later resized past desktop width (brief §25.3 !important
      exception: justified browser/viewport-state edge case) */
  }
}

.site-header__drawer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-header__drawer-link {
  display: block;
  padding: 14px 4px;
  font-size: var(--fs-body-large);
  border-bottom: 1px solid rgba(247, 248, 252, 0.12);
}

/* Scrolled state (brief §6.3): opaque, bordered, blurred. Toggled by
   main.js watching scroll position (see scripts/main.js). */
.site-header.is-scrolled {
  background: var(--card-surface);
  color: var(--text-on-light);
  border-bottom-color: var(--border-light);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .site-header.is-scrolled {
    background: color-mix(in srgb, var(--card-surface) 90%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

.site-header.is-scrolled .site-header__nav-link:not(:last-child) {
  color: var(--text-on-light);
}

.site-header.is-scrolled .site-header__hamburger {
  border-color: var(--border-light);
  color: var(--text-on-light);
}
