/* ============================================================
   Reifen — Design Tokens
   Original Swiss tire shop design system
   ============================================================ */

:root {
  /* Colors — derived from brand logo (gold rim + Swiss red + black tire) */
  --c-bg: #F7F7F5;
  --c-bg-alt: #EFEEEA;
  --c-surface: #FFFFFF;
  --c-ink: #111111;          /* near-black tire */
  --c-ink-2: #2A2A2A;
  --c-muted: #5A5A5A;
  --c-muted-2: #8B8B8B;
  --c-border: #E2E2DD;
  --c-border-strong: #C9C9C2;
  --c-accent: #E30613;       /* brand red (matches proto + reifen-schweiz.ch) */
  --c-accent-ink: #FFFFFF;
  --c-gold: #F5C518;         /* rim gold */
  --c-gold-dk: #D4A017;
  --c-header-bg: #111111;    /* dark header so white logo text is visible */
  --c-success: #1F8A5B;
  --c-success-dk: #176B45;       /* darker green - for text/icons on tinted bg, AA-safe */
  --c-success-soft: #E8F5EE;     /* very light green tint - for subtle backgrounds */
  --c-success-ring: rgba(31, 138, 91, 0.32); /* outline ring for highlighting "best class" */
  --c-warn: #D97706;
  --c-info: #2A6FDB;

  /* Type */
  --ff-sans: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --ff-mono: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --ff-display: "Inter", system-ui, sans-serif;

  --fs-xxs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;
  --fs-4xl: 44px;
  --fs-5xl: 60px;

  --lh-tight: 1.1;
  --lh-snug: 1.25;
  --lh-normal: 1.5;
  --lh-loose: 1.7;

  /* Space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;
  --s-10: 80px;
  --s-11: 120px;

  /* Radii */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(11, 18, 32, 0.04), 0 1px 1px rgba(11, 18, 32, 0.03);
  --sh-md: 0 2px 4px rgba(11, 18, 32, 0.06), 0 4px 12px rgba(11, 18, 32, 0.05);
  --sh-lg: 0 8px 24px rgba(11, 18, 32, 0.08), 0 2px 6px rgba(11, 18, 32, 0.04);

  /* Layout */
  --container: 1280px;
  --container-narrow: 920px;
  --header-h: 72px;
  --topbar-h: 32px;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

/* Anchor base rules live inside @layer base so Tailwind utilities (compiled
   into @layer utilities, which comes after base) can override `color` and
   `text-decoration` via utilities like .text-white / .hover\:no-underline.
   Without the @layer wrap, unlayered rules win over layered utilities
   regardless of specificity (CSS cascade layer rule). */
@layer base {
  a { color: inherit; text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 3px; }
}

/* ============================================================
   Utilities
   ============================================================ */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--s-6); }
.container-narrow { max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--s-6); }
.mono { font-family: var(--ff-mono); font-feature-settings: "tnum"; }
.eyebrow {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.eyebrow-accent {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-accent);
}
#catalog-h1 {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-accent);
}

/* Heading and paragraph resets live inside @layer base so Tailwind utilities
   (compiled into @layer utilities, which comes after base) can override
   margin/line-height per-element via .mt-* / .mb-* / .leading-* classes.
   Without the @layer wrap, unlayered :where() would beat layered utilities
   regardless of specificity (CSS cascade layer rule). */
@layer base {
  :where(h1, h2, h3, h4) {
    font-family: var(--ff-display);
    margin: 0;
    line-height: var(--lh-tight);
    text-wrap: balance;
  }
  :where(p) { margin: 0; text-wrap: pretty; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-5);
  height: 44px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn:active { transform: translateY(0); box-shadow: var(--sh-sm); }
.btn-primary {
  background: var(--c-ink);
  color: #fff;
  border-color: var(--c-ink);
}
.btn-primary:hover { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-ink); }
.btn-accent {
  background: var(--c-accent);
  color: var(--c-accent-ink);
  border-color: var(--c-accent);
}
.btn-accent:hover { filter: brightness(0.93); }
.btn-gold {
  background: var(--c-gold);
  color: #111;
  border-color: var(--c-gold);
  font-weight: 600;
}
.btn-gold:hover { background: var(--c-gold-dk); border-color: var(--c-gold-dk); }
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-ink);
  border-color: var(--c-border-strong);
}
.btn-secondary:hover { background: var(--c-bg-alt); border-color: var(--c-accent); color: var(--c-accent); }
.btn-ghost {
  background: transparent;
  color: var(--c-ink);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--c-bg-alt); transform: none; box-shadow: none; }
