/* ==========================================================================
   StoryMap — brand system ("Electric Sorbet")
   Shared by landing, dashboard/editor and 404.
   ========================================================================== */

:root {
  /* Core palette */
  --ink: #140f2b;
  --ink-2: #2a2350;
  --paper: #fff7ea;
  --paper-2: #fdeed6;
  --white: #ffffff;

  --pink: #ff4fa3;
  --lime: #c8ff2e;
  --violet: #7c5cff;
  --sun: #ffc93c;
  --sky: #3dd6ff;
  --orange: #ff7a30;
  --mint: #3df5b0;

  /* Semantic */
  --bg: var(--paper);
  --surface: var(--white);
  --surface-2: #fff2dc;
  --text: var(--ink);
  --text-muted: #5f5880;
  --line: var(--ink);
  --accent: var(--pink);
  --accent-2: var(--violet);
  --success: #18c27a;
  --danger: #ff3d5a;

  /* Type */
  --font-display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand: 'Caveat', 'Comic Sans MS', cursive;

  /* Shape + depth */
  --r-sm: 10px;
  --r: 18px;
  --r-lg: 28px;
  --r-pill: 999px;
  --bw: 2.5px;
  --shadow-hard: 4px 4px 0 var(--ink);
  --shadow-hard-lg: 7px 7px 0 var(--ink);
  --shadow-soft: 0 18px 50px rgba(20, 15, 43, 0.14);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 160ms;
  --t: 280ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--lime); color: var(--ink); }

/* ---------- Type helpers ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
}
.hand { font-family: var(--font-hand); font-weight: 700; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.12em;
}
.muted { color: var(--text-muted); }

/* Highlighter swipe behind a word */
.hl {
  position: relative; white-space: nowrap; z-index: 0;
}
.hl::before {
  content: ''; position: absolute; z-index: -1;
  left: -0.08em; right: -0.08em; bottom: 0.06em; height: 0.42em;
  background: var(--hl, var(--lime));
  border-radius: 0.2em;
  transform: skew(-8deg) scaleX(var(--hl-scale, 1));
  transform-origin: left;
  transition: transform 900ms var(--ease-out);
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--white);
  --btn-fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), background var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn-primary { --btn-bg: var(--pink); --btn-fg: var(--white); }
.btn-lime { --btn-bg: var(--lime); }
.btn-violet { --btn-bg: var(--violet); --btn-fg: var(--white); }
.btn-sun { --btn-bg: var(--sun); }
.btn-ink { --btn-bg: var(--ink); --btn-fg: var(--white); box-shadow: 3px 3px 0 var(--pink); }
.btn-ink:hover { box-shadow: 5px 5px 0 var(--pink); }
.btn-ghost {
  --btn-bg: transparent; border-color: transparent; box-shadow: none;
}
.btn-ghost:hover { background: rgba(20, 15, 43, 0.07); transform: none; box-shadow: none; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 16px 30px; font-size: 18px; }
.btn-icon { padding: 8px; width: 40px; height: 40px; border-radius: 14px; }
.btn-icon.btn-sm { width: 32px; height: 32px; padding: 6px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- Chips / stickers ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  background: var(--white);
  font-size: 13px; font-weight: 600;
  line-height: 1.2;
}
.chip-lime { background: var(--lime); }
.chip-pink { background: var(--pink); color: var(--white); }
.chip-sun { background: var(--sun); }
.chip-sky { background: var(--sky); }
.chip-violet { background: var(--violet); color: var(--white); }
.sticker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: var(--bw) solid var(--ink);
  border-radius: 14px;
  background: var(--sun);
  font-family: var(--font-display); font-weight: 800;
  box-shadow: var(--shadow-hard);
  transform: rotate(var(--rot, -4deg));
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-hard-lg);
}

/* ---------- Inputs ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}
.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 15px;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  box-shadow: 3px 3px 0 var(--violet);
  transform: translate(-1px, -1px);
}
.input::placeholder, .textarea::placeholder { color: #9a93b8; }

/* Toggle switch */
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #e8e2f5; transition: background var(--t);
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--ink);
  transition: transform var(--t) var(--ease-bounce);
}
.switch input:checked + span { background: var(--lime); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--violet); outline-offset: 2px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(20, 15, 43, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity var(--t), visibility var(--t);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  position: relative;
  width: 100%; max-width: 480px; max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 28px;
  transform: translateY(24px) scale(0.96) rotate(-1deg);
  transition: transform 420ms var(--ease-bounce);
}
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 720px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 12px;
  border: 2px solid var(--ink); background: var(--white);
  display: grid; place-items: center; cursor: pointer;
  font-size: 20px; line-height: 1;
  transition: transform var(--t-fast) var(--ease-bounce), background var(--t-fast);
}
.modal-close:hover { transform: rotate(90deg); background: var(--sun); }
.modal-title { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -0.03em; line-height: 1.05; margin: 0 40px 8px 0; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 5000;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border: var(--bw) solid var(--ink);
  border-radius: 16px;
  background: var(--ink); color: var(--white);
  font-weight: 600; font-size: 14px;
  box-shadow: 4px 4px 0 var(--pink);
  animation: toastIn 420ms var(--ease-bounce) both;
  pointer-events: auto;
  max-width: min(92vw, 460px);
}
.toast.success { box-shadow: 4px 4px 0 var(--lime); }
.toast.error { box-shadow: 4px 4px 0 var(--danger); }
.toast.leaving { animation: toastOut 260ms ease-in both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(0.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px) scale(0.95); } }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(36px); transition: opacity 800ms var(--ease-out), transform 800ms var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 90ms; }
.reveal[data-delay="2"] { transition-delay: 180ms; }
.reveal[data-delay="3"] { transition-delay: 270ms; }
.reveal[data-delay="4"] { transition-delay: 360ms; }

/* ---------- Marquee ---------- */
.marquee { overflow: hidden; white-space: nowrap; }
.marquee-track { display: inline-flex; gap: 28px; padding-right: 28px; animation: marquee var(--marquee-speed, 32s) linear infinite; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Logo ---------- */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.04em;
}
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border: var(--bw) solid var(--ink); border-radius: 12px;
  background: var(--lime);
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-6deg);
  transition: transform 400ms var(--ease-bounce);
}
.brand:hover .brand-mark { transform: rotate(6deg) scale(1.06); }
.brand-mark svg { width: 22px; height: 22px; }
.brand b { color: var(--pink); }

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