/* =========================================================
   Matchbook Match — vintage / matchbook aesthetic
   Warm paper, charcoal ink, ember-red LIKE, slate NOPE.
   Mobile-first, self-contained (no external assets/fonts).
   ========================================================= */

:root {
  --paper:      #f3e9d8;
  --paper-2:    #ece0cb;
  --paper-3:    #e4d6bd;
  --card:       #faf3e6;
  --ink:        #2a2320;
  --ink-soft:   #7a6d5d;
  --ink-faint:  #a99a85;
  --ember:      #d7402b;
  --ember-2:    #b8301f;
  --slate:      #4d5a63;
  --slate-2:    #38424a;
  --gold:       #c8992f;
  --gold-2:     #a87c18;
  --line:       rgba(42, 35, 32, 0.14);
  --shadow:     0 18px 40px -14px rgba(42, 26, 20, 0.45),
                0 4px 12px -6px rgba(42, 26, 20, 0.3);
  --radius:     20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  /* layered paper texture — pure CSS */
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.55), transparent 42%),
    radial-gradient(circle at 82% 88%, rgba(120, 80, 40, 0.1), transparent 46%),
    repeating-linear-gradient(45deg, rgba(120, 84, 48, 0.028) 0 2px, transparent 2px 5px),
    linear-gradient(160deg, var(--paper) 0%, var(--paper-2) 60%, var(--paper-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 6px) 14px calc(var(--safe-b) + 8px);
}

button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ===================== TOP BAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 10px;
  flex: 0 0 auto;
}
.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 4px;
  color: var(--ink);
}
.topbar__flame {
  width: 16px;
  height: 22px;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: linear-gradient(180deg, #f7b32b, var(--ember) 62%, var(--ember-2));
  box-shadow: 0 0 10px rgba(215, 64, 43, 0.55);
  transform: rotate(-4deg);
}
.topbar__title {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 17px;
}
.topbar__title span { color: var(--ember); }

.topbar__right { display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}
.chip__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ember);
}
.iconlink {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 7px 15px;
  font-weight: 700;
  font-size: 13px;
}

/* ===================== SCREENS ===================== */
.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }

/* ===================== USER PICK ===================== */
.screen--pick { justify-content: center; }
.pick {
  text-align: center;
  padding: 20px 8px 40px;
  animation: rise 0.5s ease both;
}
.pick__logo {
  width: 92px; height: 92px;
  margin: 0 auto 22px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 120%, rgba(215,64,43,0.25), transparent 60%),
    linear-gradient(160deg, #33291f, #241c15);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.08);
  position: relative;
}
.pick__logo::after {
  content: "";
  position: absolute;
  inset: 8px 8px auto 8px;
  height: 10px;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, #6f5535 0 5px, #4a3a22 5px 10px);
  opacity: 0.75;
}
.pick__flame {
  width: 30px; height: 44px;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: linear-gradient(180deg, #ffd24a, #f7912b 45%, var(--ember) 78%, var(--ember-2));
  box-shadow: 0 0 26px rgba(247, 145, 43, 0.7);
  animation: flicker 2.4s ease-in-out infinite;
}
.pick__title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.pick__sub { color: var(--ink-soft); margin: 0 0 30px; font-size: 15px; }
.pick__btns { display: grid; gap: 14px; max-width: 320px; margin: 0 auto; }
.userbtn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 18px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: 0 6px 0 -1px var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.userbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 -1px var(--ink); }
.userbtn__initials {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ember);
  color: #fff;
  font-size: 17px;
  letter-spacing: 0.02em;
}
.userbtn--alt .userbtn__initials { background: var(--slate); }
.pick__hint { color: var(--ink-faint); font-size: 13px; margin-top: 26px; }

/* ===================== SWIPE / DECK ===================== */
.deckwrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  touch-action: none;
}
.stack {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 640px;
}

.card {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid rgba(42, 35, 32, 0.08);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  will-change: transform;
  transform-origin: center bottom;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.42s cubic-bezier(0.2, 0.7, 0.25, 1), opacity 0.42s ease;
}
.card.is-top { cursor: grab; }
.card.is-dragging { transition: none; cursor: grabbing; }
.card:not(.is-top) { pointer-events: none; }

