/* 05-components.css — Cards, buttons, badges, forms, toasts, star ratings */

/* ─── Feature Grid ─── */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

/* DESIGN.md §4: depth via tonal layering + border, not glass. Glass is reserved
   for the navbar + the wine-detail hero stats panel. Don't reintroduce
   backdrop-filter on general-purpose cards or filter chrome here. */
.feature-card {
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--noir-900);
  border: 1px solid var(--border-default);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

/* Single hover affordance: amber glow + border shift. No translateY lift —
   DESIGN.md §4 explicitly replaces the cliché dashboard lift with the glow. */
.feature-card:hover {
  border-color: var(--border-accent-hover);
  box-shadow: var(--shadow-glow);
}

.feature-card h3 {
  margin-top: 1.5rem;
  font-size: 1.2rem;
}

.feature-card p {
  flex: 1;
  color: var(--ivory-300);
  line-height: 1.6;
}

.feature-card .btn {
  align-self: flex-start;
  margin-top: auto;
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--border-accent);
  color: var(--amber-400);
  font-size: 1.4rem;
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

/* ─── Filter Panel ─── */

/* DESIGN.md §4: depth via tonal layering, not glass. See feature-card note. */
.filter-panel {
  background: var(--noir-900);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--border-default);
}

.filter-panel .form-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ivory-400);
  font-weight: 500;
}

/* ─── Filter chips (styled radio groups) ─── */

.filter-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.filter-chips {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.filter-chips__label {
  flex: 0 0 100%;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ivory-400);
  font-weight: 500;
  margin: 0 0 0.25rem;
  padding: 0;
}

/* Visually hide the radio but keep it in the a11y tree + focusable. */
.filter-chips__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill, 999px);
  background: var(--noir-800);
  color: var(--ivory-300);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.filter-chip:hover {
  color: var(--ivory-100);
  border-color: var(--border-accent);
}

.filter-chips__input:checked + .filter-chip {
  background: var(--amber-400);
  border-color: var(--amber-400);
  color: var(--noir-950);
  font-weight: 500;
}

/* Keyboard focus ring on the chip when its (hidden) radio is focused. */
.filter-chips__input:focus-visible + .filter-chip {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

/* ─── Cards (Global) ─── */

.card {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: none;
  background: var(--noir-900);
  color: var(--ivory-100);
  transition: border-color var(--duration-normal) var(--ease-out),
              background-color var(--duration-normal) var(--ease-out);
}

.card:hover {
  border-color: var(--border-medium);
  background: rgba(255, 255, 255, 0.02);
}

.card:focus-within {
  border-color: var(--border-accent-hover);
}

.card-header {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-default);
  font-weight: 600;
  color: var(--ivory-100);
  padding: var(--space-4) var(--space-5);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  background: transparent;
  border-top: 1px solid var(--border-default);
}

/* ─── Tables ─── */
/* Bootstrap dropped — own the table shape directly. */
.table {
  width: 100%;
  margin-bottom: 0;
  color: var(--ivory-100);
  vertical-align: top;
  background: transparent;
  border-collapse: collapse;
}

.table > :not(caption) > * > * {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-default);
}

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ivory-400);
  border-bottom: 1px solid var(--border-default);
}

.table tbody tr:hover {
  background: rgba(212, 168, 83, 0.05);
}

/* ─── Forms (Dark) ─── */

/* Bootstrap dropped — .form-label previously existed only as the scoped
   `.filter-panel .form-label` variant above, so it never matched a bare
   label and labels sat inline beside their inputs. This is the missing
   base rule: block layout + a quiet type treatment distinct from
   `.form-text` below (NOT the DESIGN.md Eyebrow Rule treatment — that's
   amber/uppercase and reserved for section eyebrows, not ~12 form labels
   across the app). `.filter-panel .form-label` above stays more specific
   and keeps winning inside filter panels. */
.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ivory-200);
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-interactive);
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--ivory-100);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

/* Bootstrap dropped — .input-group and .input-group-text were never
   reimplemented, and .form-control's new `display: block; width: 100%`
   (above) makes an addon span, an input and a trailing indicator span
   stack vertically instead of sitting on one line. Only user of this
   pattern is the wine-search box on onboarding/quick.html. */
