/* ==========================================================================
   JORIE DAILY — essentials.css · Phase 34 · Essentials V1 ♡
   Phase 35.3 · "little product catalogue" redesign (visual only).
   No markup, behaviour or permission change: essentials.js is untouched and
   every class it renders keeps its meaning. Everything is scoped to .ess*
   classes; the shared page hero (title, eyebrow, lede) is not touched.
   Loaded just BEFORE design-system.css (Phase 33.2 rule: design-system.css
   stays last). Colours come only from the site tokens
   (burgundy · pink · white · beige).

   Layout idea
     • A category is an open "shelf": serif title, a quiet count and a hairline
       — no boxed panel, so one product never sits in a huge empty card.
     • A product is a pastel photo tile with its details printed underneath,
       like a catalogue page: type + edit mark, name, then size and price.
     • Empty categories keep their full shelf and dropdown, ready for products.
     • Hover: the tile lifts, the product rises off its little shelf shadow.

   Card grid (with subgrid, so the type line sits UNDER the photo while the
   DOM order — head, open button, slide, carousel — stays exactly as before):
       row 1  photo tile          (.ess-card__slide › .ess-card__stage)
       row 2  type · edit mark    (.ess-card__head)
       row 3  name · note · price (.ess-card__slide › .ess-card__body)
       row 4  alternatives        (.ess-carousel, only with 2+ alternatives)
   Browsers without subgrid keep the plain column (type line on top).
   ========================================================================== */

:root {
  --ess-gap-x: clamp(12px, 1.6vw, 20px);
  --ess-gap-y: clamp(18px, 2.2vw, 26px);
  --ess-col: 164px;               /* minimum product column on wide screens */
  --ess-card-r: 20px;
  --ess-stage-r: 20px;
  --ess-photo-h: 78%;             /* visual height every product reaches inside its tile */
  --ess-room: 12px;               /* breathing room so lifted tiles/shadows are never clipped */
  --ess-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ess-stage: radial-gradient(120% 90% at 50% 105%, rgb(var(--pink-rgb) / 0.62) 0%, rgb(var(--pink-rgb) / 0.26) 48%, rgb(var(--beige-rgb) / 0.55) 100%);
  --ess-stage-solid: color-mix(in srgb, var(--beige) 70%, var(--pink));
  --ess-stage-edge: rgb(var(--burgundy-rgb) / 0.06);
  --ess-shelf: rgb(var(--burgundy-rgb) / 0.2);
  --ess-lift: 0 18px 30px -20px rgb(var(--burgundy-rgb) / 0.5);
  --ess-pip-bg: rgb(var(--white-rgb) / 0.78);
}
:root[data-theme="dark"] {
  --ess-stage: radial-gradient(120% 90% at 50% 105%, rgb(var(--pink-rgb) / 0.26) 0%, rgb(var(--pink-rgb) / 0.1) 55%, rgb(var(--pink-rgb) / 0.05) 100%);
  --ess-stage-solid: color-mix(in srgb, var(--burgundy) 78%, var(--pink));
  --ess-stage-edge: rgb(var(--pink-rgb) / 0.1);
  --ess-shelf: rgb(0 0 0 / 0.5);
  --ess-lift: 0 18px 32px -18px rgb(0 0 0 / 0.75);
  --ess-pip-bg: rgb(var(--burgundy-rgb) / 0.62);
}

