/* base.css - reset, tokens, typography, base elements. Cascade: base -> components -> shop -> shops/<id>/<id>.css (palette) -> admin.
   Breakpoints (min-width): 600 phone to tablet, 700 category chips wrap, 800 two-column bands (hero, promo), 960 desktop nav and
   drawers, 1040/1200 navbar word labels (measured). Docs/UI-architecture.md is the map. */

:root {
  /* Color - neutral foundation */
  --color-bg:            #ffffff;
  --color-surface:       #f8fafc;
  --color-surface-2:     #f1f5f9;
  --color-text:          #0f172a;
  --color-text-muted:    #56657a;  /* was #64748b: 3.95-4.43 on the shops' soft and surface fills; this clears 4.9 on all (#473) */
  --color-text-subtle:   #94a3b8;
  --color-border:        #e2e8f0;
  --color-border-strong: #cbd5e1;

  /* Per-shop accent: neutral defaults only. A shop's palette lives in shops/<id>/<id>.css, linked after the globals. */
  --color-accent:        #334155;  /* slate-700 - neutral */
  --color-accent-hover:  #1e293b;  /* slate-800 */
  --color-accent-fg:     #ffffff;
  --color-accent-soft:   #f1f5f9;  /* slate-100 */

  /* Color - semantic */
  --color-success:       #059669;
  --color-success-soft:  #d1fae5;
  --color-warning:       #d97706;
  --color-warning-soft:  #fef3c7;
  /* --color-warning's own RGB at a translucent wash (#364), not the unrelated amber-500 it replaces. */
  --color-warning-wash:  rgba(217, 119, 6, 0.12);
  --color-danger:        #dc2626;
  --color-danger-soft:   #fee2e2;
  --color-info:          #0ea5e9;
  --color-info-soft:     #e0f2fe;
  /* Text-on-soft companions (#207): the hues above fail WCAG on their own soft backgrounds; text uses these, icons keep the hue. */
  --color-success-text:  #065f46;
  --color-warning-text:  #92400e;
  --color-info-text:     #075985;
  --color-danger-text:   #991b1b;

  /* Color - overlay */
  --color-overlay:       rgba(15, 23, 42, 0.5);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif,
               "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
               "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;

  --font-size-xs:   0.75rem;   /* 12px */
  --font-size-sm:   0.875rem;  /* 14px */
  --font-size-md:   1rem;      /* 16px - body */
  --font-size-lg:   1.125rem;  /* 18px */
  --font-size-xl:   1.25rem;   /* 20px */
  --font-size-2xl:  1.5rem;    /* 24px */
  --font-size-3xl:  1.875rem;  /* 30px */
  --font-size-4xl:  2.25rem;   /* 36px */

  --line-height-tight: 1.2;
  --line-height-base:  1.5;
  --line-height-loose: 1.7;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Spacing scale (4px base) */
  --space-1:  0.25rem;  /* 4px  */
  --space-2:  0.5rem;   /* 8px  */
  --space-3:  0.75rem;  /* 12px */
  --space-4:  1rem;     /* 16px */
  --space-5:  1.25rem;  /* 20px */
  --space-6:  1.5rem;   /* 24px */
  --space-8:  2rem;     /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08),
               0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08),
               0 4px 6px -4px rgba(15, 23, 42, 0.04);

  /* Layout */
  --container-max:    72rem;   /* 1152px */
  --container-narrow: 42rem;   /* 672px - for forms / readable text */
  --container-wide:   90rem;   /* 1440px - the browse grid; see .container--wide */

  /* Photo frames (#418, #419): square + cover on every shop; the gallery reads --gallery-ratio and always contains. Cover trims
       about a quarter off an upright 3:4 photo on the CARD only (a lengthwise stick loses its ends); fallback: --media-fit: contain. */
  --media-ratio:   1 / 1;
  --media-fit:     cover;
  --gallery-ratio: var(--media-ratio);
  --header-height:    56px;
  --touch-target-min: 44px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 180ms ease;
}

/* Admin pages (<body class="admin">): neutral slate tokens override the shop palette, one look for every shop. */

body.admin {
  --color-accent:        #475569;  /* slate-600 - neutral admin accent */
  --color-accent-hover:  #334155;  /* slate-700 */
  --color-accent-fg:     #ffffff;
  --color-accent-soft:   #f1f5f9;  /* slate-100 */
  --color-bg:            #ffffff;
  --color-surface:       #f8fafc;
  --color-surface-2:     #f1f5f9;
}

