/* ============================================
   Fancy Baking v3 - Design Tokens (shadcn-style)
   Warm cream light theme / cozy dark theme
   ============================================ */

:root {
  /* Native controls (select arrows, search clear buttons, scrollbars and
     date pickers) follow the page theme instead of the OS default. */
  color-scheme: light;
  --background: 40 40% 98%;
  --foreground: 24 10% 10%;
  --card: 0 0% 100%;
  --card-foreground: 24 10% 10%;
  --muted: 32 30% 94%;
  --muted-foreground: 25 5% 42%;
  --border: 30 15% 89%;
  --input: 30 15% 89%;
  --primary: 344 72% 46%;
  --primary-foreground: 0 0% 100%;
  --secondary: 32 30% 94%;
  --secondary-foreground: 24 10% 12%;
  --accent: 34 60% 90%;
  --accent-foreground: 24 10% 12%;
  --ring: 344 72% 46%;
  --radius: 0.75rem;
}

.dark {
  color-scheme: dark;
  --background: 24 12% 8%;
  --foreground: 36 25% 92%;
  --card: 24 10% 11%;
  --card-foreground: 36 25% 92%;
  --muted: 24 8% 16%;
  --muted-foreground: 33 10% 62%;
  --border: 24 8% 20%;
  --input: 24 8% 20%;
  --primary: 344 80% 70%;
  --primary-foreground: 24 20% 8%;
  --secondary: 24 8% 16%;
  --secondary-foreground: 36 25% 92%;
  --accent: 24 10% 18%;
  --accent-foreground: 36 25% 92%;
  --ring: 344 80% 70%;
}

/* Base */
* {
  border-color: hsl(var(--border));
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Plus Jakarta Sans", "Futura", ui-sans-serif, system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.font-display {
  font-family: "Fraunces", "Playfair Display", Georgia, serif;
}

::selection {
  background: hsl(var(--primary) / 0.25);
}

:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* The hidden attribute must always win over utility display classes (e.g. .flex) */
[hidden] {
  display: none !important;
}

/* Sticky header elevation once the page is scrolled */
[role="banner"].is-scrolled,
header.sticky.is-scrolled {
  background-color: hsl(var(--background) / 0.92);
  box-shadow: 0 10px 30px -18px rgb(28 15 5 / 0.35);
}

/* Gentle reveal-on-scroll for below-the-fold sections (enhancements.js) */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Large generated product grids: let the browser skip off-screen card work */
.product-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}

/* The two-column phone grid hides the description and uses a shorter image,
   so reserve the smaller height there to avoid a tall placeholder. */
@media (max-width: 639px) {
  .product-card--compact {
    contain-intrinsic-size: auto 270px;
  }
}

/* The category sidebar is now long enough to overflow short laptop screens. */
@media (min-width: 1024px) {
  aside[aria-label="Product categories"] > div {
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
  }
}

/* Gentle floating animation for hero artwork */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}

/* Accessibility: skip-to-content link (visible on keyboard focus) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  transition: top 0.2s ease-in-out;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Floating back-to-top button (injected by enhancements.js) */
#back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
  background-color: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

#back-to-top svg {
  width: 1.125rem;
  height: 1.125rem;
}

#back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Mobile order bar (injected by shop-list.js): keep the page and the
   back-to-top button clear of it. */
@media (max-width: 767px) {
  body.has-order-bar {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }

  body.has-order-bar #back-to-top {
    bottom: calc(5.75rem + env(safe-area-inset-bottom));
  }

  /* Round icon buttons in the header and the order drawer are 36px by
     default. Give them a 44px touch target on phones without changing the
     desktop header. */
  [data-menu-toggle],
  [data-theme-toggle],
  [data-list-open][aria-label],
  [data-list-close] {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  /* Footer links sit in lists, not sentences, so they need a full 24px
     target rather than the line-height of the text alone. Generated pages
     use a div with role="contentinfo", so target the shared id. */
  #footer ul a {
    display: inline-block;
    padding-block: 0.125rem;
  }
}

/* "Ordering: <product>" chip shown on the order page via ?product= */
.order-product-chip {
  margin: 1.5rem auto -1.75rem;
  max-width: 28rem;
  padding: 0.625rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  line-height: 1.45;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.06);
}

/* Live store status on the contact page (enhancements.js) */
[data-open-status] [data-open-dot] {
  background-color: hsl(var(--muted-foreground));
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

[data-open-status][data-state="open"] {
  border-color: hsl(145 55% 78%);
  background-color: hsl(145 55% 96%);
  color: hsl(145 55% 26%);
}

.dark [data-open-status][data-state="open"] {
  border-color: hsl(145 40% 30%);
  background-color: hsl(145 40% 13%);
  color: hsl(145 60% 74%);
}

[data-open-status][data-state="open"] [data-open-dot] {
  background-color: hsl(145 65% 40%);
  box-shadow: 0 0 0 3px hsl(145 65% 40% / 0.18);
}

/* Shopping list (assets/js/shop-list.js) */
[data-add-to-list][data-added="true"] [data-icon-add] {
  display: none;
}

[data-add-to-list][data-added="true"] [data-icon-check] {
  display: block;
}

[data-add-to-list][data-added="true"] {
  border-color: hsl(var(--primary));
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Quantities are typed as well as stepped; hide the tiny browser spinners. */
.qty-input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.shoplist-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: rgb(20 12 8 / 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.shoplist-backdrop.is-open {
  opacity: 1;
}

.shoplist-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 26rem;
  border-left: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: -24px 0 60px -24px rgb(20 12 8 / 0.45);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.shoplist-panel.is-open {
  transform: none;
}

.shoplist-panel[hidden],
.shoplist-backdrop[hidden] {
  display: none;
}

body.shoplist-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
