/* ==========================================================================
   Bloomy — Global Stylesheet
   Color tokens, reset, and shared components (nav bar) used on every
   customer-facing page. Page-specific styles live in their own files
   (home.css, listing.css, etc.) and load AFTER this one.
   ========================================================================== */

:root {
  --background: 0 0% 100%;
  --foreground: 30 8% 16%;
  --primary: 350 33% 64%;
  --primary-foreground: 0 0% 100%;
  --secondary: 24 47% 98%;
  --secondary-foreground: 30 8% 16%;
  --muted: 24 47% 98%;
  --muted-foreground: 30 8% 40%;
  --accent: 251 20% 62%;
  --accent-foreground: 0 0% 100%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 98%;
  --border: 24 30% 92%;
  --input: 24 30% 92%;
  --ring: 350 33% 64%;
  --radius: 1.25rem;

  --font-heading: "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Lora", ui-serif, Georgia, serif;
}

/* ---- Reset ---- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern";
  line-height: 1.5;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
}

ul {
  list-style: none;
}

/* Respect reduced-motion preference site-wide */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Visible keyboard focus everywhere (buttons, links, inputs) */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Any anchor-jump target (e.g. #featured) needs this, or the sticky nav
   covers its top ~73px, making the landing spot look like it's still on
   the previous section. */
[id] {
  scroll-margin-top: var(--nav-height, 73px);
}

/* ---- Shared layout container ---- */
.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---- Shared buttons (used across every page, not just the hero) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background-color: hsl(var(--primary) / 0.9);
}

.btn-outline {
  background-color: hsl(var(--background) / 0.7);
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background-color: hsl(var(--background));
}

/* ==========================================================================
   Site nav — shared across Homepage, Listing, Detail, Cart, Checkout,
   Order Confirmation. Sticky so it stays visible on scroll (matches every
   mockup screenshot, which shows it identically positioned at different
   scroll depths).
   ========================================================================== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: hsl(var(--background) / 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}

/* Applied via JS once the page scrolls past the hero — subtle separation
   from content instead of the nav floating with no edge. */
.site-nav.is-scrolled {
  border-bottom-color: hsl(var(--border));
}

.site-nav .container {
  display: flex;
  align-items: center;
  gap: 32px;
  padding-block: 14px;
}

.site-nav__logo {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.75rem;
  color: hsl(var(--foreground));
  flex-shrink: 0;
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 28px;
  flex: 1;
}

.site-nav__links a {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: hsl(var(--foreground));
  white-space: nowrap;
}

.site-nav__links a:hover {
  color: hsl(var(--primary));
}

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.site-nav__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 10px 16px;
  width: 220px;
}

.site-nav__search svg {
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
}

.site-nav__search input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.85rem;
  color: hsl(var(--foreground));
  width: 100%;
}

.site-nav__search input::placeholder {
  color: hsl(var(--muted-foreground));
}

.site-nav__search {
  position: relative; /* anchor for the dropdown below */
}

.site-nav__search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  box-shadow: 0 16px 32px hsl(var(--foreground) / 0.12);
  padding: 8px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 60; /* above .site-nav's z-index: 50 */
}

.site-nav__search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}

.site-nav__search-result:hover {
  background-color: hsl(var(--secondary));
}

.site-nav__search-result img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.site-nav__search-result-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-nav__search-result-price {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}

.site-nav__search-empty {
  padding: 12px 8px;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

.site-nav__cart {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.site-nav__cart-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-inline: 3px;
}

/* Hide the count badge entirely when the cart is empty (toggled via JS,
   not display:none by default — 0 items still needs the icon to render) */
.site-nav__cart-count[hidden] {
  display: none;
}

/* Mobile menu panel + backdrop are hidden by default at every width.
   The @media block below only handles showing them again (and only once
   .is-open is also present) under 900px — without this base rule they
   fell back to the browser default (block), rendering unstyled on desktop. */
.site-nav__backdrop,
.site-nav__mobile-panel {
  display: none;
}

/* ---- Shared product card (used on Homepage's featured grid and will be
   reused on Listing's product grid — kept here, not in home.css, so both
   pages reference the same styles instead of duplicating them) ---- */
.product-card__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 16px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.product-card:hover .product-card__image {
  transform: scale(1.04);
  box-shadow: 0 0 32px 4px hsl(var(--primary) / 0.22);
}

.product-card__name {
  font-weight: 600;
  margin-bottom: 4px;
  transition: color 0.2s ease;
}

.product-card:hover .product-card__name {
  color: hsl(var(--primary));
}

.product-card__price {
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
}

/* ---- Shared product grid (used by Homepage's featured grid and
   Listing's product grid — same reasoning as .product-card above) ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- Shared breadcrumb (used on Listing, About, and any inner page
   with a "Trang chủ › X" trail — moved here once a second page needed
   it, same reasoning as .product-grid and the footer) ---- */
.breadcrumb {
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 24px;
}

.breadcrumb a:hover {
  color: hsl(var(--primary));
}

.breadcrumb span {
  margin-inline: 4px;
}

/* ---- Shared section heading (eyebrow/title/lead pattern used by
   Homepage's category-nav/featured/features/testimonials and by About's
   value-cards heading) — moved here once a second page needed it ---- */
.section-heading {
  text-align: center;
  max-width: 640px;
  margin-inline: auto;
  margin-bottom: 48px;
}

.section-heading__eyebrow {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--primary));
  margin-bottom: 12px;
}

