/* ============================================================
   Sokendi Base Styles — Design System Extension
   ============================================================
   
   NOTE: Design tokens (colors, typography scale, spacing, radii, 
   shadows, motion) are defined in BaseLayout.astro critical CSS.
   This file extends them with component patterns and utilities.
   Do NOT duplicate tokens here — maintain single source of truth.

   Owns: typography, surfaces/cards, buttons, badges, ornaments,
   animation utilities. Layout primitives (.container, .grid, .stack,
   .row) live in layout.css only — both files used to define them.
   ============================================================ */

/* ------------------------------ 
   1. Base Layer Overrides
   ------------------------------ */
/* Body color, weight, min-height are set once in BaseLayout's critical
   CSS. Keep body flat (no background-image) — decorative gradients live on
   the fixed ::before layer below to avoid mobile repaint storms. Don't add
   overflow-x: hidden here: it breaks position: sticky. */

/* Decorative background layer — performance-isolated */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(242,183,26,0.06), transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 50%, rgba(0,217,181,0.03), transparent 50%);
  background-size: 100% 100%;
}

/* ------------------------------ 
   2. Typography Refinements
   ------------------------------ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  font-variation-settings: "wght" 700;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  font-variation-settings: "wght" 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variation-settings: "wght" 700;
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  font-variation-settings: "wght" 600;
  letter-spacing: -0.01em;
}

h4 {
  font-size: var(--text-lg);
  font-weight: 600;
  font-variation-settings: "wght" 600;
}

/* Body text */
p {
  line-height: 1.7;
  color: var(--text-secondary);
  text-wrap: pretty;
  max-width: 65ch;
}


.text-gradient-amber {
  background: linear-gradient(135deg, #FFD942 0%, #F2B71A 50%, #D4A010 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-cyan {
  background: linear-gradient(135deg, #00F0C8 0%, #00D9B5 50%, #00B894 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Windows High Contrast removes background images but keeps the
   transparent fill, so gradient text (the hero headline) vanished.
   !important so it also beats component-scoped copies of these classes. */
@media (forced-colors: active) {
  .text-gradient-amber,
  .text-gradient-cyan {
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
  }
}

.label {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variation-settings: "wght" 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* 3. Layout utilities → layout.css */

/* ------------------------------ 
   4. Surfaces & Cards
   ------------------------------ */
.surface {
  background: var(--sh-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.card {
  position: relative;
  background: linear-gradient(
    180deg, 
    rgba(255,255,255,0.03) 0%, 
    rgba(255,255,255,0) 100%
  ), var(--sh-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow-inner), var(--shadow-md);
  transition: 
    border-color var(--duration-base) var(--ease-out-quart),
    box-shadow var(--duration-base) var(--ease-out-quart);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.06) 0%,
    transparent 40%
  );
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out-quart);
}

/* No transform on hover (moving a card blurs its text) and no amber
   glow: border + shadow give the feedback. */
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--glow-inner), var(--shadow-lg);
}

.card:hover::before {
  opacity: 1;
}


/* Solid panels, no backdrop-filter. A backdrop blur puts the panel on
   its own GPU layer and renders the text inside it softer than the
   rest of the page (login/signup card, mobile menu, CTA boxes). On this
   near-black background the blur itself was barely visible anyway. */
.glass {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    var(--sh-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
}

.glass-strong {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    #151A24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
}

/* ------------------------------ 
   5. Buttons — Premium
   ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variation-settings: "wght" 600;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  
  transition:
    background-color var(--duration-base) var(--ease-out-quart),
    border-color var(--duration-base) var(--ease-out-quart),
    box-shadow var(--duration-base) var(--ease-out-quart),
    color var(--duration-base) var(--ease-out-quart);
}

/* Subtle top highlight on buttons */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  opacity: 0.6;
  pointer-events: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--accent-amber);
  color: var(--sh-void);
  border-color: rgba(245, 184, 0, 0.4);
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 0 0 1px rgba(245,184,0,0.2), 
    var(--shadow-md), 
    var(--glow-amber);
}

.btn-primary:hover {
  background: var(--accent-amber-hover);
  border-color: rgba(245, 184, 0, 0.7);
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 0 0 1px rgba(245,184,0,0.4), 
    var(--shadow-lg), 
    var(--glow-amber);
}

.btn-secondary {
  background: var(--sh-elevated);
  color: var(--text-secondary);
  border-color: var(--border-default);
  box-shadow: var(--glow-inner);
}

