/* ==========================================================================
   Base: reset, layout primitives, UI components, a11y
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  /* Theme swap is a cross-fade, not a hard cut */
  transition: background-color var(--dur-base) var(--ease-in-out),
    color var(--dur-base) var(--ease-in-out);
  overflow-x: hidden;
}

h1,
h2,
h3 {
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}
h1 {
  font-size: var(--fs-display);
  font-weight: 700;
}
h2 {
  font-size: var(--fs-h2);
  font-weight: 650;
}
h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
}
p {
  margin: 0;
  text-wrap: pretty;
}
img,
svg,
canvas {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 3px;
}

/* A component's own `display` beats the UA rule for [hidden], which silently
   leaves "hidden" elements on screen. Make the attribute authoritative. */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */

/* Focus ring: 3:1 against surfaces in every theme */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--accent-primary);
  color: var(--accent-on);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-out-expo);
}
.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Honeypot: hidden from humans AND from assistive tech, so a screen-reader
   user never fills it in and gets their message silently dropped. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-6);
}
@media (min-width: 768px) {
  .container {
    padding-inline: var(--space-8);
  }
}

.section {
  padding-block: var(--space-24);
  position: relative;
}
@media (min-width: 768px) {
  .section {
    padding-block: var(--space-32);
  }
}

.section__eyebrow {
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: var(--space-3);
}
.section__lead {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  max-width: 60ch;
  margin-top: var(--space-4);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-3) var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur-instant) var(--ease-out-expo),
    background-color var(--dur-instant) linear, opacity var(--dur-instant) linear;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  --btn-bg: var(--accent-primary);
  --btn-fg: var(--accent-on);
  box-shadow: var(--shadow-glow);
}
.btn--primary:hover {
  --btn-bg: color-mix(in srgb, var(--accent-primary) 88%, white);
}

.btn--ghost {
  --btn-fg: var(--text-primary);
  border-color: var(--border-subtle);
  background: var(--glass-bg);
}
.btn--ghost:hover {
  border-color: var(--accent-primary);
}

.btn--sm {
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-small);
}

/* --------------------------------------------------------------------------
   Chips, badges, glass surfaces
   -------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  font-size: var(--fs-small);
  font-weight: 550;
  white-space: nowrap;
}
.chip__icon {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.glass {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
@supports (backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px)) {
  .glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-small);
  color: var(--text-secondary);
}
.badge-live__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse-dot 2.4s var(--ease-in-out) infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field__label {
  font-size: var(--fs-small);
  font-weight: 600;
}
.field__input,
.field__textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  transition: border-color var(--dur-instant) linear;
}
.field__textarea {
  min-height: 120px;
  resize: vertical;
}
.field__input:hover,
.field__textarea:hover {
  border-color: color-mix(in srgb, var(--accent-primary) 50%, var(--border-subtle));
}
.field__input::placeholder,
.field__textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}
.field__error {
  font-size: var(--fs-small);
  color: #f87171;
  min-height: 1.25rem;
}
[data-site-theme="light"] .field__error {
  color: #b91c1c;
}
.field[data-invalid="true"] .field__input,
.field[data-invalid="true"] .field__textarea {
  border-color: #f87171;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent-primary);
  flex-shrink: 0;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Scroll reveal — start state is VISIBLE so no-JS users see everything.
   main[data-js="on"] is set by the entry script before reveal runs.
   -------------------------------------------------------------------------- */

[data-js="on"] .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--dur-slow) var(--ease-out-expo),
    transform var(--dur-slow) var(--ease-out-expo);
}
[data-js="on"] .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   Reduced motion — kill all decorative animation, keep state changes instant
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  [data-js="on"] .reveal {
    opacity: 1;
    transform: none;
  }
}
