/* ==========================================================================
   TossOrKeep Premium Design System
   ========================================================================== */

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

:root {
  /* Color Palette - Premium Earthy/Food-Centric */
  --color-bg-primary: #FAFAFA;
  --color-bg-secondary: #f4f7f1;
  --color-text-primary: #111814;
  --color-text-secondary: #4f5a53;
  --color-text-tertiary: #667066;
  --color-accent-dark: #171717;
  --color-accent-green: #18392b;
  --color-accent-green-hover: #112b20;
  --color-accent-green-light: #173728;
  --color-border: #d5ddd3;
  
  /* Typography */
  --font-sans: 'Instrument Sans', sans-serif;
  --font-serif: 'Playfair Display', serif;
  --font-mono: 'Space Mono', monospace;
  
  /* Shadows & Glass */
  --shadow-sm: 0 4px 12px rgba(17, 24, 20, 0.05);
  --shadow-lg: 0 24px 60px rgba(17, 24, 20, 0.08);
  --shadow-glow: 0 24px 70px rgba(17, 24, 20, 0.18);
  --glass-bg: rgba(255, 255, 255, 0.88);
  --glass-border: 1px solid rgba(255, 255, 255, 0.3);
  
  /* Transitions */
  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

html, body {
  width: 100%;
  overflow-x: hidden;
  font-family: var(--font-sans);
  background: 
    radial-gradient(circle at top left, rgba(23, 23, 23, 0.03), transparent 30%),
    radial-gradient(circle at 88% 24%, rgba(23, 23, 23, 0.018), transparent 20%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), var(--color-bg-primary));
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
ul { list-style: none; }
img { max-width: 100%; height: auto; }

/* 2. Typography Utilities */
.font-editorial { font-family: var(--font-serif); }
.font-data { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-xs { font-size: 0.75rem; line-height: 1.5; }
.text-sm { font-size: 0.875rem; line-height: 1.75; }
.text-base { font-size: 1rem; line-height: 1.5; }
.text-lg { font-size: 1.125rem; line-height: 1.75; }
.text-3xl { font-size: 1.875rem; line-height: 1.2; }
.text-4xl { font-size: 2.25rem; line-height: 1.1; }
.text-5xl { font-size: 3rem; line-height: 1; }
.text-6xl { font-size: 3.75rem; line-height: 1; }
.tracking-wide { letter-spacing: 0.1em; }
.tracking-wider { letter-spacing: 0.2em; }
.uppercase { text-transform: uppercase; }
.font-medium { font-weight: 500; }
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-white { color: #ffffff; }

/* 3. Layout Utilities */
.container {
  width: 100%;
  max-width: 80rem; /* 1280px */
  margin: 0 auto;
  padding: 0 1.5rem;
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }
.w-full { width: 100%; }
.max-w-3xl { max-width: 48rem; }
.max-w-4xl { max-width: 56rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.relative { position: relative; }
.hidden { display: none; }

/* 4. Backgrounds & Textures */
.paper-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(to right, rgba(23, 23, 23, 0.028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(23, 23, 23, 0.024) 1px, transparent 1px);
  background-size: 140px 140px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.2), transparent 76%);
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.2), transparent 76%);
  z-index: -1;
}

.hero-glow {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 28rem;
  background: radial-gradient(circle at top, rgba(255,255,255,0.95), transparent 72%);
  pointer-events: none;
  z-index: -1;
}

/* 5. Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  padding: 1rem 2rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  transition: all var(--transition-fast);
  text-align: center;
}
.btn-primary {
  background-color: var(--color-accent-green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(24, 57, 43, 0.2);
}
.btn-primary:hover {
  background-color: var(--color-accent-green-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(24, 57, 43, 0.3);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background-color: var(--color-accent-dark);
  color: #fff;
  letter-spacing: 0.1em;
  padding: 0.75rem 1.5rem;
}
.btn-secondary:hover { background-color: #000; transform: translateY(-1px); }

.btn-outline {
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  background: transparent;
}
.btn-outline:hover {
  border-color: var(--color-accent-dark);
  color: var(--color-text-primary);
}
.btn-outline.active {
  background-color: var(--color-accent-dark);
  color: #fff;
  border-color: var(--color-accent-dark);
}

/* Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 2rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(250, 250, 250, 0.6);
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem;
  }
}

/* Glass Search Panel */
.glass-panel {
  width: 100%;
  border-radius: 32px;
  border: 1px solid var(--color-border);
  background: var(--glass-bg);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.glass-panel:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 30px 60px rgba(17, 24, 20, 0.12);
  border-color: rgba(24, 57, 43, 0.3);
}

.search-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  padding: 0.5rem 0 1.25rem;
  font-size: 2rem;
  color: var(--color-text-primary);
  text-align: center;
  transition: border-color var(--transition-fast);
  outline: none;
}
@media (min-width: 768px) { .search-input { font-size: 2.6rem; } }
.search-input::placeholder { color: #9da7a0; font-weight: 400; }
.search-input:focus { border-color: var(--color-accent-green); }

/* Pilled Inputs */
.pill-field {
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 0.95rem 1.5rem;
  width: 100%;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast);
}
.pill-field:focus { border-color: var(--color-accent-green); }
.pill-field::placeholder { color: #7e877f; }

/* Suggestions & Tags */
.suggestion-pill {
  display: inline-block;
  border: 1px solid rgba(213, 221, 211, 0.9);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-tertiary);
  transition: all var(--transition-fast);
  background: transparent;
}
.suggestion-pill:hover {
  border-color: var(--color-accent-dark);
  color: var(--color-text-primary);
  background: #fff;
  transform: translateY(-1px);
}