.input-group {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
}

.input-group > .form-control {
  flex: 1 1 auto;
  width: auto;
}

/* Helper text under a control (e.g. "We send a verification link here").
   Must read as subordinate to .form-label, not indistinguishable from it —
   smaller size, dimmer color, spaced away from the control above. */
.form-text {
  display: block;
  margin-top: var(--space-2);
  font-size: 0.75rem;
  color: var(--ivory-300);
}

/* Suppress the native UA chevron so the custom SVG below renders alone.
   Without this, browsers (notably WebKit on macOS, Firefox) paint their own
   triangle on top of ours — the "double chevron" bug. */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.25rem;
}

.form-control::placeholder {
  color: var(--ivory-400);
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(212, 168, 83, 0.5);
  box-shadow: 0 0 0 0.2rem rgba(212, 168, 83, 0.1);
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--ivory-100);
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b8ad9e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 12px;
}

.form-select option {
  background: var(--noir-800);
  color: var(--ivory-100);
}

.form-check-input {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
}

.form-check-input:checked {
  background-color: var(--amber-400);
  border-color: var(--amber-400);
}

.form-range::-webkit-slider-thumb {
  background-color: var(--amber-400);
}

.form-range::-moz-range-thumb {
  background-color: var(--amber-400);
}

/* ─── Form Validation States ─── */

.form-control:focus {
  border-color: rgba(212, 168, 83, 0.4);
  box-shadow: var(--input-focus-ring);
  background-color: var(--noir-800);
}

.form-control.is-invalid,
.was-validated .form-control:invalid {
  border-color: rgba(139, 41, 66, 0.5);
  box-shadow: var(--input-error-ring);
}

.form-control.is-valid,
.was-validated .form-control:valid {
  border-color: rgba(59, 109, 92, 0.5);
  box-shadow: var(--input-success-ring);
}

.invalid-feedback {
  color: var(--rouge-300);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.valid-feedback {
  color: var(--sage-400);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.form-select:focus {
  border-color: rgba(212, 168, 83, 0.4);
  box-shadow: var(--input-focus-ring);
  background-color: var(--noir-800);
}

/* ─── Buttons ─── */

.btn {
  border-radius: 999px;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  /* Explicit list, not "all" — "all" swept up outline, so a keyboard focus
     ring faded in from near-black instead of snapping to amber. */
  transition: background-color var(--duration-normal) ease,
              border-color var(--duration-normal) ease,
              color var(--duration-normal) ease,
              box-shadow var(--duration-normal) ease,
              transform var(--duration-normal) ease;
}

/* Bootstrap dropped — .btn-lg previously contributed nothing, so the
   signup/auth/onboarding CTAs (10+ templates) computed to .btn's default
   ~36.4px tall (0.85rem font * 1.5 line-height + 2 * 0.5rem padding),
   under the 44px minimum touch target. Larger padding (--space-4 token)
   plus a bumped font-size clears 44px with margin:
   0.95rem (15.2px) * 1.5 line-height + 2 * 1rem (--space-4) padding = 54.8px. */
.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: 0.95rem;
}

/* Undefined pre-repair, so every "small" button (57 real templates) rendered
   at .btn's full size. Compact but not a touch target itself — matches the
   ~28-32px height 10-responsive.css already assumes for it, which is why
   that file bumps .navbar .btn (small buttons live there) to 44px under
   `@media (pointer: coarse)`. Callers relying on .btn-sm as a lone primary
   action outside that bumped context still need their own touch-target
   affordance; this class only supplies the compact visual size. */
.btn-sm {
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
}

/* Inherits border-radius: 999px from .btn — the system is pill-only.
   DESIGN.md §5: "Pill (999px radius). Square buttons are not in the system." */
.btn-primary {
  background: var(--btn-primary-gradient);
  color: var(--noir-950);
  border: none;
  font-weight: 600;
  box-shadow: var(--btn-primary-shadow);
  /* Same-specificity as .btn and declared later, so this transition (not
     .btn's) is what actually applies to .btn.btn-primary elements — must
     stay outline-free for the same reason. */
  transition: background var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #f0dba8 0%, #e3c17a 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
  box-shadow: var(--btn-primary-shadow);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}

.btn-primary:disabled,
.btn-primary.disabled {
  background: var(--noir-600);
  color: var(--ivory-400);
  border: 1px solid var(--border-default);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-primary .btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(10, 10, 10, 0.3);
  border-top-color: var(--noir-950);
  border-radius: 50%;
  animation: cellar-spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.btn-outline-primary {
  color: var(--amber-400);
  /* border-color alone leaves border-width/border-style at their UA
     initial values (medium / none) — no border ever painted, and a real
     <button> falls back to the browser's own black outset instead. The
     shorthand below sets all three. */
  border: 1px solid var(--amber-400);
}

.btn-outline-primary:hover {
  background: var(--amber-400);
  border-color: var(--amber-400);
  color: var(--noir-950);
}

.btn-outline-primary:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
  background: var(--amber-400);
  border-color: var(--amber-400);
  color: var(--noir-950);
}

.btn-outline-primary:disabled,
.btn-outline-primary.disabled {
  color: var(--ivory-400);
  border-color: var(--border-default);
  cursor: not-allowed;
  background: transparent;
}

.btn-outline-light {
  color: var(--ivory-200);
  border: 1px solid var(--border-strong);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--ivory-100);
}

