/* ==========================================================================
   feature: UI-02

   Primitives: the shared vocabulary every template is written in.

   The class names are the ones the templates have always used (.surface,
   .glass, .pill, .btn-accent, .btn-quiet, .btn-glass, .cluster). What they
   draw changed: .glass is now a tinted panel rather than a blurred one,
   .btn-glass is a plain secondary button, and nothing lifts on hover unless
   it is actually a link. Keeping the names is what let a hundred templates
   change look at once without a hundred edits.

   Blur survives in one place: the sticky site header, which is translucent
   so the page reads as scrolling under it. A repeated item never blurs.
   See plan/adr/0009-flat-neutral-design.md.
   ========================================================================== */

/* ---------------------------------------------------- bootstrap bridge --- */
/* Bootstrap's own components (tables, dropdowns, breadcrumbs, checkboxes,
   list groups) read these variables. Pointing them at the tokens means
   they follow the theme instead of staying Bootstrap-white in dark mode. */
:root {
  --bs-body-bg: var(--bg-base);
  --bs-body-color: var(--text);
  --bs-body-font-family: var(--font-sans);
  --bs-secondary-color: var(--text-muted);
  --bs-tertiary-color: var(--text-subtle);
  --bs-secondary-bg: var(--bg-subtle);
  --bs-tertiary-bg: var(--bg-subtle);
  --bs-border-color: var(--border);
  --bs-border-color-translucent: var(--border);
  --bs-emphasis-color: var(--text);
  --bs-heading-color: var(--text);
  --bs-link-color: var(--link);
  --bs-link-color-rgb: 67, 56, 202;
  --bs-link-hover-color: var(--text);
  --bs-primary: var(--c-accent-strong);
  --bs-border-radius: var(--r-sm);
  --bs-border-radius-lg: var(--r-md);
  --bs-focus-ring-color: rgba(79, 70, 229, 0.25);
}

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

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

