/* ==========================================================================
   Base, layout and components. Requires tokens.css.
   ========================================================================== */

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: var(--color-primary); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--color-primary-hover); }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--turquoise-200); color: var(--teal-950); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-heading);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-4);
}
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--color-heading);
  line-height: var(--leading-snug);
  margin: 0 0 var(--space-3);
}
h4 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-4); }
.lead { font-size: var(--text-lg); color: var(--ink-700); max-width: 62ch; }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-sm); }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow); color: var(--teal-600);
  margin-bottom: var(--space-4);
}
.eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--brass-500); }

.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: 100;
  background: var(--teal-900); color: var(--white); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-4); color: var(--white); }
.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;
}

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: var(--container-narrow); }
.section { padding-block: var(--section-y); }
.section--alt { background: var(--color-surface-alt); }
.section--teal { background: var(--teal-900); color: var(--turquoise-100); }
.section--teal h2, .section--teal h3 { color: var(--white); }
.section-header { max-width: 680px; margin-bottom: var(--space-12); }
.section-header--center { margin-inline: auto; text-align: center; }
.section-header--center .eyebrow { justify-content: center; }
.grid { display: grid; gap: var(--space-6); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* ---------- Header & navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(252, 250, 246, 0.94);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.site-header .container { max-width: 1380px; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); min-height: 78px; }
.brand { display: flex; text-decoration: none; flex-shrink: 0; }

.nav { display: flex; align-items: center; gap: var(--space-4); }
.nav__list { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; }
.nav__item { position: relative; }
.nav__row { display: flex; align-items: center; }
.nav__link {
  display: block; padding: 0.5rem 0.55rem; white-space: nowrap;
  font-size: 0.875rem; font-weight: 500; color: var(--ink-700); text-decoration: none;
  transition: color var(--duration) var(--ease);
}
.nav__link:hover { color: var(--teal-700); }
.nav__link[aria-current="page"] { color: var(--teal-800); box-shadow: inset 0 -2px 0 var(--turquoise-400); }
.nav__item--has-sub .nav__link { padding-right: 0.15rem; }
.nav__sub-toggle {
  display: inline-grid; place-items: center; width: 22px; height: 30px; padding: 0; margin-right: 0.2rem;
  background: none; border: 0; border-radius: 4px; color: var(--ink-500); cursor: pointer;
}
.nav__sub-toggle svg { transition: transform var(--duration) var(--ease); }
.nav__sub-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.subnav {
  list-style: none; margin: 0; padding: var(--space-2); min-width: 240px;
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  background: var(--white); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease), visibility 0s linear var(--duration);
}
.subnav::before { content: ""; position: absolute; inset: -8px 0 auto 0; height: 8px; }
.nav__item--has-sub:hover > .subnav,
.nav__item--has-sub:focus-within > .subnav,
.nav__item--has-sub[data-open="true"] > .subnav { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.nav__item--has-sub[data-open="false"] > .subnav { opacity: 0; visibility: hidden; }
.subnav__link { display: block; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--ink-700); text-decoration: none; }
.subnav__link:hover { background: var(--turquoise-50); color: var(--teal-800); }
.subnav__link[aria-current="page"] { color: var(--teal-800); font-weight: 600; box-shadow: inset 3px 0 0 var(--turquoise-400); }
.nav__cta { margin-left: var(--space-2); }
.nav-toggle { display: none; }
.nav-toggle__close { display: none; }
.preview-bar { background: var(--warning-50); color: var(--warning-600); text-align: center; font-size: var(--text-xs); font-weight: 600; padding: 0.4rem var(--gutter); border-bottom: 1px solid #f1dcb4; }

@media (max-width: 1279px) {
  .nav-toggle {
    display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px;
    background: var(--white); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3); font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--teal-900); cursor: pointer;
  }
  .nav-toggle[aria-expanded="true"] .nav-toggle__open { display: none; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__close { display: block; }
  .nav {
    position: absolute; inset: 100% 0 auto 0; flex-direction: column; align-items: stretch; gap: var(--space-4);
    max-height: calc(100vh - 78px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--cream-50); border-bottom: 1px solid var(--color-border); padding: var(--space-3) var(--gutter) var(--space-6);
    box-shadow: var(--shadow-md); display: none;
  }
  .nav[data-open="true"] { display: flex; }
  .nav__list { flex-direction: column; align-items: stretch; }
  .nav__item { border-bottom: 1px solid var(--color-border); }
  .nav__row { justify-content: space-between; }
  .nav__link { padding: 0.85rem 0.25rem; font-size: var(--text-base); flex: 1; }
  .nav__link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--turquoise-400); padding-left: 0.75rem; }
  .nav__sub-toggle { width: 44px; height: 44px; margin: 0; border: 1px solid var(--color-border); background: var(--white); }
  .subnav { position: static; display: none; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; background: transparent; padding: 0 0 var(--space-3) var(--space-4); min-width: 0; }
  .nav__item--has-sub:hover > .subnav, .nav__item--has-sub:focus-within > .subnav { display: none; }
  .nav__item--has-sub[data-open="true"] > .subnav { display: block; }
  .subnav__link { padding: 0.65rem 0.5rem; font-size: var(--text-base); }
  .nav__cta { margin: 0; min-height: 48px; font-size: var(--text-base); }
  .nav__item--has-sub .nav__link { padding-right: 0.25rem; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0.7rem 1.35rem; border-radius: var(--radius-pill);
  border: 1px solid transparent; font: inherit; font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.01em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--color-primary); color: var(--white); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--color-primary-hover); color: var(--white); box-shadow: var(--shadow-md); }
