/* Imajiva components (redesign Phase 2). Built only on tokens.css. No inline styles anywhere (CSP).
   Naming: .block, .block__part, .block--variant. Layout primitives first, then components. */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: var(--fs-base);
  line-height: var(--lh-body); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
/* skip link: hidden until focused (keyboard users jump past the navigation) */
.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; padding: 8px 14px; background: var(--text); color: var(--bg); border-radius: var(--r-pill); }
.skip:focus { left: 8px; }  /* width/height attributes reserve space (no layout shift); CSS decides the size */
a { color: var(--link); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3, h4, .display { font-family: var(--font-display); letter-spacing: var(--tracking-display); line-height: var(--lh-snug);
  margin: 0 0 var(--s-4); font-weight: 700; text-wrap: balance; }
.display-1, .display-2 { font-family: var(--font-display); letter-spacing: var(--tracking-display); }
.display-1 { font-size: var(--fs-5xl); font-weight: 800; line-height: var(--lh-tight); }
.display-2 { font-size: var(--fs-4xl); font-weight: 800; line-height: var(--lh-tight); }
h1, .h1 { font-size: var(--fs-3xl); } h2, .h2 { font-size: var(--fs-2xl); } h3, .h3 { font-size: var(--fs-xl); }
h4, .h4 { font-size: var(--fs-lg); font-weight: 600; }
p { margin: 0 0 var(--s-4); }
.lead { font-size: var(--fs-md); color: var(--text-muted); max-width: 60ch; }
.muted { color: var(--text-muted); } .small { font-size: var(--fs-sm); }
.eyebrow { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--link); margin-bottom: var(--s-3); }
.mark { background: linear-gradient(transparent 58%, var(--lime) 58%, var(--lime) 90%, transparent 90%); padding: 0 2px; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s-4); }
.container--narrow { max-width: var(--container-narrow); }
@media (min-width: 768px) { .container { padding: 0 var(--s-8); } }
.stack > * + * { margin-top: var(--s-4); } .stack--lg > * + * { margin-top: var(--s-8); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--s-6); } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
.span-full { grid-column: 1 / -1; }
.auto-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 160px)), 1fr)); }
.section { padding: var(--s-16) 0; } @media (min-width: 768px) { .section { padding: var(--s-24) 0; } }

/* ---------- logo ---------- */
.logo { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text); text-decoration: none; }
.logo__mark { width: 32px; height: 32px; flex: none; }
.logo__word { font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; letter-spacing: -0.03em; line-height: 1; }

/* ---------- buttons ---------- */
.btn { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px;
  padding: 0 var(--s-5); border-radius: var(--r-pill); border: var(--border-w) solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg); font: 600 var(--fs-base)/1 var(--font-body); text-decoration: none;
  cursor: pointer; transition: transform var(--dur-1) var(--ease), background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
.btn:hover { --btn-bd: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-bd: var(--primary); }
.btn--primary:hover { --btn-bg: var(--primary-hover); --btn-bd: var(--primary-hover); }
.btn--pop { box-shadow: var(--sh-press); --btn-bd: var(--text); }       /* hero / key conversion CTA */
.btn--pop:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--text); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn--ghost:hover { --btn-bg: var(--surface-2); --btn-bd: transparent; }
.btn--danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: var(--danger); }
.btn--sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn--lg { min-height: 54px; padding: 0 var(--s-8); font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn__icon { width: 18px; height: 18px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--r-md); padding: var(--s-6); }
.card--flat { background: transparent; border-style: dashed; }
.card--accent { background: var(--coral-soft); border-color: transparent; }
.card--highlight { background: var(--lime-soft); border-color: transparent; }
.card__title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); margin: 0 0 var(--s-2); }
.card--link { text-decoration: none; color: inherit; transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.card--link:hover { border-color: var(--text); transform: translateY(-2px); }

/* sticker tile: checkerboard canvas + die-cut look, the signature component */
.sticker { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: var(--r-md);
  background-color: var(--checker-a);
  background-image: conic-gradient(var(--checker-b) 25%, transparent 0 50%, var(--checker-b) 0 75%, transparent 0);
  background-size: 20px 20px; overflow: hidden; }
.sticker img { width: 86%; height: auto; filter: drop-shadow(0 6px 10px rgba(38, 35, 45, 0.18));
  transition: transform var(--dur-3) var(--ease-bounce); }
.sticker:hover img { transform: rotate(-3deg) scale(1.04); }
.sticker--plain { background: var(--surface-2); }
.sticker-card { display: flex; flex-direction: column; gap: var(--s-2); margin: 0; }
.sticker-card__label { font-weight: 600; font-size: var(--fs-sm); }
.sticker-card__meta { font-size: var(--fs-xs); color: var(--text-muted); display: flex; gap: var(--s-3); flex-wrap: wrap; }

/* ---------- badges, chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--text); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--violet { background: var(--violet-soft); color: var(--link); }
.badge--lime { background: var(--lime); color: var(--ink); } .badge--coral { background: var(--coral); color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-4);
  border: var(--border-w) solid var(--border-strong); border-radius: var(--r-pill); background: var(--surface);
  font-weight: 500; cursor: pointer; user-select: none; }
.chip:has(input:checked) { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- forms ---------- */
.field { display: grid; gap: var(--s-2); }
.label { font-weight: 600; font-size: var(--fs-sm); }
.help { font-size: var(--fs-sm); color: var(--text-muted); }
.input, .textarea, .select { width: 100%; min-height: 48px; padding: var(--s-3) var(--s-4); border-radius: var(--r-sm);
  border: var(--border-w) solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 var(--fs-base)/1.4 var(--font-body); transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--violet-soft); }