/* .btn-outline-info / .btn-outline-warning share this rule: no dedicated
   "info" or "warning" hue exists in this token set. Amber is off-limits
   (One Voice Rule caps it at <=10% of a screen and it is already the
   system's one accent), the wine-type hues are off-limits (Wine-Type
   Sacredness Rule), and rouge/sage already carry danger/success. Rather
   than invent a blue and a yellow this dark editorial palette was never
   given, both collapse to the same neutral treatment as
   .btn-outline-secondary. */
.btn-outline-secondary,
.btn-outline-info,
.btn-outline-warning {
  border: 1px solid var(--border-medium);
  color: var(--ivory-200);
}

.btn-outline-secondary:hover,
.btn-outline-info:hover,
.btn-outline-warning:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-accent-hover);
  color: var(--ivory-100);
}

/* Undefined pre-repair, so destructive actions (delete, reject, stop
   recording) carried no danger signal and looked identical to neutral
   buttons. Built from the existing rouge scale, matching how .btn-rouge /
   .btn-outline-rouge (09-features.css) are already built — no new red. */
.btn-danger {
  background: var(--rouge-500);
  color: var(--ivory-100);
  border: 1px solid var(--rouge-500);
}

.btn-danger:hover {
  background: var(--rouge-400);
  color: var(--ivory-100);
}

.btn-danger:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.btn-danger:disabled,
.btn-danger.disabled {
  background: var(--noir-600);
  color: var(--ivory-400);
  border-color: var(--border-default);
  cursor: not-allowed;
}

.btn-outline-danger {
  background: transparent;
  color: var(--rouge-300);
  border: 1px solid var(--rouge-400);
}

.btn-outline-danger:hover {
  background: rgba(139, 41, 66, 0.12);
  color: var(--ivory-100);
  border-color: var(--rouge-400);
}

.btn-outline-danger:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.btn-outline-danger:disabled,
.btn-outline-danger.disabled {
  color: var(--ivory-400);
  border-color: var(--border-default);
  cursor: not-allowed;
  background: transparent;
}

/* Undefined pre-repair, so tertiary actions (12 templates) rendered as a
   bordered nub instead of a link. Quiet by design — the One Voice Rule caps
   amber at <=10% of a screen, and several .btn-link call sites (e.g.
   _empty_state.html) sit right next to an amber .btn-outline-primary, so
   this stays on the ivory scale rather than adding a second amber accent. */
.btn-link {
  background: transparent;
  border: none;
  color: var(--ivory-300);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--ivory-100);
}

.btn-link:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

/* Undefined pre-repair. Solid neutral fill (distinct from the transparent
   .btn-outline-secondary) built from the existing noir surface + border
   scale — no new token. Used for "Cancel"-class actions in modals. */
