/* ============================================================
   The Store NZ — base.css
   Design tokens, reset, typography, controls, primitives.
   ============================================================ */

:root {
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #d2d2d7;
  --line-soft: #e6e6eb;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-pressed: #006edb;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --success: #1d8a4b;
  --success-soft: #e8f6ee;
  --warn: #b25000;
  --warn-soft: #fdf0e5;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --star: #f5a623;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  --shadow-2: 0 2px 6px rgba(0,0,0,.05), 0 14px 40px rgba(0,0,0,.09);
  --shadow-3: 0 4px 12px rgba(0,0,0,.06), 0 30px 70px rgba(0,0,0,.14);

  --nav-h: 52px;
  --content: 1080px;
  --content-wide: 1280px;

  --ease-out: cubic-bezier(.22,.8,.24,1);
  --ease-spring: cubic-bezier(.3,1.35,.4,1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.47059;
  font-weight: 400;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.022em; line-height: 1.12; }

::selection { background: rgba(0,113,227,.18); }

/* ---------- accessibility primitives ---------- */

.skip-link {
  position: fixed; top: -60px; left: 8px; z-index: 300;
  background: var(--surface); color: var(--accent);
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-2);
  transition: top .18s var(--ease-out);
}
.skip-link:focus { top: 8px; text-decoration: none; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid rgba(0,113,227,.65);
  outline-offset: 2px;
  border-radius: 6px;
}

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

/* ---------- typography ---------- */

