/**
 * Forge — mobile discovery experience.
 * Design tokens follow the Swimbait Designer color/type system
 * (see design_handoff_forge_mobile/colors_and_type.css).
 */
:root {
  /* Surfaces */
  --bg:           #0e0e0d;
  --bg-marketing: #0a0a0a;
  --sf:           #181816;
  --sf2:          #222220;
  --bd:           #2a2a26;
  --bd-hair:      #1a1a18;
  --bd-stage:     #1f1f1c;

  /* Forge stage (3D viewport) radial gradient. The bait canvas is
     alpha:true so this gradient IS the viewport backdrop. Kept
     separate from the surface tokens so lightening the stage doesn't
     touch panels/cards. Center is a warm mid-grey so the bait reads
     with contrast; edge stays near-black for the vignette. */
  --stage-glow:   #38372f;
  --stage-edge:   #131311;

  /* Text */
  --tx:           #e8e4d9;
  --mu:           #8a8778;
  --tx-dim:       #555558;

  /* Accents */
  --gold:         #c8a84e;
  --gold-bright:  #e0c060;
  --gold-dim:     #8a7535;
  --ac2:          #5a9a6b;     /* live dot, ventral curves */

  /* Saved-pill rgba helpers */
  --gold-wash:    rgba(200, 168, 78, 0.10);
  --gold-line:    rgba(200, 168, 78, 0.32);
  --gold-glow:    rgba(200, 168, 78, 0.25);

  /* Type */
  --mono:         'JetBrains Mono', 'DM Mono', ui-monospace, monospace;
  --serif:        'Instrument Serif', Georgia, serif;

  /* The bait's -12° tilt is applied scene-side (camera roll in
     senko-render.js), not via CSS canvas rotation. Rotating the canvas
     element rotated its rectangular clear-color rect on top of the
     gradient, and put the CSS drop-shadow around the canvas instead of
     around the bait silhouette. */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-marketing);
  color: var(--tx);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Topbar ────────────────────────────────────────────────────────── */
.fg-topbar {
  flex-shrink: 0;
  padding: calc(10px + env(safe-area-inset-top)) 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--bd-hair);
  z-index: 5;
}

.fg-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--tx-dim);
  font-weight: 500;
}
.fg-breadcrumb a {
  color: var(--mu);
  text-decoration: none;
  transition: color .2s ease;
  pointer-events: auto;
}
.fg-breadcrumb a:hover { color: var(--gold); }
.fg-breadcrumb .arrow { color: var(--tx-dim); }
.fg-breadcrumb .current {
  color: var(--gold);
  font-weight: 600;
}

.fg-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fg-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--tx);
  text-transform: uppercase;
}
.fg-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ac2);
  animation: fg-pulse 1.4s infinite;
}
@keyframes fg-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.fg-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.fg-saved-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 12px;
  background: var(--gold-wash);
  border: 1px solid var(--gold-line);
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--gold);
  font-weight: 500;
  text-decoration: none;
  pointer-events: auto;
  transition: background .2s ease, border-color .2s ease;
}
.fg-saved-pill:hover {
  background: rgba(200, 168, 78, 0.16);
  border-color: rgba(200, 168, 78, 0.50);
}
.fg-saved-pill .heart { font-size: 11px; }
.fg-saved-pill .num   { font-variant-numeric: tabular-nums; }
/* Hide the pill until count > 0 so signed-out / empty-collection users
   don't see a "0" floating in the topbar. */
.fg-saved-pill[data-count="0"] { display: none; }

.fg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--bd);
  color: var(--mu);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  pointer-events: auto;
  transition: color .15s ease, border-color .15s ease;
  flex-shrink: 0;
}
.fg-avatar:hover { color: var(--gold); border-color: var(--gold-line); }
.fg-avatar.authed { color: var(--gold); border-color: var(--gold-line); }
.fg-avatar.authed svg { display: none; }
.fg-avatar.authed::before { content: attr(data-initial); }

.fg-avatar-menu {
  position: absolute;
  top: 38px;
  right: 0;
  min-width: 140px;
  background: rgba(14, 14, 13, 0.96);
  border: 1px solid var(--bd);
  border-radius: 4px;
  overflow: hidden;
  display: none;
  z-index: 50;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}
.fg-avatar-menu.open { display: block; }
.fg-avatar-menu a,
.fg-avatar-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--mu);
  background: none;
  border: none;
  text-decoration: none;
  cursor: pointer;
}
.fg-avatar-menu a:hover,
.fg-avatar-menu button:hover { color: var(--gold); background: var(--gold-wash); }

