/* ============ DripFeed ============ */

:root {
  --bg: #0a0a0e;
  --panel: #16161d;
  --panel-2: #1f1f28;
  --text: #ffffff;
  --muted: #9a9aa8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --grad: linear-gradient(135deg, #38bdf8, #0ea5e9);
  --on-accent: #062b40; /* dark text/icons on the light-blue accent — white fails contrast */
  --radius: 18px;
  --nav-h: calc(58px + env(safe-area-inset-bottom));
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
/* Prevent double-tap zoom (we use double-tap to like) while keeping pinch-zoom */
button, a { touch-action: manipulation; }
/* pan-y: vertical feed scrolling passes through, but horizontal swipes are ours
   (photo carousel). pinch-zoom stays (inspecting fabric matters!); double-tap
   zoom stays disabled for double-tap-like. */
.card-media { touch-action: pan-y pinch-zoom; }
input {
  font: inherit; color: var(--text);
  background: var(--panel-2);
  border: 1px solid #2c2c38;
  border-radius: 14px;
  padding: 13px 16px;
  width: 100%;
  outline: none;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: #6b6b7a; }

.hidden { display: none !important; }

/* Desktop (R14): the app lives in a centered phone-width column on a styled
   backdrop, so marketing visitors on laptops see an intentional "phone frame"
   rather than a stretched mobile view. */
#account-screen, #onboard-screen, #feed-screen, #saved-screen, #filter-sheet, #bottomnav, #topbar {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 700px) {
  :root { --colw: 440px; }
  #account-screen, #onboard-screen, #feed-screen, #saved-screen, #filter-sheet, #bottomnav, #topbar {
    max-width: var(--colw);
  }
  .screen { background: var(--bg); } /* the column stays opaque over the backdrop */
  body { background: #06060a; }
  /* Phone-frame chrome is APP-ONLY (body.app) — the legal pages (/about etc.)
     are normal full-width documents and must not get the 440px column edges. */
  body.app::before { /* ambient brand glow behind the column */
    content: ""; position: fixed; inset: 0; pointer-events: none;
    background:
      radial-gradient(620px 480px at 50% -10%, rgba(14, 165, 233, .14), transparent 65%),
      radial-gradient(720px 560px at 50% 110%, rgba(56, 189, 248, .10), transparent 65%);
  }
  body.app::after { /* the column's edges */
    content: ""; position: fixed; top: 0; bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: var(--colw); pointer-events: none; z-index: 60;
    border-left: 1px solid rgba(255, 255, 255, .09);
    border-right: 1px solid rgba(255, 255, 255, .09);
    box-shadow: 0 0 110px rgba(0, 0, 0, .8);
  }
}

.screen { position: fixed; inset: 0; overflow-y: auto; }

/* ============ Wordmark ============ */
.wordmark {
  font-family: Didot, "Bodoni 72", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 44px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}
.wordmark.small { font-size: 24px; }

/* ============ Profiles ============ */
.profiles-inner, .onboard-inner {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 40px 28px calc(40px + env(safe-area-inset-bottom));
  text-align: center;
}
.tagline { color: var(--muted); margin-top: -10px; }
.signin-btns { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 44px; margin-top: 8px; }
.disclosure { color: var(--muted); font-size: 12px; max-width: 300px; text-align: center; margin-top: 18px; }
.legal-links { display: flex; gap: 16px; margin-top: 8px; }
.legal-links a { color: var(--muted); font-size: 13px; text-decoration: none; }
@media (hover: hover) { .legal-links a:hover { color: var(--text); } }
.profile-list { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 12px; }
.profile-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid #26262f; border-radius: var(--radius);
  padding: 18px 22px; min-width: 110px;
  transition: transform .15s ease, border-color .15s ease;
}
.pedit {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; background: var(--panel-2);
}
#onboard-taste { display: flex; flex-direction: column; align-items: center; gap: 18px; }
#onboard-stores { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.store-tools { display: flex; gap: 8px; }
.mini-btn { color: var(--muted); font-size: 13px; padding: 6px 14px; border-radius: 999px; background: var(--panel-2); border: 1px solid #2c2c38; }
.mini-btn:active { color: var(--text); }
.saved-card .price-est { font-size: 11.5px; color: var(--muted); }
.profile-card:active { transform: scale(.95); }
.profile-card .avatar { font-size: 40px; }
.profile-card .pname { font-weight: 600; }
.profile-card .pstats { color: var(--muted); font-size: 12px; }

.ghost-btn { color: var(--muted); padding: 12px 18px; border-radius: 14px; }
.ghost-btn:active { color: var(--text); }
.primary-btn {
  background: var(--grad); color: var(--on-accent); font-weight: 700;
  padding: 14px 30px; border-radius: 16px; font-size: 16px;
  box-shadow: 0 6px 22px rgba(56, 189, 248, .35);
  transition: transform .15s ease;
}
.primary-btn:active { transform: scale(.96); }

/* ============ Onboarding ============ */
.onboard-inner { justify-content: flex-start; padding-top: max(60px, env(safe-area-inset-top)); }
.onboard-inner h2 { font-size: 28px; }
.onboard-inner h3 { margin-top: 10px; }
.hint { color: var(--muted); font-size: 13px; margin-top: -12px; }

/* Guest avatar + inline person glyph (R20 — no emoji; matches the nav icon set) */
.avatar-guest {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--panel-2); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.inline-person { vertical-align: -2px; margin-right: 2px; }

/* Initial-letter avatar (R14 — the emoji picker is gone) */
.avatar-initial {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--grad); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px !important; font-weight: 800; text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(56, 189, 248, .3);
}