body {
  background-color: var(--bg-base);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

/* The page background as one fixed layer. It is now a flat colour, so it
   costs nothing, but the element stays because both shells render it and
   a theme that wants texture back has one place to put it. */
.app-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-base);
  pointer-events: none;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--lh-tight);
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 { font-size: var(--fs-3xl); letter-spacing: -0.025em; font-weight: 700; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
.h5 { font-size: var(--fs-lg); }
.h6 { font-size: var(--fs-base); }

p { margin-bottom: var(--s-4); }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

hr { border-color: var(--border); opacity: 1; }

::selection { background: var(--c-accent-tint); color: var(--text); }

.text-muted-token  { color: var(--text-muted); }
.text-subtle-token { color: var(--text-subtle); }

.tabular { font-variant-numeric: tabular-nums; }

/* Focus is a solid outline, never a glow. A glow disappears against a
   bright background, which is exactly where keyboard users need it most. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------- layout --- */
.container, .container-lg, .container-xl {
  max-width: var(--container);
  padding-inline: var(--s-5);
}

@media (max-width: 575.98px) {
  .container, .container-lg, .container-xl { padding-inline: var(--s-4); }
}

.stack   { display: flex; flex-direction: column; gap: var(--s-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

/* ---------------------------------------------------- panel (.glass) --- */
/* A tinted panel for a block that groups things: a filter column, an
   explanatory note, a summary. It is set apart by tone, not by a shadow,
   so a page with three of them still has one clear focal point. */
.glass {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.glass--heavy { background: var(--surface); box-shadow: var(--shadow-md); }
.glass--flush { border-radius: 0; }
.glass--lg    { border-radius: var(--r-xl); }
.glass--pad   { padding: var(--s-5); }

/* Text that used to need a scrim over a blur. Now a quiet callout. */
.on-glass {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--text-muted);
}

/* --------------------------------------------------- card (.surface) --- */
/* The repeated element: a product, an order row, a queue item. White on
   the page, a hairline border, no shadow until it is something you can
   click, and then only a small one. A card that is not a link does not
   move when the pointer crosses it, because movement promises an action. */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

a.surface, button.surface, .surface--link { color: var(--text); text-decoration: none; }

a.surface:hover, button.surface:hover, .surface--link:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  color: var(--text);
  text-decoration: none;
}

button.surface { cursor: pointer; }

.surface--pad  { padding: var(--s-5); }
.surface--flat { box-shadow: none; }

@media (max-width: 575.98px) {
  .glass--pad, .surface--pad { padding: var(--s-4); }
}

/* ---------------------------------------------------------- buttons --- */
/* Three weights and no more. Primary (.btn-accent) is the one thing on a
   screen we want done. Secondary (.btn-quiet, and .btn-glass, which is
   the same button under its old name) is everything else. Ghost is for
   actions inside a row. All share one height, so a form row lines up. */
.btn-accent,
.btn-quiet,
.btn-glass,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--control-h);
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.btn-accent:hover, .btn-quiet:hover, .btn-glass:hover, .btn-ghost:hover { text-decoration: none; }

.btn-accent {
  background: var(--grad-primary);
  border-color: transparent;
  color: var(--text-on-accent);
  box-shadow: var(--shadow-primary);
}

.btn-accent:hover { background: var(--grad-primary-hover); color: var(--text-on-accent); }

.btn-quiet,
.btn-glass {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-quiet:hover,
.btn-glass:hover { background: var(--bg-subtle); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-danger-quiet { color: var(--c-danger); }

.btn-lg { min-height: var(--control-h-lg); padding: 0 var(--s-5); font-size: var(--fs-base); border-radius: var(--r-md); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-block { display: flex; width: 100%; }

/* A button that cannot be pressed has to look like it. The old theme gave
   "Add to cart" on an out-of-stock listing the same full colour as a live
   one. */
.btn-accent:disabled, .btn-quiet:disabled, .btn-glass:disabled, .btn-ghost:disabled,
.btn-accent[aria-disabled="true"], .btn-quiet[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-accent:disabled:hover { background: var(--grad-primary); }

/* A square button holding one icon. */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--r-sm);
  border: 0;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.icon-btn:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; }

/* Buttons that hold an icon inline with text. */
.btn-accent svg, .btn-quiet svg, .btn-glass svg, .btn-ghost svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------ badges --- */
/* State is carried by a tinted fill AND a text colour, never by an edge
   alone: a border is invisible in forced-colours mode and to anybody who
   cannot tell the hues apart. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 0.125rem 0.5rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
  background: var(--bg-muted);
  color: var(--text-muted);
}

.pill--success { background: var(--c-success-tint); color: var(--c-success); }
.pill--warning { background: var(--c-warning-tint); color: var(--c-warning); }
.pill--danger  { background: var(--c-danger-tint);  color: var(--c-danger); }
.pill--info    { background: var(--c-info-tint);    color: var(--c-info); }
.pill--sale    { background: var(--c-accent-2-tint); color: var(--c-accent-2); }

/* A count badge. Filled with the strong accent so white text clears 4.5:1
   in both themes. Guarded by TestContrast. */
.pill--accent {
  background: var(--grad-primary);
  color: var(--text-on-accent);
  min-width: 1.25rem;
  justify-content: center;
}

/* Sponsored placement must be visibly labelled. See plan/04-seo.md. */
.pill--sponsored { background: transparent; border-color: var(--border-strong); color: var(--text-subtle); }

/* The count that sits on the corner of a header icon. */
.count-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--c-accent-2);
  color: var(--text-on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid var(--bg-base);
}

/* --------------------------------------------------------- stat tile --- */
.stat-tile {
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.stat-tile__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.stat-tile__value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

/* ------------------------------------------------------------- forms --- */
.form-control,
.form-select {
  min-height: var(--control-h);
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

/* background-color, not background: the shorthand wiped Bootstrap's arrow
   image off every select, which is why "Sort by" looked like an empty box. */
.form-control:focus,
.form-select:focus {
  background-color: var(--surface);
  border-color: var(--c-accent);
  color: var(--text);
  box-shadow: var(--ring);
}

.form-control::placeholder { color: var(--text-subtle); }
.form-control:disabled, .form-select:disabled { background-color: var(--bg-subtle); color: var(--text-subtle); }

textarea.form-control { min-height: 6rem; }

.form-label {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 550;
  margin-bottom: var(--s-1);
}

legend.form-label { float: none; }

.form-text, .helptext { color: var(--text-subtle); font-size: var(--fs-xs); }
.invalid-feedback, .errorlist { color: var(--c-danger); font-size: var(--fs-sm); }
.is-invalid { border-color: var(--c-danger) !important; }

.form-check-input {
  background-color: var(--surface);
  border-color: var(--border-strong);
}

.form-check-input:checked {
  background-color: var(--c-accent-strong);
  border-color: var(--c-accent-strong);
}

.form-check-input:focus { border-color: var(--c-accent); box-shadow: var(--ring); }
.form-check-label { font-size: var(--fs-sm); }

/* A field with a leading icon: the search boxes. */
.input-icon { position: relative; }
.input-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}
.input-icon .form-control { padding-left: 40px; }

/* ------------------------------------------------ bootstrap overrides --- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: var(--bg-subtle);
  --bs-table-hover-bg: var(--bg-subtle);
  font-size: var(--fs-sm);
}

.table > thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dropdown-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-color: var(--text);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-color: var(--text);
  --bs-dropdown-link-hover-color: var(--text);
  --bs-dropdown-link-hover-bg: var(--bg-subtle);
  --bs-dropdown-link-active-bg: var(--c-accent-tint);
  --bs-dropdown-link-active-color: var(--text);
  --bs-dropdown-divider-bg: var(--border);
  --bs-dropdown-header-color: var(--text-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: var(--s-2);
  font-size: var(--fs-sm);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
}

.dropdown-item svg { width: 18px; height: 18px; color: var(--text-subtle); }
.dropdown-item:hover { text-decoration: none; }

.breadcrumb {
  --bs-breadcrumb-divider-color: var(--text-subtle);
  --bs-breadcrumb-item-active-color: var(--text-muted);
  font-size: var(--fs-sm);
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }

.list-group {
  --bs-list-group-bg: var(--surface);
  --bs-list-group-color: var(--text);
  --bs-list-group-border-color: var(--border);
  --bs-list-group-action-hover-bg: var(--bg-subtle);
  --bs-list-group-action-hover-color: var(--text);
}

.alert { border-radius: var(--r-md); font-size: var(--fs-sm); }

.nav-tabs { --bs-nav-tabs-border-color: var(--border); --bs-nav-tabs-link-active-bg: var(--bg-base); }
.nav-link { color: var(--text-muted); }
.nav-link:hover { color: var(--text); }

.progress { --bs-progress-bg: var(--bg-muted); --bs-progress-bar-bg: var(--c-accent-strong); }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.btn-close { filter: var(--btn-close-filter, none); }

/* ------------------------------------------------------------ images --- */
/* Width and height attributes are required in templates; this keeps the box
   correct while preserving the aspect ratio. */
img { max-width: 100%; height: auto; }

.media-frame {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-subtle);
  aspect-ratio: 1 / 1;
}

.media-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* What an image well shows when there is no photo: an outline, not a hole. */
.media-frame--empty::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 36px;
  height: 36px;
  opacity: 0.35;
  background: currentColor;
  color: var(--text-subtle);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ====================================================== site header ===== */
/* Sticky and translucent, the one blurred surface on a storefront page.
   Two rows: the bar (brand, search, actions) and the category strip. */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-floating);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.site-header__bar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: var(--header-h);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  flex: 0 0 auto;
  color: var(--text);
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}