/* ── Stage ─────────────────────────────────────────────────────────── */
.fg-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  /* Wider, brighter glow than before — the previous gradient faded to
     near-black by 80% which read as a flat dark void on mobile. The
     bright zone now reaches ~92% so most of the viewport is a usable
     mid-tone and only the corners vignette. */
  background: radial-gradient(ellipse 88% 78% at 50% 46%, var(--stage-glow) 0%, var(--stage-edge) 92%);
  display: flex;
  flex-direction: column;
}

.fg-stage-meta {
  position: absolute;
  top: 14px; left: 18px; right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 3;
  pointer-events: none;
}
.fg-seed-tag,
.fg-counter {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--tx-dim);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}
.fg-seed-tag .num { color: var(--gold); font-weight: 600; }
.fg-counter      { text-align: right; transition: transform .25s cubic-bezier(0.22, 0.61, 0.36, 1); }
.fg-counter .pos { color: var(--tx); font-weight: 500; }
.fg-counter.pulse { animation: fg-counter-pulse .55s ease-out; }
@keyframes fg-counter-pulse {
  0%   { color: var(--tx-dim); transform: scale(1); }
  20%  { color: var(--gold);   transform: scale(1.06); }
  100% { color: var(--tx-dim); transform: scale(1); }
}
.fg-counter.pulse .pos {
  animation: fg-counter-pulse-pos .55s ease-out;
}
@keyframes fg-counter-pulse-pos {
  0%   { color: var(--tx); }
  20%  { color: var(--gold-bright); }
  100% { color: var(--tx); }
}

/* ── Bait frame (the worm hero) ───────────────────────────────────── */
.fg-bait-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 0 24px;
}

/* Soft elliptical plinth shadow under the worm — pure-CSS atmospheric
   anchor that grounds the floating bait. */
.fg-plinth {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 8px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.6), transparent 70%);
  border-radius: 50%;
  filter: blur(4px);
  pointer-events: none;
  z-index: 1;
}

/* The bait canvas + transient snapshot images. Canvas is upright; the
   bait's -12° tilt is rendered scene-side via camera roll (so the
   alpha-true canvas's drop-shadow follows the actual bait silhouette,
   not a tilted rectangle). */
.fg-bait-frame canvas,
.fg-bait-frame .fg-snap {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  max-width: 100%;
  max-height: 100%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.8));
  will-change: transform, opacity;
  z-index: 2;
}
.fg-snap {
  pointer-events: none;
  image-rendering: auto;
}

/* Subtle dot grid behind the worm — translates at 30% of the bait's
   travel during drag/slide so the worm reads as floating in front. */
.fg-grid {
  position: absolute;
  inset: -10% -10% -10% -10%;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(200, 168, 78, 0.10) 1px, transparent 1.4px);
  background-size: 26px 26px;
  background-position: center;
  will-change: transform;
  z-index: 0;
}

/* Loading skeleton on first paint */
.fg-skeleton {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 28%;
  border-radius: 50%;
  background: linear-gradient(90deg,
    rgba(200, 168, 78, 0.06) 0%,
    rgba(200, 168, 78, 0.16) 50%,
    rgba(200, 168, 78, 0.06) 100%);
  background-size: 200% 100%;
  animation: fg-skel 1.6s infinite;
  filter: blur(20px);
  z-index: 1;
}
@keyframes fg-skel {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

/* Resistance bounce when swiping past history limit */
.fg-bait-frame.resist canvas { animation: fg-resist .35s ease-out; }
@keyframes fg-resist {
  0%   { transform: translate(-50%, -50%); }
  40%  { transform: translate(-50%, calc(-50% + 28px)); }
  100% { transform: translate(-50%, -50%); }
}

/* Swipe hint with bob animation */
.fg-swipe-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--tx-dim);
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity .8s ease;
  z-index: 3;
}
.fg-swipe-hint.show { opacity: 1; animation: fg-bob 2.4s ease-in-out infinite; }
.fg-swipe-hint .arrow { font-size: 10px; }
@keyframes fg-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, -4px); }
}

/* ── Info panel ────────────────────────────────────────────────────── */
.fg-info-panel {
  flex-shrink: 0;
  padding: 18px 22px 14px;
  background: var(--bg);
  border-top: 1px solid var(--bd-stage);
  z-index: 4;
}

.fg-bait-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.005em;
  color: var(--tx);
  text-align: center;
  margin-bottom: 10px;
  transition: color .35s ease;
}
.fg-bait-name em {
  font-style: italic;
  color: var(--gold);
}