.card__media {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(circle at 50% 38%, #fffdf8, var(--paper-2) 88%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.card__media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 10px 18px rgba(40, 24, 14, 0.22));
}
.card__media::after {
  /* subtle vignette + top strike-strip nod to a matchbook */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 -40px 60px -40px rgba(40, 24, 14, 0.18);
}

.card__info {
  flex: 0 0 auto;
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, rgba(250,243,230,0), var(--card) 30%);
  border-top: 1px dashed var(--line);
}
.card__badges { display: flex; gap: 7px; margin-bottom: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
}
.badge--group { background: var(--ink); color: var(--paper); }
.badge--src {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.badge--price {
  background: var(--ember);
  color: #fff;
  margin-left: auto;
}
.card__title {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.card__loc {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

/* favorite ribbon */
.card__ribbon {
  position: absolute;
  top: 15px;
  left: -34px;
  transform: rotate(-45deg);
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #3a2c05;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 40px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  z-index: 4;
}

/* drag stamps */
.stamp {
  position: absolute;
  top: 26px;
  padding: 6px 16px;
  border: 4px solid;
  border-radius: 10px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.05em;
  opacity: 0;
  z-index: 5;
  pointer-events: none;
}
.stamp--like {
  left: 20px;
  color: var(--ember);
  border-color: var(--ember);
  transform: rotate(-16deg);
}
.stamp--nope {
  right: 20px;
  color: var(--slate);
  border-color: var(--slate);
  transform: rotate(16deg);
}

/* ===================== OVERLAYS ===================== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  color: var(--ink-soft);
}
.overlay__big { font-size: 26px; font-weight: 800; color: var(--ink); margin: 0; }
.overlay__msg { margin: 0; font-size: 14px; max-width: 260px; }
.overlay--done .done__mark {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--ember); color: #fff;
  display: grid; place-items: center;
  font-size: 38px; font-weight: 900;
  box-shadow: 0 12px 26px -8px rgba(215, 64, 43, 0.6);
  animation: pop 0.4s ease both;
}
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--ember);
  animation: spin 0.8s linear infinite;
}

/* ===================== HUD (progress + actions) ===================== */
.hud { flex: 0 0 auto; padding-top: 12px; }
.progress { margin-bottom: 12px; }
.progress__row {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.progress__pct { color: var(--ember); }
.progress__track {
  height: 6px;
  background: rgba(42, 35, 32, 0.1);
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember-2), var(--ember));
  transition: width 0.35s ease;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.fab {
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--card);
  box-shadow: 0 8px 20px -8px rgba(42, 26, 20, 0.5), inset 0 0 0 1.5px var(--line);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
}
.fab svg {
  width: 46%; height: 46%;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fab--nope { width: 62px; height: 62px; }
.fab--nope svg { stroke: var(--slate); }
.fab--like { width: 62px; height: 62px; }
.fab--like svg { stroke: none; fill: var(--ember); width: 52%; height: 52%; }
.fab--undo { width: 50px; height: 50px; }
.fab--undo svg { stroke: var(--gold-2); }
.fab:active { transform: scale(0.9); }
.fab:disabled { opacity: 0.4; box-shadow: inset 0 0 0 1.5px var(--line); }
.fab--nope:active { box-shadow: 0 8px 20px -8px var(--slate), inset 0 0 0 1.5px var(--slate); }
.fab--like:active { box-shadow: 0 8px 20px -8px var(--ember), inset 0 0 0 1.5px var(--ember); }

/* ===================== REVIEW ===================== */
.review {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: 4px;
}
.tabs {
  display: flex;
  gap: 6px;
  background: rgba(42, 35, 32, 0.06);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 12px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.18s, color 0.18s;
}
.tab.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tab__count {
  font-size: 12px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 20px;
}
.tab__count--hot { background: var(--ember); color: #fff; }

.review__summary {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 8px;
  text-align: center;
  font-weight: 600;
}
.review__total {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 700;
}
.review__total strong {
  font-size: 19px;
  color: var(--ember-2);
  font-weight: 900;
  letter-spacing: -0.02em;
}

/* The scroll wrapper owns height + overflow; each .grid keeps its natural
   (content) height so the square tiles resolve instead of collapsing. */
.review__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.revsec { margin-bottom: 20px; }
.revsec:last-child { margin-bottom: 4px; }
.revsec__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 2px 8px;
}
.revsec__title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.revsec--match .revsec__title { color: var(--ember-2); }
.revsec--match .revsec__title::before { content: "\2665\FE0E  "; }
.revsec__meta { font-size: 12px; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.grid {
  display: grid;
  /* minmax(0,1fr) lets tracks shrink below content min-content -> no horizontal overflow */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 2px 4px;
}
.thumb {
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid rgba(42, 35, 32, 0.08);
  box-shadow: 0 6px 16px -10px rgba(42, 26, 20, 0.5);
  display: flex;
  flex-direction: column;
  animation: rise 0.35s ease both;
}
.thumb--match { border: 1.5px solid var(--ember); box-shadow: 0 8px 20px -10px rgba(215, 64, 43, 0.55); }
.thumb__media {
  position: relative;
  width: 100%;
  /* padding-top square instead of aspect-ratio: immune to the flex/grid
     height-collapse that flattens aspect-ratio tiles in a constrained,
     overflow scroll container (the review grid). */
  padding-top: 100%;
  background: radial-gradient(circle at 50% 40%, #fffdf8, var(--paper-2));
}
.thumb__media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 12px;
}
.thumb__fav {
  position: absolute; top: 6px; right: 6px;
  font-size: 13px; color: var(--gold-2);
}
.thumb__cap {
  padding: 8px 10px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.thumb__loc { font-size: 11px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.thumb__price { font-size: 12.5px; color: var(--ember-2); font-weight: 800; margin-top: 3px; }
.thumb__price:empty { display: none; }
.thumb__badge {
  position: absolute; top: 6px; left: 6px;
  background: var(--ember); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase;
}

.review__empty {
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  color: var(--ink-soft);
  gap: 8px;
  font-size: 15px;
}
.review__back { margin-top: 12px; flex: 0 0 auto; }

/* ===================== BUTTONS / TOAST ===================== */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 22px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.btn--primary { background: var(--ember); color: #fff; box-shadow: 0 8px 20px -8px rgba(215, 64, 43, 0.6); }
.btn--primary:active { transform: translateY(2px); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 22px);
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== ANIMATIONS ===================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); opacity: 1; }
  50% { transform: scale(1.06) rotate(2deg); opacity: 0.92; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .card { transition: transform 0.18s ease, opacity 0.18s ease; }
  .pick__flame { animation: none; }
}

/* larger screens: give the deck a comfortable ceiling */
@media (min-height: 780px) {
  .stack { max-height: 600px; }
}