/* ============ Chips ============ */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel-2); border: 1px solid #2c2c38; border-radius: 999px;
  padding: 8px 15px; font-size: 14px; color: #d6d6e0;
  transition: all .12s ease;
}
.chip.selected {
  background: var(--grad); border-color: transparent; color: var(--on-accent); font-weight: 600;
}
.chip .count { opacity: .55; font-size: 12px; margin-left: 4px; }

/* ============ Top bar ============ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(to bottom, rgba(5,5,10,.75), transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.topbar-profile { font-size: 13px; color: #d6d6e0; background: rgba(20,20,30,.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 5px 11px; border-radius: 999px; }
.topbar-spacer { flex: 1; pointer-events: none; }
.icon-btn {
  position: relative;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(20,20,30,.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ============ Feed ============ */
#feed-screen { overflow: hidden; }
#feed {
  height: 100vh; /* fallback for browsers without dvh */
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  /* pruneFeed compensates scrollTop manually — native scroll anchoring would
     compensate a second time and fling the feed several cards. */
  overflow-anchor: none;
}
#feed::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  height: 100vh; /* fallback for browsers without dvh */
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: var(--panel);
}
.card-media { position: absolute; inset: 0; }
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  user-select: none; -webkit-user-select: none;
}
.card-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,5,.86) 0%, rgba(0,0,5,.38) 20%, rgba(0,0,5,.08) 36%, transparent 46%);
  pointer-events: none;
}