.btn-secondary {
  background: var(--noir-700);
  color: var(--ivory-100);
  border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
  background: var(--noir-600);
  border-color: var(--border-strong);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.btn-secondary:disabled,
.btn-secondary.disabled {
  background: var(--noir-800);
  color: var(--ivory-400);
  border-color: var(--border-default);
  cursor: not-allowed;
}

/* Undefined pre-repair. Sage is already this system's success semantic
   (DESIGN.md's Inputs/Fields: "Success: Sage halo") — reused here, not a
   new colour. Structure mirrors .btn-danger/.btn-outline-danger. */
.btn-success {
  background: var(--sage-500);
  color: var(--ivory-100);
  border: 1px solid var(--sage-500);
}

.btn-success:hover {
  background: var(--sage-400);
}

.btn-success:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.btn-success:disabled,
.btn-success.disabled {
  background: var(--noir-600);
  color: var(--ivory-400);
  border-color: var(--border-default);
  cursor: not-allowed;
}

.btn-outline-success {
  background: transparent;
  color: var(--sage-400);
  border: 1px solid rgba(59, 109, 92, 0.45);
}

.btn-outline-success:hover {
  background: rgba(59, 109, 92, 0.12);
  color: var(--ivory-100);
  border-color: var(--sage-400);
}

.btn-outline-success:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.btn-outline-success:disabled,
.btn-outline-success.disabled {
  color: var(--ivory-400);
  border-color: var(--border-default);
  cursor: not-allowed;
  background: transparent;
}

/* Modal/segmented close control (report modal). Empty-element Bootstrap
   convention — no icon markup, the X is CSS-drawn from two rotated bars in
   currentColor so no icon-registry entry or SVG asset is needed. Accessible
   name comes from the caller's own aria-label (already present in markup;
   this class supplies no text). */
.btn-close {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  color: var(--ivory-300);
  opacity: 0.7;
  transition: opacity var(--duration-fast) ease-out,
              background-color var(--duration-fast) ease-out;
}

.btn-close::before,
.btn-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.85rem;
  height: 1.5px;
  background: currentColor;
}

.btn-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.btn-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.btn-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.btn-close:focus-visible {
  opacity: 1;
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

/* Brighter variant for use on already-dark modal chrome — still the ivory
   scale, not literal white. */
.btn-close-white {
  color: var(--ivory-100);
}

/* Segmented filter row (report_list.html's status pills). Bootstrap joins
   these with zero gap + squared middle corners; this system is pill-only
   (DESIGN.md: "Square buttons are not in the system"), so instead of
   faking a flush square join, the pills sit in a wrapped flex row with a
   small gap between them. */
.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Mirrors .btn-sm's values so a wrapping .btn-group-sm sizes its children
   down without every child needing its own .btn-sm class. */
.btn-group-sm .btn {
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
}

/* ─── Badges ─── */

.badge {
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.bg-danger {
  background: rgba(164, 58, 58, 0.2) !important;
  color: #e88 !important;
}

.bg-warning {
  background: rgba(225, 185, 106, 0.15) !important;
  color: #e1b96a !important;
}

.bg-info {
  background: rgba(79, 126, 163, 0.15) !important;
  color: #6a9fc4 !important;
}

.bg-secondary {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--ivory-300) !important;
}

.bg-primary {
  background: rgba(212, 168, 83, 0.15) !important;
  color: var(--amber-400) !important;
}

/* Quiet badge variant. Replaces the Bootstrap `bg-light` residue on dark
   surfaces, which read as a stark white pill against the canvas. Token-
   driven, subtle, ivory text on a low-elevation surface. */
.badge--quiet {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ivory-200);
  border: 1px solid var(--border-default);
}

/* ─── List Group (Dark) ─── */

.list-group-item {
  background: transparent;
  border-color: var(--border-default);
  color: var(--ivory-100);
}

.list-group-item .text-muted {
  color: var(--ivory-400) !important;
}

.list-group-item a {
  color: var(--amber-400);
}

