/* ============================================================
   DTD Motion + Modern UX layer (scroll.css)
   Scroll progress bar, scroll reveals, scrolly home reel,
   live ticker, bottom tab bar, micro-interactions.
   Pure additive layer on top of the existing design system.
   ============================================================ */

/* ---------- 1. Scroll progress bar ---------- */
#scrollProgress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 0 999px 999px 0;
  box-shadow: 0 0 12px var(--primary-glow);
  pointer-events: none;
}

/* ---------- 2. Scroll reveal system ---------- */
/* Auto-reveal targets (components that animate in on scroll). */
html.motion-ok [data-reveal],
html.motion-ok .page-intro,
html.motion-ok .page-intro-pills,
html.motion-ok .feature-tile,
html.motion-ok .home-visual-card,
html.motion-ok .faq-item,
html.motion-ok .smtp-panel,
html.motion-ok .track-form,
html.motion-ok .trade-panel {
  opacity: 0;
  transform: translateY(26px);
}
html.motion-ok [data-reveal="left"] { transform: translateX(-30px); }
html.motion-ok [data-reveal="right"] { transform: translateX(30px); }
html.motion-ok [data-reveal="zoom"] { transform: scale(0.92); }

html.motion-ok [data-reveal],
html.motion-ok .page-intro,
html.motion-ok .page-intro-pills,
html.motion-ok .feature-tile,
html.motion-ok .home-visual-card,
html.motion-ok .faq-item,
html.motion-ok .smtp-panel,
html.motion-ok .track-form,
html.motion-ok .trade-panel {
  transition: opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) var(--reveal-delay, 0ms),
    transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) var(--reveal-delay, 0ms),
    border-color 0.25s ease, box-shadow 0.25s ease;
}
html.motion-ok .is-revealed,
html.motion-ok [data-reveal]:focus-within {
  opacity: 1;
  transform: none;
}

/* Stagger the visual strip + feature tiles */
html.motion-ok .home-visual-card:nth-child(1) { --reveal-delay: 0ms; }
html.motion-ok .home-visual-card:nth-child(2) { --reveal-delay: 90ms; }
html.motion-ok .home-visual-card:nth-child(3) { --reveal-delay: 180ms; }
html.motion-ok .home-visual-card:nth-child(4) { --reveal-delay: 270ms; }
html.motion-ok .feature-tile:nth-child(1) { --reveal-delay: 0ms; }
html.motion-ok .feature-tile:nth-child(2) { --reveal-delay: 90ms; }
html.motion-ok .feature-tile:nth-child(3) { --reveal-delay: 180ms; }
html.motion-ok .feature-tile:nth-child(4) { --reveal-delay: 270ms; }

@media (prefers-reduced-motion: reduce) {
  html.motion-ok [data-reveal],
  html.motion-ok .page-intro,
  html.motion-ok .page-intro-pills,
  html.motion-ok .feature-tile,
  html.motion-ok .home-visual-card,
  html.motion-ok .faq-item,
  html.motion-ok .smtp-panel,
  html.motion-ok .track-form,
  html.motion-ok .trade-panel,
  html.motion-ok .is-revealed {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ---------- 3. Bottom e-commerce tab bar ---------- */
.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--header-bg, #0a1628) 92%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.18);
}

.bottom-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 0 5px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease, background 0.2s ease;
  text-decoration: none;
}
.bottom-tab .bt-ic {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  color: var(--muted);
  transition: color 0.25s ease, background 0.25s ease,
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}
.bottom-tab .bt-ic svg {
  display: block;
  width: 20px;
  height: 20px;
}
.bottom-tab.is-active { color: var(--primary); }
.bottom-tab.is-active .bt-ic {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 24%, transparent);
  transform: translateY(-1px) scale(1.08);
}
.bottom-tab::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 44px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 2px 8px var(--primary-glow);
  transform: translateX(-50%) scaleX(0);
  transition: transform 0.25s ease;
}
.bottom-tab.is-active::before { transform: translateX(-50%) scaleX(1); }

.bt-badge {
  position: absolute;
  top: 1px;
  right: calc(50% - 27px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #04121a;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--bg) 92%, transparent);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ---------- 4. Live ticker ---------- */
.live-ticker {
  margin: 10px 0 0;
  padding: 10px 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: ticker-move 42s linear infinite;
}
.ticker-half {
  display: flex;
  gap: 52px;
  padding-right: 52px;
}
.ticker-track.is-paused { animation-play-state: paused; }
.ticker-track span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--muted);
  font: 600 0.86rem "JetBrains Mono", monospace;
}
.ticker-track .ticker-live { color: var(--primary); }
.ticker-track .ticker-flash { color: var(--accent); }
.ticker-track .ticker-premium {
  color: transparent;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
}
@keyframes ticker-move {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- 5. Home scrolly reel ---------- */
.home-reel {
  position: relative;
  padding-top: 8px;
  min-height: 170vh;
}
.reel-sticky {
  position: sticky;
  top: 96px;
  height: min(80vh, 580px);
  display: grid;
  grid-template-rows: 1fr auto;
  align-content: center;
  gap: 18px;
  place-items: center;
}
.reel-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.reel-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 22%, transparent);
  transition: width 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.reel-dot.is-active {
  width: 26px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 10px var(--primary-glow);
}
.reel-stage {
  position: relative;
  width: min(840px, 100%);
  height: min(64vh, 470px);
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    radial-gradient(90% 120% at 100% 0%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
    linear-gradient(160deg, var(--surface-strong), var(--panel));
  box-shadow: var(--panel-shadow);
}
.reel-frame {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: center;
  gap: 28px;
  padding: 34px 40px;
  visibility: hidden;
  opacity: 0;
  will-change: transform, opacity;
}
.reel-frame:first-child { visibility: visible; opacity: 1; }
.reel-frame.is-live { visibility: visible; }
.reel-frame img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.35));
}
.reel-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #04121a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 6px 18px var(--primary-glow);
}
.reel-frame h3 {
  margin: 12px 0 8px;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
}
.reel-frame p { color: var(--muted); margin: 0 0 16px; }
.reel-frame .reel-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-weight: 700;
}