.site-brand:hover { color: var(--text); text-decoration: none; }

.site-brand__mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--grad-brand);
  color: var(--text-on-accent);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.site-search { flex: 1 1 auto; max-width: 640px; margin-inline: auto; }
.site-search .form-control { min-height: 36px; background-color: var(--bg-subtle); box-shadow: none; border-color: transparent; }
.site-search .form-control:focus { background-color: var(--surface); border-color: var(--c-accent); }

.site-actions { display: flex; align-items: center; gap: var(--s-1); flex: 0 0 auto; margin-left: auto; }
.site-actions .btn-accent, .site-actions .btn-quiet { min-height: 36px; }

.account-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--control-h);
  padding: 0 var(--s-2) 0 var(--s-1);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 550;
  cursor: pointer;
}

.account-toggle:hover { background: var(--bg-subtle); }
.account-toggle .avatar { width: 28px; height: 28px; font-size: var(--fs-xs); background: var(--grad-brand); color: var(--text-on-accent); }
.account-toggle::after { display: none; }

.dropdown-menu .dropdown-meta { padding: var(--s-2) var(--s-3) var(--s-3); }
.dropdown-menu .dropdown-meta strong { display: block; font-size: var(--fs-sm); }
.dropdown-menu .dropdown-meta span { display: block; color: var(--text-subtle); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; }