/* ─── Breadcrumb ─── */

.breadcrumb {
  background: none;
  padding: 0;
  /* No Bootstrap CSS is loaded, and the global reset only zeroes list padding,
     not the markers — without this the <ol> renders its ordinal markers at the
     left edge (the stray marks seen on the producer/region pages). */
  list-style: none;
}

.breadcrumb a {
  color: var(--amber-400);
}

.breadcrumb-item.active {
  color: var(--ivory-300);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--ivory-400);
}

/* ─── Pagination ─── */

.cellar-pagination {
  display: flex;
  justify-content: center;
  margin-top: var(--space-5);
}

/* `.pagination` / `.page-item` / `.page-link` are the legacy Bootstrap class
   names still hand-rolled into wines/partials/_producer_table.html. Nothing
   defined them once Bootstrap was dropped, so a page number rendered as a
   bare 9x19px inline anchor — under the 24x24 WCAG 2.2 AA 2.5.8 floor, and
   invisible as a control. They are aliased onto this component rather than
   given a parallel one: the app must not grow a second pagination look. */
.cellar-pagination ul,
.pagination {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pagination {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-5);
}

.cellar-pagination__link,
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  /* 2.5.8 Target Size (Minimum). The padding already clears 24x24 for the
     widest labels; the floor is what holds for a single-digit page number. */
  min-width: 24px;
  min-height: 24px;
  padding: 6px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--ivory-200);
  font-size: 0.85rem;
  text-decoration: none;
  /* Explicit list, not `all` — see the note on .btn: `all` sweeps up the
     outline, so the keyboard focus ring fades in over --duration-fast
     instead of appearing the instant focus lands. */
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.cellar-pagination__link:hover,
.page-link:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-medium);
  color: var(--ivory-100);
}

.cellar-pagination__link:focus-visible,
.page-link:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.cellar-pagination__link--active,
.page-item.active .page-link {
  background: rgba(212, 168, 83, 0.12);
  border-color: rgba(212, 168, 83, 0.25);
  color: var(--amber-400);
  font-weight: 600;
}

.cellar-pagination__link--disabled,
.page-item.disabled .page-link {
  color: var(--ivory-400);
  cursor: default;
  opacity: 0.5;
}

.cellar-pagination__link--disabled:hover,
.page-item.disabled .page-link:hover {
  background: transparent;
  border-color: var(--border-default);
}

.cellar-pagination__nav {
  padding: 6px 10px;
}

/* ─── Confirmation modal (styled replacement for window.confirm) ─── */

.cask-confirm {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
}

.cask-confirm[aria-hidden="false"] {
  display: flex;
}

@media (min-width: 600px) {
  .cask-confirm { align-items: center; }
}

.cask-confirm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cask-confirm__dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--noir-900);
  border: 1px solid rgba(212, 168, 83, 0.22);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: cask-confirm-rise var(--duration-normal) var(--ease-out);
}

@keyframes cask-confirm-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cask-confirm__eyebrow {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--amber-400);
  margin: 0 0 var(--space-2);
}

.cask-confirm__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ivory-100);
  margin: 0 0 var(--space-3);
}

.cask-confirm__body {
  color: var(--ivory-300);
  margin: 0 0 var(--space-5);
  line-height: 1.5;
}

.cask-confirm__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  .cask-confirm__dialog { animation: none; }
}

/* ─── Toast notifications ─── */

.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1060;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 380px;
}

.cellar-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--noir-900);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  animation: cellar-slide-in 0.25s var(--ease-out);
}

.cellar-toast--success { border-left: 3px solid var(--sage-500); border-color: rgba(59, 109, 92, 0.25); }
.cellar-toast--error { border-left: 3px solid var(--rouge-500); border-color: rgba(139, 41, 66, 0.25); }
.cellar-toast--warning { border-left: 3px solid var(--amber-400); border-color: rgba(212, 168, 83, 0.2); }
.cellar-toast--info { border-left: 3px solid var(--ivory-300); border-color: rgba(255, 255, 255, 0.1); }

