/*
  Worth a Try — micro card-swap demo (A10, amends A8/A9).
  The card itself renders in the locked M2.2 tokens (see src/tokens.ts):
  M PLUS Rounded, the 16 category colors, and the exact "Postcard" geometry
  from src/app/lab/finalize.tsx (CARD_W=300, CARD_H=420, FRAME=6, OUTER_R=20,
  INNER_R=13, ART_H=224). Art is an original procedural pixel scene drawn to
  <canvas> per category — a stand-in for the M2.7 art pipeline, not the final
  direction, and needing no external file or license. The surrounding page
  chrome (headline, buttons, facts, footer) uses a new self-hosted pairing —
  Bricolage Grotesque + Instrument Sans — kept off the card so the card stays
  a faithful preview of the locked token set. No third-party font requests,
  no analytics, matching the app's own privacy stance.
*/

@font-face {
  font-family: 'M PLUS Rounded';
  src: url('/fonts/MPLUSRounded1c-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'M PLUS Rounded';
  src: url('/fonts/MPLUSRounded1c-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/fonts/BricolageGrotesque-Variable.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: 'Instrument Sans';
  src: url('/fonts/InstrumentSans-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #FBF7EF;
  --paper: #F6F0E2;
  --ink: #41392D;
  --ink-soft: #8A7F68;
  --line: #E6DCC3;
  --pop: #D96849;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 24px;
}

.hero {
  margin-bottom: 30px;
}

.brand {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

h1 {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(32px, 6.4vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  max-width: 16ch;
  margin: 0 auto 16px;
  color: var(--ink);
}

h1 .pop {
  color: var(--pop);
}

.sub {
  font-size: clamp(16px, 2.4vw, 18px);
  line-height: 1.5;
  max-width: 42ch;
  margin: 0 auto;
  color: var(--ink-soft);
}

/* ---------- demo ---------- */

.demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
}

.demo-hint {
  text-align: center;
  max-width: 40ch;
  margin: 0 0 26px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

.card-stage {
  /*
    Exact port of src/app/lab/finalize.tsx's FinalCard (CARD_W=300, CARD_H=420,
    FRAME=6, OUTER_R=20, INNER_R=13, ART_H=224) — fixed size like the native
    component; scales down only on screens too narrow to fit it at 100%.
    position:relative anchors the rising "embers" particles on Worth a try.
  */
  position: relative;
  width: min(300px, 90vw);
}

.card-outer {
  width: 100%;
  aspect-ratio: 300 / 420;
  border-radius: 21px;
  box-shadow: 0 10px 24px rgba(40, 34, 22, 0.22);
  font-family: 'M PLUS Rounded', system-ui, sans-serif;
  transition: transform 0.2s ease-in, opacity 0.2s ease-in;
}

.card-outer.swap-pass {
  transform: translateX(-60px) rotate(-8deg);
  opacity: 0;
}

.card-outer.swap-try {
  transform: translateX(60px) rotate(8deg);
  opacity: 0;
}

.card-outer.swap-in {
  animation: card-in 0.32s cubic-bezier(0.3, 1.4, 0.6, 1);
}

@keyframes card-in {
  0% {
    transform: translateY(10px) scale(0.94);
    opacity: 0;
  }
  65% {
    transform: translateY(0) scale(1.03);
    opacity: 1;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-outer.swap-in {
    animation: none;
  }
}

.frame {
  height: 100%;
  box-sizing: border-box;
  background: var(--accent);
  border: 1px solid var(--outer);
  border-radius: 20px;
  padding: 6px;
  display: flex;
}

.inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--inner);
  border-radius: 13px;
  overflow: hidden;
  position: relative;
}

/* foil sweep — a small "worth a try" flourish, not a rarity signal (A2/A6).
   Lives on .inner (already clipped to the rounded card) so it never pokes
   past the corners or over the drop shadow. */
.inner::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 32%, rgba(255, 244, 214, 0.45) 46%, transparent 58%);
  transform: translateX(-130%);
}

.card-outer.foil .inner::after {
  animation: foil 0.9s ease 0.08s forwards;
}

@keyframes foil {
  to {
    transform: translateX(130%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-outer.foil .inner::after {
    animation: none;
  }
}

.art {
  height: 53.333%; /* ART_H (224) / CARD_H (420) */
  flex-shrink: 0;
  overflow: hidden;
  background: var(--soft, var(--paper));
}

.art canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.pill-wrap {
  display: flex;
  justify-content: center;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(53.333% - 15px); /* ART_H - 15, floating on the art/paper seam */
  z-index: 4;
}

.pill-halo {
  background: var(--paper);
  border: 1.5px solid var(--seam);
  border-radius: 999px;
  padding: 2px;
  display: inline-flex;
}

.pill {
  background: var(--soft);
  border-radius: 999px;
  padding: 4px 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.pill span,
#cardCategory {
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
}

.caption {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-top: 2px solid var(--seam);
  padding: 22px 16px 20px;
  box-sizing: border-box;
  text-align: center;
}

.caption-spacer {
  flex: 1;
}

.card-title {
  font-weight: 700;
  font-size: 25px;
  line-height: 29px;
  margin: 4px 0 0;
  padding: 0 8px;
  color: var(--accent);
  /* matches numberOfLines={2} on the native <Text> title in finalize.tsx */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-weight: 400;
  font-size: 13.5px;
  line-height: 20px;
  margin: 8px 0 0;
  padding: 0 20px;
  color: var(--ink);
}

/* fleuron divider: —→ ◆ ←— */
.fleuron {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 170px;
  margin: 0 auto;
  flex-shrink: 0;
}

.f-line {
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
}

.f-arrow {
  width: 5px;
  height: 5px;
}

.f-arrow-l {
  border-bottom: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  transform: rotate(-45deg);
}

.f-arrow-r {
  border-bottom: 1px solid var(--accent);
  border-left: 1px solid var(--accent);
  transform: rotate(45deg);
}

.f-dot {
  background: var(--accent);
  border-radius: 1px;
  transform: rotate(45deg);
}

.f-dot-sm {
  width: 4px;
  height: 4px;
  opacity: 0.55;
}

.f-dot-lg {
  width: 7px;
  height: 7px;
  opacity: 1;
}

/* rising embers on "Worth a try" */
.ember {
  position: absolute;
  z-index: 5;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  left: 50%;
  top: 60%;
  pointer-events: none;
  animation: rise 1s ease-out forwards;
}

@keyframes rise {
  from {
    transform: translate(0, 0);
    opacity: 0.95;
  }
  to {
    transform: translate(var(--x), var(--y));
    opacity: 0;
  }
}

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

.button-row {
  display: flex;
  gap: 14px;
  margin-top: 26px;
}

.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 22px;
  border-radius: 14px;
  border: 2px solid;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn-pass {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-try {
  background: var(--accent);
  border-color: var(--outer);
  color: #FFFFFF;
}

/* ---------- binder (collection progress) ---------- */

.binder {
  display: flex;
  gap: 7px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 340px;
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: #E4DBC8;
  transition: background 0.4s, box-shadow 0.4s;
}

.dot.lit {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px currentColor;
}

.deck-count {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- facts + footer ---------- */

.strip {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 18px 30px;
}

.facts {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
}

.fact {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
}

.foot {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
  max-width: 42ch;
}

.foot p {
  margin: 0;
}