.field--error .input, .field--error .textarea { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: var(--fs-sm); font-weight: 500; }
.check { display: flex; gap: var(--s-3); align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }
/* choice cards: radio/checkbox with a picture (style selector, expressions) */
.choice { position: relative; display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md);
  border: var(--border-w) solid var(--border); background: var(--surface); cursor: pointer;
  transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.choice:hover { border-color: var(--border-strong); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--violet-soft); }
.choice:has(input:checked)::after { content: ""; position: absolute; top: 10px; right: 10px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 14px no-repeat; }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Browsers without :has() (iOS < 15.4, Chrome < 105): show the real radio/checkbox so the choice stays visible */
@supports not selector(:has(*)) {
  .choice input, .chip input { position: static; opacity: 1; pointer-events: auto; accent-color: var(--primary); }
}
.choice__title { font-weight: 600; } .choice__hint { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- alerts, empty, loading ---------- */
.alert { display: flex; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-sm); background: var(--surface-2);
  border-left: 4px solid var(--border-strong); }
.alert--success { background: var(--success-soft); border-color: var(--success); }
.alert--danger { background: var(--danger-soft); border-color: var(--danger); }
.alert--info { background: var(--violet-soft); border-color: var(--primary); }
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-3); padding: var(--s-12) var(--s-6);
  border: var(--border-w) dashed var(--border-strong); border-radius: var(--r-lg); }
.empty__art { width: 140px; }
.empty__title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); margin: 0; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.progress { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--primary); border-radius: inherit;  /* width set by ui.js from data-value */
  transition: width var(--dur-3) var(--ease); }
.progress--indeterminate .progress__bar { width: 35%; animation: indeterminate 1.2s var(--ease) infinite; }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--violet-soft); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner, .progress--indeterminate .progress__bar { animation: none; } }

/* ---------- dialog & drawer (native <dialog>, opened by ui.js) ---------- */
.dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  width: min(560px, calc(100% - 2 * var(--s-4))); box-shadow: var(--sh-2); }
.dialog::backdrop { background: rgba(22, 20, 27, 0.55); }
.dialog__body { padding: var(--s-6); } .dialog__footer { padding: 0 var(--s-6) var(--s-6); display: flex; gap: var(--s-3); justify-content: flex-end; flex-wrap: wrap; }
.drawer { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(420px, 100%); border-radius: var(--r-lg) 0 0 var(--r-lg); }

/* ---------- navigation & app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center;
  justify-content: space-between; gap: var(--s-4); padding: 0 var(--s-4); background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: var(--border-w) solid var(--border); }
.nav-links { display: none; gap: var(--s-1); }
@media (min-width: 900px) { .nav-links { display: flex; } }
.nav-link { padding: var(--s-2) var(--s-3); border-radius: var(--r-pill); color: var(--text); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); } .nav-link[aria-current="page"] { background: var(--text); color: var(--bg); }
.app { display: grid; min-height: 100vh; grid-template-rows: var(--topbar-h) 1fr; }
@media (min-width: 900px) { .app { grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 1fr; } }
.sidebar { display: none; }
@media (min-width: 900px) {
  .sidebar { display: flex; flex-direction: column; gap: var(--s-6); position: sticky; top: 0; height: 100vh;
    padding: var(--s-6) var(--s-4); border-right: var(--border-w) solid var(--border); background: var(--surface); }
  .app > .topbar { display: none; }
}
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-sm);
  color: var(--text); text-decoration: none; font-weight: 500; }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a[aria-current="page"] { background: var(--violet-soft); color: var(--link); font-weight: 600; }
.side-nav svg { width: 20px; height: 20px; flex: none; }
.main { padding: var(--s-6) var(--s-4) calc(var(--s-20) + env(safe-area-inset-bottom)); min-width: 0; }
@media (min-width: 900px) { .main { padding: var(--s-10) var(--s-10) var(--s-16); } }
.bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: var(--s-2) var(--s-2) calc(var(--s-2) + env(safe-area-inset-bottom)); background: var(--surface);
  border-top: var(--border-w) solid var(--border); }
@media (min-width: 900px) { .bottom-nav { display: none; } }
.bottom-nav a { display: grid; justify-items: center; gap: 2px; padding: var(--s-2); border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-decoration: none; }
.bottom-nav a[aria-current="page"] { color: var(--link); }
.bottom-nav svg { width: 22px; height: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-8); }
.page-head h1 { margin: 0; }

/* ---------- stats, avatar, credits ---------- */
.stat { display: grid; gap: 2px; padding: var(--s-5); border-radius: var(--r-md); background: var(--surface); border: var(--border-w) solid var(--border); }
.stat__value { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-2xl); line-height: 1.1; }
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); }
.credit-pill { display: inline-flex; align-items: center; gap: var(--s-2); padding: 6px 12px 6px 8px; border-radius: var(--r-pill);
  background: var(--lime); color: var(--ink); font-weight: 700; font-size: var(--fs-sm); text-decoration: none; }
.credit-pill__dot { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--lime);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--violet-soft); display: grid; place-items: center;
  font-weight: 700; color: var(--link); overflow: hidden; }

/* ---------- motion helpers ---------- */
.float { animation: float 6s var(--ease) infinite; }
.tilt-l { --tilt: -6deg; transform: rotate(-6deg); } .tilt-r { --tilt: 5deg; transform: rotate(5deg); } .delay-1 { animation-delay: -2s; } .delay-2 { animation-delay: -4s; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--tilt, 0deg)); } 50% { transform: translateY(-8px) rotate(var(--tilt, 0deg)); } }
@media (prefers-reduced-motion: reduce) { .float { animation: none; } }