.cellar-toast__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.cellar-toast--success .cellar-toast__icon { color: var(--sage-400); }
.cellar-toast--error .cellar-toast__icon { color: var(--rouge-300); }
.cellar-toast--warning .cellar-toast__icon { color: var(--amber-400); }
.cellar-toast--info .cellar-toast__icon { color: var(--ivory-300); }

.cellar-toast__content { flex: 1; min-width: 0; }

.cellar-toast__title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ivory-100);
}

.cellar-toast__subtitle {
  font-size: 0.8rem;
  color: var(--ivory-400);
  margin-top: 2px;
}

.cellar-toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 1px;
  transition: width linear;
}

.cellar-toast--success .cellar-toast__progress { background: rgba(59, 109, 92, 0.4); }

/* Dismiss button for server-rendered cellar-toasts (no auto-dismiss). */
.cellar-toast__dismiss {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  padding: 0;
  margin-top: 1px;
  width: 18px;
  height: 18px;
  color: var(--ivory-400);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.cellar-toast__dismiss:hover,
.cellar-toast__dismiss:focus-visible {
  color: var(--ivory-100);
}

.cellar-toast__dismiss .icon {
  width: 16px;
  height: 16px;
}

.cellar-toast--exiting {
  animation: cellar-exit 0.3s var(--ease-out) forwards;
}
.cellar-toast--error .cellar-toast__progress { background: rgba(139, 41, 66, 0.4); }
.cellar-toast--warning .cellar-toast__progress { background: rgba(212, 168, 83, 0.3); }
.cellar-toast--info .cellar-toast__progress { background: rgba(255, 255, 255, 0.15); }

.cellar-toast--exiting {
  animation: cellar-exit 0.3s var(--ease-out) forwards;
}

/* ─── Icon System ─── */

.icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon--sm {
  width: 16px;
  height: 16px;
}

.icon--lg {
  width: 32px;
  height: 32px;
}

.icon--xl {
  width: 48px;
  height: 48px;
}

/* ─── Star Rating Component ─── */
/*
 * Half-star re-enable (2026-05-17): ONE <button> per unit, click X
 * decides half-vs-full. The dual-button overlap pattern is gone — the
 * compact-mode specificity bug it caused is structurally impossible
 * here because every unit has exactly one full-size hit button, no
 * per-half siblings whose width can be overridden.
 *
 * Visual primitive: base ivory star + clipped amber fill span. The
 * fill clip is driven by --star-fill (0%, 50%, or 100%) which the
 * half/full/empty state classes set. Hover preview cascades the same
 * primitive via the --star-preview-score CSS variable, set on the
 * .star-rating container by JS.
 */

.star-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.star-rating__unit {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
}

.star-rating__visual {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform var(--duration-fast) ease;
  --star-fill: 0%;
  --star-fill-color: var(--amber-400);
}

.star-rating__unit:hover .star-rating__visual,
.star-rating__unit:focus-within .star-rating__visual {
  transform: scale(1.15);
}

.star-rating__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
}

.star-rating__icon svg {
  width: 22px;
  height: 22px;
  transition: fill var(--duration-fast) ease;
}

.star-rating__icon--base svg {
  fill: var(--ivory-400);
}

.star-rating__icon--fill {
  clip-path: inset(0 calc(100% - var(--star-fill)) 0 0);
}

.star-rating__icon--fill svg {
  fill: var(--star-fill-color);
}

.star-rating__visual--full {
  --star-fill: 100%;
}

.star-rating__visual--half {
  --star-fill: 50%;
}

.star-rating__visual--empty {
  --star-fill: 0%;
}

.star-rating__visual--preview {
  --star-fill-color: var(--amber-300);
}

/*
 * The hit button is the full unit. It sits above the icon stack with a
 * transparent background — the icons (visual) are what the user sees.
 * No width/height overrides per variant: the unit owns the size, the
 * button inherits via inset:0. Click X (read in JS) decides whether
 * the click commits the half value or the full value of this star.
 */
.star-rating__hit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
  /* Transparent — the icon stack provides the visual */
  color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.star-rating__hit:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
  border-radius: 2px;
}

