/* ============================================================
   Design-system primitives. Every reusable visual pattern lives
   here, on tokens.css variables only — feature styles in pages.css
   may compose these but never redefine them. Documented live at
   /admin/design.
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.6em;
  padding: 0.95em 1.6em;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--dur-2) var(--ease);
}
.btn:hover { background: transparent; color: var(--ink); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border-color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-quiet {
  background: transparent; border-color: var(--line); color: var(--ink-soft);
}
.btn-quiet:hover { border-color: var(--ink); color: var(--ink); }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.35; pointer-events: none; }
/* A sold-out CTA is a non-interactive span styled as a button — don't imply a click. */
.btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }

/* ---------- Text links ---------- */
.link-arrow {
  background: transparent; border: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-2) 0;
  transition: color var(--dur-1), border-color var(--dur-1);
  text-decoration: none;
}
.link-arrow:hover { color: var(--ink); border-color: var(--ink); }
.link-quiet {
  background: transparent; border: 0; cursor: pointer;
  font-family: var(--font-sans);
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-mute);
  padding: var(--sp-1) 0;
  transition: color var(--dur-1);
}
.link-quiet:hover { color: var(--ink); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--outline { color: var(--ink-soft); border-color: var(--line); background: var(--bg-card); }
.badge--solid { color: var(--ink); background: var(--bg); }
.badge--accent { color: var(--bg); background: var(--accent); }
.badge--ink { color: var(--bg); background: var(--ink); }
/* On a photo tile. --end takes the diagonally opposite corner, not the top-right:
   side by side, a long category and a stock label collide on a phone (55px in RU). */
.badge--overlay, .badge--overlay-end { position: absolute; }
.badge--overlay { top: 14px; left: 14px; }
.badge--overlay-end { top: auto; left: auto; right: 14px; bottom: 14px; }

/* ---------- Icon button ---------- */
.icon-btn {
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink-mute); font-size: 18px;
  /* ≥40px tap target */
  min-width: 40px; min-height: 40px;
  display: inline-grid; place-items: center;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn--ink { color: var(--ink); position: relative; }

/* ---------- Quantity stepper ---------- */
.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stepper__btn {
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: transparent; cursor: pointer; color: var(--ink);
  font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color var(--dur-1);
}
.stepper__btn:hover:not(:disabled) { border-color: var(--ink); }
.stepper__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper__value { min-width: 48px; text-align: center; }

/* ---------- Card ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}
.card--snug { padding: var(--sp-5); }
.card--sticky { position: sticky; top: calc(var(--header-clear) + 12px); }
.card--elevated { box-shadow: var(--shadow-2); }
/* Sticky is pointless once the page grid stacks; release it and give the card air. */
@media (max-width: 900px) {
  .card--sticky { position: static; margin-top: 24px; }
}

/* ---------- Form grid ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Form field ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { display: flex; flex-direction: column; gap: 6px; }
.field p { margin: 0; }
.field__label {
  font-family: var(--font-sans);
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-mute);
}
.field__hint { font-size: 12px; color: var(--ink-mute); }
.field__error { font-size: 12px; color: var(--danger); }
.field input:not([type="submit"]), .field select, .field textarea {
  padding: var(--sp-3);
  border: 1px solid var(--line); background: var(--bg-card);
  border-radius: var(--r-md);
  font-family: var(--font-serif); font-size: 15px;
  color: var(--ink);
  outline: none;
}
.field select { cursor: pointer; }
.field input:not([type="submit"]):focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink);
}
.field--invalid input, .field--invalid select, .field--invalid textarea {
  border-color: var(--danger);
}

/* ---------- Summary rows ---------- */
.summary { margin: 0; }
.summary__row {
  display: flex; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-serif);
}
.summary__row--muted { color: var(--ink-soft); }
.summary__total {
  display: flex; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) 0 0;
  font-family: var(--font-serif);
  font-size: var(--step-1);
}
.summary__em { font-style: italic; }