.btn--secondary { background: var(--white); color: var(--teal-800); border-color: var(--color-border-strong); }
.btn--secondary:hover { border-color: var(--teal-600); color: var(--teal-900); }
.btn--ghost { background: transparent; color: var(--teal-700); padding-inline: var(--space-2); }
.btn--ghost:hover { color: var(--teal-900); text-decoration: underline; }
.btn--light { background: var(--white); color: var(--teal-900); }
.btn--light:hover { background: var(--turquoise-100); color: var(--teal-950); }
.btn--danger { background: var(--danger-600); color: var(--white); }
.btn--lg { min-height: 52px; padding: 0.85rem 1.6rem; font-size: 0.95rem; }
.btn--outline-light { background: transparent; color: var(--white); border-color: rgba(220, 243, 241, 0.45); }
.btn--outline-light:hover { border-color: var(--white); color: var(--white); background: rgba(255,255,255,0.06); }
.btn--sm { min-height: 36px; padding: 0.45rem 0.9rem; font-size: var(--text-xs); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: var(--space-8); box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--turquoise-200); }
.card__icon {
  width: 48px; height: 48px; border-radius: var(--radius-md); display: grid; place-items: center;
  background: var(--turquoise-50); color: var(--teal-700); margin-bottom: var(--space-5);
}
.card__title { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; color: var(--teal-950); margin-bottom: var(--space-2); line-height: 1.2; }
.card__meta { font-size: var(--text-sm); color: var(--color-text-muted); }

/* ---------- Placeholder (clearly marked missing content) ---------- */
.placeholder {
  border: 1.5px dashed var(--brass-500); background: var(--brass-100); color: #6b5232;
  border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); font-size: var(--text-sm);
}
.placeholder::before { content: "PLACEHOLDER · "; font-weight: 700; letter-spacing: 0.06em; }
.placeholder-media {
  display: grid; place-items: center; width: 100%; height: 100%; min-height: 220px; padding: var(--space-6);
  text-align: center; color: var(--turquoise-200); font-size: var(--text-sm); letter-spacing: 0.04em;
}

