/* ux-polish.css — Cahier de Recette UX: touch-first, warm, fluid
 * Owns: bottom nav, skeleton loading, transitions, mobile touch targets
 * Does NOT own: page-specific layouts, color tokens (see theme.css)
 */

/* ── Bottom Navigation Bar ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  background: rgba(247, 242, 232, 0.94);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid rgba(160, 98, 42, 0.15);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 24px rgba(80, 40, 10, 0.08);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--fg-dim);
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s ease;
  min-height: 44px;
  cursor: pointer;
  border: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  padding: 6px 4px;
}

.bottom-nav-item:active {
  transform: scale(0.94);
  transition: transform 0.08s ease, color 0.15s ease;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--accent-amber);
}

.bottom-nav-icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
}

.bottom-nav-label {
  font-size: 0.6rem;
  line-height: 1;
}

/* Body padding to account for bottom nav */
body.has-bottom-nav {
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

/* ── Paper Texture Overlay ──────────────────────────────────────────── */
/* Subtle grain on light background — barely perceptible warmth */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 300px 300px;
}

/* ── Skeleton Loading ───────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(160, 98, 42, 0.06) 0%,
    rgba(160, 98, 42, 0.14) 50%,
    rgba(160, 98, 42, 0.06) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

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

.skeleton-card {
  background: var(--bg-card);
  border: 1px solid rgba(160, 98, 42, 0.1);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  animation: cardIn 0.4s ease-out backwards;
  box-shadow: 0 2px 8px rgba(80, 40, 10, 0.07);
}

.skeleton-line {
  height: 16px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-100 { width: 100%; }
.skeleton-line.h-12 { height: 12px; }
.skeleton-line.h-20 { height: 20px; }
.skeleton-line.h-28 { height: 28px; }

.skeleton-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.skeleton-tag {
  height: 26px;
  width: 70px;
  border-radius: 100px;
}

/* ── Page Transition ────────────────────────────────────────────────── */
body {
  animation: pageFadeIn 0.25s ease-out;
}

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

/* ── Card Slide-Up ──────────────────────────────────────────────────── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Touch Targets ──────────────────────────────────────────────────── */
/* All interactive elements: minimum 44×44px tap target */
button,
a,
[role="button"],
input[type="submit"],
select,
.featured-chip,
.autocomplete-item,
.ingredient-option,
.bottom-nav-item {
  min-height: 44px;
}

/* But don't force tags/badges to be that tall */
.pairing-tag,
.counter-chip,
.pro-badge,
.tag-chip,
.card-share-btn {
  min-height: unset;
}

/* ── Sticky Search Bar (mobile) ─────────────────────────────────────── */
@media (max-width: 768px) {
  .search-hero {
    position: sticky;
    top: 0;
    z-index: 150;
    padding-top: 3rem !important;
    padding-bottom: 1.5rem !important;
    min-height: unset !important;
    background:
      radial-gradient(ellipse 90% 100% at 50% 0%, rgba(160,98,42,0.05) 0%, transparent 80%),
      rgba(247, 242, 232, 0.97) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(160, 98, 42, 0.1);
  }

  /* Hide hero text on mobile when sticky — just show search */
  .search-hero-label,
  .search-hero-sub {
    display: none;
  }

  .search-hero h1 {
    font-size: 1.5rem !important;
    margin-bottom: 1rem !important;
  }
}

/* ── Search Bar Real-time: hide button on mobile ────────────────────── */
@media (max-width: 600px) {
  .search-btn {
    display: none;
  }

  .search-bar-inner {
    padding-right: 1rem !important;
  }
}

/* ── Swipe Hint on Cards ────────────────────────────────────────────── */
.pairing-card {
  touch-action: pan-y;
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.23, 1, 0.32, 1),
              border-color 0.3s ease,
              box-shadow 0.3s ease !important;
}

.pairing-card.swipe-left {
  transform: translateX(-8px) rotate(-0.5deg);
  border-color: rgba(160, 98, 42, 0.35) !important;
}

.pairing-card.swipe-right {
  transform: translateX(8px) rotate(0.5deg);
  border-color: rgba(184, 134, 11, 0.35) !important;
}

/* ── Hero CTA Button ─────────────────────────────────────────────────── */
.hero-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--accent-amber);
  color: #faf6ee;
  text-decoration: none;
  border-radius: 14px;
  padding: 1rem 2.25rem;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
  box-shadow: 0 4px 20px rgba(160, 98, 42, 0.25);
  margin-top: 1rem;
  min-height: 56px;
}

.hero-cta-btn:hover {
  background: var(--accent-copper);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(160, 98, 42, 0.35);
}

.hero-cta-btn:active {
  transform: scale(0.97);
}

.hero-cta-arrow {
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.hero-cta-btn:hover .hero-cta-arrow {
  transform: translateX(3px);
}

/* ── Search Real-time Indicator ─────────────────────────────────────── */
.search-live-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-amber);
  animation: livePulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

