/* ==========================================================================
   Snowwords design system
   Dark ink ground, Instrument Serif display, Geist body, JetBrains Mono data,
   one burnt-orange accent. Every page links this file; page-specific rules
   live in each view's own <style> block and build on these tokens.
   ========================================================================== */

:root {
  color-scheme: dark;

  --ink: #09090b;
  --surface: #18181b;
  --raised: #1f1f23;
  --well: #111113;

  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --line-hover: rgba(255, 255, 255, 0.28);

  --snow: #fafafa;
  --mute: #a1a1aa;
  --faint: #71717a;

  --ember: #e0703a;
  --ember-hover: #ea8150;
  --ember-soft: rgba(224, 112, 58, 0.12);
  --ember-line: rgba(224, 112, 58, 0.4);

  --good: #8fbf8a;
  --good-soft: rgba(143, 191, 138, 0.12);
  --bad: #ef6b6b;
  --bad-soft: rgba(239, 107, 107, 0.12);

  --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  --inner: inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
  --lift: inset 0 1px 0 0 rgba(255, 255, 255, 0.05), 0 20px 40px -20px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --gutter: clamp(16px, 4vw, 40px);
  --page: 1152px;
}

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

html { background: var(--ink); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--snow);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 500; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--ember); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

/* ---------- Type ---------------------------------------------------------- */

.sw-serif { font-family: var(--font-serif); font-weight: 400; }
.sw-mono { font-family: var(--font-mono); }
.sw-tabular { font-variant-numeric: tabular-nums; }

.sw-display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.75rem, 7vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.sw-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.025em;
}

.sw-title em, .sw-display em { font-style: italic; color: var(--mute); }

.sw-h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.sw-h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sw-lede {
  max-width: 34rem;
  color: var(--mute);
  font-size: 1rem;
  line-height: 1.65;
}

.sw-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.sw-eyebrow::before {
  content: '';
  width: 28px;
  height: 1px;
  background: var(--ember);
}

.sw-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.sw-muted { color: var(--mute); }
.sw-faint { color: var(--faint); }
.sw-accent { color: var(--ember); }

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

.sw-page {
  width: 100%;
  max-width: calc(var(--page) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sw-main { padding-block: clamp(32px, 6vw, 64px) clamp(56px, 8vw, 96px); }

.sw-pagehead {
  display: grid;
  gap: 20px;
  padding-bottom: clamp(28px, 4vw, 44px);
  margin-bottom: clamp(28px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 900px) {
  .sw-pagehead--split {
    grid-template-columns: 7fr 5fr;
    align-items: end;
    gap: 32px;
  }
}

/* ---------- Nav ----------------------------------------------------------- */

.sw-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.sw-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.sw-wordmark {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ember);
  text-decoration: none;
  transition: opacity 0.2s var(--ease);
  flex-shrink: 0;
}
.sw-wordmark:hover { opacity: 0.85; }

.sw-nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sw-nav__links::-webkit-scrollbar { display: none; }

.sw-nav__link {
  position: relative;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--mute);
  text-decoration: none;
  font-size: 14px;
  font-weight: 450;
  white-space: nowrap;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.sw-nav__link:hover { color: var(--snow); background: rgba(255, 255, 255, 0.04); }
.sw-nav__link[aria-current='page'] { color: var(--snow); }
.sw-nav__link[aria-current='page']::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 1px;
  background: var(--ember);
}
.sw-nav__sep {
  width: 1px;
  height: 18px;
  margin-inline: 8px;
  background: var(--line-strong);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .sw-nav__inner { flex-wrap: wrap; gap: 4px 12px; padding-block: 10px; min-height: 0; }
  .sw-nav__links { width: 100%; margin-inline: -12px; padding-inline: 0; }
  .sw-wordmark { font-size: 1.5rem; }
}

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

.sw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--snow);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
}
.sw-btn:hover { border-color: var(--line-hover); background: rgba(255, 255, 255, 0.03); }
.sw-btn:active { transform: translateY(1px); }
.sw-btn:disabled, .sw-btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; transform: none; }

