/* ------------------------------------------------------------------------
   Manifest storefronts - shared shop chassis.

   Structure only: rhythm, controls, product cards, checkout. Each shop sets its
   own identity layer (palette, type, texture) in its own <style> block, because
   the whole premise is three unrelated businesses. Nothing here should make them
   look like siblings.

   Radius rule for every shop: 0 on surfaces, full-pill on interactive controls.
   One system, applied everywhere.
   --------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* Overridden per shop. Neutral fallbacks only. */
  --paper: #ffffff;
  --raise: #fafafa;
  --ink: #16181c;
  --muted: #5f646d;
  --line: rgba(20, 22, 26, 0.14);
  --accent: #1f4d3d;
  --accent-ink: #ffffff;
  --sold: #8a8f98;

  --pill: 999px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --display: system-ui, sans-serif;
  --body: system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap {
  width: min(100% - var(--gutter) * 2, 1240px);
  margin-inline: auto;
}

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

/* ------------------------------------------------------------------ nav -- */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  block-size: 64px;
}

.nav__mark {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  white-space: nowrap;
}

.nav__links {
  display: flex;
  gap: 1.1rem;
  margin-left: auto;
  align-items: center;
  font-size: 0.85rem;
}

.nav__links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s var(--ease);
  white-space: nowrap;
}

.nav__links a:hover {
  color: var(--ink);
}

/* Live indicator: real semantic state (is the agent link up), not decoration. */
.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 0.3rem 0.65rem;
  white-space: nowrap;
}

.agent-state::before {
  content: "";
  inline-size: 6px;
  block-size: 6px;
  border-radius: 50%;
  background: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .agent-state::before {
    animation: pulse 2.6s ease-out infinite;
  }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ----------------------------------------------------------------- hero -- */

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  padding-block: clamp(2rem, 5vw, 4.5rem);
}

.hero__copy {
  max-width: 34ch;
}

/* Scale planned against the image, not chosen for drama: at this size a
   six-word headline sets on two lines beside a 5:4 photograph. */
.hero h2 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 0.9rem;
  font-weight: 500;
  text-wrap: balance;
}

.hero p {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.05rem);
  max-width: 42ch;
}

.hero__figure {
  position: relative;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  background: var(--raise);
}

.hero__figure img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

@media (max-width: 780px) {
  .hero {
    grid-template-columns: 1fr;
    padding-block: 1.5rem 2rem;
  }
  .hero__copy {
    max-width: none;
  }
  .hero__figure {
    aspect-ratio: 16 / 9;
  }
}

/* ---------------------------------------------------------------- shelf -- */

.shelf {
  padding-block: clamp(1.5rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
}

.shelf__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.shelf__title {
  font-family: var(--display);
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.75rem);
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.shelf__count {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-row input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--paper);
  color: var(--ink);
  min-inline-size: 14rem;
  transition: border-color 0.18s var(--ease);
}

.search-row input::placeholder {
  /* Kept above the 4.5:1 threshold rather than the usual faint grey. */
  color: var(--muted);
  opacity: 1;
}

.search-row input:focus {
  border-color: var(--accent);
  outline: none;
}

/* ---------------------------------------------------------------- grid -- */

.grid {
  display: grid;
  gap: clamp(1.1rem, 2.5vw, 2rem) clamp(1rem, 2vw, 1.75rem);
  grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

.card__figure {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--raise);
  margin-bottom: 0.35rem;
}

.card__figure img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}

@media (prefers-reduced-motion: no-preference) {
  .card:hover .card__figure img {
    transform: scale(1.035);
  }
}