.search-live-dot.active {
  display: inline-block;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ── Nav refinements ─────────────────────────────────────────────────── */
.nav-back,
.lang-switcher,
.search-counter {
  z-index: 190;
}

/* ── Form mobile: generous spacing ─────────────────────────────────── */
@media (max-width: 600px) {
  .form-input,
  .form-textarea {
    padding: 1rem 1.1rem !important;
    font-size: 16px !important; /* prevent iOS zoom on focus */
    min-height: 52px;
  }

  .form-label {
    font-size: 0.85rem !important;
    margin-bottom: 0.6rem !important;
  }

  .submit-btn {
    padding: 1.1rem 2rem !important;
    font-size: 1rem !important;
    min-height: 56px !important;
    border-radius: 16px !important;
  }

  .form-card {
    padding: 1.5rem 1.25rem !important;
  }
}

/* ── Responsive bottom-nav: show on mobile, hide on desktop ─────────── */
@media (min-width: 1024px) {
  .bottom-nav {
    display: none;
  }

  body.has-bottom-nav {
    padding-bottom: 0;
  }
}

/* ── Desktop Top-Bar Navigation ─────────────────────────────────────── */
/* Hidden on mobile; shown alongside the bottom-nav breakpoint */
.top-bar-nav {
  display: none;
}

@media (min-width: 1024px) {
  .top-bar-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
  }
}

.top-bar-nav-link {
  padding: 0.38rem 0.8rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-dim);
  text-decoration: none;
  border-radius: 8px;
  letter-spacing: 0.02em;
  transition: color 0.18s ease, background 0.18s ease;
}

.top-bar-nav-link:hover {
  color: var(--accent-amber);
  background: rgba(212, 149, 90, 0.07);
}

.top-bar-nav-link.active {
  color: var(--accent-amber);
  background: rgba(212, 149, 90, 0.1);
}

/* ── Ensure content z-index is above paper texture ─────────────────── */
.hero,
.search-hero,
.results-section,
.empty-state,
.contribute-page,
.philosophy,
.engine,
.dimensions,
.closing,
.footer {
  position: relative;
  z-index: 1;
}

/* ── Page Exit Transition ────────────────────────────────────────────── */
/* Matches ux-transitions.js .page-exiting class */
.page-exiting {
  animation: pageExitFade 0.18s ease-in forwards !important;
}

@keyframes pageExitFade {
  to { opacity: 0; transform: translateY(-5px); }
}

/* ── Button Tap Micro-interaction ────────────────────────────────────── */
.btn-tap-active {
  transform: scale(0.95) !important;
  opacity: 0.82 !important;
  transition: transform 0.06s ease, opacity 0.06s ease !important;
}

/* ── Card Hover Lift (unified across all pages) ──────────────────────── */
.pairing-card:hover,
.chef-card:hover,
.composition-card:hover,
.featured-chip:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 36px rgba(80, 40, 10, 0.16) !important;
}

/* ── Lazy Image Placeholder ──────────────────────────────────────────── */
img.img-lazy {
  filter: blur(6px);
  transition: filter 0.35s ease;
}
img.img-loaded {
  filter: blur(0);
}

/* ── Sticky Search Bar Wrapper ────────────────────────────────────────── */
.search-bar-sticky-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 180;
  padding: 0.6rem 1rem;
  background: rgba(247, 242, 232, 0.97);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid rgba(160, 98, 42, 0.13);
  box-shadow: 0 2px 16px rgba(80, 40, 10, 0.1);
  /* Hidden by default — JS adds .visible */
  transform: translateY(-110%);
  transition: transform 0.25s cubic-bezier(0.23, 1, 0.32, 1);
}

.search-bar-sticky-wrap.visible {
  transform: translateY(0);
}

/* Hide sticky bar on mobile (search-hero is already sticky there) */
@media (max-width: 768px) {
  .search-bar-sticky-wrap {
    display: none;
  }
}

/* ── Search Clear Button ─────────────────────────────────────────────── */
.search-clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-dim);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.35rem;
  min-height: unset;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.search-clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.search-clear-btn:hover {
  color: var(--accent-amber);
}

/* ── Heart/Star Pop Animation ─────────────────────────────────────────── */
@keyframes heartPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.heart-animate {
  animation: heartPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Stagger Utility (add class to parent) ────────────────────────────── */
.stagger-children > *:nth-child(1)  { animation-delay: 0ms; }
.stagger-children > *:nth-child(2)  { animation-delay: 65ms; }
.stagger-children > *:nth-child(3)  { animation-delay: 130ms; }
.stagger-children > *:nth-child(4)  { animation-delay: 195ms; }
.stagger-children > *:nth-child(5)  { animation-delay: 260ms; }
.stagger-children > *:nth-child(6)  { animation-delay: 325ms; }
.stagger-children > *:nth-child(7)  { animation-delay: 390ms; }
.stagger-children > *:nth-child(8)  { animation-delay: 455ms; }

/* ── Skeleton Title / Badge helpers ──────────────────────────────────── */
.skeleton-title { height: 18px; width: 55%; }
.skeleton-badge { height: 14px; width: 35%; border-radius: 100px; }
.skeleton-text-sm { height: 13px; margin-bottom: 8px; }
.skeleton-text-xs { height: 11px; width: 60%; }