.sw-btn--primary {
  background: var(--ember);
  border-color: var(--ember);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.sw-btn--primary:hover { background: var(--ember-hover); border-color: var(--ember-hover); }

.sw-btn--lg { min-height: 52px; padding: 0 26px; font-size: 15px; }
.sw-btn--sm { min-height: 36px; padding: 0 14px; font-size: 13px; border-radius: var(--r-sm); }
.sw-btn--block { width: 100%; }

.sw-link {
  color: var(--snow);
  text-decoration: underline;
  text-decoration-color: var(--ember-line);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s var(--ease);
}
.sw-link:hover { text-decoration-color: var(--ember); }

/* ---------- Surfaces ------------------------------------------------------ */

.sw-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--inner);
  padding: clamp(20px, 3vw, 28px);
}
.sw-card--quiet { background: transparent; border-color: var(--line); box-shadow: none; }

.sw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.05);
  color: var(--mute);
  border: 1px solid var(--line);
}
.sw-chip--ember { background: var(--ember-soft); color: var(--ember); border-color: transparent; }
.sw-chip--good { background: var(--good-soft); color: var(--good); border-color: transparent; }

.sw-bar { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.sw-bar > i { display: block; height: 100%; border-radius: inherit; background: var(--ember); transition: width 0.6s var(--ease); }

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

.sw-field { display: grid; gap: 8px; }
.sw-field > label, .sw-field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--mute);
}

.sw-input,
.sw-field input:not([type='hidden']):not([type='radio']):not([type='checkbox']):not([type='file']),
.sw-field select,
.sw-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--well);
  color: var(--snow);
  font-size: 15px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.sw-field textarea { min-height: 140px; resize: vertical; line-height: 1.55; }
.sw-field select {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.sw-input::placeholder, .sw-field input::placeholder, .sw-field textarea::placeholder { color: var(--faint); }
.sw-input:hover, .sw-field input:hover, .sw-field select:hover, .sw-field textarea:hover { border-color: var(--line-hover); }
.sw-input:focus, .sw-field input:focus, .sw-field select:focus, .sw-field textarea:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 3px var(--ember-soft);
}

.sw-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.sw-divider::before, .sw-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Alerts -------------------------------------------------------- */

.sw-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--snow);
  font-size: 14px;
  line-height: 1.5;
}
.sw-alert::before {
  content: '';
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--mute);
}
.sw-alert--error { border-color: rgba(239, 107, 107, 0.35); background: var(--bad-soft); }
.sw-alert--error::before { background: var(--bad); }
.sw-alert--ok { border-color: rgba(143, 191, 138, 0.35); background: var(--good-soft); }
.sw-alert--ok::before { background: var(--good); }
.sw-alert--info { border-color: var(--ember-line); background: var(--ember-soft); }
.sw-alert--info::before { background: var(--ember); }

/* ---------- Spinner ------------------------------------------------------- */

.sw-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ember);
  animation: sw-spin 0.9s linear infinite;
}
@keyframes sw-spin { to { transform: rotate(360deg); } }

/* ---------- Footer -------------------------------------------------------- */

.sw-footer {
  border-top: 1px solid var(--line);
  padding-block: 32px calc(32px + env(safe-area-inset-bottom, 0px));
  color: var(--faint);
  font-size: 13px;
}
.sw-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
}
.sw-footer__brand { font-family: var(--font-serif); font-size: 1.25rem; color: var(--mute); }
.sw-footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.sw-footer a { color: var(--mute); text-decoration: none; transition: color 0.2s var(--ease); }
.sw-footer a:hover { color: var(--snow); }

/* ---------- Motion -------------------------------------------------------- */

.sw-rise { animation: sw-rise 0.7s var(--ease) both; }
.sw-rise--1 { animation-delay: 0.06s; }
.sw-rise--2 { animation-delay: 0.12s; }
.sw-rise--3 { animation-delay: 0.18s; }
@keyframes sw-rise { from { transform: translateY(8px); opacity: 0.001; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.sw-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}
