/* Spotify-style Inter font import */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* Skip link - hide visually but keep for screen readers */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Design System Spacing Variables */
:root {
  /* Base spacing unit: 8px */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  --space-20: 5rem;    /* 80px */
  --space-24: 6rem;    /* 96px */
  
  /* Component spacing */
  --section-gap: var(--space-12);      /* 48px between sections */
  --component-gap: var(--space-8);     /* 32px between components */
  --element-gap: var(--space-4);       /* 16px between elements */
  --edge-padding: var(--space-8);      /* 32px edge padding */
  
  /* Brand Colors — cream canvas, one warm primary for all CTAs */
  --brand-primary: #E81B27;
  --brand-black: #2D2D2D;
  --brand-white: #FFFFFF;
  --brand-yellow: #E81B27;
  --brand-cream: #FFF8F0;
  --brand-ink: #2D2D2D;

  /* RGB channels for Tailwind alpha support */
  --brand-black-rgb: 45 45 45;
  --brand-white-rgb: 255 255 255;
  --brand-cream-rgb: 255 248 240;
}

/* Prevent white bar on overscroll */
html, body {
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  overscroll-behavior-x: none;
  background-color: #FFF8F0;
  color: #2D2D2D;
}

/* Brand-themed scrollbars - cross-browser consistent */
* {
  scrollbar-width: thin;
  scrollbar-color: #E81B27 transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #E81B27;
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #FFA001;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Force nav logo size */
.nav-logo-large {
  height: 96px !important;
  width: auto !important;
  max-height: none !important;
  max-width: none !important;
  min-height: 96px !important;
}

/* Tap highlight only — do not force uppercase/weight on every button */
button {
  -webkit-tap-highlight-color: transparent;
}

/* Primary CTAs opt in to uppercase. Use className="btn-cta". */
.btn-cta {
  text-align: center;
  text-transform: uppercase;
  font-weight: 600;
}

/* Legacy escape hatch if a parent still wraps CTA text */
button.no-uppercase,
button[data-no-uppercase="true"],
.no-uppercase button {
  text-transform: none !important;
}

/* Utility classes */
.scrollbar-hide {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Global font family and text rendering */
* {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  background-color: #FFF8F0;
  color: #2D2D2D;
}

h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
}

.bg-brand-cream { background-color: #FFF8F0; }
.text-brand-ink { color: #2D2D2D; }

/* iOS Safari zooms focused form controls below 16px. Keep that floor on inputs only. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
textarea,
select {
  font-size: max(16px, 1em);
}

/* Subtle raised effect on all text */
h1, h2, h3, h4, h5, h6, p, span, button, a, label, input, textarea {
  text-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.2), 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* Shimmer animation for loading states */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* Smooth fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse animation for skeleton screens */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Auth pages styling */
.auth-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2A0A0A !important;
  overscroll-behavior: none;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Ensure auth page containers fill the viewport */
.auth-container {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  background-color: #2A0A0A !important;
  width: 100%;
  overflow-y: auto;
  padding-top: 0;
  box-sizing: border-box;
}

/* Inverted sections (footer, dark sections) */
.inverted-section {
  background-color: #2A0A0A;
  color: #FFFFFF;
}

/* Brand color utility classes - use CSS vars for dark mode auto-swap */
.bg-brand-primary { background-color: #E81B27; }
.bg-brand-black { background-color: rgb(var(--brand-black-rgb)); }
.bg-brand-white { background-color: rgb(var(--brand-white-rgb)); }
.bg-brand-yellow { background-color: #FFA001; }

.text-brand-primary { color: #E81B27; }
.text-brand-on-primary { color: #FFFFFF; }
.text-brand-black { color: rgb(var(--brand-black-rgb)); }
.text-brand-white { color: rgb(var(--brand-white-rgb)); }
.text-brand-yellow { color: #FFA001; }

.border-brand-primary { border-color: #E81B27; }
.border-brand-black { border-color: rgb(var(--brand-black-rgb)); }
.border-brand-white { border-color: rgb(var(--brand-white-rgb)); }
.border-brand-yellow { border-color: #FFA001; }

/* ============================================
   DARK MODE STYLES
   ============================================ */

/* Dark mode base styles - swap brand-black and brand-white RGB channels */
.dark {
  color-scheme: dark;
  --brand-black-rgb: 255 255 255;
  --brand-white-rgb: 26 26 26;
}

.dark body {
  background-color: #2A0A0A;
  color: #FFFFFF;
}

/* Dark mode overscroll */
.dark html,
.dark body {
  background-color: #2A0A0A;
}

/* Dark mode scrollbars */
.dark * {
  scrollbar-color: #E81B27 #2A0A0A;
}

.dark *::-webkit-scrollbar-track {
  background: #2A0A0A;
}

.dark *::-webkit-scrollbar-thumb {
  border: 1px solid #2A0A0A;
}

.dark *::-webkit-scrollbar-corner {
  background: #2A0A0A;
}

/* Dark mode text shadow adjustment */
.dark h1, .dark h2, .dark h3, .dark h4, .dark h5, .dark h6,
.dark p, .dark span, .dark button, .dark a, .dark label,
.dark input, .dark textarea {
  text-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Dark mode for common background patterns */
.dark .bg-white { background-color: #2A0A0A !important; }
.dark .bg-brand-white { background-color: #2A0A0A !important; }
.dark .bg-gray-50 { background-color: #1a1a1a !important; }
.dark .bg-gray-100 { background-color: #222222 !important; }
.dark .bg-gray-200 { background-color: #333333 !important; }

/* Dark mode text colors */
.dark .text-black { color: #FFFFFF !important; }
.dark .text-gray-900 { color: #FFFFFF !important; }
.dark .text-gray-800 { color: #f0f0f0 !important; }
.dark .text-gray-700 { color: #e0e0e0 !important; }
.dark .text-gray-600 { color: #d0d0d0 !important; }
.dark .text-gray-500 { color: #c0c0c0 !important; }

/* Dark mode borders */
.dark .border-gray-200 { border-color: #333333 !important; }
.dark .border-gray-300 { border-color: #444444 !important; }

/* Dark mode cards and surfaces */
.dark .bg-\[\#FFFFFF\] { background-color: #2A0A0A !important; }
.dark .bg-\[\#111111\] { background-color: #FFFFFF !important; }

/* Dark mode inverted sections stay the same */
.dark .inverted-section {
  background-color: #FFFFFF;
  color: #111111;
}

/* Dark mode button outlines removed — buttons rely on their own Tailwind classes for borders */

/* Dark mode inputs */
.dark input, .dark textarea, .dark select {
  background-color: #1a1a1a;
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Dark mode transition */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Staggered card entrance animation for recipe grids */
.card-stagger > * {
  opacity: 0;
  transform: translateY(12px);
  animation: cardEnter 0.4s ease-out forwards;
}
.card-stagger > *:nth-child(1) { animation-delay: 0ms; }
.card-stagger > *:nth-child(2) { animation-delay: 50ms; }
.card-stagger > *:nth-child(3) { animation-delay: 100ms; }
.card-stagger > *:nth-child(4) { animation-delay: 150ms; }
.card-stagger > *:nth-child(5) { animation-delay: 200ms; }
.card-stagger > *:nth-child(6) { animation-delay: 250ms; }
.card-stagger > *:nth-child(7) { animation-delay: 300ms; }
.card-stagger > *:nth-child(8) { animation-delay: 350ms; }
.card-stagger > *:nth-child(n+9) { animation-delay: 400ms; }

@keyframes cardEnter {
  to { opacity: 1; transform: translateY(0); }
}

/* Respect user motion preferences */
@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;
  }
}

/* Global focus-visible indicator for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Remove default outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Smooth scrolling (disabled by reduced-motion above) */
html {
  scroll-behavior: smooth;
}

/* Print styles - clean recipe output */
@media print {
  /* Hide app chrome */
  nav, footer, .mobile-bottom-nav, .floating-action-button,
  .announcement-bar, .toast-container, .modal-backdrop,
  [data-no-print] {
    display: none !important;
  }

  /* Clean up layout */
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
    line-height: 1.5;
  }

  /* Ensure images print */
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  /* Recipe content formatting */
  h1, h2, h3 {
    page-break-after: avoid;
    color: black !important;
  }

  /* Remove shadows and backgrounds */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Prevent orphans/widows */
  p, li {
    orphans: 3;
    widows: 3;
  }
}