/* Premium Waitlist/Newsletter Section */
.premium-card {
  border-radius: 32px;
  border: 1px solid var(--color-border);
  background: var(--color-accent-green-light);
  color: #fff;
  padding: 3rem 2rem;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}
.premium-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.1), transparent 70%);
  border-radius: 50%;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 10rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
@media (min-width: 768px) { .main-content { padding-top: 12rem; } }

/* Footer */
.app-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  border-top: 1px solid rgba(0,0,0,0.05);
  margin-top: auto;
}

/* 6. Animations */
#appShell {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
}
[data-rise] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
}
body.app-ready #appShell {
  opacity: 1;
  transform: translateY(0) scale(1);
}
body.app-ready [data-rise] {
  opacity: 1;
  transform: translateY(0);
}
body.app-ready [data-delay="1"] { transition-delay: 90ms; }
body.app-ready [data-delay="2"] { transition-delay: 180ms; }
body.app-ready [data-delay="3"] { transition-delay: 270ms; }
body.app-ready [data-delay="4"] { transition-delay: 360ms; }

@keyframes heroSuggestionReveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
body.app-ready .suggestion-pill {
  animation: heroSuggestionReveal 680ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .suggestion-pill { opacity: 1; transform: none; }
  body.app-ready .suggestion-pill { animation: none; }
}

/* Fridge Sidebar (Drawer) */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 100%;
  max-width: 450px;
  background: var(--color-bg-primary);
  border-left: 1px solid var(--color-border);
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0,0,0,0.05);
}
.drawer.open {
  transform: translateX(0);
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
  z-index: 40;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer-header {
  padding: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--color-border);
}
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

/* Item Result Cards */
.result-card {
  background: #fff;
  border-radius: 24px;
  border: 1px solid var(--color-border);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.region-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  background: #f0fdf4;
  color: var(--color-accent-green);
  border: 1px solid rgba(24, 57, 43, 0.2);
}
.spoilage-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (min-width: 640px) {
  .spoilage-grid { grid-template-columns: repeat(3, 1fr); }
}
.spoilage-item {
  background: var(--color-bg-secondary);
  padding: 1.25rem;
  border-radius: 16px;
  border: 1px solid var(--color-border);
}

/* Animations pulse for trending */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.1); }
}
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* ==========================================================================
   7. Depth layer — 3D feel without heavy JS
   ========================================================================== */

/* Ambient drifting light orbs behind everything */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: -2;
}
body::before {
  width: 44vw;
  height: 44vw;
  top: -14vw;
  right: -10vw;
  background: radial-gradient(circle, rgba(24, 57, 43, 0.10), transparent 65%);
  animation: orbDriftA 26s ease-in-out infinite alternate;
}
body::after {
  width: 36vw;
  height: 36vw;
  bottom: -12vw;
  left: -8vw;
  background: radial-gradient(circle, rgba(184, 146, 74, 0.08), transparent 65%);
  animation: orbDriftB 34s ease-in-out infinite alternate;
}
@keyframes orbDriftA {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-6vw, 8vh, 0) scale(1.15); }
}
@keyframes orbDriftB {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(7vw, -6vh, 0) scale(1.1); }
}

/* Layered card depth: crisp top light edge + soft distant shadow */
#appShell section[class*="rounded-["],
#appShell div[class*="rounded-[28px]"],
.result-card {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 2px 4px rgba(17, 24, 20, 0.04),
    0 12px 24px -8px rgba(17, 24, 20, 0.10),
    0 32px 64px -24px rgba(17, 24, 20, 0.14);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 320ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
#appShell section[class*="rounded-["]:hover,
#appShell div[class*="rounded-[28px]"]:hover,
.result-card:hover {
  transform: perspective(1100px) translateY(-5px) rotateX(1deg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 4px 8px rgba(17, 24, 20, 0.05),
    0 24px 44px -12px rgba(17, 24, 20, 0.16),
    0 56px 96px -32px rgba(17, 24, 20, 0.20);
}

/* Search panel: floating slab */
.glass-panel {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(17, 24, 20, 0.04),
    0 18px 36px -10px rgba(17, 24, 20, 0.12),
    0 48px 96px -28px rgba(17, 24, 20, 0.18);
}
.glass-panel:focus-within {
  transform: perspective(1100px) translateY(-4px) rotateX(0.6deg) scale(1.005);
}

/* Buttons: pressable */
.btn-primary {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 4px 14px rgba(24, 57, 43, 0.25),
    0 14px 28px -10px rgba(24, 57, 43, 0.35);
}
.btn-primary:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(24, 57, 43, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  #appShell section[class*="rounded-["]:hover,
  #appShell div[class*="rounded-[28px]"]:hover,
  .result-card:hover,
  .glass-panel:focus-within { transform: none; }
}
