/*
  FROMOLDED · Telegram Mini App demo kit
  Desktop: the app sits in a phone frame next to a short description.
  Mobile: the app fills the screen. Inside Telegram (html.in-telegram) the fake chrome is hidden
  and Telegram's own header, theme and MainButton are used.
*/

:root {
  --app-bg: #0f1218;
  --app-bg-2: #161a22;
  --app-card: #1b2029;
  --app-text: #f5f7fa;
  --app-hint: #8b93a1;
  --app-line: rgba(255, 255, 255, 0.08);
  --app-accent: #2aabee;
  --app-accent-text: #ffffff;
  --app-danger: #ff5a5f;
  --app-success: #34c759;
  --hdr-bg: var(--app-bg);
  --stage-bg: #0a0c10;
  --stage-text: #f5f7fa;
  --stage-hint: #9aa3b2;
  --radius: 16px;
  --font: -apple-system, "SF Pro Text", "Inter", Roboto, "Segoe UI", system-ui, sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--stage-bg);
  color: var(--app-text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

/* ——— Stage (desktop presentation) ——— */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: auto minmax(0, 440px);
  align-items: center;
  justify-content: center;
  gap: 64px;
  padding: 24px;
}

.info {
  color: var(--stage-text);
}

.info__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--stage-hint);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.info__kicker svg {
  width: 16px;
  height: 16px;
  fill: #2aabee;
}

.info h1 {
  margin: 18px 0 12px;
  font-size: 44px;
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.info__lead {
  color: var(--stage-hint);
  font-size: 17px;
  line-height: 1.55;
}

.info__features {
  display: grid;
  gap: 12px;
  margin-top: 26px;
  list-style: none;
}

.info__features li {
  display: flex;
  gap: 12px;
  font-size: 15px;
  line-height: 1.45;
}

.info__features li::before {
  content: "";
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
      center / 14px no-repeat,
    var(--app-accent);
}

.info__features b {
  font-weight: 700;
}

.info__try {
  margin-top: 26px;
  padding: 14px 16px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  color: var(--stage-hint);
  font-size: 14px;
}

.info__try b {
  color: var(--stage-text);
}

.info__foot {
  margin-top: 26px;
  color: var(--stage-hint);
  font-size: 12px;
  opacity: 0.8;
}

/* ——— Phone frame ——— */
.phone {
  position: relative;
  width: 390px;
  height: min(844px, calc(100vh - 48px));
  height: min(844px, calc(100dvh - 48px));
  min-height: 640px;
  padding: 10px;
  border-radius: 54px;
  background: #0b0b0d;
  box-shadow:
    0 0 0 2px #2b2c31,
    0 0 0 6px #121316,
    0 50px 100px rgba(0, 0, 0, 0.5);
}

.phone::before {
  content: "";
  position: absolute;
  z-index: 30;
  top: 21px;
  left: 50%;
  width: 112px;
  height: 32px;
  border-radius: 20px;
  background: #000;
  transform: translateX(-50%);
}

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 44px;
  background: var(--app-bg);
  overflow: hidden;
  isolation: isolate;
}

.statusbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 6px 30px 0 34px;
  background: var(--hdr-bg);
  color: var(--app-text);
  font-size: 15px;
  font-weight: 600;
}

.statusbar__icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.statusbar__icons svg {
  height: 12px;
  fill: currentColor;
}

/* ——— Telegram Mini App header ——— */
.tg-header {
  position: relative;
  z-index: 10;
  flex: none;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  height: 52px;
  padding: 0 12px;
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--app-line);
}

.tg-header__close {
  justify-self: start;
  color: var(--app-accent);
  font-size: 16px;
}

.tg-header__title {
  text-align: center;
  line-height: 1.2;
}

.tg-header__title b {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.tg-header__title span {
  color: var(--app-hint);
  font-size: 12px;
}

.tg-header__more {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--app-accent);
  color: var(--app-accent);
}

.tg-header__more svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ——— App area ——— */
.app {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.app::-webkit-scrollbar {
  display: none;
}

/* Telegram-style MainButton (used outside Telegram) */
.mainbtn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  margin: 8px 12px 14px;
  border-radius: 12px;
  background: var(--app-accent);
  color: var(--app-accent-text);
  font-size: 16px;
  font-weight: 600;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.mainbtn:active {
  transform: scale(0.98);
}

.mainbtn[hidden] {
  display: none;
}

.mainbtn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.mainbtn.is-loading::after {
  content: "";
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: kit-spin 0.7s linear infinite;
}

@keyframes kit-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ——— Toast ——— */
.toast {
  position: absolute;
  z-index: 60;
  left: 12px;
  right: 12px;
  bottom: 84px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(30, 33, 40, 0.96);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.is-visible {
  transform: none;
  opacity: 1;
}

/* ——— Bottom sheet ——— */
.sheet {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.25s ease;
}

.sheet.is-open {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.sheet__panel {
  max-height: 88%;
  overflow-y: auto;
  padding: 10px 16px 20px;
  border-radius: 20px 20px 0 0;
  background: var(--app-bg-2);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  scrollbar-width: none;
}

.sheet.is-open .sheet__panel {
  transform: none;
}

.sheet__grip {
  width: 38px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 3px;
  background: var(--app-line);
  background: rgba(127, 127, 127, 0.35);
}

/* Demo credit inside the app (visible on mobile) */
.demo-note {
  padding: 18px 16px 24px;
  color: var(--app-hint);
  font-size: 12px;
  text-align: center;
}

.demo-note a {
  color: var(--app-hint);
}

/* ——— Mobile: the app is the page ——— */
@media (max-width: 880px) {
  .stage {
    display: block;
    padding: 0;
  }

  .info {
    display: none;
  }

  .phone {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  .phone::before,
  .statusbar {
    display: none;
  }

  .screen {
    border-radius: 0;
  }

  .mainbtn {
    margin-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ——— Inside Telegram: Telegram draws the header and the MainButton ——— */
.in-telegram .stage {
  display: block;
  padding: 0;
}

.in-telegram .info,
.in-telegram .statusbar,
.in-telegram .tg-header,
.in-telegram .phone::before {
  display: none;
}

.in-telegram .phone {
  width: 100%;
  height: var(--tg-viewport-stable-height, 100vh);
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.in-telegram .screen {
  border-radius: 0;
}

.in-telegram .mainbtn.is-native {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