/* ---------------------------------------------------------------- page */
.ess-disclaimer {
  margin: calc(-1 * clamp(8px, 1.4vw, 16px)) 0 clamp(10px, 1.6vw, 16px);
  font-size: var(--fs-xs); color: var(--ink-3); letter-spacing: 0.01em;
}
/* Shelves flow in rows: full width on phones, packed side by side on wider screens. */
.ess-app {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px;
  padding-bottom: clamp(24px, 4vw, 48px);
}
.ess-app > .ess-state { flex: 1 1 100%; }
.ess-summary {
  flex: 1 1 100%;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  margin: 0; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500;
}
.ess-summary__num { font-family: var(--font-display); font-size: 1.35em; font-weight: 700; color: var(--ink); line-height: 1; }
.ess-summary__sep { display: none; }
.ess-summary__need, .ess-summary__ro {
  display: inline-flex; align-items: center; padding: 3px 11px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); line-height: 1.4;
}
.ess-summary__need { background: var(--btn-bg); color: var(--btn-ink); font-weight: 700; }
.ess-summary__ro { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

/* Loading / error */
.ess-state {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 0; padding: 18px 20px; color: var(--ink-2); font-size: var(--fs-sm);
}
.ess-state__dot {
  flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%;
  background: var(--accent); animation: essPulse 1.4s var(--ease-in-out) infinite;
}
@keyframes essPulse { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }
.ess-state--error { color: var(--ink); background: var(--ds-attn-bg, rgb(var(--pink-rgb) / 0.45)); }
.ess-state--error > .icon { flex: none; width: 20px; height: 20px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ess-state__title { margin: 0 0 2px; font-weight: 700; color: var(--ink); }
.ess-state__text { margin: 0 0 10px; color: var(--ink-2); }

/* ---------------------------------------------------------------- shelves (categories)
   The section still carries the shared .card class from the markup; the
   shelf look removes that box (higher specificity, scoped to .ess-cat). */
.ess-cat.card {
  flex: 1 1 100%; min-width: 0;
  padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; transform: none;
  overflow: visible;
}
.ess-cat.card { margin-top: 10px; }
.ess-cat__heading { margin: 0; font: inherit; }
.ess-cat__toggle {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 44px; padding: 2px 0;
  border: 0; border-radius: 12px; background: none; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ess-cat__toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.ess-cat__title {
  order: 0; flex: none;
  font-family: var(--font-display); font-size: clamp(1.2rem, 1.08rem + 0.5vw, 1.45rem);
  font-weight: 650; font-variation-settings: "SOFT" 100; letter-spacing: -0.015em; line-height: 1.15;
}
.ess-cat__count {
  order: 1; flex: none;
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
/* The shelf's hairline runs from the count to the chevron. */
.ess-cat__toggle::after {
  content: ""; order: 2; flex: 1 1 auto; min-width: 12px; height: 1px;
  background: linear-gradient(90deg, var(--line-2), var(--line) 40%, var(--line));
  transform-origin: left center;
  transition: opacity var(--dur-2) ease, transform var(--dur-3) var(--ess-ease);
}
.ess-cat__chev {
  order: 3; flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--ink-2); background: transparent;
  transition: transform var(--dur-3) var(--ess-ease), background-color var(--dur-2) ease, color var(--dur-2) ease, border-color var(--dur-2) ease;
}
.ess-cat__chev .icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ess-cat.is-open .ess-cat__chev { transform: rotate(180deg); }
@media (hover: hover) {
  .ess-cat__toggle:hover .ess-cat__chev { background: var(--accent-soft); color: var(--ink); border-color: transparent; }
  .ess-cat:not(.ess-cat--empty) .ess-cat__toggle:hover::after { opacity: 0.6; transform: scaleX(0.985); }
}

/* Empty categories keep the full shelf (title, line and dropdown arrow), ready
   for new products; only the title is a touch softer. They open and close like
   every other category and become normal shelves as soon as they hold a product. */
.ess-cat--empty .ess-cat__title { color: var(--ink-2); }

/* Smooth open/close without measuring heights; closed panels are inert and hidden. */
.ess-cat__panel {
  display: grid; grid-template-rows: 0fr; grid-template-columns: minmax(0, 1fr); visibility: hidden;
  transition: grid-template-rows var(--dur-3) var(--ess-ease), visibility 0s linear var(--dur-3);
}
.ess-cat.is-open .ess-cat__panel {
  grid-template-rows: 1fr; visibility: visible;
  transition: grid-template-rows var(--dur-3) var(--ess-ease), visibility 0s linear 0s;
}
/* The clip needs overflow:hidden for the collapse; its padding (paid back by a
   negative margin) leaves room for lifted tiles and their shadows. */
.ess-cat__clip { min-height: 0; min-width: 0; overflow: hidden; margin: 0 calc(-1 * var(--ess-room)); padding: 0 var(--ess-room); }
.ess-cat__body { padding: 14px 0 var(--ess-room); }
.ess-cat__empty {
  margin: 0; padding: 10px 14px; border-radius: 14px; border: 1px dashed var(--line-2);
  color: var(--ink-2); font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------- grid
   Column width depends only on the (full-width) shelf, so the columns of
   every category line up with each other. */
ul.ess-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--ess-gap-y) var(--ess-gap-x);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--ess-col)), 1fr));
}
.ess-cell { display: flex; min-width: 0; }
.ess-cell > .ess-card { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- one product */
.ess-card {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; gap: 10px;
  padding: 0; border-radius: var(--ess-card-r);
}

/* Type line + edit mark (Marjorie only). */
.ess-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; padding: 0 2px; }
.ess-card__type {
  margin: 0; min-width: 0; font-size: var(--fs-xs); font-weight: 600; line-height: 1.3; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ess-card__edit {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  color: var(--ink-3); background: transparent;
  transition: color var(--dur-2) ease, background-color var(--dur-2) ease, transform var(--dur-3) var(--ease-spring);
}
.ess-card__edit .icon { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* The whole card is one button (stretched under the carousel controls). */
.ess-card__open {
  position: absolute; inset: 0; z-index: 1;
  border: 0; border-radius: inherit; background: transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ess-card__open--view { cursor: zoom-in; }
.ess-card__open:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 5px; }

.ess-card__slide { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ess-card__slide.is-from-next { animation: essSlideIn var(--dur-3) var(--ess-ease) both; --ess-from: 16px; }
.ess-card__slide.is-from-prev { animation: essSlideIn var(--dur-3) var(--ess-ease) both; --ess-from: -16px; }
@keyframes essSlideIn { from { opacity: 0; transform: translateX(var(--ess-from, 16px)); } to { opacity: 1; transform: none; } }

/* Photo tile: one square pastel frame for every product. */
.ess-card__stage {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--ess-stage-r); overflow: hidden;
  background: var(--ess-stage-solid); background: var(--ess-stage);
  box-shadow: inset 0 0 0 1px var(--ess-stage-edge), 0 0 0 transparent;
  transition: transform var(--dur-3) var(--ess-ease), box-shadow var(--dur-3) var(--ess-ease);
}
/* The soft "shelf" shadow the product stands on. */
.ess-card__stage::before {
  content: ""; position: absolute; left: 50%; bottom: 6%; width: 50%; height: 6%;
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(closest-side, var(--ess-shelf), transparent);
  transition: transform var(--dur-3) var(--ess-ease), opacity var(--dur-3) var(--ess-ease);
}
/* Photos are sized by HEIGHT so every product reaches the same visual height
   and stands on the same shelf line. essentials.js measures each photo once
   and sets --ess-fill (share of the file's height the product fills) and
   --ess-bpad (empty space under it); these defaults suit a full-bleed photo. */
.ess-card__img {
  --ess-img-h: calc(var(--ess-photo-h) / var(--ess-fill, 0.95));
  --ess-rise: 0%;
  position: absolute; left: 50%; z-index: 0;
  bottom: calc(9% - var(--ess-bpad, 0.02) * var(--ess-img-h));
  display: block; width: auto; max-width: 92%;
  height: var(--ess-img-h); max-height: 96%;
  transform: translateX(-50%) translateY(var(--ess-rise)) scale(var(--ess-scale, 1));
  transform-origin: 50% 100%;
  object-fit: contain; object-position: center bottom;
  filter: drop-shadow(0 8px 10px rgb(var(--burgundy-rgb) / 0.14));
  transition: transform var(--dur-3) var(--ess-ease), filter var(--dur-3) var(--ess-ease);
}
:root[data-theme="dark"] .ess-card__img { filter: drop-shadow(0 8px 12px rgb(0 0 0 / 0.35)); }

/* Hover: the tile lifts a touch and the product rises off its shelf. */
@media (hover: hover) {
  .ess-card:hover .ess-card__stage { transform: translateY(-4px); box-shadow: inset 0 0 0 1px var(--ess-stage-edge), var(--ess-lift); }
  .ess-card:hover .ess-card__img { --ess-rise: -4%; --ess-scale: 1.04; filter: drop-shadow(0 14px 14px rgb(var(--burgundy-rgb) / 0.18)); }
  :root[data-theme="dark"] .ess-card:hover .ess-card__img { filter: drop-shadow(0 14px 16px rgb(0 0 0 / 0.42)); }
  .ess-card:hover .ess-card__stage::before { transform: translateX(-50%) scale(0.78); opacity: 0.7; }
  .ess-card:hover .ess-card__edit { color: var(--ink); background: var(--accent-soft); transform: rotate(-8deg); }
  .ess-card:hover .ess-card__name { color: var(--ink); }
}
.ess-card:active .ess-card__stage { transform: translateY(-1px) scale(0.985); transition-duration: var(--dur-1); }
.ess-card:has(.ess-card__open:focus-visible) .ess-card__stage { box-shadow: inset 0 0 0 1px var(--ess-stage-edge), var(--ess-lift); }

.ess-card__stage.is-missing { display: grid; place-items: center; }
.ess-card__stage.is-missing::after {
  content: "Image unavailable"; position: relative; font-size: var(--fs-xs); color: var(--ink-3); letter-spacing: 0.02em;
}
.ess-card__tags {
  position: absolute; z-index: 1; top: 9px; left: 9px; right: 38px;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 5px; pointer-events: none;
}
/* Country flag pip (top-right of the tile). */
.ess-card__country {
  position: absolute; z-index: 1; top: 9px; right: 9px; margin: 0; pointer-events: none;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ess-pip-bg); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ess-flag { font-size: 0.85rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }

/* Status bubble (active alternative, "Need to buy" only) — small and discreet. */
.ess-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px 3px 7px; border-radius: var(--radius-pill);
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.01em; line-height: 1.25; white-space: nowrap;
  box-shadow: 0 6px 14px -10px rgb(var(--burgundy-rgb) / 0.7);
  animation: essPop 420ms var(--ease-spring) both;
}
.ess-badge .icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ess-badge--need { background: var(--btn-bg); color: var(--btn-ink); }
.ess-badge--bought { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
@keyframes essPop { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }
.ess-chip {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.02em; line-height: 1.3; white-space: nowrap;
  background: var(--ess-pip-bg); color: var(--ink-2);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ess-chip--active { color: var(--ink); }

/* Details under the tile: name, optional photo note, then size + price on one
   line pinned to the bottom so prices line up along a row. */
.ess-card__body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 0 2px; }
.ess-card__name {
  order: 1; margin: 0;
  font-family: var(--font-display); font-size: 1rem; font-weight: 600;
  font-variation-settings: "SOFT" 100; letter-spacing: -0.01em; line-height: 1.25; color: var(--ink);
  overflow-wrap: break-word; hyphens: manual; text-wrap: pretty;
  transition: color var(--dur-2) ease;
}
.ess-card__note {
  order: 2; margin: -2px 0 0;
  font-size: 0.6875rem; font-style: italic; line-height: 1.3; color: var(--ink-3);
}
.ess-card__facts {
  order: 3; margin: auto 0 0; padding-top: 2px;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px;
}
.ess-card__facts div { display: flex; align-items: baseline; min-width: 0; }
/* The "Size"/"Price" words stay for screen readers; sighted readers see the values. */
.ess-card__facts dt {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.ess-card__facts dd { margin: 0; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ess-card__facts div:first-child dd { font-size: var(--fs-xs); font-weight: 500; color: var(--ink-3); }
.ess-card__facts div:last-child dd { font-size: 0.875rem; font-weight: 700; color: var(--ink); }
/* Narrow phone cards: slightly smaller name and price (a viewport query — a
   container query inside the subgrid card left Chromium's hit-testing stale
   after layout shifts, so taps could miss the card). The price may also wrap
   under the size rather than squeeze. */
@media (max-width: 400px) {
  .ess-card__name { font-size: 0.92rem; }
  .ess-card__facts div:last-child dd { font-size: 0.8125rem; }
}

/* Subgrid placement comes after every base card rule so nothing overrides it. */
@supports (grid-template-rows: subgrid) {
  .ess-card { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; gap: 0; }
  .ess-card__slide { grid-row: 1 / 4; grid-column: 1; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: subgrid; gap: 0; }
  .ess-card__stage { grid-row: 1; }
  .ess-card__head { grid-row: 2; grid-column: 1; margin-top: 11px; }
  .ess-card__body { grid-row: 3; margin-top: 3px; }
  .ess-carousel { grid-row: 4; }
}

/* Alternatives (only rendered when a card has 2+ alternatives) */
.ess-carousel {
  position: relative; z-index: 2;   /* above the stretched card button */
  display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 8px;
}
.ess-nav {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background-color var(--dur-2) ease, border-color var(--dur-2) ease, transform var(--dur-2) var(--ease-spring);
}
.ess-nav .icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .ess-nav:hover { background: var(--accent-soft); border-color: transparent; transform: scale(1.06); } }
.ess-nav:active { transform: scale(0.92); }
.ess-dots { display: inline-flex; min-width: 0; flex-wrap: wrap; justify-content: center; gap: 0; }
.ess-dot { width: 18px; height: 20px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.ess-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--line-2);
  transition: width var(--dur-3) var(--ess-ease), background-color var(--dur-2) ease;
}
.ess-dot[aria-current="true"]::before { width: 14px; background: var(--ink); }
.ess-count { min-width: 3ch; font-size: var(--fs-2xs); font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: center; }
.ess-nav:focus-visible, .ess-dot:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 50%; }
@media (pointer: coarse) { .ess-nav { width: 40px; height: 40px; } .ess-dot { width: 24px; height: 26px; } }
.ess-card--multi .ess-card__slide, .ess-card--multi .ess-card__open { touch-action: pan-y; }   /* horizontal swipes browse */

/* Wider screens: short shelves sit side by side, each just wide enough for its
   products (counted with :has), like shelves in a little shop. A shelf with
   seven or more products takes the full row. Without :has support every
   shelf simply keeps a full row. */
@media (min-width: 560px) {
  :root { --ess-col-w: 172px; --ess-shelf-gap: clamp(28px, 3.4vw, 40px); }
  .ess-cat:not(.ess-cat--empty):has(.ess-cell) {
    --n: 1;
    flex: 1 1 max(15rem, calc(var(--n) * var(--ess-col-w) + (var(--n) - 1) * var(--ess-gap-x)));
    max-width: 100%;
  }
  /* Shelves keep a wider gap than the base 10px: each shelf carries the extra on
     its right, and the app reaches that far into the page gutter (the extra,
     at most 30px, is always narrower than the gutter) so the last shelf of a
     row still lines up with the page edge. */
  .ess-app { margin-right: calc(10px - var(--ess-shelf-gap)); }
  .ess-cat--empty.card { margin-right: calc(var(--ess-shelf-gap) - 10px); }
  .ess-cat:not(.ess-cat--empty):has(.ess-cell) { margin-right: calc(var(--ess-shelf-gap) - 10px); }

  .ess-cat:has(.ess-cell:nth-child(2)) { --n: 2; }
  .ess-cat:has(.ess-cell:nth-child(3)) { --n: 3; }
  .ess-cat:has(.ess-cell:nth-child(4)) { --n: 4; }
  .ess-cat:has(.ess-cell:nth-child(5)) { --n: 5; }
  .ess-cat:has(.ess-cell:nth-child(6)) { --n: 6; }
  .ess-cat:not(.ess-cat--empty):has(.ess-cell:nth-child(7)) { flex: 1 1 100%; }
  .ess-cat:has(.ess-cell) ul.ess-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--ess-col-w)), var(--ess-col-w))); }
  .ess-cat:has(.ess-cell:nth-child(7)) ul.ess-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--ess-col-w)), 1fr)); }
}