/* The category strip. One line that scrolls sideways on a phone rather
   than wrapping into a wall of links. */
.site-nav {
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(var(--s-2) * -1);
  padding-bottom: var(--s-2);
}

.site-nav::-webkit-scrollbar { display: none; }

.site-nav a {
  flex: 0 0 auto;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}

.site-nav a:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 650; }
.site-nav .site-nav__deals { color: var(--c-accent-2); background: var(--c-accent-2-tint); font-weight: 650; }
.site-nav .site-nav__deals:hover { color: var(--c-accent-2); background: var(--c-accent-2-tint); }

.site-search--mobile { display: none; padding-bottom: var(--s-3); }

@media (max-width: 767.98px) {
  .site-header__bar { gap: var(--s-2); min-height: 56px; }
  .site-header__bar .site-search { display: none; }
  .site-search--mobile { display: block; max-width: none; }
  .site-actions .hide-sm { display: none !important; }
}

/* ====================================================== site footer ===== */
.site-footer {
  margin-top: var(--s-8);
  background: var(--footer-bg);
  color: var(--footer-text);
  border-top: 1px solid var(--footer-border);
  padding: var(--s-7) 0 var(--s-5);
  font-size: var(--fs-sm);
}

.site-footer h2 {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--footer-muted);
  font-weight: 650;
  margin-bottom: var(--s-3);
}

.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.site-footer a { color: var(--footer-text); }
.site-footer a:hover { color: var(--text-inverse); }
.site-footer .site-brand, .site-footer .site-brand:hover { color: var(--footer-text); }
.site-footer .text-muted-token { color: var(--footer-muted); }
.site-footer .btn-ghost { color: var(--footer-muted); }
.site-footer .btn-ghost:hover { background: var(--footer-border); color: var(--footer-text); }

.site-footer__base {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--footer-border);
  color: var(--footer-muted);
  font-size: var(--fs-xs);
}

/* ======================================================= page parts ===== */
/* A section heading with an optional link on the right. */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

.section-head h2 { margin: 0; font-size: var(--fs-xl); }
.section-head a { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }

.section { margin-bottom: var(--s-7); }

.page-head { margin-bottom: var(--s-5); }
.page-head h1 { margin-bottom: var(--s-2); }
.page-head p { color: var(--text-muted); margin-bottom: 0; max-width: 60ch; }

.eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: var(--s-2);
}

/* The home page hero. */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--grad-hero);
  border: 1px solid var(--border);
  padding: var(--s-7) var(--s-7);
  margin-bottom: var(--s-7);
}

