/* ============================================================
   SXT STYLES — UI ENHANCEMENTS
   Layers on top of existing style.css without modifying it.
   ============================================================ */

/* ── REACT HOMEPAGE MOBILE NAV FIX ──────────────────────────── */
/* Target the React app's nav structure for mobile */
@media (max-width: 640px) {
  /* Make the entire page respect mobile viewport */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* Fix React app nav - horizontal scroll to show all */
  header {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 0.5rem 0.75rem !important;
  }

  header::-webkit-scrollbar {
    display: none !important;
  }

  /* Shrink nav link pills on mobile */
  header nav a,
  header a[class*="rounded"],
  header a[class*="px-"] {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.65rem !important;
    white-space: nowrap !important;
  }

  /* Shrink logo on mobile */
  header a:first-child,
  header > a[class*="font"] {
    font-size: 1rem !important;
  }

  /* Fix hero section padding */
  main > div:first-child,
  section:first-of-type {
    padding-top: 4.5rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Fix button row wrapping */
  [class*="flex"][class*="gap"] {
    flex-wrap: wrap !important;
  }

  /* Ensure buttons don't overflow */
  button, a[class*="rounded"] {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  /* Even smaller screens */
  header nav a,
  header a[class*="rounded"],
  header a[class*="px-"] {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.6rem !important;
  }

  header a:first-child {
    font-size: 0.9rem !important;
  }
}

/* ── CSS VARIABLES FOR ENHANCEMENTS ─────────────────────────── */
:root {
  --glass-bg: rgba(250, 249, 247, 0.85);
  --glass-border: rgba(224, 221, 216, 0.6);
  --focus-ring: rgba(26, 26, 26, 0.25);
  --success: #16a34a;
  --error: #dc2626;
}

/* ── DARK MODE (System Preference) ──────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --white: #181c24;
    --fg: #f4f7ff;
    --sub: #b8c0d0;
    --muted: #7a8599;
    --border: #2a3040;
    --accent: #f4f7ff;
    --glass-bg: rgba(15, 17, 21, 0.88);
    --glass-border: rgba(42, 48, 64, 0.7);
    --focus-ring: rgba(244, 247, 255, 0.2);
  }

  body {
    background: var(--bg);
    color: var(--fg);
  }

  .nav {
    background: var(--bg);
    border-bottom-color: var(--border);
  }

  .mobile-menu {
    background: var(--bg);
    border-top-color: var(--border);
  }

  .feature-card,
  .portal-card,
  .team-card,
  .upload-zone,
  .tryon-canvas,
  .celeb-card {
    background: var(--white);
    border-color: var(--border);
  }

  .ea-form,
  .contact-form {
    background: var(--white);
  }

  .cf-row input,
  .cf-row textarea,
  .cf-row select {
    background: var(--bg);
    border-color: var(--border);
    color: var(--fg);
  }

  .btn-primary {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
  }

  .btn-primary:hover {
    background: transparent;
    color: var(--fg);
  }

  .btn-secondary {
    color: var(--fg);
    border-color: var(--fg);
  }

  .btn-secondary:hover {
    background: var(--fg);
    color: var(--bg);
  }

  .footer {
    border-top-color: var(--border);
  }

  .footer-bar {
    border-top-color: var(--border);
  }

  .stats-bar {
    border-color: var(--border);
  }

  .stat-item {
    border-right-color: var(--border);
  }

  .hero-split-img::after {
    background: linear-gradient(to right, var(--bg) 0%, transparent 35%);
  }

  #loginModal > div {
    background: var(--white) !important;
    border-color: var(--border) !important;
  }

  .kicker-line {
    background: var(--muted);
  }

  .scan-step,
  .portal-card,
  .team-card {
    border-color: var(--border);
  }
}

/* ── ACCESSIBILITY: SKIP LINK ───────────────────────────────── */
.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 9999;
  transform: translateY(-200%);
  background: var(--fg);
  color: var(--bg);
  padding: 0.65rem 0.9rem;
  text-decoration: none;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ── ACCESSIBILITY: FOCUS STATES ────────────────────────────── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* ── ACCESSIBILITY: REDUCED MOTION ──────────────────────────── */
@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;
  }
}

/* ── NAVIGATION FIXES ───────────────────────────────────────── */
.nav-links {
  gap: 1.4rem;
}

.nav-links a {
  min-height: auto;
  padding: 0.4rem 0;
}

.nav-cta {
  padding: 0.5rem 1.4rem !important;
  font-size: 0.6rem !important;
  min-height: auto;
}