/* Phones: a two-up catalogue grid. */
@media (max-width: 559px) {
  :root { --ess-gap-x: 12px; --ess-gap-y: 20px; --ess-stage-r: 18px; --ess-card-r: 18px; --ess-room: 10px; }
  ul.ess-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ess-cat__toggle { gap: 10px; }
  .ess-cat__body { padding-top: 10px; }
  .ess-card__tags { top: 7px; left: 7px; right: 34px; }
  .ess-card__country { top: 7px; right: 7px; width: 22px; height: 22px; }
  .ess-flag { font-size: 0.78rem; }
  .ess-badge { padding: 3px 7px 3px 6px; font-size: 0.625rem; }
  .ess-badge .icon { width: 11px; height: 11px; }
  .ess-card__type { font-size: 0.6875rem; }
  .ess-card__edit { width: 22px; height: 22px; }
  /* Narrow cards: the counter stays for screen readers; arrows + dots stay touch-sized. */
  .ess-count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .ess-carousel { gap: 2px; }
}
/* Very small phones: still two-up, slightly tighter. */
@media (max-width: 359px) {
  :root { --ess-gap-x: 10px; --ess-room: 8px; }
  .ess-card__tags { right: 30px; }
}

/* ---------------------------------------------------------------- motion preferences */
@media (prefers-reduced-motion: reduce) {
  .ess-cat__panel, .ess-cat.is-open .ess-cat__panel, .ess-cat__chev, .ess-cat__toggle, .ess-cat__toggle::after,
  .ess-card, .ess-card__slide, .ess-card__stage, .ess-card__stage::before, .ess-card__img, .ess-card__edit,
  .ess-badge, .ess-dialog[open], .ess-state__dot, .ess-dot::before, .ess-nav, .ess-seg__opt > span {
    transition: none !important; animation: none !important;
  }
  .ess-card:hover .ess-card__stage, .ess-card:active .ess-card__stage { transform: none; }
  .ess-card:hover .ess-card__img { --ess-rise: 0%; --ess-scale: 1; }
  .ess-card:hover .ess-card__stage::before { transform: translateX(-50%); opacity: 1; }
  .ess-card:hover .ess-card__edit, .ess-nav:hover { transform: none; }
}
@media print {
  .ess-carousel, .ess-card__edit, .ess-card__open { display: none !important; }
  .ess-cat__panel { visibility: visible !important; grid-template-rows: 1fr !important; }
}