.hero h1 { font-size: var(--fs-4xl); line-height: 1.08; max-width: 18ch; margin-bottom: var(--s-4); }
.hero h1 em {
  font-style: normal;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { font-size: var(--fs-lg); color: var(--text-muted); max-width: 46ch; margin-bottom: var(--s-5); }
.hero__search { display: flex; gap: var(--s-2); max-width: 520px; }
.hero__search .input-icon { flex: 1 1 auto; }
.hero__search .form-control { min-height: var(--control-h-lg); font-size: var(--fs-base); }
.hero__img { width: 100%; border-radius: var(--r-lg); object-fit: cover; aspect-ratio: 4 / 3; }

.hero__points { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-5); color: var(--text-muted); font-size: var(--fs-sm); }
.hero__points span { display: inline-flex; align-items: center; gap: var(--s-2); }
.hero__points svg { width: 18px; height: 18px; color: var(--c-success); }

@media (max-width: 767.98px) {
  .hero { padding: var(--s-6) var(--s-4); border-radius: var(--r-lg); }
  .hero h1 { font-size: var(--fs-3xl); }
  .hero p { font-size: var(--fs-base); }
}

/* A category tile. */
.category-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  height: 100%;
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.category-tile:hover { border-color: var(--border-strong); background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.category-tile strong { display: block; font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; }
.category-tile span { display: block; font-size: var(--fs-xs); color: var(--text-subtle); }
.category-tile svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-subtle); }
.category-tile__chip {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid !important;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--hue-tint, var(--c-accent-tint));
  color: var(--hue, var(--c-accent)) !important;
  font-size: var(--fs-sm) !important;
  font-weight: 750;
}
.category-tile:hover { border-color: var(--hue, var(--border-strong)); }

/* Cycle the hues over any grid of tiles or cards. */
.hues > :nth-child(6n+1) { --hue: var(--hue-1); --hue-tint: var(--hue-1-tint); }
.hues > :nth-child(6n+2) { --hue: var(--hue-2); --hue-tint: var(--hue-2-tint); }
.hues > :nth-child(6n+3) { --hue: var(--hue-3); --hue-tint: var(--hue-3-tint); }
.hues > :nth-child(6n+4) { --hue: var(--hue-4); --hue-tint: var(--hue-4-tint); }
.hues > :nth-child(6n+5) { --hue: var(--hue-5); --hue-tint: var(--hue-5-tint); }
.hues > :nth-child(6n+6) { --hue: var(--hue-6); --hue-tint: var(--hue-6-tint); }

/* A product in a grid. */
.product-card { position: relative; display: flex; flex-direction: column; height: 100%; }
.product-card__media { display: block; margin-bottom: var(--s-3); }
.product-card__media .media-frame { transition: opacity var(--dur-fast) var(--ease-out); }
.product-card:hover .product-card__media .media-frame { opacity: 0.92; }
.product-card__badges { position: absolute; top: var(--s-2); left: var(--s-2); display: flex; gap: var(--s-1); z-index: var(--z-raised); }
.product-card__badges .pill { background: var(--surface); box-shadow: var(--shadow-sm); }
.product-card__badges .pill--success { background: var(--c-success-tint); }
.product-card__badges .pill--sale, .product-card__badges .pill--danger { background: var(--c-accent-2-tint); color: var(--c-accent-2); }

.product-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 2px;
  font-size: var(--fs-sm);
  font-weight: 550;
  line-height: 1.4;
}

.product-card__title a { color: var(--text); }
.product-card__title a::after { content: ""; position: absolute; inset: 0; }
.product-card__title a:hover { text-decoration: none; }
.product-card:hover .product-card__title a { text-decoration: underline; text-underline-offset: 3px; }

.product-card__seller { position: relative; z-index: var(--z-raised); font-size: var(--fs-xs); color: var(--text-subtle); margin-bottom: var(--s-2); }
.product-card__seller a { color: var(--text-subtle); }
.product-card__foot { margin-top: auto; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.product-card__meta { font-size: var(--fs-xs); color: var(--text-subtle); }

.price { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); letter-spacing: -0.01em; }
.price s { font-weight: 400; color: var(--text-subtle); font-size: 0.85em; margin-left: var(--s-1); }
.price--sale { color: var(--c-accent-2); }
.price--lg { font-size: var(--fs-3xl); }