.nav-hamburger {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── MOBILE MENU FIXES ──────────────────────────────────────── */
.mobile-menu a {
  min-height: 48px;
  display: flex;
  align-items: center;
}

/* ── BUTTON IMPROVEMENTS ────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-ghost {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
}

.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active {
  transform: scale(0.98);
}

.btn-primary:hover,
.btn-secondary:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  .btn-primary:hover,
  .btn-secondary:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* ── GLASSMORPHISM: NAV ON SCROLL ───────────────────────────── */
.nav.scrolled {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--glass-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .nav.scrolled {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  }
}

/* ── GLASSMORPHISM: MOBILE MENU ─────────────────────────────── */
.mobile-menu.open {
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

/* ── CARD IMPROVEMENTS ──────────────────────────────────────── */
.feature-card,
.portal-card,
.team-card,
.celeb-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.feature-card:hover,
.portal-card:hover,
.team-card:hover,
.celeb-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
  border-color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .feature-card:hover,
  .portal-card:hover,
  .team-card:hover,
  .celeb-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

/* ── FORM INPUT IMPROVEMENTS ────────────────────────────────── */
.cf-row input,
.cf-row textarea,
.cf-row select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cf-row input:focus,
.cf-row textarea:focus,
.cf-row select:focus {
  border-color: var(--fg);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.cf-row input::placeholder,
.cf-row textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* ── SELECT DROPDOWN STYLING ────────────────────────────────── */
.cf-row select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* ── LOADING SPINNER ────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── LOGIN MODAL IMPROVEMENTS ───────────────────────────────── */
#loginModal {
  transition: opacity 0.25s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#loginModal > div {
  animation: modalSlideIn 0.25s ease;
  border-radius: 6px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  #loginModal {
    align-items: flex-end !important;
  }

  #loginModal > div {
    width: 100% !important;
    max-width: none !important;
    border-radius: 12px 12px 0 0 !important;
    padding-bottom: calc(2.5rem + env(safe-area-inset-bottom)) !important;
    animation: sheetSlideUp 0.3s ease;
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* ── TYPOGRAPHY IMPROVEMENTS ────────────────────────────────── */
h1, h2, h3 {
  line-height: 1.15;
}

.lead {
  max-width: 640px;
}

p {
  max-width: 65ch;
}

/* ── CONSISTENT SECTION SPACING ─────────────────────────────── */
.section {
  padding-top: 5rem;
  padding-bottom: 5rem;
}

.section-inner {
  max-width: 1100px;
}

/* ── HERO ANIMATIONS ────────────────────────────────────────── */
.page-hero h1,
.hero-split h1 {
  animation: fadeInUp 0.5s ease;
}

.page-hero .lead,
.hero-split .lead {
  animation: fadeInUp 0.5s ease 0.08s both;
}

.page-hero .btn-row,
.hero-split .btn-row {
  animation: fadeInUp 0.5s ease 0.16s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── SCROLL TRIGGERED FADE IN ───────────────────────────────── */
.feature-card,
.portal-card,
.stat-item,
.team-card,
.celeb-card {
  opacity: 0;
  transform: translateY(12px);
  animation: scrollFadeIn 0.4s ease forwards;
}

.feature-card:nth-child(1) { animation-delay: 0s; }
.feature-card:nth-child(2) { animation-delay: 0.05s; }
.feature-card:nth-child(3) { animation-delay: 0.1s; }
.feature-card:nth-child(4) { animation-delay: 0.15s; }

.stat-item:nth-child(1) { animation-delay: 0s; }
.stat-item:nth-child(2) { animation-delay: 0.04s; }
.stat-item:nth-child(3) { animation-delay: 0.08s; }
.stat-item:nth-child(4) { animation-delay: 0.12s; }
.stat-item:nth-child(5) { animation-delay: 0.16s; }
.stat-item:nth-child(6) { animation-delay: 0.2s; }

@keyframes scrollFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── CURSOR IMPROVEMENTS ────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-ghost,
.feature-card,
.portal-card,
.garment-item,
.upload-zone {
  cursor: pointer;
}

/* ── SELECTION STYLING ──────────────────────────────────────── */
::selection {
  background: var(--fg);
  color: var(--bg);
}

/* ── SMOOTH SCROLLING ───────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ── IMAGE LAZY LOADING FADE ────────────────────────────────── */
img {
  transition: opacity 0.3s ease;
}

img[loading="lazy"] {
  opacity: 0;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src=""]) {
  opacity: 1;
}

/* ── FOOTER POWERED BY ──────────────────────────────────────── */
.footer-powered {
  display: block;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.2rem;
  font-weight: 500;
}

/* ── FOOTER IMPROVEMENTS ────────────────────────────────────── */
.footer {
  padding-top: 4.5rem;
  padding-bottom: 2.5rem;
}

.footer-inner {
  gap: 3rem;
}

/* ── THEME TOGGLE BUTTON ────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.theme-toggle:hover {
  border-color: var(--fg);
  color: var(--fg);
}

/* ── ARIA CURRENT PAGE ──────────────────────────────────────── */
.nav-links a[aria-current="page"],
.mobile-menu a[aria-current="page"] {
  color: var(--fg);
}

/* ── TOOLTIP STYLES ─────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--fg);
  color: var(--bg);
  padding: 0.35rem 0.6rem;
  font-size: 0.65rem;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-8px);
}

/* ── SKELETON LOADING ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--white) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── SUCCESS/ERROR STATES ───────────────────────────────────── */
.form-success {
  color: var(--success);
}

.form-error {
  color: var(--error);
}

/* ── TABLET BREAKPOINT FIXES ────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  .celeb-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .section-inner {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* ── PREVENT HORIZONTAL OVERFLOW ────────────────────────────── */
body {
  overflow-x: hidden;
}

.section-inner,
.page-hero-inner,
.footer-inner {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ── CONSISTENT VERTICAL RHYTHM ─────────────────────────────── */
.kicker {
  margin-bottom: 1rem;
}

h2 {
  margin-bottom: 1.25rem;
}

.lead {
  margin-bottom: 0;
}

.btn-row {
  margin-top: 2rem;
}

/* ── PRINT STYLES ───────────────────────────────────────────── */
@media print {
  .nav,
  .mobile-menu,
  .footer,
  .btn-row,
  .skip-link,
  .theme-toggle {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .page-hero,
  .section {
    padding: 2rem 0 !important;
  }
}