.star-rating__label {
  font-size: 0.85rem;
  color: var(--ivory-300);
  margin-left: var(--space-2);
  font-family: var(--font-sans, "DM Sans", sans-serif);
  letter-spacing: 0.02em;
  transition: color var(--duration-fast) ease;
  min-width: 5.5rem; /* reserve space so star row doesn't reflow on swap */
  display: inline-block;
}

/* On hover/focus of any star in the row, label warms to amber-400 to
 * preview the editorial word. */
.star-rating:hover .star-rating__label,
.star-rating:focus-within .star-rating__label {
  color: var(--amber-400);
}

/* Save-confirmation pulse: amber-400 for 600ms then fades back to
 * ivory-300. Applied via JS (and on initial render via just_saved) so a
 * click that returns the partial reads as confirmed. */
@keyframes star-rating-label-flash {
  0% {
    color: var(--amber-400);
    transform: translateY(0);
  }
  60% {
    color: var(--amber-400);
  }
  100% {
    color: var(--ivory-300);
  }
}

.star-rating__label--flash {
  animation: star-rating-label-flash 600ms ease-out 1;
}

/* Compact variant (vintage rows): smaller stars, label hidden for
 * density. The unit sizing cascades to the button via inset:0 — there
 * is intentionally NO ``.star-rating--compact .star-rating__hit`` rule
 * here. Resizing the unit is enough; the hit button has no width/height
 * of its own to override. (This is the structural fix for the bug that
 * broke half-star clicks before today's redesign.) */
.star-rating--compact .star-rating__unit {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.star-rating--compact .star-rating__icon,
.star-rating--compact .star-rating__icon svg {
  width: 18px;
  height: 18px;
}

.user-rating-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
}

/* Median/computed rating variant */
.star-rating--median .star-rating__visual {
  opacity: 0.5;
}

.star-rating--median .star-rating__label {
  font-style: italic;
  color: var(--ivory-400);
  font-size: 0.75rem;
}

/* Inherited rating — muted stars with source label */
.star-rating--inherited .star-rating__visual {
  opacity: 0.5;
}

.star-rating__inherited-label {
  font-size: 0.75rem;
  color: var(--ivory-400);
  margin-left: var(--space-1);
  font-style: italic;
}

/* ─── Tooltips ─── */

.cellar-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
  color: var(--ivory-400);
  transition: color var(--duration-fast) ease;
}

.cellar-tooltip:hover,
.cellar-tooltip:focus-visible {
  color: var(--ivory-200);
}

.cellar-tooltip__content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--noir-800);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ivory-200);
  white-space: normal;
  width: max-content;
  max-width: 240px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) ease, visibility var(--duration-fast) ease;
  pointer-events: none;
  z-index: 1050;
}

.cellar-tooltip__content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--noir-800);
}

.cellar-tooltip:hover .cellar-tooltip__content,
.cellar-tooltip:focus-visible .cellar-tooltip__content {
  opacity: 1;
  visibility: visible;
}

/* ─── Modal (HTMX-injected — the report modal is the only user) ───
   Structure mirrors .cask-confirm / .search-overlay above: a fixed,
   centered overlay holding a panel that scrolls its own body once content
   outgrows the viewport. Unlike those two, this modal is inserted/removed
   from the DOM by HTMX rather than toggled via aria-hidden, so there is no
   [aria-hidden="false"] gate here — presence in the DOM is the open state. */
.ds-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  /* Tinted noir scrim, never pure black — see DESIGN.md "The No-Pure-Black Rule". */
  background: rgba(10, 10, 10, 0.72);
}

.ds-modal-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - var(--space-6) * 2);
  display: flex;
  flex-direction: column;
  /* --noir-900 sits inside --border-interactive's sanctioned #090909-#2a2a2a
     ground window (DESIGN.md "Borders — Decorative vs. Interactive"), so the
     panel border below clears 3:1. */
  background: var(--noir-900);
  border: 1px solid var(--border-interactive);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  color: var(--ivory-100);
  overflow: hidden;
  animation: cellar-rise 0.2s var(--ease-out);
}

.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-interactive);
  flex-shrink: 0;
}

