/* ==========================================================================
   SATURDAYS — Design System
   "For the moments that aren't for everyone else."
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
  /* Colors — Warm, analog palette */
  --color-cream: #FDF6EC;
  --color-cream-dark: #F5ECDD;
  --color-parchment: #F0E6D3;
  --color-brown: #5C4033;
  --color-brown-light: #7A5C4F;
  --color-brown-dark: #3D2B22;
  --color-gold: #C9A96E;
  --color-gold-light: #D4BC8E;
  --color-gold-muted: rgba(201, 169, 110, 0.15);
  --color-terracotta: #C67B5C;
  --color-terracotta-light: #D4977E;
  --color-sage: #8B9E7E;
  --color-sage-light: #A8B89E;
  --color-dusty-rose: #C4918A;
  --color-dusty-rose-light: #D4ABA5;
  --color-ink: #2C1810;
  --color-ink-light: #4A3428;
  --color-text: #3D2B22;
  --color-text-secondary: #7A6B62;
  --color-text-faint: #A89888;
  --color-border: rgba(92, 64, 51, 0.12);
  --color-border-strong: rgba(92, 64, 51, 0.25);
  --color-shadow: rgba(60, 40, 25, 0.08);
  --color-shadow-strong: rgba(60, 40, 25, 0.15);
  --color-overlay: rgba(44, 24, 16, 0.5);
  --color-white: #FFFFFF;

  /* Typography */
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Font Sizes — Fluid scale */
  --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
  --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.9rem, 0.85rem + 0.3vw, 1rem);
  --text-md: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
  --text-lg: clamp(1.1rem, 1rem + 0.5vw, 1.25rem);
  --text-xl: clamp(1.3rem, 1.1rem + 0.8vw, 1.5rem);
  --text-2xl: clamp(1.6rem, 1.3rem + 1.2vw, 2rem);
  --text-3xl: clamp(2rem, 1.6rem + 1.6vw, 2.5rem);
  --text-4xl: clamp(2.5rem, 2rem + 2vw, 3.25rem);
  --text-5xl: clamp(3rem, 2.2rem + 3vw, 4.5rem);

  /* Font Weights */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Line Heights */
  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-normal: 1.6;
  --leading-relaxed: 1.8;

  /* Letter Spacing */
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-wider: 0.08em;
  --tracking-widest: 0.16em;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;
  --space-5xl: 8rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px var(--color-shadow);
  --shadow-md: 0 4px 12px var(--color-shadow);
  --shadow-lg: 0 8px 24px var(--color-shadow);
  --shadow-xl: 0 12px 40px var(--color-shadow-strong);
  --shadow-photo: 0 4px 20px rgba(60, 40, 25, 0.12), 0 1px 4px rgba(60, 40, 25, 0.08);
  --shadow-card: 0 2px 8px rgba(60, 40, 25, 0.06), 0 0 0 1px var(--color-border);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 800ms;

  /* Layout */
  --content-width: 560px;
  --content-width-wide: 720px;
  --nav-height: 64px;
  --bottom-nav-height: 72px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-cream);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* Paper grain texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-ink);
  letter-spacing: var(--tracking-tight);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p {
  line-height: var(--leading-relaxed);
  color: var(--color-text);
}

a {
  color: var(--color-terracotta);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--color-brown);
}

small {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

strong {
  font-weight: var(--weight-semibold);
}

em {
  font-style: italic;
}

/* --- Images --- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Lists --- */
ul, ol {
  list-style: none;
}

/* --- Inputs --- */
input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
}

/* --- Selection --- */
::selection {
  background: var(--color-gold-muted);
  color: var(--color-brown-dark);
}

/* --- Utility Classes --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-serif { font-family: var(--font-serif); }
.text-sans { font-family: var(--font-sans); }
.text-mono { font-family: var(--font-mono); }

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-faint { color: var(--color-text-faint); }
.text-secondary { color: var(--color-text-secondary); }
.text-gold { color: var(--color-gold); }
.text-terracotta { color: var(--color-terracotta); }
.text-sage { color: var(--color-sage); }

.uppercase {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.italic { font-style: italic; }

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-fade-in {
  animation: fadeIn var(--duration-slow) var(--ease-out) both;
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

.animate-fade-in-down {
  animation: fadeInDown var(--duration-normal) var(--ease-out) both;
}

.animate-scale-in {
  animation: scaleIn var(--duration-slow) var(--ease-out) both;
}

/* Stagger children animations */
.stagger-children > * {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 80ms; }
.stagger-children > *:nth-child(3) { animation-delay: 160ms; }
.stagger-children > *:nth-child(4) { animation-delay: 240ms; }
.stagger-children > *:nth-child(5) { animation-delay: 320ms; }
.stagger-children > *:nth-child(6) { animation-delay: 400ms; }
.stagger-children > *:nth-child(7) { animation-delay: 480ms; }
.stagger-children > *:nth-child(8) { animation-delay: 560ms; }

/* --- App Shell --- */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Wide content variant */
#app-content.wide {
  max-width: var(--content-width-wide);
}

/* Full-bleed variant */
#app-content.full-bleed {
  max-width: none;
  padding: 0;
}

/* View transitions */
.view-enter {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

.view-exit {
  animation: fadeIn var(--duration-fast) var(--ease-out) both reverse;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  :root {
    --space-lg: 1.25rem;
  }
  
  #app-content {
    padding: 0 var(--space-md);
  }
}

@media (min-width: 768px) {
  :root {
    --content-width: 600px;
    --content-width-wide: 760px;
  }
}

@media (min-width: 1024px) {
  :root {
    --content-width: 620px;
    --content-width-wide: 800px;
  }
  
  .bottom-nav {
    max-width: 480px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border: 1px solid var(--color-border);
    border-bottom: none;
  }
}