.btn-sm { height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn-lg { height: 52px; padding: 0 var(--s-7); font-size: var(--fs-md); }
.btn-block { width: 100%; }

/* ============================================================
   Forms - canonical primitives (single source of truth)
   ------------------------------------------------------------
   Page-specific files MUST NOT redefine these dimensions,
   borders, paddings, fonts or colors. Documented dark variants:
   - .search-bar input (header)
   - .newsletter-form .input (footer)
   ============================================================ */

/* Field group: label above control, helper / error below */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field label, .field-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-ink-2);
}
.field-help {
  font-size: var(--fs-xs);
  color: var(--c-muted);
  line-height: 1.4;
}
.field-error {
  font-size: var(--fs-xs);
  color: var(--c-accent);
  display: flex;
  align-items: center;
  gap: 4px;
}
/* Required marker (use .req or aliases .auth-required / .co-req) */
.req,
.auth-required,
.co-req { color: var(--c-accent); }

/* Inline rows (checkbox + label, radio + label) */
.checkbox-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--c-ink-2);
  line-height: 1.5;
}
/* When the label is multi-line, top-align the box */
.checkbox-row--top,
.radio-row--top { align-items: flex-start; }

/* Text inputs / select / textarea share one shape */
.input, .select, .textarea {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-ink);
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder,
.textarea::placeholder { color: var(--c-muted); }

.textarea {
  height: auto;
  min-height: 96px;
  padding: var(--s-3) var(--s-4);
  resize: vertical;
}

/* Custom select: kill native chevron, draw our own */
.select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235A5A5A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-4) center;
  background-size: 12px 8px;
  cursor: pointer;
}
.select::-ms-expand { display: none; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-ink);
  box-shadow: 0 0 0 3px rgba(11, 18, 32, 0.08);
}

/* Disabled state - visual only (cursor handled by other rules) */
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--c-bg-alt);
  color: var(--c-muted);
  opacity: 0.7;
}

/* Error state - red border + matching ring */
.input--error,
.select--error,
.textarea--error,
.field--error .input,
.field--error .select,
.field--error .textarea {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.10);
}

/* Checkbox - custom 18x18 box with SVG tick when checked */
.checkbox {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  border: 1.5px solid var(--c-border-strong);
  border-radius: 3px;
  background: var(--c-surface);
  position: relative;
  transition: border-color 120ms ease, background 120ms ease;
}
.checkbox:checked {
  background-color: var(--c-accent);
  border-color: var(--c-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10' fill='none'%3E%3Cpath d='M1 5L4.5 8.5L11 1.5' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 10px;
}
.checkbox:disabled { opacity: 0.5; }

/* Radio - custom 18x18 circle with brand-red dot when selected */
.radio {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  border: 1.5px solid var(--c-border-strong);
  border-radius: 50%;
  background: var(--c-surface);
  position: relative;
  transition: border-color 120ms ease, background 120ms ease;
}
.radio:checked { border-color: var(--c-accent); }
.radio:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--c-accent);
}
.radio:disabled { opacity: 0.5; }

/* Quantity stepper - canonical [-] <input> [+] control.
   Default size: 48px (product page). Modifiers: --sm (36px), --xs (30px). */
.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  height: 48px;
}
.qty button {
  width: 48px;
  height: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-ink);
  padding: 0;
}
.qty input {
  width: 56px;
  height: 100%;
  text-align: center;
  border: 0;
  background: transparent;
  font-family: var(--ff-mono);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--c-ink);
  padding: 0;
  -moz-appearance: textfield;
}
.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty--sm { height: 36px; }
.qty--sm button { width: 32px; }
.qty--sm input { width: 40px; font-size: var(--fs-sm); }
.qty--xs { height: 30px; }
.qty--xs button { width: 28px; }
.qty--xs input { width: 32px; font-size: var(--fs-sm); }

/* ============================================================
   Badges & chips
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--c-bg-alt);
  color: var(--c-ink-2);
  border: 1px solid var(--c-border);
}
.badge-accent { background: var(--c-accent); color: var(--c-accent-ink); border-color: var(--c-accent); }
.badge-success { background: rgba(31, 138, 91, 0.1); color: var(--c-success); border-color: rgba(31, 138, 91, 0.2); }
.badge-warn { background: rgba(217, 119, 6, 0.1); color: var(--c-warn); border-color: rgba(217, 119, 6, 0.2); }
.badge-danger { background: rgba(227, 6, 19, 0.1); color: var(--c-accent); border-color: rgba(227, 6, 19, 0.2); }
.badge-mono { font-family: var(--ff-mono); font-size: var(--fs-xxs); letter-spacing: 0.04em; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
}

/* ============================================================
   Image placeholder (striped)
   ============================================================ */