.btn-secondary:hover {
  background: var(--sh-higher);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-cyan {
  background: var(--accent-cyan);
  color: var(--sh-void);
  border-color: rgba(0, 217, 181, 0.4);
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 0 0 1px rgba(0,217,181,0.2), 
    var(--shadow-md), 
    var(--glow-cyan);
}

.btn-cyan:hover {
  background: #00F0C8;
  border-color: rgba(0, 217, 181, 0.7);
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 0 0 1px rgba(0,217,181,0.4), 
    var(--shadow-lg), 
    var(--glow-cyan);
}

/* Press feedback without transform: scale(0.97) resampled the label and
   blurred it on every click. A slight dim reads as "pressed". */
.btn:active:not(:disabled) {
  filter: brightness(0.92);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

/* Sizes */
.btn-sm { 
  padding: 0.45rem 1rem; 
  font-size: var(--text-xs); 
  font-weight: 500;
  font-variation-settings: "wght" 500;
}
.btn-lg { 
  padding: 0.9rem 2.25rem; 
  font-size: var(--text-md); 
}

/* ------------------------------ 
   6. Badges & Labels
   ------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variation-settings: "wght" 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border-subtle);
  background: var(--sh-elevated);
  color: var(--text-muted);
  box-shadow: var(--glow-inner);
}

.badge-amber {
  border-color: rgba(242, 183, 26, 0.15);
  color: var(--accent-amber);
  background: rgba(242, 183, 26, 0.08);
}

.badge-cyan {
  border-color: rgba(0, 217, 181, 0.15);
  color: var(--accent-cyan);
  background: rgba(0, 217, 181, 0.08);
}

.badge-live {
  position: relative;
  padding-left: 1.5rem;
}

.badge-live::before {
  content: '';
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { 
    opacity: 1; 
    transform: translateY(-50%) scale(1); 
  }
  50% { 
    opacity: 0.5; 
    transform: translateY(-50%) scale(1.3); 
  }
}

/* ------------------------------ 
   7. Dividers & Ornaments
   ------------------------------ */
.divider {
  height: 1px;
  background: linear-gradient(
    90deg, 
    transparent, 
    var(--border-default), 
    transparent
  );
  border: none;
  margin-block: var(--space-8);
}

.glow-line {
  height: 1px;
  background: linear-gradient(
    90deg, 
    transparent, 
    var(--accent-amber), 
    transparent
  );
  opacity: 0.35;
  box-shadow: 0 0 16px rgba(242, 183, 26, 0.15);
}

/* ------------------------------ 
   8. Animation Utilities
   ------------------------------ */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 
 * Animation utilities now start invisible.
 * Prevents flash of unstyled content before animation triggers.
 */
.animate-fade-in-up {
  opacity: 0;
  animation: fade-in-up 0.7s var(--ease-out-expo) forwards;
}

.animate-fade-in {
  opacity: 0;
  animation: fade-in 0.5s var(--ease-out-quart) forwards;
}

.animate-scale-in {
  opacity: 0;
  animation: scale-in 0.5s var(--ease-out-expo) forwards;
}

/* Stagger children — extended to 10 items */
.stagger-children > * {
  opacity: 0;
  animation: fade-in-up 0.6s var(--ease-out-expo) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 70ms; }
.stagger-children > *:nth-child(3) { animation-delay: 140ms; }
.stagger-children > *:nth-child(4) { animation-delay: 210ms; }
.stagger-children > *:nth-child(5) { animation-delay: 280ms; }
.stagger-children > *:nth-child(6) { animation-delay: 350ms; }
.stagger-children > *:nth-child(7) { animation-delay: 420ms; }
.stagger-children > *:nth-child(8) { animation-delay: 490ms; }
.stagger-children > *:nth-child(9) { animation-delay: 560ms; }
.stagger-children > *:nth-child(10) { animation-delay: 630ms; }

/* ------------------------------ 
   9. Accessibility Utilities
   ------------------------------ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ------------------------------ 
   10. Link Contextual Behavior
   ------------------------------ */
/* 
 * Global link hover no longer forces amber on everything.
 * Only links inside prose or explicit .link class get accent hover.
 * This prevents nav items and buttons from turning amber unexpectedly.
 */
/* The global `a` reset lives in BaseLayout's critical CSS. */

.link {
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease-out-quart);
}
.link:hover { color: var(--text-primary); }

/* Links inside running text: these were the SAME color as the paragraph
   (both --text-secondary) with no underline, so readers couldn't see
   them (WCAG 1.4.1). Brighter text + an amber underline fixes that. */
.prose a:not(.btn),
p a:not(.btn) {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: rgba(242, 183, 26, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--duration-fast) var(--ease-out-quart),
              text-decoration-color var(--duration-fast) var(--ease-out-quart);
}
/* Hover: the underline goes solid white instead of the text turning amber. */
.prose a:not(.btn):hover,
p a:not(.btn):hover {
  text-decoration-color: currentColor;
}

/* ------------------------------ 
   11. Reduced Motion
   ------------------------------ */
/* The global "kill all motion" rule is in BaseLayout's critical CSS.
   Here: entrance animations start at opacity 0, so show them outright. */
@media (prefers-reduced-motion: reduce) {
  .animate-fade-in-up,
  .animate-fade-in,
  .animate-scale-in,
  .stagger-children > * {
    opacity: 1;
    animation: none;
  }
}

/* ------------------------------ 
   12. Responsive
   ------------------------------ */
@media (max-width: 768px) {
  h1 { 
    font-size: clamp(1.875rem, 6vw, 2.5rem); 
    letter-spacing: -0.025em;
  }
  h2 { 
    font-size: clamp(1.5rem, 4.5vw, 1.75rem); 
  }
}

/* Body text stays 16px on phones. It used to drop to 15px, which also
   made every form input 15px (inputs inherit font) — iOS zooms the page
   in when you focus an input under 16px, e.g. on the signup form. */
@media (max-width: 480px) {
  .btn { 
    padding: 0.6rem 1.2rem; 
  }
}