.section-heading__title {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.section-heading__title em {
  color: hsl(var(--primary));
  font-style: italic;
}

.section-heading__lead {
  color: hsl(var(--muted-foreground));
}

/* ---- Mobile nav ---- */
.site-nav__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: hsl(var(--foreground));
  width: 40px;
  height: 40px;
}

/* Toggle button holds both icons; JS swaps which is visible by adding
   .is-open to .site-nav (not the button) so the backdrop/panel below can
   key off the same class. */
.site-nav__toggle .icon-close {
  display: none;
}

.site-nav.is-open .site-nav__toggle .icon-menu {
  display: none;
}

.site-nav.is-open .site-nav__toggle .icon-close {
  display: block;
}

@media (max-width: 900px) {
  .site-nav .container {
    padding-block: 14px;
  }

  .site-nav__links {
    display: none;
  }

  .site-nav__search {
    display: none;
  }

  .site-nav__actions {
    margin-left: auto;
  }

  .site-nav__toggle {
    display: flex;
  }

  /* Dimmed backdrop behind the dropdown panel. Visual only — deliberately
     no click-to-close handler; the X button is the only way to close.
     pointer-events left enabled so it still blocks accidental taps on
     whatever's underneath while the menu is open. */
  .site-nav__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--nav-height, 73px);
    background-color: hsl(var(--foreground) / 0.35);
    z-index: 40;
  }

  .site-nav.is-open .site-nav__backdrop {
    display: block;
  }

  /* Mobile menu panel: overlays the page (doesn't push content), anchored
     directly under the fixed header. */
  .site-nav__mobile-panel {
    display: none;
    position: fixed;
    top: var(--nav-height, 73px);
    left: 0;
    right: 0;
    z-index: 41;
    background-color: hsl(var(--background) / 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 0 0 24px 24px;
    box-shadow: 0 16px 32px hsl(var(--foreground) / 0.12);
    padding: 12px 16px 16px;
    flex-direction: column;
    max-height: calc(100vh - var(--nav-height, 73px));
    overflow-y: auto;
  }

  .site-nav.is-open .site-nav__mobile-panel {
    display: flex;
  }

  .site-nav__mobile-panel .site-nav__search {
    display: flex;
    width: 100%;
    margin-bottom: 2px;
    padding: 8px 14px;
  }

  .site-nav__mobile-panel a {
    display: block;
    padding: 11px 4px;
    font-size: 0.88rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    border-bottom: 1px solid hsl(var(--border));
  }

  .site-nav__mobile-panel a:last-child {
    border-bottom: none;
  }
}
/* ==========================================================================
   Shared footer — identical markup on every customer-facing page, moved
   here from home.css (same reasoning as .product-grid: shared markup
   needs shared CSS, or pages loading only their own page-specific file
   render it completely unstyled).
   ========================================================================== */
.site-footer {
  background-color: hsl(var(--foreground));
  color: hsl(var(--background) / 0.7);
  padding-block: 64px 32px;
}

.site-footer .container {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 48px;
}

.site-footer__brand-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
  color: hsl(var(--background));
  margin-bottom: 16px;
}

.site-footer__desc {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 20px;
  max-width: 32ch;
}

.site-footer__social {
  display: flex;
  gap: 12px;
}

.site-footer__social a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid hsl(var(--background) / 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--background));
}

.site-footer__col h4 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--background) / 0.5);
  margin-bottom: 16px;
}

