/* ============================================================
   NW Agentic — Base Styles
   nwagentic.ai
   ============================================================
   Reset + base typography + container + button + card + pill
   primitives. Wrapped in @layer base so page-specific styles
   in higher layers always win.

   Phase 2 pages opt in by loading tokens.css + base.css INSTEAD
   of the legacy styles.css. Existing pages remain on styles.css
   until their phase rebuilds them.

   Depends on: tokens.css (variables only).
   See DESIGN.md §4.6 for component primitives.
   ============================================================ */

@layer reset, base, components, utilities;

/* ─────────────────────────────────────────────────────────
   RESET (modern, minimal)
   ───────────────────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; padding: 0; }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }

  body {
    min-height: 100svh;
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  img, svg, video, canvas, picture {
    display: block;
    max-width: 100%;
    height: auto;
  }

  input, button, textarea, select {
    font: inherit;
    color: inherit;
  }

  button { background: none; border: none; cursor: pointer; }

  ul, ol { list-style: none; }

  a { color: inherit; text-decoration: none; }

  table { border-collapse: collapse; border-spacing: 0; }

  /* Always-visible focus for keyboard users; mouse :focus-visible hidden */
  :focus-visible {
    outline: 2px solid var(--blue-bright);
    outline-offset: 2px;
    border-radius: 2px;
  }

  /* Skip link */
  .skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: var(--z-toast);
    padding: 0.5rem 1rem;
    background: var(--navy);
    color: var(--text-on-dark);
    border-radius: var(--radius);
    transition: top 0.2s ease;
  }
  .skip-link:focus { top: 8px; }
}

/* ─────────────────────────────────────────────────────────
   BASE — typography, body, surfaces
   ───────────────────────────────────────────────────────── */
@layer base {
  body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    color: var(--text-primary);
    background: var(--bg);
  }

  /* Headings — base sizes; pages may override per section */
  h1, .h1 {
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    line-height: var(--lh-heading);
    letter-spacing: var(--tr-heading);
    color: var(--text-primary);
  }
  h2, .h2 {
    font-size: var(--fs-h2);
    font-weight: var(--fw-bold);
    line-height: var(--lh-heading);
    letter-spacing: var(--tr-heading);
    color: var(--text-primary);
  }
  h3, .h3 {
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    letter-spacing: var(--tr-tight);
    color: var(--text-primary);
  }
  h4, .h4 {
    font-size: var(--fs-h4);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    color: var(--text-primary);
  }

  /* Display — used for hero headlines */
  .display {
    font-size: var(--fs-display);
    font-weight: var(--fw-extrabold);
    line-height: var(--lh-display);
    letter-spacing: var(--tr-display);
    color: var(--text-primary);
  }
  .display em,
  .display .accent {
    color: var(--blue);
    font-style: normal;
  }

  p {
    color: var(--text-secondary);
    line-height: var(--lh-body);
  }

  .lead {
    font-size: var(--fs-body-lg);
    line-height: var(--lh-body);
    color: var(--text-secondary);
  }

  small { font-size: var(--fs-body-sm); }

  code, pre, kbd, samp {
    font-family: var(--font-mono);
    font-size: var(--fs-code);
  }

  /* On-dark wrapper — flips text colors for hero, dark CTA bands, etc.
     Apply to the section element, not body. */
  .on-dark {
    background: var(--navy);
    color: var(--text-on-dark);
  }
  .on-dark h1, .on-dark .h1,
  .on-dark h2, .on-dark .h2,
  .on-dark h3, .on-dark .h3,
  .on-dark h4, .on-dark .h4,
  .on-dark .display { color: var(--text-on-dark); }
  .on-dark p,
  .on-dark .lead { color: var(--text-on-dark-soft); }
  .on-dark .display em,
  .on-dark .display .accent { color: var(--blue-bright); }
}

/* ─────────────────────────────────────────────────────────
   COMPONENTS — primitives shared across all pages
   ───────────────────────────────────────────────────────── */