/* ---------- Badges & alerts ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35em; padding: 0.2rem 0.6rem; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600; background: var(--turquoise-50); color: var(--teal-700);
}
.badge--success { background: var(--success-50); color: var(--success-600); }
.badge--warning { background: var(--warning-50); color: var(--warning-600); }
.badge--danger { background: var(--danger-50); color: var(--danger-600); }
.badge--neutral { background: var(--cream-100); color: var(--ink-700); }

.alert { border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); font-size: var(--text-sm); border: 1px solid; margin-bottom: var(--space-6); }
.alert--success { background: var(--success-50); color: var(--success-600); border-color: #bfe3cf; }
.alert--error { background: var(--danger-50); color: var(--danger-600); border-color: #f5c2bd; }
.alert--warning { background: var(--warning-50); color: var(--warning-600); border-color: #f1dcb4; }
.alert--info { background: var(--info-50); color: var(--teal-800); border-color: var(--turquoise-200); }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--space-5); }
.label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--ink-700); margin-bottom: var(--space-2); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 0.7rem 0.9rem; font: inherit; font-size: var(--text-base); color: var(--color-text);
  background: var(--white); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.textarea { min-height: 140px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal-600); box-shadow: 0 0 0 4px rgba(38, 169, 166, 0.18); }
.input[aria-invalid="true"] { border-color: var(--danger-600); }
.help { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-2); }
.field-error { font-size: var(--text-xs); color: var(--danger-600); margin-top: var(--space-2); font-weight: 500; }

/* ---------- Footer ---------- */
.site-footer { background: var(--teal-950); color: rgba(220, 243, 241, 0.78); padding-top: var(--space-16); font-size: var(--text-sm); }
.site-footer a { color: var(--turquoise-100); text-decoration: none; }
.site-footer a:hover { color: var(--white); text-decoration: underline; }
.site-footer__grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.1fr; gap: var(--space-10); padding-bottom: var(--space-10); }
@media (max-width: 1000px) { .site-footer__grid { grid-template-columns: 1fr 1fr; } }
.site-footer__title { font-family: var(--font-sans); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); color: var(--turquoise-200); margin-bottom: var(--space-4); }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.site-footer__brand { font-family: var(--font-display); font-size: 1.8rem; color: var(--white); margin-bottom: var(--space-3); }
.site-footer__bottom { border-top: 1px solid rgba(169, 227, 223, 0.15); padding-block: var(--space-6); display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; }
.social-link { display: inline-flex; align-items: center; gap: var(--space-2); }
.social-link svg { width: 18px; height: 18px; }
@media (max-width: 640px) { .site-footer__grid { grid-template-columns: 1fr; } }

/* ---------- Page header (inner pages) ---------- */
.page-hero { padding-block: clamp(3rem, 2rem + 4vw, 5rem); background: linear-gradient(180deg, var(--cream-100), var(--cream-50)); border-bottom: 1px solid var(--color-border); }
.breadcrumbs { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-5); }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.breadcrumbs li + li::before { content: "/"; margin-right: 0.35rem; color: var(--stone-300); }
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs [aria-current] { color: var(--ink-700); }

/* ---------- Error pages ---------- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: var(--space-16) var(--gutter); }
.error-page__code { font-family: var(--font-display); font-size: clamp(4rem, 10vw, 7rem); color: var(--turquoise-400); line-height: 1; }

/* ---------- Style guide helpers ---------- */
.swatch { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--color-border); background: var(--white); font-size: var(--text-xs); }
.swatch__chip { height: 72px; }
.swatch__meta { padding: var(--space-2) var(--space-3); }

/* ---------- Utilities (inline styles are blocked by the CSP) ---------- */
.m-0 { margin: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mt-6 { margin-top: var(--space-6); }
.max-w-form { max-width: 520px; }
.cluster--between { justify-content: space-between; }
.error-page__title { font-size: 2.2rem; }
.error-page__detail { text-align: left; white-space: pre-wrap; font-size: 12px; max-width: 900px; overflow: auto; }
.swatch__chip-teal-950 { background: var(--teal-950); } .swatch__chip-teal-700 { background: var(--teal-700); }
.swatch__chip-teal-600 { background: var(--teal-600); } .swatch__chip-turquoise-400 { background: var(--turquoise-400); }
.swatch__chip-turquoise-100 { background: var(--turquoise-100); } .swatch__chip-cream-50 { background: var(--cream-50); }
.swatch__chip-cream-100 { background: var(--cream-100); } .swatch__chip-brass-500 { background: var(--brass-500); }
.swatch__chip-ink-900 { background: var(--ink-900); } .swatch__chip-ink-500 { background: var(--ink-500); }

/* ---------- Logo ---------- */
.brand__logo { height: 50px; width: auto; }
.site-footer__logo { height: 56px; width: auto; margin-bottom: var(--space-4); }
@media (max-width: 480px) { .brand__logo { height: 42px; } }
.hero__credentials { font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.04em; color: var(--teal-700); margin: calc(-1 * var(--space-2)) 0 var(--space-5); }