/* [hidden] must beat every component's display rule (the report modal once stuck open), so one attribute toggles anything. */

[hidden] {
  display: none !important;
}

/* ---- Modern reset (lean) ---- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* The header is sticky, so whatever the browser scrolls to - an invalid field on submit, a #anchor from a table of
   contents or the footer's Contact link - must stop below it, not under it (#456). :target covers every anchor. */
:target, .field, .form-section, .field-row { scroll-margin-top: calc(var(--header-height) + var(--space-3)); }

/* One switch for every animation and smooth scroll on a device that asked for less motion; ui.js reads the same query
   for the gallery's scrollTo (#456). */
@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; }
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  /* No horizontal scroll from off-canvas drawers. clip, not hidden: clip creates no scroll container, so sticky keeps working. */
  overflow-x: clip;
}

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

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

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* ---- Typography ---- */

h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }
h6 { font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: 0.05em; }

p {
  line-height: var(--line-height-base);
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

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

small {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

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

/* ---- Focus ring (accessibility) ---- */

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Container ---- */

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

/* The post form: a narrow measure, it reads worse the wider it gets. Sibling of .container, no specificity trick needed. */
.container--xs { max-width: 35rem; }

.container--narrow {
  max-width: var(--container-narrow);
}

/* The browse grid (#403): 90rem gives five columns and half the gutters of 72rem on a 1700px screen; full-bleed would stretch
   the header and the filter bar. */
.container--wide {
  max-width: var(--container-wide);
}

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

/* ---- Utility: visually hidden but accessible ---- */

.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;
}

/* ---- Utilities ----
   Each replaced an inline style. THE DOUBLED CLASS IS DELIBERATE: .u-mt-3.u-mt-3 has specificity (0,2,0), so it wins against
   any single-class rule in the later files (components, shop, palette, admin) without a copy per cascade. Add new ones alike. */

.text-muted.text-muted { color: var(--color-text-muted); }
.text-danger.text-danger { color: var(--color-danger); font-weight: var(--font-weight-medium); }
.text-center.text-center { text-align: center; }
.text-sm.text-sm  { font-size: var(--font-size-sm); }
.u-inline.u-inline { display: inline; }
.u-inline-block.u-inline-block { display: inline-block; }
.u-valign-middle.u-valign-middle { vertical-align: middle; }
.u-w-full.u-w-full { width: 100%; }
.u-w-auto.u-w-auto { width: auto; }
.u-flex-1.u-flex-1 { flex: 1; }
.u-self-end.u-self-end { align-self: end; }
.u-wrap.u-wrap    { white-space: normal; }
.u-pre-line.u-pre-line { white-space: pre-line; }
.u-scroll-x.u-scroll-x { overflow-x: auto; }
.u-m-0.u-m-0      { margin: 0; }
.u-mt-1.u-mt-1    { margin-block-start: var(--space-1); }
.u-mt-2.u-mt-2    { margin-block-start: var(--space-2); }
.u-mt-3.u-mt-3    { margin-block-start: var(--space-3); }
.u-mt-4.u-mt-4    { margin-block-start: var(--space-4); }
.u-mt-5.u-mt-5    { margin-block-start: var(--space-5); }
.u-mt-6.u-mt-6    { margin-block-start: var(--space-6); }
.u-mb-0.u-mb-0    { margin-block-end: 0; }
.u-mb-2.u-mb-2    { margin-block-end: var(--space-2); }
.u-mb-3.u-mb-3    { margin-block-end: var(--space-3); }
.u-mb-4.u-mb-4    { margin-block-end: var(--space-4); }
.u-mb-5.u-mb-5    { margin-block-end: var(--space-5); }
.u-mx-1.u-mx-1    { margin-inline: var(--space-1); }
.u-ml-0.u-ml-0    { margin-inline-start: 0; }
.u-me-2.u-me-2    { margin-inline-end: var(--space-2); }
.u-my-2-4.u-my-2-4 { margin-block: var(--space-2) var(--space-4); }
.u-my-6-3.u-my-6-3 { margin-block: var(--space-6) var(--space-3); }
.u-my-6-2.u-my-6-2 { margin-block: var(--space-6) var(--space-2); }
.stack.stack      { display: grid; gap: var(--space-3); }

/* ---- Page body baseline (used on .html pages) ---- */

body.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.page > main {
  flex: 1;
  padding-block: var(--space-6);
}

@media (min-width: 960px) {
  body.page > main {
    padding-block: var(--space-10);
  }
}
