/* Debrowser demo store. Uses the site tokens (src/styles/tokens.css, inlined
   by the layout) through custom properties; this file is served as written so
   the Styles panel shows nesting, :has(), container queries, color-mix(),
   oklch and relative colours as authored. */

:root {
  --shop-header-h: 3.5rem;
  --shop-glow: color-mix(in oklch, var(--brand-cyan) 45%, transparent);
  --shop-pedestal: radial-gradient(
    60% 100% at 50% 100%,
    color-mix(in oklch, var(--brand-ultramarine) 22%, transparent),
    transparent 70%
  );
  --lamp-light: oklch(0.97 0.04 210);
  --lamp-finish: var(--brand-ultramarine);
}

@media (prefers-color-scheme: dark) {
  :root {
    --shop-glow: color-mix(in oklch, var(--brand-cyan) 60%, transparent);
    --shop-pedestal: radial-gradient(
      60% 100% at 50% 100%,
      color-mix(in oklch, var(--brand-cyan) 26%, transparent),
      transparent 70%
    );
  }
}

html {
  scroll-padding-top: calc(var(--shop-header-h) + var(--space-6));
}

/* Header: the floating glass bar from the site nav, plus a cart badge */
.store-header {
  position: sticky;
  top: var(--space-3);
  z-index: 20;
  padding-inline: var(--space-3);

  & .store-header__bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    max-width: 75rem;
    height: var(--shop-header-h);
    margin-inline: auto;
    padding: 0 var(--space-2) 0 var(--space-4);
    background:
      linear-gradient(
          color-mix(in oklch, var(--color-surface) 72%, transparent),
          color-mix(in oklch, var(--color-surface) 72%, transparent)
        )
        padding-box,
      var(--edge-spec) border-box;
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
  }

  & .store-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text);
    font-weight: var(--weight-strong);
    text-decoration: none;

    & img {
      filter: drop-shadow(0 0 10px var(--shop-glow));
    }
  }

  & .store-header__links {
    display: none;
    gap: var(--space-1);
    margin: 0 auto;
    padding: 0;
    list-style: none;

    & a {
      display: block;
      padding: var(--space-2) var(--space-3);
      border-radius: var(--radius-sm);
      color: var(--color-text-muted);
      font-size: var(--text-small);
      text-decoration: none;
      transition: background var(--duration-fast) var(--ease-out);

      &:hover {
        background: var(--color-accent-soft);
        color: var(--color-text);
      }
    }
  }

  & .store-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
  }

  & .store-header__wish {
    color: var(--color-text-faint);
    font-size: var(--text-label);
  }

  @media (min-width: 48rem) {
    & .store-header__links {
      display: flex;
    }
    & .store-header__actions {
      margin-left: 0;
    }
  }
}

.cart-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--inset-spec);
  cursor: pointer;
  transition: box-shadow var(--duration-fast) var(--ease-out);

  &:hover {
    box-shadow: var(--inset-spec), var(--glow-cyan);
  }

  & .cart-button__badge {
    position: absolute;
    top: -0.375rem;
    right: -0.375rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding-inline: 0.3rem;
    border-radius: var(--radius-xs);
    background: var(--brand-ultramarine);
    color: var(--color-on-accent);
    font: var(--weight-mono) 0.6875rem/1.25rem var(--font-mono);
    text-align: center;
    scale: 0;
    transition: scale var(--duration-base) var(--ease-out);
  }
}

/* The badge only appears once the cart has something in it */
.store-header:not([data-cart-count="0"]) .cart-button__badge {
  scale: 1;
  box-shadow: 0 0 12px var(--shop-glow);
}

/* Hero: centred like the site hero, a lamp inside the orbit */
.store-hero {
  position: relative;
  margin-top: calc(-1 * (var(--shop-header-h) + var(--space-3)));
  padding-top: calc(var(--shop-header-h) + var(--space-9));
  overflow: clip;
  text-align: center;

  & .store-hero__inner {
    position: relative;
    display: grid;
    justify-items: center;
    gap: var(--space-5);
  }

  & .store-hero__title {
    margin: 0;

    & span {
      display: block;
    }
  }

  & .store-hero__lead {
    max-width: 52ch;
    margin: 0;
  }

  & .store-hero__actions {
    justify-content: center;
  }
}

.store-hero__stage {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(100%, 40rem);
  margin: var(--space-6) 0 0;
  padding-bottom: var(--space-8);
  background: var(--shop-pedestal) bottom / 100% 40% no-repeat;

  & .lamp {
    width: min(70%, 22rem);
    height: auto;
    filter: drop-shadow(
      0 30px 40px
        color-mix(in oklch, var(--brand-ultramarine-900) 35%, transparent)
    );
  }

  & figcaption {
    font-size: var(--text-label);
  }
}

.store-hero__ring {
  position: absolute;
  inset: 38% -10% auto;
  width: 120%;
  rotate: -7deg;
  pointer-events: none;

  & ellipse {
    fill: none;
    stroke: var(--orbit-line);
    stroke-width: 1.5;
    filter: drop-shadow(0 0 6px var(--orbit-glow));
  }
}