.fg-specs-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--mu);
  font-weight: 400;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.fg-specs-row .spec {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.fg-specs-row .v {
  color: var(--tx);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.fg-specs-row .swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  border: 1px solid #4a5060;
  margin-right: 4px;
}
.fg-specs-row .sep {
  color: var(--tx-dim);
  opacity: 0.5;
}

.fg-action-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: stretch;
}

.fg-heart-btn,
.fg-ghost-btn {
  height: 44px;
  border-radius: 22px;
  background: transparent;
  border: 1.5px solid var(--bd);
  color: var(--mu);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--mono);
}
.fg-heart-btn:active,
.fg-ghost-btn:active,
.fg-primary-cta:active { transform: scale(0.95); }

.fg-heart-btn.saved {
  background: rgba(200, 168, 78, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}
.fg-heart-btn.busy { opacity: 0.5; pointer-events: none; }
.fg-heart-btn.pulse { animation: fg-heart-pulse .42s cubic-bezier(0.22, 0.61, 0.36, 1); }
@keyframes fg-heart-pulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.fg-primary-cta {
  height: 44px;
  border-radius: 22px;
  background: var(--gold);
  color: #0a0a0a;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 16px var(--gold-glow);
  transition: background .15s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.fg-primary-cta:hover { background: var(--gold-bright); }
.fg-primary-cta .arrow { font-size: 14px; }
.fg-primary-cta .hint {
  font-size: 9px;
  letter-spacing: 1.2px;
  opacity: 0.7;
  text-transform: none;
  font-weight: 400;
}
.fg-primary-cta.busy { opacity: 0.5; pointer-events: none; }
.fg-primary-cta:disabled,
.fg-primary-cta[aria-disabled="true"] {
  background: var(--sf2);
  color: var(--mu);
  box-shadow: none;
  cursor: not-allowed;
}
.fg-primary-cta:disabled:hover,
.fg-primary-cta[aria-disabled="true"]:hover { background: var(--sf2); }
.fg-primary-cta:disabled:active,
.fg-primary-cta[aria-disabled="true"]:active { transform: none; }

.fg-ghost-btn { font-size: 14px; }

/* ── Attribution footer ────────────────────────────────────────────── */
.fg-attribution {
  flex-shrink: 0;
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--tx-dim);
  background: var(--bg-marketing);
  border-top: 1px solid var(--bd-hair);
}
.fg-link {
  color: var(--gold);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .15s ease;
}
.fg-link:hover { color: var(--gold-bright); }
.fg-link .arrow { font-size: 10px; }

/* ── Tuning panel (only rendered with ?tune=1) ─────────────────────── */
.fg-tune {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(14, 14, 13, 0.94);
  border-top: 1px solid var(--bd);
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  z-index: 50;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mu);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  max-height: 50vh;
  overflow-y: auto;
}
.fg-tune.collapsed { transform: translateY(calc(100% - 32px)); }
.fg-tune-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold); cursor: pointer; user-select: none;
  padding: 2px 0 6px;
}
.fg-tune-row {
  display: grid; grid-template-columns: 80px 1fr 56px;
  align-items: center; gap: 10px; padding: 5px 0;
}
.fg-tune-row label { color: var(--mu); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.fg-tune-row input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px; background: transparent;
}
.fg-tune-row input[type=range]::-webkit-slider-runnable-track {
  height: 2px; background: var(--bd); border-radius: 2px;
}
.fg-tune-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--gold); margin-top: -7px;
  box-shadow: 0 0 0 4px rgba(200, 168, 78, 0.18);
  border: none;
}
.fg-tune-row .v {
  text-align: right; color: var(--tx); font-variant-numeric: tabular-nums;
  font-size: 10px;
}
.fg-tune-actions { display: flex; gap: 8px; margin-top: 10px; }
.fg-tune-btn {
  flex: 1; padding: 8px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 1.5px; text-transform: uppercase;
  background: transparent; color: var(--gold);
  border: 1px solid var(--gold-line); border-radius: 3px;
  cursor: pointer;
}
.fg-tune-btn:hover { background: var(--gold-wash); }
.fg-tune-btn.ghost { color: var(--mu); border-color: var(--bd); }
.fg-tune-status { font-size: 10px; color: var(--ac2); padding: 4px 0 0; min-height: 14px; }
.fg-tune-badge {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 60; font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold); background: rgba(200, 168, 78, 0.15);
  border: 1px solid var(--gold-line); padding: 4px 10px; border-radius: 12px;
  pointer-events: none;
}