.img-ph {
  background-color: #E8E8E2;
  background-image: repeating-linear-gradient(
    135deg,
    #E8E8E2 0,
    #E8E8E2 10px,
    #DEDED7 10px,
    #DEDED7 20px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8B92A0;
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  text-align: center;
  padding: var(--s-4);
  position: relative;
  overflow: hidden;
}
.img-ph::after {
  content: "";
  position: absolute; inset: 8px;
  border: 1px dashed rgba(0,0,0,.12);
  border-radius: 4px;
  pointer-events: none;
}
.img-ph > * { position: relative; z-index: 1; background: rgba(247,247,245,.85); padding: 4px 8px; border-radius: 3px; }

/* Density modifiers (controlled via Tweaks) */
[data-density="compact"] { --s-6: 16px; --s-7: 24px; --s-8: 32px; --s-9: 40px; --s-10: 56px; }
[data-density="comfortable"] { --s-6: 32px; --s-7: 40px; --s-8: 56px; --s-9: 80px; --s-10: 120px; }

/* ============================================================
   Header / Footer (shared)
   ============================================================ */
.topbar {
  background: var(--c-ink);
  color: #C9CDD4;
  font-size: var(--fs-xs);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
}
.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.topbar-left { display: flex; gap: var(--s-5); align-items: center; }
.topbar-right { display: flex; gap: var(--s-5); align-items: center; }

.header {
  background: var(--c-header-bg);
  border-bottom: 1px solid #000;
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 50;
  color: #fff;
}
.header .icon-btn { color: #fff; }
.header .icon-btn:hover { background: rgba(255,255,255,.08); }
.search-bar {
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.15) !important;
  color: #fff;
}
.search-bar input { color: #fff; }
.search-bar input::placeholder { color: rgba(255,255,255,.5) !important; }
.search-bar .badge { background: rgba(255,255,255,.1) !important; color: rgba(255,255,255,.7) !important; border-color: rgba(255,255,255,.15) !important; }
.header .container {
  display: flex;
  align-items: center;
  gap: var(--s-7);
  height: 100%;
}
.logo {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--c-ink);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.logo-mark::before, .logo-mark::after {
  content: "";
  position: absolute;
  background: var(--c-bg);
  border-radius: 50%;
}
.logo-mark::before { inset: 8px; }
.logo-mark::after { inset: 13px; background: var(--c-ink); }

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 0 var(--s-4);
  height: 44px;
  max-width: 560px;
  gap: var(--s-3);
}
.search-bar input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  color: var(--c-ink);
}
.search-bar input::placeholder { color: var(--c-muted); }

.header-nav {
  display: flex;
  gap: var(--s-6);
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: 500;
}
.header-nav a { color: var(--c-ink-2); }
.header-actions { display: flex; gap: var(--s-2); align-items: center; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  background: transparent;
  border: 0;
  color: var(--c-ink);
  position: relative;
}
.icon-btn:hover { background: var(--c-bg-alt); }
.icon-btn .count {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--c-accent); color: #fff;
  border-radius: var(--r-pill);
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

.subnav {
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.subnav .container {
  display: flex;
  gap: var(--s-7);
  align-items: center;
  height: 48px;
  font-size: var(--fs-sm);
  overflow-x: auto;
}
.subnav a { color: var(--c-muted); white-space: nowrap; }
.subnav a:hover { color: var(--c-ink); text-decoration: none; }

.topbar {
  background: #000;
}

.footer {
  background: var(--c-ink);
  color: #C9CDD4;
  padding: var(--s-10) 0 var(--s-7);
  margin-top: var(--s-11);
}
.footer h4 {
  color: #fff;
  font-size: var(--fs-sm);
  font-family: var(--ff-mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--s-4);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1.2fr;
  gap: var(--s-7);
}
.footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s-3); font-size: var(--fs-sm); }
.footer ul a { color: #C9CDD4; }
.footer ul a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: var(--s-9);
  padding-top: var(--s-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: #8B92A0;
  flex-wrap: wrap;
  gap: var(--s-4);
}
.lang-switch { display: flex; gap: var(--s-2); }
.lang-switch button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #C9CDD4;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-family: var(--ff-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lang-switch button.active { background: #fff; color: var(--c-ink); border-color: #fff; }

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .header-nav { display: none; }
  .search-bar { max-width: none; }
}
