/*
  base.css — shared design system for catalog-v2.
  Reset, tokens, typography, buttons, form controls, shared components.
  Layout specific to the public catalog or the admin panel lives in
  catalog.css / admin.css, loaded AFTER this file.

  Light theme only — no dark mode. Mobile-first: base rules target 320px,
  min-width media queries only widen from there.
*/

/* ---------------------------------------------------------------------
   1. Reset — the ~20 lines that are actually needed
   --------------------------------------------------------------------- */

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

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

body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

html, body {
  height: 100%;
}

body {
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, picture, svg {
  max-width: 100%;
  display: block;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
}

ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---------------------------------------------------------------------
   2. Tokens
   --------------------------------------------------------------------- */

:root {
  /* Color */
  --c-bg: #ffffff;
  --c-surface: #f7f7f8;
  --c-border: #e4e4e7;
  --c-text: #18181b;
  --c-muted: #71717a;
  --c-accent: #1d4ed8;
  --c-accent-hover: #1e40af;
  --c-danger: #b91c1c;
  --c-success: #15803d;

  /* Tints derived from the tokens above, for badges/flash backgrounds.
     Still greyscale + the two semantic colors — no new hues introduced. */
  --c-success-bg: color-mix(in srgb, var(--c-success) 12%, white);
  --c-danger-bg: color-mix(in srgb, var(--c-danger) 12%, white);

  /* Type — five sizes, nothing else */
  --fs-1: 13px;
  --fs-2: 14px;
  --fs-3: 16px;
  --fs-4: 20px;
  --fs-5: 26px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --lh-body: 1.55;
  --lh-heading: 1.25;

  /* Space — strict scale, no arbitrary values */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radius */
  --radius-md: 8px;
  --radius-pill: 999px;
  --radius-lg: 14px;

  /* Elevation — borders, not shadows. The one shadow, used only by the
     product dialog in catalog.css. */
  --shadow-dialog: 0 8px 30px rgba(0, 0, 0, 0.16);

  /* Focus */
  --focus-ring: 2px solid var(--c-accent);
  --focus-offset: 2px;

  /* Motion — kept short and optional, per prefers-reduced-motion below */
  --transition-fast: 150ms ease;
}

/* ---------------------------------------------------------------------
   3. Base typography
   --------------------------------------------------------------------- */

body {
  font-family: var(--font-sans);
  font-size: var(--fs-3);
  color: var(--c-text);
  background: var(--c-bg);
}

h1, h2, h3 {
  font-weight: 700;
  line-height: var(--lh-heading);
}

h1 { font-size: var(--fs-5); }
h2 { font-size: var(--fs-4); }
h3 { font-size: var(--fs-3); }

p {
  margin-bottom: var(--space-3);
}

a {
  color: var(--c-accent);
  text-decoration: underline;
}

a:hover {
  color: var(--c-accent-hover);
}

hr {
  border: 0;
  border-top: 1px solid var(--c-border);
  margin: var(--space-5) 0;
}

/* ---------------------------------------------------------------------
   4. Buttons
   --------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--space-4);
  font-size: var(--fs-3);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast),
    border-color var(--transition-fast), color var(--transition-fast);
}

.btn-primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
}

.btn-danger {
  background: var(--c-danger);
  border-color: var(--c-danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

.btn-ghost {
  background: transparent;
  border-color: var(--c-border);
  color: var(--c-text);
}

.btn-ghost:hover {
  background: var(--c-surface);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------
   5. Form controls
   --------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

label {
  font-size: var(--fs-2);
  font-weight: 600;
}

.help {
  font-size: var(--fs-2);
  color: var(--c-muted);
}

.field-error {
  font-size: var(--fs-2);
  font-weight: 600;
  color: var(--c-danger);
}

.field-error::before {
  content: "\26A0  ";
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-size: 16px; /* exact, never smaller: prevents iOS Safari zoom-on-focus */
  background: var(--c-bg);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"],
input.invalid,
textarea.invalid,
select.invalid {
  border: 2px solid var(--c-danger);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
}

.checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex-shrink: 0;
  accent-color: var(--c-accent);
}

.checkbox label {
  font-weight: 400;
  font-size: var(--fs-3);
}

/* ---------------------------------------------------------------------
   6. Shared components
   --------------------------------------------------------------------- */

.container {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding-inline: var(--space-6);
  }
}

.card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-1);
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text);
}

.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.flash-ok {
  background: var(--c-success-bg);
  border-color: var(--c-success);
  color: var(--c-success);
}

.flash-error {
  background: var(--c-danger-bg);
  border-color: var(--c-danger);
  color: var(--c-danger);
}

.muted {
  color: var(--c-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------------
   7. Focus — always visible on keyboard focus, never removed without
   a replacement.
   --------------------------------------------------------------------- */

:focus {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* ---------------------------------------------------------------------
   8. Reduced motion
   --------------------------------------------------------------------- */

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