.display-xl { font-size: clamp(2.6rem, 6.2vw, 4.6rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.display-l { font-size: clamp(2.1rem, 4.6vw, 3.4rem); letter-spacing: -0.026em; }
.display-m { font-size: clamp(1.6rem, 3vw, 2.3rem); letter-spacing: -0.022em; }
.headline { font-size: clamp(1.35rem, 2.2vw, 1.75rem); font-weight: 600; letter-spacing: -0.018em; }
.subhead { color: var(--muted); font-size: clamp(1.05rem, 1.6vw, 1.3rem); line-height: 1.38; }
.eyebrow { font-size: .82rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.body-sm { font-size: .93rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 0; border-radius: 980px; cursor: pointer;
  padding: 12px 24px; font-size: 1rem; font-weight: 400; letter-spacing: -0.01em;
  text-decoration: none !important; line-height: 1.2;
  transition: background .18s var(--ease-out), color .18s var(--ease-out), transform .18s var(--ease-out), box-shadow .18s var(--ease-out), opacity .18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 8px 22px rgba(0,113,227,.28); }
.btn-primary:disabled, .btn[disabled] { background: #b7b7bd; color: #fff; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.btn-secondary:hover { background: var(--accent); color: #fff; }
.btn-quiet { background: rgba(0,0,0,.05); color: var(--ink); }
.btn-quiet:hover { background: rgba(0,0,0,.09); }
.btn-dark { background: #1d1d1f; color: #fff; }
.btn-dark:hover { background: #333336; box-shadow: 0 8px 22px rgba(0,0,0,.25); }
.btn-lg { padding: 16px 32px; font-size: 1.08rem; }
.btn-sm { padding: 8px 16px; font-size: .93rem; }
.btn-block { width: 100%; }
.btn-link {
  background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer;
  font-size: inherit; display: inline-flex; align-items: center; gap: .35em;
}
.btn-link:hover { text-decoration: underline; }
.chevron { display: inline-block; transition: transform .2s var(--ease-out); font-size: .9em; margin-top: .08em; }
.btn-link:hover .chevron { transform: translateX(3px); }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: .45rem; margin-block: 0 1.15rem; }
.field > label { font-size: .95rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .84rem; color: var(--faint); }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 15px;
  transition: border-color .16s, box-shadow .16s;
  appearance: none;
}
.textarea { resize: vertical; min-height: 84px; }
.input::placeholder, .textarea::placeholder { color: #a1a1a6; }
.input:hover, .select:hover, .textarea:hover { border-color: #b8b8bf; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(0,113,227,.18);
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236e6e73' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px;
  padding-right: 40px; cursor: pointer;
}
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.field.invalid .input:focus-visible, .field.invalid .select:focus-visible { box-shadow: 0 0 0 3.5px rgba(192,57,43,.16); }
.field-error { display: none; font-size: .85rem; color: var(--danger); align-items: center; gap: .4em; }
.field.invalid .field-error { display: flex; }
.field-error::before { content: "!"; width: 15px; height: 15px; flex: none; border-radius: 50%; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.field.valid-note { font-size: .85rem; color: var(--success); display: flex; gap: .4em; }

.checkbox-row { display: flex; align-items: flex-start; gap: .7rem; cursor: pointer; padding: .35rem 0; }
.checkbox-row input {
  appearance: none; width: 21px; height: 21px; flex: none; margin-top: .1rem;
  border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2.5 7.5 5.5 10.5 11.5 3.5' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 0; background-position: center; background-repeat: no-repeat;
  transition: background-color .14s, background-size .16s var(--ease-out), border-color .14s; cursor: pointer;
}
.checkbox-row input:checked { background-color: var(--accent); border-color: var(--accent); background-size: 13px; }
.checkbox-row input:focus-visible { outline: 3px solid rgba(0,113,227,.5); outline-offset: 2px; }
.checkbox-row .chk-label { font-size: .95rem; color: var(--ink-2); }
.checkbox-row .chk-sub { display: block; font-size: .84rem; color: var(--faint); margin-top: .15rem; }

/* ---------- badges & chips ---------- */

.badge { display: inline-flex; align-items: center; border-radius: 999px; font-size: .78rem; font-weight: 600; padding: 3px 10px; letter-spacing: .01em; }
.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-soldout { background: #ececef; color: var(--muted); }
.badge-free { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

.pill-note { display: inline-flex; align-items: center; gap: .45em; background: #fff; border: 1px solid var(--line-soft); border-radius: 999px; padding: 6px 14px; font-size: .86rem; color: var(--ink-2); box-shadow: var(--shadow-1); }

/* ---------- toasts ---------- */

.toast-region { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 240; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: min(94vw, 480px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: .7rem;
  background: rgba(29, 29, 31, .92); color: #f5f5f7; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 14px; padding: 12px 18px; box-shadow: var(--shadow-3);
  font-size: .93rem; max-width: 100%;
  animation: toast-in .34s var(--ease-spring);
}
.toast.leaving { animation: toast-out .25s var(--ease-out) forwards; }
.toast .t-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.toast.ok .t-icon { background: var(--success); }
.toast.warn .t-icon { background: var(--warn); }
.toast .t-icon svg { width: 12px; height: 12px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---------- modal ---------- */

.modal-root { position: relative; z-index: 250; }
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 250; animation: fade-in .2s ease; }
.modal {
  position: fixed; z-index: 251; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(94vw, 560px); max-height: min(86vh, 720px); overflow: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  padding: 28px; animation: modal-in .32s var(--ease-spring);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.35rem; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.06); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.modal-close:hover { background: rgba(0,0,0,.12); }
@keyframes modal-in { from { opacity: 0; transform: translate(-50%,-47%) scale(.96); } }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- skeletons ---------- */

.skel { position: relative; overflow: hidden; background: #e8e8ed; border-radius: var(--r-md); }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  animation: shimmer 1.35s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 14px; border-radius: 7px; }
.skel-line.w60 { width: 60%; } .skel-line.w40 { width: 40%; } .skel-line.w80 { width: 80%; }
.skel-card { border-radius: var(--r-lg); background: #ececf1; }

/* ---------- scroll reveal ---------- */

.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: .08s; }
.reveal[data-delay="2"] { transition-delay: .16s; }
.reveal[data-delay="3"] { transition-delay: .24s; }
.reveal[data-delay="4"] { transition-delay: .32s; }

/* ---------- price tick ---------- */

.price-tick { display: inline-block; }
.price-tick.bump { animation: price-bump .4s var(--ease-spring); }
@keyframes price-bump { 30% { transform: translateY(-4px) scale(1.04); } }

/* ---------- misc ---------- */

.divider { border: 0; border-top: 1px solid var(--line-soft); margin: 0; }
.aurora-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.stars { display: inline-flex; gap: 1px; color: var(--star); font-size: .8em; letter-spacing: .05em; }

.card-hover { transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out); }
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-swap { animation: fade-swap .32s var(--ease-out); }
@keyframes fade-swap { from { opacity: 0; transform: translateY(6px); } }

/* ---------- reduced motion ---------- */

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