/* ---------------------------------------------------------------- editor dialog */
.ess-dialog {
  margin: auto; width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius-xl);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden;
}
.ess-dialog[open] { display: flex; flex-direction: column; animation: essDialogIn 420ms var(--ease-spring) both; }
@keyframes essDialogIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.ess-dialog::backdrop { background: rgb(var(--burgundy-rgb) / 0.42); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.ess-dialog__inner { display: flex; flex-direction: column; gap: 14px; min-height: 0; max-height: inherit; padding: clamp(18px, 3.6vw, 28px); }
.ess-dialog__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ess-dialog__eyebrow { margin: 0 0 6px; }
.ess-dialog__title {
  margin: 0; font-family: var(--font-display); font-size: clamp(1.45rem, 1.25rem + 1vw, 1.85rem);
  font-weight: 750; font-variation-settings: "SOFT" 100; letter-spacing: -0.025em; line-height: 1.08;
}
.ess-dialog .ess-dialog__x { flex: none; --btn-h: 44px; width: 44px; min-width: 44px; height: 44px; padding: 0; }
.ess-dialog .ess-dialog__x .icon { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ess-dialog__lede { margin: -4px 0 0; color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.5; }
.ess-dialog__list { display: grid; gap: 10px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 2px 4px; }

.ess-alt {
  display: grid; gap: 12px; margin: 0; padding: 14px; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--ink) 2%, transparent);
  transition: border-color var(--dur-2) ease, background-color var(--dur-2) ease;
}
.ess-alt.is-active { border-color: var(--line-2); background: rgb(var(--pink-rgb) / 0.22); }
:root[data-theme="dark"] .ess-alt.is-active { background: rgb(var(--pink-rgb) / 0.07); }
.ess-alt__info { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; }
.ess-alt__thumb { position: relative; display: block; width: 64px; height: 64px; border-radius: 12px; background: var(--ess-stage-solid); background: var(--ess-stage); overflow: hidden; }
.ess-alt__thumb.is-missing { display: grid; place-items: center; }
/* Same height-based sizing as the cards, so a square source file isn't tiny here either. */
.ess-alt__img { --ess-img-h: calc(82% / var(--ess-fill, 0.95)); position: absolute; left: 50%; bottom: calc(8% - var(--ess-bpad, 0.02) * var(--ess-img-h)); width: auto; max-width: 92%; height: var(--ess-img-h); max-height: 96%; transform: translateX(-50%); object-fit: contain; object-position: center bottom; }
.ess-alt__text { min-width: 0; }
.ess-alt__name { margin: 0 0 3px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.ess-alt__meta { margin: 0; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; }
.ess-alt__note { margin: 3px 0 0; font-size: var(--fs-xs); font-style: italic; color: var(--ink-3); }
.ess-alt__use { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.ess-alt__use input { width: 18px; height: 18px; accent-color: var(--ink); }

/* Status: one segmented track (the Phase 33.9 tab language). */
.ess-seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  border-radius: 18px; border: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 4%, transparent);
}
.ess-seg__opt { position: relative; display: block; cursor: pointer; }
.ess-seg__opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ess-seg__opt > span {
  display: grid; place-items: center; min-height: 40px; padding: 0 8px; border-radius: 14px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); text-align: center; line-height: 1.15;
  transition: background-color var(--dur-2) ease, color var(--dur-2) ease, box-shadow var(--dur-2) ease;
}
.ess-seg__opt input:checked + span { background: rgb(var(--pink-rgb) / 0.72); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px rgb(var(--burgundy-rgb) / 0.12); }
:root[data-theme="dark"] .ess-seg__opt input:checked + span { background: rgb(var(--pink-rgb) / 0.2); box-shadow: inset 0 0 0 1px rgb(var(--pink-rgb) / 0.35); }
.ess-seg__opt input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.ess-seg__opt input:disabled, .ess-seg__opt input:disabled + span { cursor: not-allowed; }
.ess-seg__opt input:disabled:not(:checked) + span { opacity: 0.55; }