/* Lamp illustrations: shade colour from --lamp-finish via relative oklch */
.lamp {
  display: block;

  & .lamp__shade-hi {
    stop-color: oklch(from var(--lamp-finish) calc(l + 0.18) c h);
  }
  & .lamp__shade-mid {
    stop-color: var(--lamp-finish);
  }
  & .lamp__shade-lo {
    stop-color: oklch(from var(--lamp-finish) calc(l - 0.22) c h);
  }
  & .lamp__glow-stop {
    stop-color: var(--lamp-light);
  }
  & .lamp__cord,
  & .lamp__stem {
    stroke: var(--color-text-faint);
    stroke-width: 2;
  }
  & rect.lamp__stem,
  & .lamp__base,
  & .lamp__cap,
  & .lamp__joint {
    fill: color-mix(in oklch, var(--color-text) 75%, var(--lamp-finish));
    stroke: none;
  }
  & .lamp__bulb {
    fill: var(--brand-core);
    filter: drop-shadow(0 0 6px var(--brand-cyan-bright));
  }
  & .lamp__floor {
    fill: color-mix(in oklch, var(--brand-ultramarine-900) 18%, transparent);
  }
}

/* Shelf: lamps standing on lit pedestals, laid out by a container query */
.shelf__filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-7);
  padding: 0;
  border: 0;
}

.shelf__filter {
  & input {
    position: absolute;
    opacity: 0;
  }

  & span {
    display: inline-flex;
    align-items: center;
    height: 2rem;
    padding-inline: var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-xs);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font: var(--weight-mono) var(--text-label) / 1 var(--font-mono);
    cursor: pointer;
    transition:
      background var(--duration-fast) var(--ease-out),
      color var(--duration-fast) var(--ease-out);
  }

  &:has(input:checked) span {
    border-color: transparent;
    background: var(--brand-ultramarine);
    color: var(--color-on-accent);
    box-shadow: var(--glow-accent);
  }

  &:has(input:focus-visible) span {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
  }
}

/* Filtering with :has() and no script */
.shelf:has(input[name="kind"][value="pendant"]:checked)
  .product:not([data-kind="pendant"]),
.shelf:has(input[name="kind"][value="table"]:checked)
  .product:not([data-kind="table"]),
.shelf:has(input[name="kind"][value="floor"]:checked)
  .product:not([data-kind="floor"]) {
  display: none;
}

.shelf__grid {
  container: shelf / inline-size;
  display: grid;
  gap: var(--space-7) var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf__grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr));
}

.product {
  position: relative;

  & .product__inner {
    display: grid;
    gap: var(--space-4);
  }

  & .product__media {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 5 / 4;
    margin: 0;
    border-bottom: 1px solid var(--color-border);
    background: var(--shop-pedestal) bottom / 100% 55% no-repeat;
    transition: background-size var(--duration-base) var(--ease-out);

    & .lamp {
      width: 62%;
      height: auto;
      transition: translate var(--duration-base) var(--ease-out);
    }
  }

  & .product__badge {
    position: absolute;
    top: var(--space-2);
    left: 0;
  }

  & .product__wish {
    position: absolute;
    top: var(--space-2);
    right: 0;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: color-mix(in oklch, var(--color-surface) 80%, transparent);
    color: var(--color-text-muted);
    cursor: pointer;

    & path {
      fill: none;
      stroke: currentColor;
      stroke-width: 1.6;
      transition: fill var(--duration-fast) var(--ease-out);
    }

    &[aria-pressed="true"] {
      color: var(--brand-ultramarine);
      border-color: var(--color-border-strong);

      & path {
        fill: currentColor;
      }
    }
  }

  & .product__body {
    display: grid;
    gap: var(--space-2);
  }

  & .product__kind {
    margin: 0;
    color: var(--color-accent);
    font-size: var(--text-label);
  }

  & .product__name {
    margin: 0;
  }

  & .product__tagline {
    margin: 0;
    text-wrap: pretty;
  }

  & .product__stock {
    margin: 0;
    font-size: var(--text-label);

    &[data-level="low"] {
      color: var(--color-warning);
    }
    &[data-level="out"] {
      color: var(--color-danger);
    }
  }

  & .product__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-2);
  }

  & .product__price {
    font-size: var(--text-h3);
    font-weight: var(--weight-strong);
    letter-spacing: var(--tracking-snug);
    font-variant-numeric: tabular-nums;
  }

  /* Hover state for :hov: the pedestal brightens and the lamp lifts */
  &:hover .product__media,
  &:focus-within .product__media {
    background-size: 100% 80%;

    & .lamp {
      translate: 0 -6px;
    }
  }

  /* Finish swatches recolour the lamp through :has(), no script */
  &:has(input[value="ultramarine"]:checked) {
    --lamp-finish: var(--brand-ultramarine);
  }
  &:has(input[value="ice"]:checked) {
    --lamp-finish: var(--brand-ice);
  }
  &:has(input[value="abyss"]:checked) {
    --lamp-finish: var(--brand-abyss);
  }
  &:has(input[value="snow"]:checked) {
    --lamp-finish: var(--brand-snow);
  }
  &:has(input[value="azure"]:checked) {
    --lamp-finish: var(--brand-azure);
  }
}