.rating { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rating svg { width: 14px; height: 14px; color: var(--c-star); fill: currentColor; }

/* The product grid. Fixed columns per breakpoint rather than auto-fill, so
   a row of two cards on a wide screen keeps card size instead of
   stretching them to half the page. */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-5) var(--s-4);
}

@media (min-width: 768px)  { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .product-grid--wide { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* The listing page layout: a filter column and the results. */
.browse { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.browse__filters { position: sticky; top: calc(var(--header-h) + 56px); }
.browse__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); min-height: 40px; }
.browse__count { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }

@media (max-width: 991.98px) {
  .browse { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .browse__filters { position: static; }
}

/* The filter panel. A <details> on small screens, so filters fold away
   rather than pushing every result below the fold. */
.filters { font-size: var(--fs-sm); }
.filters summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-weight: 650; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary svg { width: 18px; height: 18px; transition: transform var(--dur-fast) var(--ease-out); }
.filters[open] summary svg { transform: rotate(180deg); }
.filters__group { padding: var(--s-4) 0; border-top: 1px solid var(--border); }
.filters__group:first-of-type { border-top: 0; }
.filters__title { font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); margin-bottom: var(--s-2); }

@media (min-width: 992px) {
  .filters summary { pointer-events: none; }
  .filters summary svg { display: none; }
}

/* Subcategory chips. */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 0.375rem 0.875rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.chip:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.chip[aria-current] { background: var(--text); border-color: var(--text); color: var(--bg-base); }

/* An empty state: a list that has nothing in it yet. */
.empty-state {
  padding: var(--s-7) var(--s-5);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-muted);
}

.empty-state svg { width: 40px; height: 40px; color: var(--text-subtle); margin-bottom: var(--s-3); }
.empty-state h2, .empty-state h3 { font-size: var(--fs-lg); margin-bottom: var(--s-2); }
.empty-state p { max-width: 44ch; margin: 0 auto var(--s-4); }
.empty-state p:last-child { margin-bottom: 0; }

/* A definition list laid out as rows: summaries, specifications. */
.kv { display: grid; gap: var(--s-2); margin: 0; font-size: var(--fs-sm); }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-4); }
.kv dt { font-weight: 400; color: var(--text-muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.kv__total { padding-top: var(--s-3); margin-top: var(--s-1); border-top: 1px solid var(--border); }
.kv__total dt, .kv__total dd { color: var(--text); font-weight: 700; font-size: var(--fs-base); }

.spec-table { width: 100%; font-size: var(--fs-sm); border-collapse: collapse; }
.spec-table th, .spec-table td { padding: var(--s-2) 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.spec-table th { width: 40%; color: var(--text-muted); font-weight: 400; padding-right: var(--s-4); }

/* A row inside a list card: a cart line, an order item. */
.line-item { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) 0; border-top: 1px solid var(--border); }
.line-item:first-child { border-top: 0; padding-top: 0; }
.line-item__img { width: 72px; height: 72px; flex: 0 0 auto; border-radius: var(--r-sm); object-fit: cover; background: var(--bg-subtle); }
.line-item__body { flex: 1 1 auto; min-width: 0; }
.line-item__title { font-weight: 600; color: var(--text); font-size: var(--fs-sm); }
.line-item__meta { color: var(--text-subtle); font-size: var(--fs-xs); }
.line-item__end { display: flex; align-items: center; gap: var(--s-3); flex: 0 0 auto; }

@media (max-width: 575.98px) {
  .line-item { flex-wrap: wrap; }
  .line-item__end { width: 100%; justify-content: space-between; gap: var(--s-2); }
  .line-item__end strong { min-width: 0 !important; margin-left: auto; }
}

/* A block that sticks beside a long column: the cart summary, the buy box. */
.sticky-aside { position: sticky; top: calc(var(--header-h) + var(--s-5)); }

@media (max-width: 991.98px) { .sticky-aside { position: static; } }

/* Small reassurance rows under a buy button. */
.assurances { display: grid; gap: var(--s-2); margin: var(--s-4) 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--text-muted); }
.assurances li { display: flex; gap: var(--s-2); align-items: flex-start; }
.assurances svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; color: var(--text-subtle); }

