/* "See it in action": animated replicas of the Telegram Mini App (templates/partials/demos.html, demo.js).
   Copied from frontend/ (app/src/css + telegram/miniapp.css): Telegram's colours and system font, coral as the
   accent, settings-style groups, the Bientôt pin, the door's green result. Refresh after an app redesign
   (docs/landing.md). Everything is scoped to .demos; the phones follow the site's light / dark theme. */
.demos {
  --d-ground: #efeff4; --d-surface: #fff; --d-text: #000; --d-hint: #8e8e93; --d-sep: rgba(60, 60, 67, .18);
  --d-fill: rgba(118, 118, 128, .12); --d-head: #efeff4; --d-coral: #D85A30; --d-coral-ink: #C24A1F;
  --d-coral-soft: rgba(216, 90, 48, .12); --d-bezel: #161616; --d-dot: #14182E;
  --d-land: #f2efe9; --d-road: #fff; --d-road-edge: #ddd8cf; --d-minor: #e8e3da; --d-water: #b5d6e3; --d-park: #d5e8c6;
  --d-label: #8a8378; --d-ease: cubic-bezier(.32, .72, 0, 1);
  --d-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] .demos {
  --d-ground: #1c1c1d; --d-surface: #2c2c2e; --d-text: #fff; --d-hint: #98989e; --d-sep: rgba(84, 84, 88, .55);
  --d-fill: rgba(118, 118, 128, .24); --d-head: #1c1c1d; --d-coral-ink: #F08A62; --d-coral-soft: rgba(240, 138, 98, .16);
  --d-bezel: #2b2b2b; --d-dot: #fff;
  --d-land: #22252b; --d-road: #3a3e47; --d-road-edge: #2a2d33; --d-minor: #2c3037; --d-water: #1f3d4d; --d-park: #24382a;
  --d-label: #8d929c;
}