/* ---------- Flash messages ---------- */
#flash {
  position: fixed;
  top: var(--header-clear); /* so the toast never covers the nav */
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  z-index: var(--z-flash);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}
.flash {
  --flash-enter: -8px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 12px 14px 12px 22px;
  border-radius: var(--r-pill);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-2);
  animation: flashIn 0.25s var(--ease);
}
.flash-alert  { background: var(--terracotta-deep); color: var(--white); }
.flash-notice { background: var(--sage-deep); color: var(--white); }
.flash-error  { background: var(--danger); color: var(--white); }
.flash--accent { background: var(--accent); color: var(--bg); }
/* Embedded validation/error box rather than a floating toast. */
.flash--inline {
  position: static;
  transform: none;
  border-radius: var(--r-md);
  animation: none;
  box-shadow: none;
  margin-bottom: 20px;
}
.flash-text { min-width: 0; }
.flash-close {
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: inherit;
  opacity: 0.8;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--r-pill);
}
/* Pads the hit area to ~42px without inflating the pill. */
.flash-close::after { content: ""; position: absolute; inset: -8px; }
.flash-close:hover { opacity: 1; }
.flash-close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 2px; }
.flash.is-leaving {
  opacity: 0;
  transform: translateY(var(--flash-enter));
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
@keyframes flashIn {
  from { opacity: 0; transform: translateY(var(--flash-enter)); }
  to   { opacity: 1; transform: none; }
}
/* Below 375px the header wraps to two rows and would sit under a top-anchored
   toast, so phones get the standard bottom placement instead. */
@media (max-width: 560px) {
  #flash { top: auto; bottom: 16px; }
  .flash { --flash-enter: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
  .flash.is-leaving { transition: none; }
}

/* ---------- Modal shell ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--scrim);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn var(--dur-2) var(--ease);
}
.modal-scrim[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  background: var(--bg);
  border-radius: var(--r-lg);
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-2);
  animation: modalIn var(--dur-3) var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.modal-head h3 { margin: 4px 0 0; font-style: italic; }
.modal-body { padding: 28px 32px; min-height: 280px; }
.modal-foot {
  display: flex; justify-content: space-between; gap: var(--sp-3);
  padding: 20px 32px; border-top: 1px solid var(--line);
}

/* ---------- Drawer shell ---------- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: var(--scrim);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2);
}
.drawer-scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-panel);
  width: min(440px, 100%);
  background: var(--bg);
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-2);
}
.drawer.on { transform: translateX(0); }
.drawer__head {
  display: flex; justify-content: space-between;
  padding: var(--sp-5) 28px;
  border-bottom: 1px solid var(--line);
}
.drawer__head h3 { margin: 0; font-style: italic; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; color: var(--ink-mute); padding: var(--sp-8) 0; }
.empty-state--snug { padding: var(--sp-7) 0; }
.empty-state__action { margin-top: var(--sp-5); }

/* ---------- Page hero ---------- */
.page-hero {
  padding: clamp(60px, 9vw, 120px) 0 clamp(40px, 6vw, 80px);
  border-bottom: 1px solid var(--line);
}
/* Detail pages use the hero band only for a back-link, so it needs far less
   air than a title-bearing index hero — otherwise the product sits low behind
   a tall empty strip. */
.page-hero--back {
  padding: clamp(24px, 4vw, 40px) 0 clamp(18px, 2.5vw, 26px);
}
.page-hero .eyebrow { margin-bottom: 16px; }
.page-hero--back .eyebrow { margin-bottom: 0; }
.page-hero h1 {
  font-style: italic;
  font-size: var(--display-1);
  margin: 0 0 20px;
  line-height: 0.95;
}
.page-hero .lede {
  max-width: 560px;
  font-size: var(--step-1);
  color: var(--ink-soft);
  margin: 0;
}
