/* ==========================================================================
   Mera Pets — base.css
   Reset, typographic system, containers, primitives.
   Design system v1.0 · §4 Typography, §5 Space/grid, §8 Icons, §9.1–9.3.
   ========================================================================== */

/* --- Reset ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--mp-bg);
  color: var(--mp-text);
  font-family: var(--mp-font-ui);
  font-size: var(--mp-t-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
picture { display: contents; }
img { font-style: italic; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--mp-text-link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4 { font-family: var(--mp-font-display); font-weight: 400; line-height: 1.14; letter-spacing: -0.012em; }
h1 { line-height: 1.03; letter-spacing: -0.022em; }
strong, b { font-weight: 600; }
::selection { background: var(--mp-ember-100); color: var(--mp-ink); }

:focus-visible {
  outline: 2px solid var(--mp-focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip link (§13) */
.mp-skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 200;
  background: var(--mp-ink); color: var(--mp-porcelain);
  padding: 12px 20px; border-radius: var(--mp-r-sm); font-size: var(--mp-t-sm);
  transition: top var(--mp-dur-2) var(--mp-ease-out);
}
.mp-skip-link:focus { top: 16px; }

/* --- Typographic primitives ---------------------------------------- */
.mp-display {
  font-family: var(--mp-font-display);
  font-variation-settings: "opsz" 96, "SOFT" 28, "WONK" 1;
  font-weight: 400;
  letter-spacing: -0.022em;
  line-height: 1.03;
  text-wrap: balance;
}

.mp-eyebrow {
  font-family: var(--mp-font-mono);
  font-size: var(--mp-t-micro);
  font-variation-settings: "wdth" 75;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mp-stone-600);
}

.mp-figures { font-variant-numeric: tabular-nums lining-nums; }
.mp-price { font-family: var(--mp-font-display); font-variation-settings: "opsz" 48, "WONK" 0; font-weight: 400; }

.mp-muted { color: var(--mp-text-muted); }
.mp-lede { font-size: var(--mp-t-lg); line-height: 1.55; max-width: 54ch; }

/* --- Containers & grid (§5.2–5.3) ----------------------------------- */
.mp-container { width: min(100% - (var(--mp-gutter) * 2), var(--mp-w-cont)); margin-inline: auto; }
.mp-container--wide  { --mp-w-cont: var(--mp-w-wide); }
.mp-container--bleed { --mp-w-cont: var(--mp-w-bleed); }
.mp-container--text  { --mp-w-cont: var(--mp-w-text); }

.mp-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--mp-s-6); }
.mp-col-4 { grid-column: span 4; }
.mp-col-5 { grid-column: span 5; }
.mp-col-6 { grid-column: span 6; }
.mp-col-7 { grid-column: span 7; }
.mp-col-8 { grid-column: span 8; }

/* --- Icons (§8) ------------------------------------------------------ */
.mp-icon-inline, .mp-iconrun .mp-icon { display: inline-block; }
.mp-icon {
  width: 1em; height: 1em;
  stroke: currentColor; stroke-width: 1.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.12em; flex: none;
}

