/* ═══════════════════════════════════════════════════════
   ShredPlanner Design System
   ═══════════════════════════════════════════════════════ */

:root {
  /* ── Core Palette ── */
  --sp-midnight: #0f1923;
  --sp-slate: #1a2a3a;
  --sp-steel: #2d3f52;
  --sp-fog: #8899aa;
  --sp-snow: #e8edf2;
  --sp-white: #f8f9fa;

  /* ── Accent ── */
  --sp-teal: #00bfa5;
  --sp-teal-hover: #00a88f;
  --sp-teal-glow: rgba(0, 191, 165, 0.15);
  --sp-amber: #f5a623;
  --sp-red: #e74c3c;

  /* ── Trail Difficulty ── */
  --sp-green: #22c55e;
  --sp-blue: #3b82f6;
  --sp-black: #1a1a1a;
  --sp-orange: #f97316;

  /* ── Typography ── */
  --font-display: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* ── Spacing ── */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;
  --sp-3xl: 64px;

  /* ── Elevation ── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px var(--sp-teal-glow);

  /* ── Radius ── */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* ── Transitions ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ═══════════════════════════════════════════
   Body
   ═══════════════════════════════════════════ */
body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding-top: 64px; /* fixed header height */
}

a { color: var(--sp-teal); }
a:hover { color: var(--sp-teal-hover); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════
   Header
   ═══════════════════════════════════════════ */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--sp-midnight);
  border-bottom: 1px solid transparent;
  transition: all var(--duration-normal) var(--ease-out);
}

.header--scrolled {
  background: rgba(15, 25, 35, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sp-steel);
  box-shadow: var(--shadow-md);
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-lg);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__logo {
  display: flex;
  flex-direction: column;
  align-items: flex-end;   /* right-aligns the "Steamboat" label under the wordmark */
  gap: 0;
  text-decoration: none;
  /* This `color` is inherited by the inline SVG's `fill:currentColor`.
     Change to any brand color to recolor the logo without editing SVG. */
  color: var(--sp-snow);
  transition: color var(--duration-fast) var(--ease-out);
}

.header__logo:hover {
  color: var(--sp-teal);
}

.header__logo-svg {
  /* Explicit width avoids the `width:auto` intrinsic-sizing edge cases
     that can leave SVGs at 0px in certain browser / layout combinations.
     Derived from the viewBox 1328 × 207.48 aspect ratio at 34px tall. */
  height: 34px;
  width: 218px;
  display: block;
  color: inherit;
  fill: currentColor;
}

/* "Steamboat" tag under the logo — mono, small caps, tight to the
   baseline of the wordmark. Color stays static (fog) so the logo's
   hover transition doesn't recolor the region label. */
.header__logo-region {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--sp-fog);
  line-height: 1;
  margin-top: 2px;
  padding-right: 2px;
}

/* Legacy — kept for any stray references to the old <img> wrapper. */
.header__logo-img {
  height: 40px;
  width: auto;
  display: block;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.header__link {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--sp-fog);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.header__link:hover {
  color: var(--sp-snow);
  background: rgba(255, 255, 255, 0.06);
}

.header__link--active {
  color: var(--sp-teal);
  background: var(--sp-teal-glow);
}

/* ── Actions (right side) ── */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.header__conditions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--sp-steel);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--sp-snow);
}

.header__conditions-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sp-teal);
  animation: sp-pulse 2s ease-in-out infinite;
}

@keyframes sp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Hamburger ── */
.header__hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--sp-snow);
  cursor: pointer;
  padding: var(--sp-xs);
}

/* ── Mobile menu ── */
.header__mobile {
  padding: var(--sp-sm) var(--sp-lg) var(--sp-lg);
  background: var(--sp-midnight);
  border-top: 1px solid var(--sp-steel);
}

.header__mobile-link {
  display: block;
  padding: 12px 0;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: var(--sp-fog);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: color var(--duration-fast);
}

.header__mobile-link:hover {
  color: var(--sp-teal);
}

/* ── Admin dropdown ── */
.header__admin-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--sp-fog);
  background: transparent;
  border: 1px solid var(--sp-steel);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.header__admin-btn:hover {
  color: var(--sp-snow);
  border-color: var(--sp-fog);
}

.header__admin-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  width: 220px;
  background: var(--sp-slate);
  border: 1px solid var(--sp-steel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  z-index: 100;
}

.header__admin-menu a {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--sp-fog);
  text-decoration: none;
  transition: all var(--duration-fast);
}

.header__admin-menu a:hover {
  color: var(--sp-snow);
  background: rgba(255, 255, 255, 0.04);
}

.header__admin-divider {
  border-top: 1px solid var(--sp-steel);
  margin: 4px 0;
}

.header__admin-label {
  padding: 6px 14px 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--sp-fog);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@media (max-width: 768px) {
  .header__nav { display: none; }
  .header__conditions { display: none; }
  .header__hamburger { display: block; }
}

/* ═══════════════════════════════════════════
   Reusable Components
   ═══════════════════════════════════════════ */

/* ── Cards ── */
.sp-card {
  background: var(--sp-slate);
  border: 1px solid var(--sp-steel);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  transition: all var(--duration-normal) var(--ease-out);
}

.sp-card:hover {
  border-color: var(--sp-teal);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

/* ── Buttons ── */
.sp-btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
}

.sp-btn--primary {
  background: var(--sp-teal);
  color: var(--sp-midnight);
}

.sp-btn--primary:hover {
  background: var(--sp-teal-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.sp-btn--secondary {
  background: transparent;
  color: var(--sp-snow);
  border: 1px solid var(--sp-steel);
}

.sp-btn--secondary:hover {
  border-color: var(--sp-fog);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Badges ── */
.sp-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sp-badge--green  { background: rgba(34, 197, 94, 0.15); color: var(--sp-green); }
.sp-badge--blue   { background: rgba(59, 130, 246, 0.15); color: var(--sp-blue); }
.sp-badge--black  { background: rgba(255, 255, 255, 0.1); color: var(--sp-white); }
.sp-badge--expert { background: rgba(249, 115, 22, 0.15); color: var(--sp-orange); }

/* ── Stats ── */
.sp-stat {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 28px;
  color: var(--sp-white);
  line-height: 1;
}

.sp-stat-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--sp-fog);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ── Selection State (pills, toggle buttons) ── */
.sp-selected {
  background: rgba(0, 191, 165, 0.2) !important;
  font-weight: 700 !important;
  border-color: var(--sp-teal) !important;
  color: var(--sp-teal) !important;
  box-shadow: 0 0 0 1px rgba(0, 191, 165, 0.3), inset 0 0 8px rgba(0, 191, 165, 0.1) !important;
}

/* ═══ HTMX loading states ═══
   While a form's request is in flight, dim + lock its submit button and
   show a spinner. Covers the budget wizard and any other hx-post form
   with no per-template markup. */
form.htmx-request button[type="submit"] {
  opacity: 0.6;
  pointer-events: none;
}
form.htmx-request button[type="submit"]::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: sp-spin 0.6s linear infinite;
}
@keyframes sp-spin {
  to { transform: rotate(360deg); }
}