.ds-modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ivory-100);
  margin: 0;
}

.ds-modal-body {
  padding: var(--space-5);
  overflow-y: auto;
}

@media (prefers-reduced-motion: reduce) {
  .ds-modal-panel { animation: none; }
}

/* ─── Alerts (Django messages) ─── */
/* Bootstrap's .alert was carrying the styling; now owned in-system. */
.alert {
  position: relative;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
}

.alert-info,
.alert-primary {
  background: rgba(212, 168, 83, 0.08);
  border-color: rgba(212, 168, 83, 0.2);
  color: var(--amber-200);
}

.alert-success {
  background: rgba(59, 109, 92, 0.1);
  border-color: rgba(59, 109, 92, 0.3);
  color: var(--sage-400);
}

.alert-warning {
  background: rgba(212, 168, 83, 0.1);
  border-color: rgba(212, 168, 83, 0.25);
  color: var(--amber-300);
}

.alert-danger,
.alert-error {
  background: rgba(139, 41, 66, 0.12);
  border-color: rgba(139, 41, 66, 0.3);
  color: var(--rouge-300);
}

/* ─── Navbar shape ─── */
/* Owned in-system now. Visual styling (colors, padding, brand mark) is
   already in 03-layout.css; this is structural shape only. */
.navbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  padding-top: 0.3125rem;
  padding-bottom: 0.3125rem;
  margin-right: 1rem;
  text-decoration: none;
  white-space: nowrap;
}

.navbar-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

.navbar-nav .nav-link {
  padding-right: 0.5rem;
  padding-left: 0.5rem;
  text-decoration: none;
}

/* Safari hardening: <li> defaults to display:list-item, but explicit
   display:list-item here paired with the parent's list-style:none was
   resurrecting bullet markers in WebKit when ::marker rendering picked
   up the descendant context. display:block + an inline list-style:none
   reset on the item is the belt-and-suspenders fix. */
.nav-item { display: block; list-style: none; }

.navbar-toggler {
  padding: 0.25rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: box-shadow var(--duration-fast) ease;
}

.navbar-toggler:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.navbar-toggler-icon {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  vertical-align: middle;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100%;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28245,240,232,0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Desktop layout: nav items visible inline */
@media (min-width: 992px) {
  .navbar-expand-lg .navbar-toggler { display: none; }
  .navbar-expand-lg .navbar-collapse {
    display: flex !important;
    flex-basis: auto;
    flex-grow: 1;
    align-items: center;
  }
  .navbar-expand-lg .navbar-nav {
    flex-direction: row;
  }
}

/* Mobile: collapsed by default, open class shows it */
@media (max-width: 991.98px) {
  .navbar-collapse {
    flex-basis: 100%;
    flex-grow: 1;
    display: none;
  }
  .navbar-collapse.is-open {
    display: block;
  }
  .navbar-nav { flex-direction: column; }
}

/* ─── Dropdown (the user menu) ─── */
/* We use <details>/<summary> now — no Bootstrap JS. */
.user-menu {
  position: relative;
}

.user-menu > summary {
  /* Safari hardening: <summary> defaults to display:list-item which
     paints the disclosure triangle. list-style:none alone doesn't
     suppress it in older WebKit — display:block does. */
  display: block;
  list-style: none;
  cursor: pointer;
}

/* Split the pseudo-element rules: per CSS spec a selector list with an
   unknown pseudo-element invalidates the entire rule. Older Safari
   doesn't recognize ::marker on <summary> and would discard both
   declarations. Splitting keeps the WebKit-specific marker hidden
   even when ::marker is unrecognized. */
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary::marker { display: none; content: ""; }

.user-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 12rem;
  background: var(--noir-800);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  padding: 0.5rem 0;
  z-index: 1040;
}

.user-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 0;
  text-align: left;
  color: var(--ivory-200);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.user-menu__item:hover,
.user-menu__item:focus-visible {
  background: rgba(212, 168, 83, 0.1);
  color: var(--amber-300);
}

.user-menu__divider {
  height: 1px;
  margin: 0.5rem 0;
  background: var(--border-default);
  border: 0;
}