/* --- Button (§9.1) ---------------------------------------------------- */
.mp-btn {
  --_pad-y: 14px; --_pad-x: 28px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--mp-s-2);
  padding: var(--_pad-y) var(--_pad-x);
  font-family: var(--mp-font-ui); font-size: var(--mp-t-sm); font-weight: 500;
  letter-spacing: -0.005em; line-height: 1; min-height: 44px;
  border-radius: var(--mp-r-pill);
  border: 0; cursor: pointer; text-decoration: none;
  transition: background-color var(--mp-dur-2) var(--mp-ease-std),
              transform var(--mp-dur-2) var(--mp-ease-out),
              box-shadow var(--mp-dur-2) var(--mp-ease-std);
}
.mp-btn--primary { background: var(--mp-ember); color: #FFFFFF; box-shadow: var(--mp-e-2); }
.mp-btn--primary:hover { background: var(--mp-ember-700); transform: translateY(-1px); box-shadow: var(--mp-e-3); }
.mp-btn--primary:active { transform: translateY(0); box-shadow: var(--mp-e-1); }
.mp-btn--secondary { background: transparent; color: var(--mp-text); box-shadow: inset 0 0 0 1.5px var(--mp-border-strong); }
.mp-btn--secondary:hover { box-shadow: inset 0 0 0 1.5px var(--mp-text); }
.mp-btn--ghost { background: transparent; color: var(--mp-text-link); padding-left: 4px; padding-right: 4px; }
.mp-btn--ghost .mp-icon { transition: transform var(--mp-dur-2) var(--mp-ease-out); }
.mp-btn--ghost:hover .mp-icon { transform: translateX(3px); }
.mp-btn--inverse { background: var(--mp-porcelain); color: var(--mp-ink); }
.mp-btn--inverse:hover { background: #FFFFFF; transform: translateY(-1px); box-shadow: var(--mp-e-3); }
.mp-btn--inverse-outline { background: transparent; color: var(--mp-porcelain); box-shadow: inset 0 0 0 1.5px rgba(251,249,245,.42); }
.mp-btn--inverse-outline:hover { box-shadow: inset 0 0 0 1.5px var(--mp-porcelain); }
.mp-btn--lg { --_pad-y: 18px; --_pad-x: 36px; font-size: var(--mp-t-md); }
.mp-btn:focus-visible { outline: 2px solid var(--mp-focus); outline-offset: 3px; }

/* --- Badge / pill (§9.2) ---------------------------------------------- */
.mp-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: var(--mp-r-pill); background: var(--mp-ember-100); color: var(--mp-ember-700);
  font-family: var(--mp-font-mono); font-size: var(--mp-t-micro);
  font-variation-settings: "wdth" 75; letter-spacing: .08em; text-transform: uppercase;
}
.mp-badge--green { background: #E7EEDD; color: #3F5C2C; }
.mp-badge--ink   { background: var(--mp-ink); color: var(--mp-porcelain); }
.mp-badge--inverse { background: rgba(251,249,245,.14); color: var(--mp-porcelain); }

/* --- Forms (§9.6) ----------------------------------------------------- */
.mp-field { display: grid; gap: 8px; }
.mp-label { font-family: var(--mp-font-ui); font-size: var(--mp-t-sm); font-weight: 500; color: var(--mp-ink); }
.mp-input {
  height: 52px; padding: 0 16px; border-radius: var(--mp-r-xs);
  background: var(--mp-surface); border: 1px solid var(--mp-border);
  font-family: var(--mp-font-ui); font-size: var(--mp-t-md); color: var(--mp-text);
  transition: border-color var(--mp-dur-2) var(--mp-ease-std), box-shadow var(--mp-dur-2) var(--mp-ease-std);
}
.mp-input::placeholder { color: var(--mp-stone-500); }
.mp-input:focus-visible { outline: none; border-color: var(--mp-ink); box-shadow: 0 0 0 3px rgba(224,160,60,.35); }
.mp-input[aria-invalid="true"] { border-color: var(--mp-danger); box-shadow: 0 0 0 3px rgba(158,52,35,.18); }
.mp-help { font-size: var(--mp-t-xs); color: var(--mp-stone-600); }
.mp-error { font-size: var(--mp-t-xs); color: var(--mp-danger); display: flex; gap: 6px; align-items: center; }

/* --- Grain overlay (§7.5) ---------------------------------------------- */
.mp-grain { position: relative; isolation: isolate; }
.mp-grain::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  opacity: .06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- Reveal (§6.3) ----------------------------------------------------- */
[data-reveal] {
  opacity: 0; transform: translate3d(0, 24px, 0);
  transition: opacity var(--mp-dur-4) var(--mp-ease-out),
              transform var(--mp-dur-4) var(--mp-ease-out);
}
[data-reveal].is-in { opacity: 1; transform: none; }

/* --- Utility: visually hidden (§9.14) ---------------------------------- */
.mp-vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- Reduced motion (§6.4) --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}