.site-footer__col ul li {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.site-footer__col ul li a:hover {
  color: hsl(var(--background));
}

.site-footer__contact li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.site-footer__bottom {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  align-items: center;
  gap: 40px;
  padding-top: 24px;
  border-top: 1px solid hsl(var(--background) / 0.15);
  font-size: 0.8rem;
}

/* Copyright text is the last child in the row — placed in the grid's
   4th column so it lines up under "Chính sách" above it. */
.site-footer__bottom > *:last-child {
  grid-column: 4;
}

.payment-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.payment-badge {
  padding: 6px 14px;
  border: 1px solid hsl(var(--background) / 0.25);
  border-radius: 999px;
  font-size: 0.75rem;
}

@media (max-width: 900px) {
  .site-footer .container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .site-footer .container {
    grid-template-columns: 1fr;
  }

  .site-footer__bottom {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .site-footer__bottom > *:last-child {
    grid-column: 1;
  }
}

/* ---- Shared icon/title/desc card (About's value cards, Story's
   philosophy cards — same component, moved here on 2nd real use) ---- */
.value-card {
  background-color: hsl(var(--background));
  border-radius: var(--radius);
  padding: 24px;
}

.value-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-color: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.value-card__title {
  font-weight: 600;
  margin-bottom: 8px;
}

.value-card__desc {
  font-size: 0.88rem;
  line-height: 1.6;
  color: hsl(var(--muted-foreground));
}

/* ---- Shared quantity stepper (Product Detail's quantity selector, now
   also Cart's per-line-item control — promoted here on Cart's need, same
   "promote on 2nd real use" rule as .product-grid/.breadcrumb/.value-card
   above) ---- */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 6px;
}

.qty-stepper button {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 50%;
  font-size: 1.1rem;
  color: hsl(var(--foreground));
}

.qty-stepper button:hover {
  background-color: hsl(var(--secondary));
}

.qty-stepper span {
  width: 28px;
  text-align: center;
  font-weight: 600;
}

/* ---- Shared status badge (Product Detail's discontinued badge, Cart's
   discontinued-item flag — promoted on 2nd use) ---- */
.status-badge {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge--discontinued {
  background-color: hsl(var(--foreground) / 0.85);
  color: hsl(var(--background));
}

/* ---- Shared disabled-button state (Add to cart when discontinued,
   Checkout CTA when a discontinued item is in the cart — generalized
   from what was a one-off #add-to-cart:disabled rule in product.css) ---- */
.btn-primary:disabled,
.btn-primary:disabled:hover {
  background-color: hsl(var(--muted-foreground) / 0.3);
  color: hsl(var(--background));
  cursor: not-allowed;
}

/* ---- Shared empty/not-found state (Cart's empty-cart view, now also
   Checkout's empty-cart guard and Order Confirmation's invalid-token
   state — promoted here on the 3rd real use, same rule as everything
   else in this section) ---- */
.cart-empty {
  text-align: center;
  max-width: 440px;
  margin-inline: auto;
  padding-block: 96px;
}

.cart-empty__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.cart-empty__heading {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.cart-empty__heading em {
  color: hsl(var(--primary));
  font-style: italic;
}

.cart-empty__subtitle {
  color: hsl(var(--muted-foreground));
  margin-bottom: 28px;
}

/* ---- Shared order-summary sidebar (Checkout's order total, now also
   Order Confirmation's order recap — promoted here on Confirmation's
   need, same "promote on 2nd real use" rule as everything else above).
   Checkout-only pieces (submit button, its help text, the error message)
   stay local to checkout.css, since Confirmation has no equivalent. ---- */
.checkout-summary {
  background-color: hsl(var(--secondary));
  border-radius: var(--radius);
  padding: 28px;
  position: sticky;
  top: calc(var(--nav-height, 73px) + 24px);
}

.checkout-summary__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 20px;
}

.checkout-summary__items {
  margin-bottom: 4px;
}

.checkout-summary__item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.checkout-summary__item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}

.checkout-summary__item-info {
  flex: 1;
  min-width: 0;
}

.checkout-summary__item-name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkout-summary__item-qty {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
}

.checkout-summary__item-total {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.checkout-summary__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  margin-bottom: 14px;
  color: hsl(var(--muted-foreground));
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
}

.checkout-summary__items + .checkout-summary__row {
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
}

.checkout-summary__free {
  color: hsl(var(--primary));
  font-weight: 600;
}

.checkout-summary__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
  margin-bottom: 20px;
  font-weight: 600;
}

.checkout-summary__total span:last-child {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: hsl(var(--primary));
}

.checkout-summary__notes {
  font-size: 0.82rem;
  color: hsl(var(--muted-foreground));
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
}

.checkout-summary__notes li {
  margin-bottom: 8px;
}

/* Un-stick once the host page's own 2-column layout collapses to 1 —
   both Checkout and Order Confirmation collapse at the same 900px, so
   this lives here instead of being duplicated in both page stylesheets. */
@media (max-width: 900px) {
  .checkout-summary {
    position: static;
  }
}