/* The shelf's own width, not the viewport, decides the media shape */
@container shelf (max-width: 30rem) {
  .product .product__media {
    aspect-ratio: 16 / 10;
  }
}

@container shelf (min-width: 60rem) {
  .product .product__media {
    aspect-ratio: 1;
  }
}

.product__finishes {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-1) 0 0;
  padding: 0;
  border: 0;
}

.swatch {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    oklch(from var(--swatch) calc(l + 0.2) c h),
    var(--swatch) 60%
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in oklch, var(--color-text) 20%, transparent),
    var(--shadow-sm);
  cursor: pointer;

  & input {
    position: absolute;
    opacity: 0;
  }

  &:has(input:checked) {
    outline: 1.5px solid var(--orbit-line);
    outline-offset: 3px;
  }

  &:has(input:focus-visible) {
    outline: 2px solid var(--color-accent);
  }
}

/* Studio: a stage band with a horizon, like the site's iPad section */
.studio__inner {
  display: grid;
  gap: var(--space-7);
  align-items: center;

  @media (min-width: 64rem) {
    grid-template-columns: 1fr 1fr;
  }
}

.studio__specs {
  margin-top: var(--space-6);
}

.studio__image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* Reviews */
.reviews__list {
  display: grid;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;

  @media (min-width: 48rem) {
    grid-template-columns: repeat(3, 1fr);
  }
}

.review {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-strong);

  & .review__stars {
    color: var(--color-accent);
    font-family: var(--font-mono);
    letter-spacing: 0.15em;
  }

  & blockquote {
    margin: var(--space-3) 0;
    font-size: var(--text-body);
    text-wrap: pretty;
  }

  & .review__by {
    color: var(--color-text-faint);
    font: var(--weight-mono) var(--text-label) / 1.4 var(--font-mono);
  }
}

.review--skeleton {
  min-height: 9rem;
  background: linear-gradient(
      90deg,
      transparent,
      color-mix(in oklch, var(--color-accent) 10%, transparent),
      transparent
    )
    0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

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

/* Footer */
.store-footer {
  position: relative;
  padding-block: var(--space-8) var(--space-7);

  & .store-footer__inner {
    display: grid;
    gap: var(--space-6);
  }

  & .store-footer__mark {
    margin: 0;
    font-size: var(--text-h2);
    font-weight: var(--weight-light);
    letter-spacing: var(--tracking-tight);
    background: var(--display-fill);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  & .store-footer__cols {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-7);

    & ul {
      margin: var(--space-3) 0 0;
      padding: 0;
      list-style: none;
    }

    & li + li {
      margin-top: var(--space-2);
    }
  }

  & .store-footer__note {
    max-width: 60ch;
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
  }
}

/* Cart dialog */
.cart {
  width: min(100% - 2 * var(--space-4), 26rem);
  max-height: min(80dvh, 40rem);
  margin: auto var(--space-4) auto auto;
  padding: var(--space-5);
  color: var(--color-text);

  &::backdrop {
    background: color-mix(in oklch, var(--brand-void) 45%, transparent);
    backdrop-filter: blur(4px);
  }

  &[open] {
    display: grid;
    gap: var(--space-4);
    animation: cart-in var(--duration-base) var(--ease-out);
  }

  & .cart__head {
    display: flex;
    align-items: center;
    justify-content: space-between;

    & h2 {
      margin: 0;
    }
  }

  & .cart__close {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    font-size: 1.25rem;
    cursor: pointer;
  }

  & .cart__lines {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;

    & li {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: var(--space-1) var(--space-3);
      padding-bottom: var(--space-3);
      border-bottom: 1px solid var(--color-border);
    }
  }

  &:has(.cart__lines li) .cart__empty {
    display: none;
  }

  & .cart__promo-row {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);

    & input {
      flex: 1;
      min-width: 0;
      height: 3rem;
      padding-inline: var(--space-3);
      border: 1px solid var(--color-border-strong);
      border-radius: var(--radius-md);
      background: var(--color-bg);
      color: var(--color-text);
      font: inherit;
    }
  }

  & .cart__total {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-h3);
    font-weight: var(--weight-strong);
  }
}

@keyframes cart-in {
  from {
    opacity: 0;
    translate: var(--space-5) 0;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: max(var(--space-5), env(safe-area-inset-bottom));
  left: 50%;
  z-index: 30;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-small);
  translate: -50% calc(100% + var(--space-6));
  visibility: hidden;
  transition:
    translate var(--duration-base) var(--ease-out),
    visibility 0s linear var(--duration-base);

  &[data-show] {
    translate: -50% 0;
    visibility: visible;
    transition: translate var(--duration-base) var(--ease-out);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