.card__producer {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.card__name {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.card__desc {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.card__price {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Sold out: the card stays legible, the image reads as unavailable. */
.card[data-stock="out"] .card__figure img {
  filter: grayscale(1);
  opacity: 0.55;
}

.card[data-stock="out"] .card__name,
.card[data-stock="out"] .card__price {
  color: var(--sold);
}

.card__flag {
  position: absolute;
  inset-block-start: 0.6rem;
  inset-inline-start: 0.6rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.28rem 0.5rem;
  border-radius: var(--pill);
}

/* -------------------------------------------------------------- buttons -- */

.btn-solid {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--pill);
  padding: 0.5rem 1.05rem;
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  transition: filter 0.18s var(--ease), transform 0.12s var(--ease);
}

.btn-solid:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-solid:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-solid:disabled {
  background: transparent;
  color: var(--sold);
  border-color: var(--line);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 0.5rem 1.05rem;
  font-size: 0.84rem;
  white-space: nowrap;
  transition: border-color 0.18s var(--ease);
}

.btn-ghost:hover {
  border-color: var(--ink);
}

/* ----------------------------------------------------------------- cart -- */

/*
  The cart rides at the bottom of the viewport while you shop. It is fixed
  rather than sticky because a sticky bar inside normal flow sits on top of the
  grid it is meant to sit below; the body reserves matching space instead.
*/
.cart-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 15;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-block: 0.8rem;
}

body {
  padding-bottom: 5.5rem;
}

.cart-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.cart-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.cart-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cart-total {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

/* ------------------------------------------------------------- checkout -- */

.checkout-veil {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.6);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 50;
}

@media (prefers-reduced-motion: no-preference) {
  .checkout-veil {
    animation: veil 0.2s ease-out;
  }
  .checkout-card {
    animation: lift 0.26s var(--ease);
  }
}

@keyframes veil {
  from { opacity: 0; }
}

@keyframes lift {
  from { opacity: 0; transform: translateY(10px); }
}

.checkout-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: clamp(1.4rem, 3vw, 2rem);
  inline-size: min(100%, 27rem);
  box-shadow: 0 30px 70px -24px color-mix(in srgb, var(--ink) 45%, transparent);
}

.checkout-eyebrow {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.55rem;
}

.checkout-card h2 {
  font-family: var(--display);
  font-size: 1.4rem;
  margin: 0 0 1.1rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.checkout-lines {
  list-style: none;
  margin: 0 0 0.8rem;
  padding: 0 0 0.8rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
}

.checkout-lines li,
.checkout-total {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.checkout-total {
  font-size: 0.98rem;
  margin: 0 0 1rem;
}

.checkout-note {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 1.2rem;
}

.checkout-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

/* ---------------------------------------------------------------- misc --- */

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2.5rem 0;
  text-align: center;
}

.store-foot {
  border-top: 1px solid var(--line);
  padding-block: 1.75rem 3rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.store-foot code {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink);
}

/* Entry reveal. Motion earns its place by showing the shelf filling in the
   order the shop stocked it; it collapses entirely under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .card {
    animation: rise 0.5s var(--ease) both;
    animation-delay: calc(var(--i, 0) * 45ms);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ---------------------------------------------------------------------- */
/* Embedded small inside the Manifest hub. The shop must still read as a
   shop, not a squeezed desktop page. */
@media (max-width: 560px) {
  :root {
    --gutter: 0.9rem;
  }
  .nav__inner {
    block-size: 52px;
  }
  .nav__links a {
    display: none;
  }
  .nav__links {
    margin-left: auto;
  }
  /* At this size the shop is either on a phone or embedded in the hub. Either
     way the goods matter more than the pitch, so the hero steps aside. */
  .hero {
    display: none;
  }
  .shelf {
    padding-block: 0.9rem 1.1rem;
    border-top: 0;
  }
  .shelf__head {
    margin-bottom: 0.9rem;
  }
  .grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
  .card {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    gap: 0 0.75rem;
    align-items: start;
  }
  .card__figure {
    grid-row: 1 / span 4;
    aspect-ratio: 1;
    margin-bottom: 0;
  }
  .card__desc {
    -webkit-line-clamp: 2;
    font-size: 0.8rem;
  }
  .card__foot {
    padding-top: 0.3rem;
  }
  body {
    padding-bottom: 0;
  }
  /* Inside the hub the frame scrolls on its own, so a bar pinned to the
     viewport would just cover the goods. It rides with the content instead. */
  .cart-bar {
    position: static;
    padding-block: 0.55rem;
    margin-top: 0.75rem;
  }
  .store-foot {
    display: none;
  }
}

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