/* ==========================================================================
   base.css — reset + design tokens
   Tokens map 1:1 to future Shopify theme settings.
   Fonts and type scale come in Step 1.3.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette (raw values — use the scheme tokens below in components).
     Green and lime are background-only colors: never use them as text on white. */
  --palette-white: #ffffff;
  --palette-mist: #f2f2ef;
  --palette-ink: #0b0b0c;
  --palette-green: #3dff7e; /* fluo green */
  --palette-lime: #d2ff2e; /* yellow lime */
  --palette-blue: #2a3cff; /* electric blue */

  /* Color scheme: default (white). Every background has a paired foreground. */
  --color-bg: var(--palette-white);
  --color-fg: var(--palette-ink);
  --color-fg-muted: #5a5a5e; /* 6.9:1 on white */
  --color-line: rgb(11 11 12 / 0.18); /* hairline rules */
  --color-accent: var(--palette-blue);
  --color-accent-fg: var(--palette-white); /* 6.7:1 */
  --color-focus: var(--palette-blue);
  --color-error: #c4001a; /* 6.3:1 on white */

  /* Fonts — both are in the Shopify font library (Unbounded 2–9, Inter 1–9 + italic).
     Prototype loads them from Google Fonts; the theme will use Shopify's font settings. */
  --font-display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-display: 500; /* Unbounded is wide: medium keeps it elegant */

  /* Type scale — fluid, clamp(min, preferred, max) between 375px and 1920px.
     Unbounded is very wide, so display sizes are smaller than a narrow grotesk. */
  --text-2xs: 0.6875rem; /* 11px caption */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: clamp(1.125rem, 1.05rem + 0.3vw, 1.375rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.7vw, 1.875rem);
  --text-2xl: clamp(1.75rem, 1.4rem + 1.4vw, 2.75rem);
  --text-3xl: clamp(2.25rem, 1.6rem + 2.6vw, 4rem);
  --text-4xl: clamp(2.75rem, 1.8rem + 4vw, 6rem);
  --text-5xl: clamp(3.25rem, 1.9rem + 6vw, 9rem); /* giant hero headline */

  /* Leading and tracking */
  --leading-display: 0.98;
  --leading-heading: 1.1;
  --leading-body: 1.55;
  --tracking-display: -0.03em;
  --tracking-heading: -0.02em;
  --tracking-caption: 0.08em;

  /* Spacing scale (4px base) */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;
  --space-3xl: 9rem;

  /* Grid */
  --grid-columns: 4;
  --grid-gutter: var(--space-sm);
  --grid-margin: var(--space-sm);
  --page-max: 120rem;

  /* Radius — merchants will tune via a "Corner radius" setting (default: round) */
  --radius-sm: 0.5rem; /* buttons, inputs, badges */
  --radius-md: 1rem; /* cards, thumbnails */
  --radius-lg: 2rem; /* large images, notch curves */
  --radius-pill: 999px; /* pills, round buttons */

  /* Borders */
  --border-hairline: 1px solid var(--color-line);
  --border-strong: 1px solid var(--color-fg);

  /* Shadows (used sparingly: drawers, popovers) */
  --shadow-sm: 0 1px 2px rgb(21 18 16 / 0.08);
  --shadow-md: 0 8px 24px rgb(21 18 16 / 0.12);

  /* Z-index scale */
  --z-base: 1;
  --z-sticky: 10;
  --z-header: 20;
  --z-drawer: 30;
  --z-modal: 40;
  --z-toast: 50;

  /* Motion */
  --duration-fast: 150ms;
  --duration-base: 300ms;
  --duration-slow: 700ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Touch target minimum (Shopify: >= 24px; we aim higher) */
  --target-min: 2.75rem;
}

@media (min-width: 48em) {
  :root {
    --grid-columns: 8;
    --grid-gutter: var(--space-md);
    --grid-margin: var(--space-lg);
  }
}

@media (min-width: 80em) {
  :root {
    --grid-columns: 12;
    --grid-margin: var(--space-xl);
  }
}

/* --------------------------------------------------------------------------
   2. Color schemes (switch with data-scheme on any element)
   -------------------------------------------------------------------------- */