/* ---------- 6. Scroll-linked hero / strip motion ---------- */
.hero-section[data-scrolly] .hero-panel {
  transform: scale(calc(1 - var(--scrolly, 0) * 0.08));
  transform-origin: 78% 50%;
  opacity: calc(1 - var(--scrolly, 0) * 0.55);
  filter: blur(calc(var(--scrolly, 0) * 6px));
}
.hero-section[data-scrolly] .hero-copy {
  opacity: calc(1 - var(--scrolly, 0) * 0.45);
}
.home-visual-strip[data-scrolly] {
  transform: translateY(calc(var(--scrolly, 0) * -18px)) translateX(calc(var(--scrolly, 0) * -34px));
}

/* ---------- 7. Glass sheen + card lift polish ---------- */
.glass { position: relative; }

/* Profile store-links grid */
.dtd-profile-links { margin-top: 16px; }
.dtd-profile-links h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dtd-profile-links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.profile-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--surface) 88%, transparent), var(--panel));
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.profile-link-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}
.profile-link-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}
.profile-link-icon svg { width: 20px; height: 20px; }
.profile-link-card strong { display: block; font-size: 0.95rem; line-height: 1.2; }
.profile-link-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}
.profile-link-join {
  margin-left: auto;
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #000));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Profile verified-admin trust banner */
.dtd-profile-trust {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, #10b981 45%, transparent);
  border-radius: 16px;
  background: linear-gradient(150deg, color-mix(in srgb, #10b981 12%, var(--surface)), var(--panel));
}
.dtd-trust-shield {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, #10b981 18%, transparent);
  color: #10b981;
}
.dtd-trust-shield svg { width: 22px; height: 22px; }
.dtd-trust-copy { min-width: 0; }
.dtd-trust-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}
.dtd-trust-title strong { color: var(--text); }
.dtd-trust-title span { color: #10b981; font-weight: 700; }
.dtd-trust-note {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.dtd-trust-cta {
  flex: none;
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: #10b981;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}
.dtd-trust-cta:hover { filter: brightness(1.1); }
@media (max-width: 480px) {
  .dtd-profile-trust { flex-wrap: wrap; }
  .dtd-trust-cta { margin-left: 0; }
}
@media (max-width: 900px) {
  .dtd-profile-links-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .dtd-profile-links-grid { grid-template-columns: 1fr; }
}

/* Side nav SVG icons */
.side-link-icon svg,
.nav-group-label .side-link-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 90% at 12% 0%, rgba(255, 255, 255, 0.09), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.glass:hover::before { opacity: 1; }

.feature-tile[data-reveal] { will-change: opacity, transform; }
.home-visual-card { will-change: transform; }

/* ---------- 8. Page enter polish ---------- */
html.motion-ok .page.is-active { animation: motion-page-in 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
@keyframes motion-page-in {
  from { opacity: 0; transform: translateY(14px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

/* ---------- 9. Responsive: mobile + mini app ---------- */
@media (max-width: 720px) {
  .bottom-tabs { display: grid; }
  .bottom-tab { padding-top: 8px; }
  #telegramBot { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  .shell-footer { position: static; }

  .reel-sticky { top: 72px; height: auto; }
  .reel-stage { height: min(52vh, 420px); }
  .reel-frame {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    text-align: center;
    gap: 8px;
    padding: 22px 22px 26px;
  }
  .reel-frame img { max-height: 200px; }
  .reel-frame h3 { margin-top: 8px; }
  .reel-frame .reel-cta { justify-content: center; }
}

html.tg-mini-app .bottom-tabs { display: grid; }
html.tg-mini-app #telegramBot { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
html.tg-mini-app .shell-footer { position: static; }
html.tg-mini-app body.has-shell { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 720px) {
  body.has-shell { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}

/* Hover micro-interaction on cards everywhere (desktop only) */
@media (hover: hover) and (pointer: fine) {
  .bottom-tab:hover { color: var(--text); }
  .bottom-tab:hover .bt-ic {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    transform: translateY(-1px) scale(1.06);
  }
}

/* ---------- 10. Reduced-motion safety ---------- */
/* If scroll.js is disabled (reduced motion or error), nothing stays hidden. */
@media (prefers-reduced-motion: reduce) {
  .reel-frame {
    visibility: hidden !important;
    opacity: 0 !important;
  }
  .reel-frame:first-child {
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .home-reel { min-height: auto; }
  .reel-sticky { position: static; height: auto; }
  .hero-section[data-scrolly] .hero-panel,
  .hero-section[data-scrolly] .hero-copy,
  .home-visual-strip[data-scrolly] {
    transform: none !important;
    opacity: 1 !important;
    filter: none !important;
  }
  .ticker-track { animation: none !important; width: auto; }
  .ticker-half { flex-wrap: wrap; }
  #scrollProgress { display: none; }
}
