@layer reset, tokens, base, layout, components, pages, account, content, service, theme;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p, dl, dd { margin: 0; }
  button, input, textarea, select { font: inherit; }
  img, picture, svg { display: block; max-width: 100%; }
}

.ajax-inline-status {
  margin: .5rem 0 0;
  color: var(--color-muted, #68717a);
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.45;
}

.ajax-inline-status[data-state="success"] { color: #247348; }
.ajax-inline-status[data-state="error"] { color: #b42318; }
.ajax-inline-status[data-state="info"] { color: #59636d; }

button[aria-busy="true"] {
  cursor: wait;
  opacity: .72;
}

.ajax-skeleton { display: block; border-radius: 0.5rem; background: #e2e6e9; }

@layer tokens {
  :root {
    --color-canvas: #fafafa;
    --color-surface: #ffffff;
    --color-text: #292d31;
    --color-muted: #6c7379;
    --color-brand: #68717a;
    --color-brand-strong: #343a40;
    --color-accent: #c9a35f;
    --color-accent-soft: #f5efe4;
    --color-border: #dde1e4;
    --shadow-soft: 0 1rem 3rem rgb(52 58 64 / 9%);
    --radius-sm: 0.75rem;
    --radius-lg: 1.5rem;
    --space-1: 0.5rem;
    --space-2: 0.75rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;
    --shell: 78rem;
  }
}

@layer base {
  body {
    min-height: 100vh;
    background: var(--color-canvas);
    color: var(--color-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
  }

  a { color: inherit; }

  h1, h2, h3 { line-height: 1.18; text-wrap: balance; }

  h2 { font-size: clamp(1.75rem, 4vw, 3rem); }

  :focus-visible {
    outline: 0.2rem solid #68717a;
    outline-offset: 0.2rem;
  }
}

@layer layout {
  .shell {
    width: min(100% - 2rem, var(--shell));
    margin-inline: auto;
  }

  .site-header {
    position: sticky;
    z-index: 5;
    top: 0;
    background: rgb(255 255 255 / 96%);
    backdrop-filter: blur(1rem);
  }

  .site-footer__inner {
    display: grid;
    gap: var(--space-4);
  }

  .benefit-bar { background: var(--color-brand-strong); color: white; }
  .benefit-bar__inner { display: grid; grid-template-columns: repeat(4, 1fr); min-height: 2.4rem; align-items: center; gap: 1rem; font-size: 0.78rem; text-align: center; }
  .benefit-bar__inner span { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; }

  .site-header__main { display: grid; grid-template-columns: auto auto minmax(13rem, 1fr) auto; min-height: 5.6rem; align-items: center; gap: clamp(.7rem, 1.45vw, 1.35rem); }
  .site-header__search-mobile { display: none; }

  .site-footer {
    border-top: 1px solid var(--color-border);
    background: #31383c;
    color: #eef2f3;
    font-size: 0.875rem;
  }

  .site-footer__inner { padding-block: clamp(2.5rem, 6vw, 4.5rem) 1.5rem; }
  .site-footer__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(1.5rem, 4vw, 4rem); }
  .site-footer__bottom { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.5rem; border-top: 1px solid rgb(255 255 255 / 16%); color: #c9d0d3; }
  .site-footer__bottom p { margin: 0; }
}

@layer components {
  .ui-icon { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; overflow: visible; color: currentColor; }
  .ui-icon--empty { width: 3rem; height: 3rem; }
  a:has(> .ui-icon), button:has(> .ui-icon) { gap: 0.45rem; }
  .skip-link {
    position: fixed;
    z-index: 10;
    top: var(--space-3);
    left: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--color-text);
    color: white;
    transform: translateY(-200%);
  }

  .skip-link:focus { transform: translateY(0); }

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

  .brand {
    display: block;
    text-decoration: none;
  }

  .brand__logo { width: clamp(9.5rem, 17vw, 12.5rem); height: auto; }

  .site-search { position: relative; min-width: 0; }
  .site-search input { width: 100%; min-height: 3rem; padding: 0.65rem 3.4rem 0.65rem 1.1rem; border: 1px solid #cfd5dc; border-radius: 999px; background: #fbfcfd; color: var(--color-text); }
  .site-search input::placeholder { color: #7a828a; }
  .site-search button { position: absolute; top: 0.125rem; right: 0.2rem; display: grid; width: 2.75rem; height: 2.75rem; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--color-brand-strong); cursor: pointer; }
  .site-search button .ui-icon { width: 1.35rem; height: 1.35rem; }
  .site-search button:hover { background: #edf2f7; }
  .site-search__suggestions { position: absolute; z-index: 12; top: calc(100% + 0.4rem); right: 0; left: 0; overflow: hidden; border: 1px solid var(--color-border); border-radius: 0.85rem; background: var(--color-surface); box-shadow: 0 1rem 2.5rem rgb(30 35 40 / 16%); }
  .site-search__suggestions[hidden] { display: none; }
  .site-search__suggestions [role="listbox"] { display: grid; max-height: min(24rem, 60vh); overflow-y: auto; }
  .site-search__suggestion { display: grid; min-height: 4.2rem; grid-template-columns: 3rem minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; }
  .site-search__suggestion:is(:hover, [aria-selected="true"]) { background: var(--color-canvas); }
  .site-search__suggestion img { width: 3rem; height: 3rem; border-radius: 0.55rem; background: #f5eee5; object-fit: contain; }
  .site-search__suggestion span { min-width: 0; }
  .site-search__suggestion strong, .site-search__suggestion small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .site-search__suggestion strong { font-size: 0.86rem; }
  .site-search__suggestion small { margin-top: 0.15rem; color: var(--color-muted); font-size: 0.7rem; }
  .site-search__suggestion b { color: var(--color-brand-strong); font-size: 0.76rem; white-space: nowrap; }
  .site-search__suggestions > a { display: flex; min-height: 2.75rem; align-items: center; justify-content: center; color: #7a4d27; font-size: 0.78rem; font-weight: 800; text-decoration: none; }

  .header-actions { display: flex; align-items: center; gap: 1.25rem; }
  .header-action { position: relative; display: grid; min-width: 3.2rem; min-height: 3rem; place-items: center; color: var(--color-brand-strong); line-height: 1; text-align: center; }
  a.header-action { text-decoration: none; }
  .line-order-link { text-decoration: none; }
  .header-action > .ui-icon { width: 1.55rem; height: 1.55rem; }
  .header-action small { margin-top: 0.25rem; font-size: 0.68rem; white-space: nowrap; }
  .header-action b { position: absolute; top: -0.1rem; right: 0.05rem; display: grid; width: 1.1rem; height: 1.1rem; place-items: center; border-radius: 50%; background: var(--color-brand-strong); color: white; font-size: 0.62rem; }
  .header-action--cart.is-cart-bump > .ui-icon { animation: cart-bump 480ms cubic-bezier(.2,.9,.3,1); }
  .header-action--cart.is-cart-bump b { animation: cart-badge-bump 480ms cubic-bezier(.2,.9,.3,1); }
  .header-action--line { color: #079641; }

  .nav-link {
    display: inline-flex;
    min-height: 2.75rem;
    align-items: center;
    padding-inline: var(--space-3);
    border-radius: 999px;
    text-decoration: none;
  }

  .nav-link:hover { background: var(--color-canvas); }

  .desktop-nav,
  .footer-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }

  .footer-nav { gap: var(--space-4); }

  .footer-nav a { text-underline-offset: 0.2em; }

  .footer-section { display: grid; align-content: start; gap: 0.58rem; }
  .footer-section h2 { margin: 0 0 0.3rem; color: white; font-size: 1rem; }
  .footer-section a { color: #d7dcde; text-decoration: none; }
  .footer-section a:hover { color: white; text-decoration: underline; text-underline-offset: 0.18em; }
  .site-footer__line { display: inline-flex; min-height: 2.75rem; align-items: center; padding: 0.65rem 1rem; border-radius: 999px; background: #09a94b; color: white; font-weight: 800; text-decoration: none; white-space: nowrap; }

  .mobile-nav { display: none; }

  .cart-drawer {
    width: min(100%, 26rem);
    max-width: none;
    height: 100%;
    max-height: none;
    padding: 0;
    border: 0;
    margin: 0 0 0 auto;
    background: transparent;
  }

  .cart-drawer::backdrop { background: transparent; transition: background-color 220ms ease; }
  .cart-drawer.is-visible::backdrop { background: rgb(6 31 58 / 52%); }

  .cart-drawer__panel {
    display: grid;
    min-height: 100%;
    grid-template-rows: auto 1fr auto;
    padding: var(--space-3);
    background: var(--color-surface);
    box-shadow: -1rem 0 3rem rgb(6 31 58 / 18%);
    transform: translateX(100%);
    opacity: 0;
    transition: transform 220ms cubic-bezier(.2,.75,.25,1), opacity 180ms ease;
    will-change: transform, opacity;
  }
  .cart-drawer.is-visible .cart-drawer__panel { transform: translateX(0); opacity: 1; }
  .cart-drawer.is-closing .cart-drawer__panel { transform: translateX(100%); opacity: 0; }

  .cart-drawer__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .cart-drawer__header h2 { font-size: 1.2rem; }
  .cart-drawer__close { display: grid; width: 2.5rem; height: 2.5rem; padding: 0; place-items: center; border: 1px solid var(--color-border); border-radius: 50%; background: white; cursor: pointer; }
  .cart-drawer__body { position: relative; min-height: 0; padding-block: var(--space-3); overflow: auto; overscroll-behavior: contain; }
  .cart-drawer__body.is-loading > :not(.cart-drawer__skeleton) { visibility: hidden; }
  .cart-drawer__skeleton { position: absolute; inset: var(--space-4) 0 auto; display: grid; min-height: 8rem; grid-template-columns: 3.5rem minmax(0, 1fr) auto; align-items: start; gap: 0.75rem; pointer-events: none; }
  .cart-drawer__skeleton-image { width: 3.5rem; height: 4.4rem; }
  .cart-drawer__skeleton-copy { display: grid; gap: 0.5rem; }
  .cart-drawer__skeleton-copy .ajax-skeleton { width: 100%; height: 0.7rem; }
  .cart-drawer__skeleton-copy .ajax-skeleton:nth-child(2) { width: 62%; }
  .cart-drawer__skeleton-copy .ajax-skeleton:nth-child(3) { width: 78%; height: 2rem; margin-top: 0.2rem; }
  .cart-drawer__skeleton-price { width: 4.5rem; height: 0.8rem; }
  .cart-drawer__skeleton-total { width: 100%; height: 1.1rem; grid-column: 1 / -1; margin-top: 1rem; }
  .cart-drawer__body strong { color: var(--color-brand-strong); font-size: 1.2rem; }
  .cart-drawer__hint { margin-top: var(--space-2); color: var(--color-muted); font-size: 0.9rem; }
  .cart-drawer__empty { display: grid; min-height: 12rem; align-content: center; gap: 0.45rem; text-align: center; }
  .cart-drawer__empty p { color: var(--color-muted); font-size: 0.9rem; }
  .cart-drawer__lines { display: grid; padding: 0; margin: 0; gap: 0.65rem; list-style: none; }
  .cart-drawer__lines li { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr) auto; align-items: center; gap: 0.65rem; max-height: 8rem; padding-bottom: 0.65rem; overflow: hidden; border-bottom: 1px solid var(--color-border); transition: max-height 220ms ease, padding 220ms ease, opacity 160ms ease, transform 220ms ease; }
  .cart-drawer__lines li.is-removing { max-height: 0; padding-bottom: 0; border-bottom-color: transparent; opacity: 0; transform: translateX(1rem); }
  .cart-drawer__lines img { width: 3.25rem; height: 4rem; border-radius: 0.55rem; background: #eef5fa; object-fit: cover; }
  .cart-drawer__lines div { display: grid; min-width: 0; gap: 0.2rem; }
  .cart-drawer__lines a { display: -webkit-box; overflow: hidden; font-size: 0.86rem; font-weight: 760; line-height: 1.3; text-decoration: none; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .cart-drawer__lines strong { font-size: 0.82rem; white-space: nowrap; }
  .cart-drawer__line-actions { display: flex !important; align-items: center; gap: 0.3rem !important; margin-top: 0.2rem; }
  .cart-drawer__line-actions form { display: flex; align-items: center; }
  .cart-drawer__quantity-control { display: flex; align-items: center; gap: 0.3rem; color: var(--color-muted); font-size: 0.68rem; }
  .cart-drawer__line-actions select { min-width: 3rem; min-height: 2rem; padding: 0.15rem 1.25rem 0.15rem 0.4rem; border: 1px solid var(--color-border); border-radius: 0.5rem; background: #fff; }
  .cart-drawer__line-actions button { min-height: 2rem; padding: 0.25rem 0.5rem; border: 1px solid var(--color-border); border-radius: 0.5rem; background: #fff; color: var(--color-brand-strong); font-size: 0.7rem; font-weight: 750; white-space: nowrap; cursor: pointer; }
  .cart-drawer__line-actions button[aria-busy="true"] { cursor: wait; opacity: 0.68; }
  .cart-drawer__line-actions select[aria-busy="true"] { cursor: wait; opacity: 0.68; }
  .cart-drawer__line-actions .cart-drawer__remove { border-color: transparent; color: #9b2f2f; }
  .cart-drawer__total { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1rem; }
  .cart-drawer__total strong { font-size: 1.05rem; }
  .cart-drawer__checkout { display: grid; min-height: 3rem; place-items: center; border-radius: 999px; background: var(--color-brand-strong); color: white; font-weight: 750; text-decoration: none; }
  .cart-drawer__footer { display: grid; gap: 0.5rem; }
  .cart-drawer__status { min-height: 1.2rem; color: #286141; font-size: 0.78rem; text-align: center; }
  .cart-drawer__status[data-state="error"] { color: #a32929; }
  .cart-drawer [aria-busy="true"] { cursor: wait; }
  .is-value-changing { animation: cart-value-change 180ms ease-out; }
  .cart-flight { position: fixed; z-index: 30; border: 2px solid white; border-radius: 50%; box-shadow: 0 0.8rem 2rem rgb(6 31 58 / 28%); object-fit: cover; pointer-events: none; will-change: transform, opacity; }
  .cart-toast { position: fixed; z-index: 20; right: 1rem; bottom: 1rem; display: flex; max-width: min(28rem, calc(100vw - 2rem)); align-items: center; gap: 1rem; padding: 0.8rem 0.9rem 0.8rem 1rem; border: 1px solid #b8d7c4; border-radius: 0.8rem; background: #f2fff6; box-shadow: 0 1rem 3rem rgb(6 31 58 / 18%); color: #075d31; transform: translateY(1rem); opacity: 0; }
  .cart-toast[hidden] { display: none; }
  .cart-toast.is-visible { transform: translateY(0); opacity: 1; }
  .cart-toast a { min-height: 2.5rem; padding: 0.45rem 0.8rem; border-radius: 999px; background: #075d31; color: white; font-weight: 800; text-decoration: none; white-space: nowrap; }
}

@media (max-width: 64rem) {
  .benefit-bar__inner { display: flex; min-height: 2rem; justify-content: center; font-size: 0.7rem; }
  .benefit-bar__inner span { display: none; }
  .benefit-bar__inner span:first-child { display: inline-flex; }
  .site-header__main { position: relative; z-index: 2; grid-template-columns: 2.75rem 1fr 2.75rem; min-height: 4.25rem; gap: 0.5rem; }
  .site-header__main > .site-search { display: none; }
  .site-header__search-mobile { position: relative; z-index: 1; display: block; padding-bottom: 0.75rem; }
  .brand { justify-self: center; }
  .brand__logo { width: min(10rem, 48vw); }
  .header-actions { justify-self: end; }
  .header-action:not(.header-action--cart):not(.header-action--line),
  .header-action small { display: none; }
  .header-action { min-width: 2.75rem; }
  .header-action b { right: -0.1rem; }
  .desktop-nav { display: none; }
  .mobile-nav { position: relative; z-index: 3; display: block; }
  .mobile-nav summary { display: grid; width: 2.75rem; min-height: 2.75rem; cursor: pointer; place-items: center; font-weight: 700; list-style: none; }
  .mobile-nav summary .ui-icon { width: 1.45rem; height: 1.45rem; }
  .mobile-nav summary::-webkit-details-marker { display: none; }
  .mobile-nav nav { position: absolute; z-index: 4; left: 0; display: grid; width: 13rem; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); box-shadow: var(--shadow-soft); }
}

@media (max-width: 48rem) {
  .site-footer__inner { padding-block: 2rem 1.25rem; }
  .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.25rem; }
  .site-footer__bottom { align-items: flex-start; flex-direction: column; }
  .footer-nav { flex-wrap: wrap; }
  .cart-drawer { width: min(92vw, 24rem); }
  .cart-drawer__panel { padding: 0.85rem; }
  .cart-drawer__lines li { grid-template-columns: 3.25rem minmax(0, 1fr); align-items: start; }
  .cart-drawer__lines img { width: 3.25rem; height: 4rem; grid-row: 1 / span 2; }
  .cart-drawer__lines li > strong { grid-column: 2; justify-self: end; }
}

@media (max-width: 22rem) {
  .site-footer__grid { grid-template-columns: 1fr; gap: 1.75rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .skip-link { transition: transform 160ms ease; }
  .cart-toast { transition: opacity 180ms ease, transform 180ms ease; }
  [data-wishlist-form] button.is-wishlist-pop .ui-icon { transform-origin: center; animation: wishlist-heart-pop 320ms ease-out 1; }
  html { scroll-behavior: smooth; }
}

@keyframes cart-value-change { 0% { opacity: .45; transform: translateY(.2rem); } 100% { opacity: 1; transform: translateY(0); } }

@keyframes cart-bump {
  0%, 100% { transform: translateY(0) rotate(0); }
  38% { transform: translateY(-0.35rem) rotate(-9deg) scale(1.16); }
  70% { transform: translateY(0.08rem) rotate(5deg); }
}

@keyframes cart-badge-bump {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.38); background: #c8942e; }
}

@keyframes wishlist-heart-pop {
  0%, 100% { transform: scale(1); }
  48% { transform: scale(1.14); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@layer theme {
  .button--primary,
  .button--product,
  .button--checkout,
  .place-order,
  .account-primary,
  .service-card button,
  .content-empty a,
  .celestar-button--primary,
  .celestar-package-card button,
  .cart-drawer__checkout { background: var(--color-brand-strong); color: white; }

  .button--primary:hover,
  .celestar-button--primary:hover { background: #6b4525; }

  .button--secondary,
  .celestar-button--ghost { border-color: #a77a50; color: var(--color-brand-strong); }

  .button--light,
  .celestar-button--light { color: var(--color-brand-strong); }

  .text-link,
  .catalog-card__quick,
  .cart-line__actions button,
  .continue-link,
  .checkout-heading a,
  .checkout-account-note a,
  .content-link,
  .service-result a,
  .payment-receipt a,
  .account-links a,
  .celestar-text-link { color: #7a4d27; }

  .home-hero h1,
  .section-title-row h2,
  .catalog-hero h1,
  .catalog-toolbar h2,
  .catalog-card h3 a,
  .cart-hero h1,
  .cart-lines > h2,
  .cart-summary h2,
  .cart-line h3 a,
  .checkout-main h1,
  .checkout-main legend,
  .checkout-summary h2,
  .checkout-summary li strong,
  .success-card h1,
  .celestar-heading h2,
  .celestar-hero h1,
  .celestar-care-card h3,
  .celestar-steps h3,
  .celestar-service__copy h2,
  .celestar-faq-list summary { color: var(--color-brand-strong); }

  .catalog-hero,
  .cart-hero { background: #f5ede3; }

  .catalog-card__media,
  .cart-line__media,
  .cart-drawer__lines img,
  .quick-view img { background: #f5eee5; }

  .catalog-card__quantity { background: var(--color-brand); }
  .catalog-card__badge { background: var(--color-accent); }
  .catalog-card__body > strong,
  .result-count strong,
  .cart-line__total,
  .cart-summary dd,
  .checkout-summary dd,
  .success-card dd,
  .account-stats strong,
  .celestar-package-card > p,
  .celestar-facts dd,
  .celestar-hero__note { color: var(--color-brand-strong); }

  .payment-option:has(input:checked) { border-color: var(--color-brand); box-shadow: 0 0 0 2px rgb(104 113 122 / 14%); }
  .payment-option input { accent-color: var(--color-brand); }

  .celestar-eyebrow { color: #9a6b12; }
  .celestar-hero {
    background:
      radial-gradient(circle at 82% 20%, rgb(201 163 95 / 20%), transparent 22rem),
      radial-gradient(circle at 12% 92%, rgb(104 113 122 / 9%), transparent 18rem),
      linear-gradient(145deg, #fffaf4, #f3e7d7 60%, #fffaf4);
  }
  .celestar-purchase,
  .celestar-section--soft { background: #f8f2ea; }
  .celestar-section--ink {
    background:
      radial-gradient(circle at 20% 10%, rgb(201 163 95 / 15%), transparent 18rem),
      linear-gradient(145deg, #2f1d12, #5b371f);
  }
  .celestar-feature__copy .celestar-eyebrow,
  .celestar-closing__card .celestar-eyebrow { color: #efc979; }
  .celestar-check-list span { border-color: rgb(239 201 121 / 45%); color: #efc979; }
  .celestar-steps li { border-top-color: var(--color-accent); }
  .celestar-steps li > span { background: #f6ead8; color: #7a4d27; }
  .celestar-assurance .ui-icon { color: var(--color-brand); }
  .celestar-closing__card {
    background:
      radial-gradient(circle at 100% 0, rgb(239 201 121 / 18%), transparent 18rem),
      #343a40;
  }

  .account-nav a,
  .account-nav button { color: var(--color-brand-strong); }
  .account-nav a:hover,
  .account-nav button:hover,
  .order-meta span { background: #f3e9dd; }
}