/* A numbered step indicator: checkout. */
.steps { display: flex; gap: var(--s-2); list-style: none; padding: 0; margin: 0 0 var(--s-5); font-size: var(--fs-sm); color: var(--text-subtle); }
.steps li { display: flex; align-items: center; gap: var(--s-2); }
.steps li + li::before { content: ""; width: 24px; height: 1px; background: var(--border-strong); }
.steps li[aria-current] { color: var(--text); font-weight: 600; }

/* Messages (Django's flash messages). */
.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-sm);
}

.flash svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; }
.flash--success { border-color: color-mix(in srgb, var(--c-success) 35%, var(--border)); }
.flash--success svg { color: var(--c-success); }
.flash--error { border-color: color-mix(in srgb, var(--c-danger) 35%, var(--border)); }
.flash--error svg { color: var(--c-danger); }
.flash--warning { border-color: color-mix(in srgb, var(--c-warning) 35%, var(--border)); }
.flash--warning svg { color: var(--c-warning); }
.flash--info svg { color: var(--c-info); }

/* ---------------------------------------------------------- avatars --- */
.avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: var(--c-accent-tint);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--c-accent);
  overflow: hidden;
}

.avatar--sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar--lg { width: 48px; height: 48px; }

/* ============================ accessibility preferences ================== */

/* Some viewers find translucency hard to read. The header is the only
   translucent surface left, and it turns opaque. */