.img-dots {
  position: absolute; top: calc(64px + env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; gap: 5px; justify-content: center; pointer-events: none;
}
.img-dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.35); transition: all .2s; }
.img-dots span.on { background: #fff; width: 16px; }

.card-info {
  position: absolute; left: 16px; right: 86px;
  bottom: calc(var(--nav-h) + 14px);
  display: flex; flex-direction: column; gap: 7px;
  pointer-events: none;
}
.card-info > * { pointer-events: auto; }
.brand-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand-pill {
  font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  background: rgba(255,255,255,.16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 5px 11px; border-radius: 999px;
}
.cat-pill { font-size: 12px; color: #cfcfda; background: rgba(20,20,30,.45); padding: 5px 11px; border-radius: 999px; }
.card-title { font-size: 17px; font-weight: 600; line-height: 1.3; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.price-row { display: flex; align-items: baseline; gap: 9px; }
.price { font-size: 21px; font-weight: 800; }
.price-est { color: #cfcfda; font-size: 13.5px; font-weight: 600; }
.price-compare { color: #b9b9c6; text-decoration: line-through; font-size: 14px; }
.sale-badge {
  background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 800;
  padding: 3px 8px; border-radius: 7px;
}
.sizes-row { color: #cfcfda; font-size: 12.5px; letter-spacing: .4px; }

/* Right action rail */
.rail {
  position: absolute; right: 12px;
  bottom: calc(var(--nav-h) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #fff; font-size: 11px;
}
.rail-btn .rail-icon {
  width: 50px; height: 50px; border-radius: 50%;
  background: rgba(20,20,30,.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  transition: transform .15s ease, background .15s ease;
}
.rail-btn:active .rail-icon { transform: scale(1.18); }
.rail-btn.on .rail-icon { background: var(--grad); color: var(--on-accent); }
.rail-btn svg { width: 26px; height: 26px; }
.rail-btn.buy .rail-icon { background: #fff; color: #0a0a0e; }

/* Double-tap heart burst */
.heart-burst {
  position: absolute; left: 50%; top: 45%;
  width: 110px; height: 110px; margin: -55px 0 0 -55px;
  pointer-events: none;
  animation: heartpop .8s ease forwards;
}
@keyframes heartpop {
  0%   { transform: scale(.3) rotate(-12deg); opacity: 0; }
  25%  { transform: scale(1.15) rotate(4deg); opacity: 1; }
  55%  { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Feed messages */
.feed-message {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg); text-align: center; padding: 30px; color: var(--muted);
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid #2c2c38; border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.swipe-hint {
  position: absolute; bottom: calc(var(--nav-h) + 90px); left: 0; right: 0; z-index: 15;
  display: flex; justify-content: center; pointer-events: none;
}
.swipe-hint div {
  background: rgba(20,20,30,.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px;
  animation: floaty 2s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-7px);} }

/* ============ Saved ============ */
#saved-screen { padding-bottom: var(--nav-h); background: var(--bg); }
.page-header {
  padding: calc(18px + env(safe-area-inset-top)) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.page-header h2 { font-size: 26px; }
.tab-row { display: flex; gap: 6px; background: var(--panel); border-radius: 999px; padding: 4px; }
.tab { padding: 7px 16px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab.active { background: var(--grad); color: var(--on-accent); }

.saved-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 6px 14px 20px;
}
.saved-card {
  background: var(--panel); border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column;
}
.saved-card .img-wrap { position: relative; aspect-ratio: 3/4; }
.saved-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.saved-card .gone-overlay {
  position: absolute; inset: 0; background: rgba(5,5,10,.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 1px; color: #fff;
}
.saved-card .sc-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.saved-card .sc-brand { font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); }
.saved-card .sc-title { font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.saved-card .sc-price { font-weight: 800; font-size: 15px; }
.saved-card .sc-actions { display: flex; gap: 8px; margin-top: 6px; }
.saved-card .sc-buy {
  flex: 1; background: var(--grad); color: var(--on-accent); font-weight: 700; font-size: 13px;
  padding: 9px 0; border-radius: 11px; text-align: center; text-decoration: none;
}
.saved-card .sc-remove {
  width: 38px; border-radius: 11px; background: var(--panel-2); color: var(--muted); font-size: 15px;
}

/* ============ Filter sheet ============ */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--panel); border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 82vh; /* fallback for browsers without dvh */
  max-height: 82dvh; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  animation: sheetup .25s ease;
}
/* Only the middle scrolls — "show me" stays pinned and always visible (R15:
   people scrolled the sheet, never saw the button, thought filters applied). */
.sheet-scroll {
  overflow-y: auto; flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  margin: 0 -6px; padding: 0 6px; /* keep chip shadows unclipped */
}
@keyframes sheetup { from { transform: translateY(60%);} to { transform: translateY(0);} }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: #34343f; margin: 0 auto; }
.sheet-close {
  position: absolute; top: 14px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel-2); color: var(--muted); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.sheet h3 { font-size: 20px; }
.sheet h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions .primary-btn { flex: 1; }

/* ============ Bottom nav ============ */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10,10,16,.72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,.06);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #7d7d8c; font-size: 11px; padding: 3px 18px;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: #fff; }
.nav-emoji { font-size: 21px; line-height: 24px; }

/* Landscape / short viewports: shrink the rail so all buttons stay reachable */
@media (max-height: 540px) {
  .rail { gap: 8px; bottom: 12px; }
  .rail-btn { font-size: 0; gap: 0; } /* hides the text label (a bare text node) */
  .rail-btn .rail-icon { width: 40px; height: 40px; font-size: 19px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .card-info { bottom: 12px; }
}

/* Desktop pointers get hover feedback (R14 — marketing brings laptop visitors) */
@media (hover: hover) {
  .primary-btn:hover { filter: brightness(1.08); }
  .ghost-btn:hover, .mini-btn:hover, .nav-btn:hover { color: var(--text); }
  .chip:not(.selected):hover { border-color: #3f3f4e; color: #fff; }
  .icon-btn:hover, .rail-btn:not(.buy):not(.on):hover .rail-icon { background: rgba(40,40,55,.65); }
  .topbar-profile:hover { background: rgba(40,40,55,.65); }
  .saved-card { transition: transform .15s ease; }
  .saved-card:hover { transform: translateY(-2px); }
}

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 20px); z-index: 40;
  background: #fff; color: #0a0a0e; font-weight: 600; font-size: 14px;
  padding: 11px 20px; border-radius: 999px;
  box-shadow: 0 8px 28px rgba(0,0,0,.4);
  animation: toastin .2s ease;
  max-width: 82vw; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px);} to { opacity: 1; transform: translate(-50%, 0);} }