/* Resets a nested block to the default (white) scheme, e.g. a card on top of a photo */
[data-scheme='white'] {
  --color-bg: var(--palette-white);
  --color-fg: var(--palette-ink);
  --color-fg-muted: #5a5a5e;
  --color-line: rgb(11 11 12 / 0.18);
  --color-accent: var(--palette-blue);
  --color-accent-fg: var(--palette-white);
  --color-focus: var(--palette-blue);
  --color-error: #c4001a;
}

[data-scheme='mist'] {
  --color-bg: var(--palette-mist);
  --color-fg: var(--palette-ink);
  --color-fg-muted: #55555a; /* 6.4:1 on mist */
  --color-line: rgb(11 11 12 / 0.18);
  --color-error: #c4001a; /* 5.6:1 on mist */
}

[data-scheme='ink'] {
  --color-bg: var(--palette-ink);
  --color-fg: var(--palette-white);
  --color-fg-muted: #b5b5b8; /* 9.8:1 on ink */
  --color-line: rgb(255 255 255 / 0.25);
  --color-accent: var(--palette-green); /* blue on ink would be only 2.9:1 */
  --color-accent-fg: var(--palette-ink);
  --color-focus: var(--palette-green);
  --color-error: #ff9aa6; /* 10:1 on ink */
}

[data-scheme='green'] {
  --color-bg: var(--palette-green);
  --color-fg: var(--palette-ink);
  --color-fg-muted: #2b2b2e; /* 10:1 on green */
  --color-line: rgb(11 11 12 / 0.3);
  --color-accent: var(--palette-ink);
  --color-accent-fg: var(--palette-green);
  --color-focus: var(--palette-ink);
  --color-error: #9b0014; /* 6.6:1 on green */
}

[data-scheme='lime'] {
  --color-bg: var(--palette-lime);
  --color-fg: var(--palette-ink);
  --color-fg-muted: #2b2b2e; /* 11:1 on lime */
  --color-line: rgb(11 11 12 / 0.3);
  --color-accent: var(--palette-ink);
  --color-accent-fg: var(--palette-lime);
  --color-focus: var(--palette-ink);
  --color-error: #9b0014; /* 7.5:1 on lime */
}

[data-scheme='blue'] {
  --color-bg: var(--palette-blue);
  --color-fg: var(--palette-white);
  --color-fg-muted: #e4e7ff; /* 5.4:1 on blue */
  --color-line: rgb(255 255 255 / 0.4);
  --color-accent: var(--palette-lime);
  --color-accent-fg: var(--palette-ink);
  --color-focus: var(--palette-white);
  --color-error: var(--palette-white); /* errors are also marked by an icon and bold text */
}

/* --------------------------------------------------------------------------
   3. Reset (minimal, modern)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  scrollbar-gutter: stable; /* no layout shift when a drawer locks the scroll */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html.scroll-lock {
  overflow: hidden;
}

body {
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

img,
video {
  height: auto;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

/* The hidden attribute must win over component display rules (badge, grid, flex…) */
[hidden] {
  display: none !important;
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

/* --------------------------------------------------------------------------
   3b. Base typography — distinct sizes for h1–h6 (Shopify requirement).
   Utility classes (.h1–.h6, .display) let a section pick the look without
   changing the semantic tag. Atoms (heading, caption, rte) come in Step 2.
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
.display {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  text-wrap: balance;
}

.display {
  font-size: var(--text-5xl);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
}

h1,
.h1 {
  font-size: var(--text-4xl);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
}

h2,
.h2 {
  font-size: var(--text-3xl);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
}

h3,
.h3 {
  font-size: var(--text-2xl);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
}

h4,
.h4 {
  font-size: var(--text-xl);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
}

h5,
.h5 {
  font-size: var(--text-lg);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
}

h6,
.h6 {
  font-size: var(--text-base);
  line-height: var(--leading-heading);
  letter-spacing: 0;
}

/* --------------------------------------------------------------------------
   4. Accessibility helpers
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: var(--z-toast);
  padding: var(--space-xs) var(--space-sm);
  background-color: var(--color-fg);
  color: var(--color-bg);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   5. Layout utilities
   -------------------------------------------------------------------------- */
.page-width {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--grid-margin);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  column-gap: var(--grid-gutter);
}

/* --------------------------------------------------------------------------
   6. Reduced motion — kill animations and smooth scrolling
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