@media (prefers-reduced-transparency: reduce) {
  .site-header,
  .glass-nav {
    background: var(--glass-bg-strong) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

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

@media (forced-colors: active) {
  .glass, .surface, .btn-glass, .btn-quiet, .pill, .site-header, .category-tile, .flash {
    background: Canvas;
    border: 1px solid CanvasText;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ------------------------------------------------------------- utility --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
}

.skip-link:focus { left: var(--s-4); top: var(--s-4); }

.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ============================== account pages ============================
   allauth renders its own markup, so these rules style it as a centred card
   without needing a wrapper element the account templates do not provide.
   ========================================================================= */
main.auth-shell {
  max-width: 28rem;
  margin: var(--s-7) auto;
  padding: var(--s-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

@media (max-width: 575.98px) {
  main.auth-shell { margin: var(--s-4); padding: var(--s-5); }
}

main.auth-shell h1 { font-size: var(--fs-2xl); margin-bottom: var(--s-3); }
main.auth-shell p  { color: var(--text-muted); font-size: var(--fs-sm); }

/* allauth's own field element bypasses crispy in a few places, so raw
   controls get the same treatment rather than falling back to browser
   defaults. */
main.auth-shell input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
main.auth-shell select,
main.auth-shell textarea {
  width: 100%;
  min-height: 42px;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-sm);
}

main.auth-shell input:focus, main.auth-shell select:focus, main.auth-shell textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: var(--ring);
}

main.auth-shell label { color: var(--text); font-size: var(--fs-sm); font-weight: 550; }
main.auth-shell ul { list-style: none; padding-left: 0; }
main.auth-shell .errorlist { color: var(--c-danger); font-size: var(--fs-sm); }
main.auth-shell form { display: grid; gap: var(--s-2); }

main.auth-shell button[type="submit"],
main.auth-shell [type="submit"] {
  width: 100%;
  min-height: 44px;
  margin-top: var(--s-3);
  cursor: pointer;
}

main.auth-shell hr { margin: var(--s-5) 0; }

/* ------------------------------------------------------- theme toggle --- */
/* Shows the icon for the theme you would switch to. */
.theme-toggle span { display: inline-grid; place-items: center; }
.theme-toggle__dark { display: none !important; }
:root[data-theme="dark"] .theme-toggle__light { display: none !important; }
:root[data-theme="dark"] .theme-toggle__dark { display: inline-grid !important; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__light { display: none !important; }
  :root:not([data-theme="light"]) .theme-toggle__dark { display: inline-grid !important; }
}

.account-toggle__chevron { display: inline-flex; width: 16px; color: var(--text-subtle); }
.account-menu { min-width: 15rem; }

/* ---------------------------------------------------- product gallery --- */
.product-gallery { display: grid; gap: var(--s-3); }
.product-gallery__main { border-radius: var(--r-lg); }
.product-gallery__thumbs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-2); }
.product-gallery__thumb {
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}
.product-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-gallery__thumb:hover { border-color: var(--border-strong); }
.product-gallery__thumb[aria-current="true"] { border-color: var(--text); }

@media (max-width: 575.98px) {
  .product-gallery__thumbs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ----------------------------------------------------------- reviews --- */
.review { padding: var(--s-4) 0; border-top: 1px solid var(--border); }
.review:first-child { border-top: 0; padding-top: 0; }

.stars { display: inline-flex; gap: 1px; vertical-align: middle; }
.stars svg { width: 16px; height: 16px; }
.stars__on { color: var(--c-star); display: inline-flex; }
.stars__on svg { fill: currentColor; }
.stars__off { color: var(--border-strong); display: inline-flex; }

/* ------------------------------------------------------------- heart --- */
.heart { padding: 0; width: 40px; }
.heart.btn-lg { width: 48px; }
.heart--on { color: var(--c-danger); }
.heart--on:hover { color: var(--c-danger); }

/* ---------------------------------------------------------- promo band --- */
.promo-band {
  background: var(--grad-primary);
  color: var(--text-on-accent);
  border: 0;
  border-radius: var(--r-xl);
  padding: var(--s-6) var(--s-7);
}
.promo-band h2, .promo-band p, .promo-band .text-muted-token { color: var(--text-on-accent); }
.promo-band p { opacity: 0.88; }
.promo-band .btn-quiet { background: var(--surface); color: var(--text); border-color: transparent; }

/* Stat tiles pick up the cycling hue as a top edge and a tinted label. */
.hues > .stat-tile, .hues > * > .stat-tile, .hues > .work-card {
  box-shadow: inset 0 3px 0 var(--hue, transparent);
}
.hues > * .stat-tile__label, .hues > .work-card .stat-tile__label { color: var(--hue, var(--text-muted)); font-weight: 600; }

/* Avatars take a hue too when they sit in a cycling list. */
.hues > * .avatar { background: var(--hue-tint, var(--c-accent-tint)); color: var(--hue, var(--c-accent)); }

/* ---------------------------------------------------------- compact --- */
/* Density. Headings, sections and cards are tighter than a document page,
   because these pages are for scanning and doing, not reading. */
.section { margin-bottom: var(--s-7); }
.page-head { margin-bottom: var(--s-5); }
.section-head { margin-bottom: var(--s-3); }
.product-grid { gap: var(--s-5) var(--s-3); }
@media (min-width: 1200px) { .product-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .product-grid--wide { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.browse { grid-template-columns: 224px minmax(0, 1fr); gap: var(--s-6); }
@media (max-width: 991.98px) { .browse { grid-template-columns: minmax(0, 1fr); } }
.table > :not(caption) > * > * { padding: 0.5rem 0.625rem; }
.line-item__img { width: 60px; height: 60px; }
.empty-state { padding: var(--s-7) var(--s-5); }
main.container { padding-top: var(--s-5) !important; padding-bottom: var(--s-6) !important; }

/* Icons inside badges and avatars size to the text around them. */
.pill svg { width: 12px; height: 12px; }
.avatar svg { width: 55%; height: 55%; }

/* A small "back to" link above a page title. */
.back-link { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--s-2); }
.back-link svg { width: 16px; height: 16px; transform: rotate(180deg); }
.back-link:hover { color: var(--text); }