@layer components {
  /* Container */
  .container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-pad-x);
  }

  /* Section vertical rhythm */
  .section {
    padding-block: var(--section-y-mobile);
  }
  @media (min-width: 768px) {
    .section { padding-block: var(--section-y-desktop); }
  }

  /* Eyebrow — small uppercase label above section titles */
  .eyebrow {
    display: inline-block;
    font-size: var(--fs-eyebrow);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tr-eyebrow);
    text-transform: uppercase;
    color: var(--blue);
    position: relative;
    padding-block-end: var(--space-2);
    margin-block-end: var(--space-4);
  }
  .eyebrow::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 32px;
    height: 2px;
    background: var(--brand-gradient);
    border-radius: 2px;
  }
  .on-dark .eyebrow { color: var(--blue-bright); }

  /* ── Buttons ─────────────────────────────────────────── */
  .btn {
    --btn-bg: var(--blue);
    --btn-color: var(--text-on-dark);
    --btn-border: transparent;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-color);
    font-family: var(--font-sans);
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-semibold);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition:
      background var(--t),
      border-color var(--t),
      box-shadow var(--t),
      transform var(--t-fast),
      color var(--t);
  }
  .btn:hover { transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .btn:focus-visible {
    outline: 2px solid var(--blue-bright);
    outline-offset: 3px;
  }

  .btn--lg {
    min-height: 52px;
    padding: 0.875rem 1.75rem;
    font-size: var(--fs-body);
    border-radius: var(--radius);
  }

  /* Primary — gradient action; the hero CTA */
  .btn--primary {
    background: var(--blue);
    color: var(--text-on-dark);
    border-color: var(--blue);
    box-shadow: var(--shadow-glow-blue);
  }
  .btn--primary:hover {
    background: var(--blue-hover);
    border-color: var(--blue-hover);
  }

  /* Secondary — bordered, neutral */
  .btn--secondary {
    background: var(--bg);
    color: var(--text-primary);
    border-color: var(--border-strong);
  }
  .btn--secondary:hover {
    border-color: var(--text-primary);
    background: var(--bg-subtle);
  }
  .on-dark .btn--secondary {
    background: transparent;
    color: var(--text-on-dark);
    border-color: var(--border-on-dark);
  }
  .on-dark .btn--secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.45);
  }

  /* Ghost — text + arrow, subtle */
  .btn--ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
    padding-inline: 0.5rem;
  }
  .btn--ghost:hover {
    color: var(--blue);
    transform: translateX(2px);
  }
  .on-dark .btn--ghost { color: var(--text-on-dark); }
  .on-dark .btn--ghost:hover { color: var(--blue-bright); }

  /* Talk-with-us — used for Forge and Private Edge CTAs.
     Looks like a link with an arrow; communicates "this is
     a conversation, not a self-serve checkout." */
  .btn--talk {
    background: transparent;
    color: var(--blue);
    border-color: transparent;
    padding-inline: 0;
    min-height: auto;
    font-weight: var(--fw-semibold);
  }
  .btn--talk::after {
    content: '\2192';                 /* → */
    transition: transform var(--t);
  }
  .btn--talk:hover { transform: none; }
  .btn--talk:hover::after { transform: translateX(4px); }

  .btn--full { width: 100%; }

  /* ── Cards ───────────────────────────────────────────── */
  .card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    transition: box-shadow var(--t-slow), transform var(--t-slow), border-color var(--t);
  }
  @media (max-width: 767px) {
    .card { padding: var(--space-6); }
  }
  .card--hover:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--border-strong);
  }
  .card--dark {
    background: var(--navy-mid);
    border-color: var(--border-on-dark);
    color: var(--text-on-dark);
  }

  /* Tier card — adds the colored chip from the logo */
  .card--tier {
    position: relative;
    padding-top: calc(var(--space-8) + 12px);
  }
  .card--tier::before {
    content: '';
    position: absolute;
    top: var(--space-8);
    left: var(--space-8);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
  }
  .card--tier-core::before {
    background: var(--tier-core);
    border: 1px solid var(--border-strong);
  }
  .card--tier-forge::before { background: var(--tier-forge); }
  .card--tier-edge::before  { background: var(--tier-edge);  }
  .card--tier .card__title { margin-top: var(--space-12); }

  /* ── Pills / Badges ──────────────────────────────────── */
  .pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-medium);
    line-height: 1.2;
    background: var(--blue-pale);
    color: var(--blue-hover);
  }
  .pill--live {
    background: rgba(245, 158, 11, 0.12);
    color: var(--amber);
  }
  .pill--live::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--amber-light);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
    animation: nwa-pulse 2s ease-in-out infinite;
  }
  @media (prefers-reduced-motion: reduce) {
    .pill--live::before { animation: none; }
  }
  @keyframes nwa-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  }

  /* Tier-identity chip — the three squares from the logo */
  .tier-chip {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 0.5rem;
  }
  .tier-chip--core  { background: var(--tier-core); border: 1px solid var(--border-strong); }
  .tier-chip--forge { background: var(--tier-forge); }
  .tier-chip--edge  { background: var(--tier-edge);  }

  /* ── Code block ──────────────────────────────────────── */
  .code-block {
    background: var(--navy-deep);
    color: var(--text-on-dark);
    border-radius: var(--radius);
    padding: var(--space-6);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: var(--fs-code);
    line-height: var(--lh-body);
  }

  /* ── Stat tile ───────────────────────────────────────── */
  .stat__value {
    font-size: var(--fs-h1);
    font-weight: var(--fw-extrabold);
    line-height: 1;
    letter-spacing: var(--tr-display);
    color: var(--text-primary);
  }
  .on-dark .stat__value { color: var(--text-on-dark); }
  .stat__label {
    font-size: var(--fs-body-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-2);
  }

  /* ── Scroll reveal ───────────────────────────────────── */
  .reveal {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--t-reveal), transform var(--t-reveal);
  }
  .reveal.visible {
    opacity: 1;
    transform: none;
  }
  @media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
  }
}

/* ─────────────────────────────────────────────────────────
   UTILITIES — small helpers
   ───────────────────────────────────────────────────────── */
@layer utilities {
  .text-center  { text-align: center; }
  .text-balance { text-wrap: balance; }
  .text-pretty  { text-wrap: pretty; }
  .accent       { color: var(--blue); }
  .on-dark .accent { color: var(--blue-bright); }
  .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .stack > * + * { margin-top: var(--stack-gap, var(--space-4)); }
  .grid {
    display: grid;
    gap: var(--grid-gap, var(--space-6));
  }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
  @media (max-width: 767px) {
    .grid--3, .grid--4 { grid-template-columns: 1fr; }
  }
  @media (min-width: 768px) and (max-width: 1023px) {
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
  }
}