.ess-dialog__err {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line); background: rgb(var(--pink-rgb) / 0.32);
  color: var(--ink); font-size: var(--fs-sm); line-height: 1.45;
}
.ess-dialog__err[hidden] { display: none; }
:root[data-theme="dark"] .ess-dialog__err { border-color: rgb(var(--pink-rgb) / 0.22); background: rgb(var(--pink-rgb) / 0.1); }
.ess-dialog__err p { margin: 0; }
.ess-dialog__err strong { font-weight: 700; }
.ess-dialog__err .icon { flex: none; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ess-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 2px; }
.ess-dialog__actions .btn { min-width: 128px; }
.ess-dialog [aria-busy="true"].btn { cursor: progress; }

@media (max-width: 479px) {
  .ess-dialog { width: calc(100vw - 20px); border-radius: var(--radius-lg); }
  .ess-dialog__inner { padding: 18px 16px 16px; }
  .ess-dialog__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .ess-dialog__actions .btn { min-width: 0; --btn-h: var(--ds-btn-md, 44px); }
  .ess-seg__opt > span { min-height: 44px; font-size: 0.8125rem; }
}


/* Phase 34.5 — photo-forward Essentials details. Retains Phase 34.4 cards,
   typography, tokens and gestures; never presents controls to the viewer. */