/* ---------- layout: three phones side by side; one at a time (swipe) on narrow screens ---------- */
.demo-track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 3vw, 40px); margin-top: 56px; }
.demo { margin: 0; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.demo figcaption { margin-top: 18px; text-align: center; max-width: 30ch; font-size: 16px; color: var(--body); }
.demo-dots { display: none; }

@media (max-width: 960px) {
  .demo-track {
    display: flex; gap: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin: 40px calc(var(--gutter) * -1) 0; padding: 0; overscroll-behavior-x: contain;
  }
  .demo-track::-webkit-scrollbar { display: none; }
  .demo { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; padding: 0 var(--gutter); }
  .demo-dots { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
  .demo-dots button { all: unset; cursor: pointer; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); transition: width .25s, background-color .25s; }
  .demo-dots button[aria-selected="true"] { width: 22px; border-radius: 4px; background: var(--coral); }
}

/* ---------- the phone ---------- */
.phone {
  width: 272px; height: 560px; flex: none; padding: 9px; border-radius: 46px; background: var(--d-bezel);
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.d-screen {
  position: relative; height: 100%; overflow: hidden; border-radius: 37px; background: var(--d-ground);
  color: var(--d-text); font: 400 13px/1.35 var(--d-font); letter-spacing: 0; -webkit-font-smoothing: antialiased;
  isolation: isolate; user-select: none;
}
.d-screen svg { display: inline-block; }
.tg-head {
  position: relative; z-index: 5; height: 54px; padding: 18px 14px 0; display: flex; align-items: center;
  justify-content: space-between; background: var(--d-head); font-size: 13px;
}
.tg-head b { font-weight: 600; font-size: 14px; }
.tg-x, .tg-more { color: #2a8af6; min-width: 56px; }
.tg-more { text-align: right; letter-spacing: 1px; }
.view { position: absolute; inset: 54px 0 0; }

/* the tap: a soft circle, no cursor */
.tap {
  position: absolute; z-index: 30; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(128, 128, 128, .35); pointer-events: none; animation: d-tap .6s ease-out forwards;
}
@keyframes d-tap { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* ---------- shared pieces (the app's rows, chips, Join button) ---------- */
.th { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--d-fill); display: block; }
.th-coding { background: linear-gradient(135deg, hsl(230 60% 62%), hsl(270 50% 40%)); }
.th-coding2 { background: linear-gradient(135deg, hsl(200 60% 55%), hsl(230 55% 38%)); }
.th-music { background: linear-gradient(135deg, hsl(330 60% 64%), hsl(10 55% 45%)); }
.th-startup { background: linear-gradient(135deg, hsl(30 75% 60%), hsl(10 60% 45%)); }
.th-design { background: linear-gradient(135deg, hsl(160 45% 52%), hsl(195 55% 36%)); }
.d-get {
  flex: none; font: 600 12px/26px var(--d-font); height: 26px; padding: 0 12px; border-radius: 999px;
  background: var(--d-coral); color: #fff; font-style: normal;
}

/* ---------- 1. Discover ---------- */
.v-list { overflow: hidden; }
.scroller { padding: 12px 14px 80px; transition: transform .9s var(--d-ease); }
.d-title { margin: 0; font: 700 25px/1.1 var(--d-font); letter-spacing: -.02em; color: var(--d-text); }
.d-sub { margin: 3px 0 0; color: var(--d-hint); font-size: 12.5px; }
.d-chips { display: flex; gap: 6px; margin: 14px -14px 10px; padding: 0 14px; overflow: hidden; white-space: nowrap; }
.d-chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 999px;
  background: var(--d-surface); font-size: 12.5px; font-weight: 500; transition: background-color .2s, color .2s, transform .15s;
}
.d-chip svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.d-lists { position: relative; }
.d-group { background: var(--d-surface); border-radius: 12px; overflow: hidden; transition: opacity .25s; }
.d-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.d-row + .d-row::before { content: ""; position: absolute; top: 0; left: 62px; right: 0; border-top: .5px solid var(--d-sep); }
.d-row > div { flex: 1; min-width: 0; }
.d-row b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-row span { display: block; color: var(--d-hint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.d-skel, .list-coding { position: absolute; inset: 0 0 auto; opacity: 0; }
.d-skel s { display: block; height: 10px; border-radius: 5px; background: var(--d-fill); margin: 4px 0; text-decoration: none; }
.d-skel s.short { width: 55%; }
.d-tabs {
  position: absolute; left: 0; right: 0; bottom: 0; height: 64px; padding: 7px 6px 0; display: flex; justify-content: space-around;
  background: var(--d-surface); box-shadow: 0 -.5px 0 var(--d-sep); transition: transform .35s var(--d-ease);
}
.d-tabs span { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 600; color: var(--d-hint); width: 58px; }
.d-tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.d-tabs .on { color: var(--d-coral); }

.demo.s-scroll .scroller { transform: translateY(-34px); }
.demo.s-filter .chip-coding { background: var(--d-coral); color: #fff; }
.demo.s-loading .list-all { opacity: 0; }
.demo.s-loading .d-skel { opacity: 1; }
.demo.s-coding .list-all, .demo.s-coding .d-skel { opacity: 0; }
.demo.s-coding .list-coding { opacity: 1; }

/* the event page slides in from the right */
.v-event { background: var(--d-ground); transform: translateX(100%); transition: transform .45s var(--d-ease); z-index: 3; }
.demo.s-open .v-event { transform: none; }
.demo.s-open .v-list { transform: translateX(-28%); transition: transform .45s var(--d-ease); }
.ev-cover { height: 132px; position: relative; }
.ev-pill { position: absolute; left: 12px; bottom: 10px; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, .9); color: #1d2a6b; }
.ev-body { padding: 12px 14px; }
.ev-body h4 { margin: 0; font: 700 19px/1.2 var(--d-font); letter-spacing: -.01em; color: var(--d-text); }
.ev-by { margin: 2px 0 12px; color: var(--d-hint); font-size: 12px; }
.ev-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ev-facts > div, .ev-place { background: var(--d-surface); border-radius: 12px; padding: 9px 11px; }
.ev-place { margin-top: 8px; }
.ev-facts small, .ev-place small { display: flex; align-items: center; gap: 4px; color: var(--d-hint); font-size: 11px; }
.ev-facts svg, .ev-place svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ev-facts b, .ev-place b { display: block; margin-top: 3px; font-size: 13px; font-weight: 600; }
.ev-bar {
  position: absolute; left: 0; right: 0; bottom: 62px; padding: 9px 14px; display: flex; justify-content: space-between;
  background: var(--d-surface); box-shadow: 0 -.5px 0 var(--d-sep); font-size: 12px;
}
.ev-bar span { color: var(--d-hint); }
.d-toast {
  position: absolute; left: 12px; right: 12px; top: 10px; padding: 10px 12px; border-radius: 12px; background: #1f9d55; color: #fff;
  font-size: 12px; font-weight: 600; transform: translateY(-140%); transition: transform .4s var(--d-ease);
}
.demo.s-done .d-toast { transform: none; }

/* Telegram's MainButton */
.mainbtn {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; height: 62px; padding: 8px 10px 14px; background: var(--d-head);
  transform: translateY(100%); transition: transform .35s var(--d-ease);
}
.mainbtn > span {
  position: absolute; inset: 8px 10px 14px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 600; font-size: 14.5px; background: var(--d-coral); color: #fff; transition: opacity .2s, background-color .3s;
}
.mainbtn .mb-spin, .mainbtn .mb-done { opacity: 0; }
.mb-spin::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: d-spin .7s linear infinite; }
@keyframes d-spin { to { transform: rotate(360deg); } }
.mainbtn .mb-done { background: var(--d-coral-soft); color: var(--d-coral-ink); }
.mb-done svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.demo.s-open .mainbtn { transform: none; }
.demo.s-busy .mb-join { opacity: 0; }
.demo.s-busy .mb-spin { opacity: 1; }
.demo.s-done .mb-join, .demo.s-done .mb-spin { opacity: 0; }
.demo.s-done .mb-done { opacity: 1; }

/* ---------- 2. Map ---------- */
.v-map { overflow: hidden; background: var(--d-land); }
.m-land { position: absolute; inset: 0; width: 100%; height: 100%; }
.m-bg { fill: var(--d-land); }
.m-park { fill: var(--d-park); }
.m-water { fill: none; stroke: var(--d-water); stroke-width: 9; stroke-linecap: round; }
.m-lake { fill: var(--d-water); }
.m-road { fill: none; stroke: var(--d-road); stroke-width: 6; stroke-linecap: round; paint-order: stroke; }
.m-road * { filter: drop-shadow(0 0 .6px var(--d-road-edge)); }
.m-minor { fill: none; stroke: var(--d-minor); stroke-width: 2.5; stroke-linecap: round; }
.m-label { fill: var(--d-label); font: 600 10px var(--d-font); letter-spacing: .04em; text-transform: uppercase; }
.m-pill {
  position: absolute; z-index: 2; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px;
  border-radius: 999px; background: var(--d-surface); font-size: 12px; font-weight: 600; box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.m-pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.m-pin {
  position: absolute; z-index: 1; left: var(--x); top: var(--y); width: 26px; height: 27px; margin: -27px 0 0 -13px;
  opacity: 0; transform: translateY(-34px); transform-origin: 50% 100%;
}
.m-pin svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .3)); transition: transform .3s var(--d-ease); transform-origin: 50% 100%; }
.m-pin circle { fill: var(--d-dot); }
.m-pin path { fill: none; stroke: var(--d-coral); stroke-width: 16; stroke-linecap: round; stroke-linejoin: round; }
.demo.s-pins .m-pin { animation: d-drop .55s cubic-bezier(.3, 1.4, .5, 1) calc(var(--i) * .22s) forwards; }
@keyframes d-drop { from { opacity: 0; transform: translateY(-34px); } 60% { opacity: 1; } to { opacity: 1; transform: none; } }
.demo.s-pick .m-pick svg { transform: scale(1.45); }
.m-card {
  position: absolute; z-index: 3; left: 10px; right: 10px; bottom: 12px; padding: 11px; border-radius: 16px; background: var(--d-surface);
  display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  transform: translateY(130%); transition: transform .5s var(--d-ease);
}
.m-card > div { flex: 1; min-width: 0; }
.m-card b { display: block; font-size: 13.5px; font-weight: 600; }
.m-card span { display: block; color: var(--d-hint); font-size: 11.5px; margin-top: 1px; }
.m-card .th { width: 48px; height: 48px; border-radius: 12px; }
.demo.s-pick .m-card { transform: none; }

/* ---------- 3. Check-in (the door: dark by nature, like the app's camera page) ---------- */
.dark-screen { background: #0b0b0c; color: #fff; }
.dark-screen .tg-head { background: #0b0b0c; color: #fff; }
.v-door { display: flex; flex-direction: column; align-items: center; }
.s-top { width: 100%; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; }
.s-top b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-count { flex: none; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, .14); font-weight: 600; }
.s-count em { font-style: normal; }
.s-count .c-after, .demo.s-ok .s-count .c-before { display: none; }
.demo.s-ok .s-count .c-after { display: inline; }
.s-frame { position: relative; width: 188px; height: 188px; margin-top: 56px; overflow: hidden; border-radius: 22px; }
.s-corners { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; }
.s-ticket {
  position: absolute; inset: 24px; border-radius: 12px; background: #fff; padding: 12px;
  transform: translateY(170%) rotate(-6deg); transition: transform .8s var(--d-ease);
}
.s-ticket svg { width: 100%; height: 100%; display: block; }
.demo.s-qr .s-ticket { transform: none; }
.s-line { position: absolute; z-index: 3; left: 14px; right: 14px; top: 16px; height: 2px; border-radius: 1px; background: var(--d-coral); box-shadow: 0 0 10px var(--d-coral); opacity: 0; }
.demo.s-scan .s-line { animation: d-scan .9s ease-in-out forwards; }
@keyframes d-scan { 0% { opacity: 0; transform: none; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(154px); } }
.s-hint { margin: 22px 0 0; font-size: 12px; color: rgba(255, 255, 255, .7); }
.s-flash {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 20px; text-align: center; background: #1f9d55; color: #fff; opacity: 0; transform: scale(1.03);
  transition: opacity .2s ease-out, transform .2s ease-out; pointer-events: none;
}
.s-check { width: 104px; height: 104px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: grid; place-items: center; margin-bottom: 6px; transform: scale(.6); transition: transform .45s cubic-bezier(.3, 1.5, .5, 1) .05s; }
.s-check svg { width: 62px; height: 62px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.s-flash small { font-size: 15px; font-weight: 700; opacity: .95; }
.s-flash b { font: 800 25px/1.15 var(--d-font); letter-spacing: -.01em; }
.s-flash span { font-size: 14px; font-weight: 600; opacity: .95; }
.s-flash em { font-style: normal; font-size: 12px; opacity: .8; }
.demo.s-ok .s-flash { opacity: 1; transform: none; }
.demo.s-ok .s-check { transform: none; }

/* no animations when the visitor asked for less motion: demo.js shows one still frame */
@media (prefers-reduced-motion: reduce) {
  .demos *, .demos *::before, .demos *::after { animation: none !important; transition: none !important; }
  .demo.s-pins .m-pin { opacity: 1; transform: none; }
}