.ess-dialog { width: min(744px, calc(100vw - 20px)); }
.ess-dialog__inner { gap: 12px; }
.ess-dialog__preview {
  display: grid; grid-template-columns: minmax(0, 0.93fr) minmax(0, 1.07fr); gap: clamp(14px, 2.6vw, 24px);
  align-items: center; padding: clamp(12px, 2vw, 18px);
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--ess-stage-solid);
  min-width: 0;
}
.ess-dialog__photo {
  position: relative; display: grid; place-items: center; min-width: 0;
  height: clamp(196px, 25vw, 254px); overflow: hidden; border-radius: var(--ess-stage-r);
  background: var(--ess-stage); 
}
.ess-dialog__photo::before {
  content: ''; position: absolute; left: 24%; right: 24%; bottom: 11%; height: 10%;
  border-radius: 50%; background: radial-gradient(ellipse at center, var(--ess-shelf), transparent);
}
.ess-dialog__photo-img { position: relative; display: block; width: 100%; height: 92%; object-fit: contain; object-position: center; }
.ess-dialog__photo.is-missing::after {
  content: 'Photo unavailable'; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--ink-3); font-size: var(--fs-sm); text-align: center;
}
.ess-dialog__product { min-width: 0; }
.ess-dialog__product-eyebrow { margin: 0 0 8px; line-height: 1.35; }
.ess-dialog__product-name {
  margin: 0 0 10px; font-family: var(--font-display); font-size: clamp(1.25rem, 1rem + 0.6vw, 1.58rem);
  font-weight: 700; line-height: 1.18; color: var(--ink); overflow-wrap: anywhere;
}
.ess-dialog__product-note { margin: -2px 0 10px; color: var(--ink-3); font-size: var(--fs-xs); font-style: italic; }
.ess-dialog__product-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; }
.ess-dialog__product-facts div { min-width: 0; }
.ess-dialog__product-facts dt { margin-bottom: 3px; color: var(--ink-3); font-size: var(--fs-2xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.ess-dialog__product-facts dd { margin: 0; color: var(--ink); font-size: var(--fs-sm); font-weight: 700; overflow-wrap: anywhere; }
.ess-dialog__product-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; color: var(--ink-2); font-size: var(--fs-xs); }
.ess-dialog__status-value {
  padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink); font-size: var(--fs-xs); font-weight: 700;
}
.ess-dialog__status-value.is-needed { background: var(--accent-soft); color: var(--ink); }
.ess-dialog__status-value.is-bought { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.ess-dialog__preview-help { margin: 9px 0 0; color: var(--ink-3); font-size: var(--fs-xs); line-height: 1.45; }
.ess-alt__preview {
  display: flex; flex-direction: column; gap: 5px; align-items: center; min-width: 0; padding: 0;
  border: 0; background: transparent; color: var(--ink-2); cursor: zoom-in;
}
.ess-alt__preview-label { font-size: 0.7rem; font-weight: 650; text-align: center; line-height: 1.2; }
.ess-alt__preview:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: 12px; }
.ess-alt__preview[aria-pressed="true"] .ess-alt__thumb { outline: 2px solid var(--line-2); outline-offset: 2px; }
.ess-alt__read-status { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.ess-alt__read-status strong { color: var(--ink); }
.ess-dialog__list { flex: 1 1 auto; }
.ess-dialog__actions { flex: none; }
@media (max-width: 599px) {
  .ess-dialog { width: calc(100vw - 20px); }
  .ess-dialog__inner { padding: 16px; gap: 10px; }
  .ess-dialog__preview { grid-template-columns: 1fr; gap: 10px; padding: 10px; }
  .ess-dialog__photo { height: clamp(138px, 24vh, 188px); }
  .ess-dialog__photo-img { height: 96%; }
  .ess-dialog__product-eyebrow { margin-bottom: 4px; }
  .ess-dialog__product-name { font-size: 1.17rem; margin-bottom: 6px; }
  .ess-dialog__product-facts { margin-bottom: 7px; }
  .ess-dialog__preview-help { margin-top: 5px; }
}
@media (max-width: 359px), (max-height: 620px) {
  .ess-dialog__photo { height: 128px; }
  .ess-dialog__inner { gap: 8px; }
  .ess-dialog__preview { padding: 8px; }
}

/* Keep all purchase rows scrollable within the bounded native dialog. */
.ess-dialog__inner { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.ess-dialog__top, .ess-dialog__preview, .ess-dialog__lede, .ess-dialog__actions { flex-shrink: 0; }
.ess-dialog__list { flex: 1 1 0; min-height: 50px; }
@media (max-width: 359px), (max-height: 620px) {
  .ess-dialog__photo { height: 112px; }
  .ess-dialog__product-eyebrow, .ess-dialog__product-note, .ess-dialog__preview-help { display: none; }
  .ess-dialog__product-name { font-size: 1rem; margin: 0 0 4px; }
  .ess-dialog__product-facts { gap: 5px; margin-bottom: 5px; }
  .ess-dialog__product-facts dt { font-size: 0.65rem; margin: 0; }
  .ess-dialog__product-facts dd { font-size: 0.75rem; }
  .ess-dialog__lede { font-size: 0.76rem; line-height: 1.3; }
}
/* The photo, statuses and save action each have usable room; the product
   alternatives, not the entire page, scroll in a bounded interior region. */
.ess-dialog[open] { height: min(740px, calc(100dvh - 24px)); }
@media (max-width: 359px), (max-height: 620px) {
  .ess-dialog__photo { height: 124px; }
}
/* The image must be sized against the FRAME rather than its intrinsic aspect
   ratio; otherwise a tall PNG makes a grid row overflow and crops its bottom. */
.ess-dialog__photo-img { position: absolute; inset: 4%; width: 92%; height: 92%; object-fit: contain; }
@media (max-width: 599px) { .ess-dialog__photo-img { height: 92%; } }

/* Phase 35.2 — Essentials dialog has ONE large product image.
   The purchase-status row no longer repeats a small thumbnail or full product
   details. Keep a compact, accessible text-only switcher for multi-alternatives. */
.ess-alt--single { padding: 8px; gap: 0; background: transparent; }
.ess-alt__choose {
  display: block; width: 100%; padding: 2px 0; margin: 0;
  border: 0; background: transparent; text-align: left;
  color: var(--ink); font: inherit; font-size: var(--fs-sm); font-weight: 700;
  cursor: pointer; overflow-wrap: anywhere;
}
.ess-alt__choose[aria-pressed="true"] { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; }
.ess-alt__choose:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: 4px; }
/* The editor should fit its actual content instead of reserving 740 px for
   a thumbnail list that is no longer present. A long alternative list can
   still scroll, and the native dialog stays within the viewport. */
.ess-dialog[open] { height: auto; max-height: calc(100dvh - 24px); }
.ess-dialog__inner { max-height: calc(100dvh - 24px); }
.ess-dialog__list { flex: 0 1 auto; min-height: 0; }
.ess-dialog__list--single { overflow: visible; }
/* Explicit intrinsic sizing also cancels the old flex dialog's leftover space. */
.ess-dialog[open] { display: block; height: fit-content; }
.ess-dialog__inner { flex: none; overflow-y: auto; }

/* Phase 35.3 — dialog polish to match the catalogue tiles (visual only). */
.ess-dialog__preview { border-color: var(--ess-stage-edge); border-radius: 24px; }
.ess-dialog__photo { border-radius: 18px; box-shadow: inset 0 0 0 1px var(--ess-stage-edge); }
.ess-dialog__photo-img { animation: essPhotoIn var(--dur-3) var(--ess-ease) both; }
@keyframes essPhotoIn { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
.ess-dialog__title { font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem); font-weight: 650; }
.ess-dialog__product-eyebrow { text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.ess-dialog__product-eyebrow::before { display: none; }
.ess-dialog__product-name { font-weight: 600; }
.ess-dialog__product-facts dt { text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); font-weight: 500; }
.ess-dialog__product-facts dd { font-size: var(--fs-base); }
.ess-seg { border-radius: 16px; }
.ess-seg__opt > span { border-radius: 12px; }
@media (hover: hover) {
  .ess-seg__opt:hover input:not(:checked):not(:disabled) + span { background: rgb(var(--pink-rgb) / 0.28); color: var(--ink); }
  :root[data-theme="dark"] .ess-seg__opt:hover input:not(:checked):not(:disabled) + span { background: rgb(var(--pink-rgb) / 0.1); }
}
.ess-alt.ess-alt--single { padding: 0; border: 0; }
@media (prefers-reduced-motion: reduce) { .ess-dialog__photo-img { animation: none !important; } }

/* Phase 35.4: don't truncate a product type at 320px phone widths. */
@media (max-width: 359px) {
  .ess-card__type { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .ess-card__head { align-items: flex-start; }
}
