/* Tellygram landing page — palette lifted from the app's own theme
   (ui/theme/Theme.kt, JetStream dark scheme) so the site and the app match. */
:root {
  --bg:        #1A1C1E;
  --panel:     #121316;
  --panel-2:   #16181B;
  --on:        #C7C6CA;
  --on-variant:#C4C6CF;
  --outline:   #8E9099;
  --accent:    #A8C8FF;
  --accent-ink:#003062;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--on);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: #E3E2E6; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.05rem; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  max-width: 1080px; margin: 0 auto; padding: 28px 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: #E3E2E6; font-weight: 600; letter-spacing: .01em; font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.site-header nav { display: flex; gap: 22px; font-size: .95rem; }
.site-header nav a { color: var(--on-variant); }
.site-header nav a:hover { color: var(--accent); }

/* ---------- hero ---------- */
.hero {
  max-width: 1080px; margin: 0 auto; padding: 32px 24px 24px;
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center;
}
.lede { font-size: 1.1rem; color: var(--on-variant); margin: 0 0 12px; }
.lede-cn { font-size: 1rem; color: var(--on-variant); opacity: .85; margin: 0 0 26px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 8px;
  font-weight: 600; font-size: .95rem; border: 1px solid transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { border-color: var(--outline); color: var(--on); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.meta { margin: 18px 0 0; font-size: .85rem; color: var(--outline); }

/* decorative TV panel — abstract, deliberately not a mock screenshot */
.hero-art { display: flex; justify-content: center; }
.tv {
  width: 100%; max-width: 420px; padding: 14px; border-radius: 14px;
  background: linear-gradient(160deg, #22262B, #101214);
  box-shadow: 0 24px 60px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.05);
}
.tv-screen {
  position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
  background: radial-gradient(120% 120% at 20% 0%, #1E2A44 0%, #0E1013 60%);
  display: grid; place-items: center;
}
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 78%; opacity: .5; }
.grid span { display: block; aspect-ratio: 16 / 10; border-radius: 4px; background: rgba(255,255,255,.10); }
.play {
  position: absolute; width: 54px; height: 54px; border-radius: 50%;
  background: rgba(168,200,255,.92);
  clip-path: none;
}
.play::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent-ink);
  clip-path: polygon(38% 30%, 38% 70%, 70% 50%);
}
.tv-stand { width: 34%; height: 8px; margin: 12px auto 0; border-radius: 3px; background: #2A2E33; }

/* ---------- sections ---------- */
.section { max-width: 1080px; margin: 0 auto; padding: 56px 24px; border-top: 1px solid rgba(255,255,255,.06); }
.section-lede { color: var(--on-variant); max-width: 62ch; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.card {
  background: var(--panel); border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 20px;
}
.card p { margin: 0; color: var(--on-variant); font-size: .94rem; }

/* ---------- downloads ---------- */
.downloads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.dl {
  display: flex; flex-direction: column; gap: 4px; padding: 16px;
  background: var(--panel); border: 1px solid rgba(255,255,255,.08); border-radius: 10px;
  color: var(--on);
}
.dl:hover { border-color: var(--accent); text-decoration: none; }
.dl-abi { font-weight: 600; color: #E3E2E6; }
.dl-size { font-size: .82rem; color: var(--outline); }
.dl-tag {
  align-self: flex-start; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  background: rgba(168,200,255,.16); color: var(--accent); border-radius: 4px; padding: 2px 6px;
}
.dl-recommended { border-color: rgba(168,200,255,.45); }

.steps { color: var(--on-variant); padding-left: 20px; }
.steps li { margin: 6px 0; }
.note { font-size: .88rem; color: var(--outline); max-width: 70ch; }

/* ---------- faq ---------- */
.faq { margin: 24px 0 0; }
.faq dt { font-weight: 600; color: #E3E2E6; margin-top: 20px; }
.faq dd { margin: 6px 0 0; color: var(--on-variant); max-width: 72ch; }

.cn p { color: var(--on-variant); max-width: 72ch; }

/* ---------- footer ---------- */
.site-footer {
  max-width: 1080px; margin: 0 auto; padding: 32px 24px 56px;
  border-top: 1px solid rgba(255,255,255,.06); color: var(--outline); font-size: .85rem;
}
.footer-meta { display: flex; gap: 16px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .downloads { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .cards, .downloads { grid-template-columns: 1fr; }
  .site-header nav { gap: 14px; font-size: .88rem; }
}

/* ---------- personal APK page (form + progress) ---------- */
.page { max-width: 860px; margin: 0 auto; padding: 24px 24px 64px; }
.page-title { margin: 16px 0 8px; }

.box {
  background: var(--panel); border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 22px 24px; margin: 22px 0;
}
.box h2 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin-bottom: 12px; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 50%; background: rgba(168,200,255,.16); color: var(--accent);
  font-size: .85rem; font-weight: 600;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; color: #E3E2E6; font-size: .92rem; }
.field input, .field select {
  background: #0E1013; color: var(--on); border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px; padding: 11px 13px; font-size: .95rem; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: #6C7076; }
.hint { font-size: .8rem; color: var(--outline); }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.actions .btn[disabled] { opacity: .55; cursor: default; }

.progress { margin-top: 8px; }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.09); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.status-text { margin: 14px 0 4px; font-weight: 600; color: #E3E2E6; }
.hashline { font-size: .78rem; color: var(--outline); word-break: break-all; margin-top: 10px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em; background: rgba(255,255,255,.06);
  padding: 1px 5px; border-radius: 4px; color: var(--on-variant);
}
.en { color: var(--on-variant); font-size: .95rem; }
.steps code { font-size: .85em; }

/* ---------- bilingual content + language switch ---------- */
/* Only one language is in flow at a time. `revert` hands the property back to
   the user-agent origin, so paragraphs stay block, spans stay inline and list
   items stay list items — which is why [data-lang] must not sit on an element
   whose display an author rule overrides (a .btn, a flex row, ...). */
/* Only the INACTIVE language is hidden. The active one is never touched, so
   no `revert` is involved (an engine that drops `revert` used to leave both
   languages on screen at once, which is exactly what looked "中英夹杂"). */
html[lang="en"] [data-lang="zh"],
html[lang="zh"] [data-lang="en"] { display: none; }

.lang-switch {
  background: none; border: 1px solid var(--outline); color: var(--on);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .85rem;
  cursor: pointer; line-height: 1.4;
}
.lang-switch:hover { border-color: var(--accent); color: var(--accent); }
.site-header nav { align-items: center; }

/* ---------- icons (inline SVG sprite, no icon font, no CDN) ---------- */
.sprite { display: none; }
.ico {
  width: 1em; height: 1em; flex: none;
  vertical-align: -0.125em;
  fill: currentColor;
}
.ico-stroke { fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.btn .ico { width: 1.05em; height: 1.05em; margin-right: .5em; vertical-align: -0.15em; }
.lang-switch .ico { margin-right: .35em; }
.card h3 .ico { width: 1.15em; height: 1.15em; margin-right: .5em; color: var(--accent); vertical-align: -0.2em; }
.nav-icon { width: 20px; height: 20px; color: var(--on-variant); }
.nav-icon:hover { color: var(--accent); }
h2 .ico { color: var(--accent); margin-right: .5em; }
.site-header nav a.with-icon { display: inline-flex; align-items: center; }

/* ---------- mobile navigation (burger + panel) ---------- */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  background: none; border: 1px solid var(--outline); color: var(--on);
  border-radius: 8px; padding: 6px 9px; line-height: 1; cursor: pointer;
}
.nav-toggle .ico { width: 20px; height: 20px; }
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

@media (max-width: 720px) {
  .site-header { position: relative; padding: 20px 16px; }
  .nav-toggle { display: inline-flex; }
  .site-header .lang-switch { margin-left: auto; }

  /* The links become a panel under the header instead of an overflowing row. */
  html.nav-js #site-nav {
    display: none;
    position: absolute; top: calc(100% - 6px); left: 16px; right: 16px;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: #1F2226; border: 1px solid rgba(255,255,255,.16);
    border-radius: 12px; padding: 8px;
    box-shadow: 0 18px 44px rgba(0,0,0,.6);
    z-index: 60;
  }
  html.nav-js #site-nav.open { display: flex; }
  html.nav-js #site-nav a {
    padding: 12px 14px; border-radius: 8px; font-size: 1rem;
  }
  html.nav-js #site-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
  html.nav-js #site-nav a.with-icon { justify-content: flex-start; }
}

/* header layout after splitting the language button out of <nav>:
   brand on the left, links + language grouped on the right */
.site-header { justify-content: flex-start; }
.site-header > nav { margin-left: auto; }

/* ---------- mobile menu polish (scrim + stronger separation) ---------- */
@media (max-width: 720px) {
  /* header sits above the scrim so brand / language / burger stay crisp */
  .site-header { z-index: 70; }
  html.nav-js #site-nav {
    box-shadow: 0 24px 60px rgba(0,0,0,.75), 0 0 0 1px rgba(255,255,255,.06);
  }
}
.nav-scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .62);
  z-index: 50;
}
.nav-scrim[hidden] { display: none; }
@media (min-width: 721px) { .nav-scrim { display: none; } }

/* ---------- sticky header ---------- */
/* The page is long and the header carries the language switch and the way to
   /personal/, so it sticks. Two things it needs: an opaque-ish surface (it used
   to be transparent on the page background) and an anchor offset, otherwise
   #features / #download / #faq land under the bar. */
html { scroll-padding-top: 88px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 70;
  background: rgba(26, 28, 30, .90);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: padding .18s ease, background .18s ease, border-color .18s ease;
}
.site-header.scrolled {
  padding-top: 14px; padding-bottom: 14px;
  background: rgba(26, 28, 30, .97);
  border-bottom-color: rgba(255, 255, 255, .08);
}

@media (max-width: 720px) {
  /* re-assert sticky here: the mobile block above sets position: relative */
  html { scroll-padding-top: 78px; }
  .site-header { position: sticky; padding-top: 14px; padding-bottom: 14px; }
}

/* ---------- mobile menu: motion + depth ---------- */
@media (max-width: 720px) {
  .nav-toggle { transition: transform .12s ease, border-color .15s ease, color .15s ease; }
  .nav-toggle:active { transform: scale(.93); }

  /* The panel stays in the layout so it can animate; `visibility` keeps it out
     of the accessibility tree and `pointer-events` keeps it out of the way, so
     nothing invisible is clickable. */
  html.nav-js #site-nav {
    display: flex;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(-10px) scale(.985);
    transform-origin: top center;
    transition: opacity .18s ease, transform .24s cubic-bezier(.2,.9,.25,1),
                visibility 0s linear .24s;
    background: linear-gradient(180deg, #23272C, #1E2126);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 2px 2px 14px 14px;   /* square where it meets the header */
    padding: 10px;
    /* two layers: a wide soft drop, plus a faint ring that reads on dark UI */
    box-shadow: 0 24px 60px rgba(0,0,0,.85), 0 2px 8px rgba(0,0,0,.55),
                0 0 0 1px rgba(255,255,255,.05);
  }
  html.nav-js #site-nav.open {
    opacity: 1; visibility: visible; pointer-events: auto;
    transform: translateY(0) scale(1);
    transition: opacity .16s ease, transform .26s cubic-bezier(.2,.9,.25,1), visibility 0s;
  }

  /* links settle in one after another instead of appearing all at once */
  html.nav-js #site-nav a {
    opacity: 0; transform: translateY(-6px);
    transition: opacity .2s ease, transform .24s ease, background .16s ease;
  }
  html.nav-js #site-nav.open a { opacity: 1; transform: none; }
  html.nav-js #site-nav.open a:nth-child(1) { transition-delay: .05s; }
  html.nav-js #site-nav.open a:nth-child(2) { transition-delay: .09s; }
  html.nav-js #site-nav.open a:nth-child(3) { transition-delay: .13s; }
  html.nav-js #site-nav.open a:nth-child(4) { transition-delay: .17s; }
}

.nav-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .62);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.nav-scrim.on { opacity: 1; pointer-events: auto; }
@media (min-width: 721px) { .nav-scrim { display: none; } }

/* Motion is decoration, never information: honour the OS preference. */
@media (prefers-reduced-motion: reduce) {
  html.nav-js #site-nav,
  html.nav-js #site-nav a,
  .nav-scrim, .site-header, .nav-toggle { transition: none !important; }
}

/* panel polish round 2: tuck under the header, stronger lift, and give the
   GitHub row a label on mobile so it shares the same rhythm as text links */
.nav-label { display: none; }
@media (max-width: 720px) {
  html.nav-js #site-nav {
    box-shadow: 0 28px 70px rgba(0,0,0,.9), 0 3px 10px rgba(0,0,0,.6),
                0 0 0 1px rgba(255,255,255,.06);
  }
  html.nav-js #site-nav a.with-icon { gap: 12px; }
  html.nav-js #site-nav a.with-icon .nav-label { display: inline; }
}

/* panel polish round 3: comfortable tap targets on phones */
@media (max-width: 720px) {
  .site-header .lang-switch { padding: 7px 13px; font-size: .9rem; }
  .nav-toggle { padding: 8px 11px; }
}

/* ---------- content effects (opt-in: html.fx) ---------- */
html.fx [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s ease, transform .55s cubic-bezier(.2, .9, .25, 1);
}
html.fx [data-reveal].in { opacity: 1; transform: none; }

/* a thin reading-progress line under the sticky header */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, #A8C8FF, #5E93F5);
  z-index: 80; pointer-events: none;
}

/* hover polish: cards, download rows and buttons lift a little */
.card { transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.card:hover { transform: translateY(-3px); border-color: rgba(168, 200, 255, .35); background: var(--panel-2); }
.dl { transition: transform .16s ease, border-color .16s ease; }
.dl:hover { transform: translateY(-2px); }
.btn { transition: transform .15s ease, filter .15s ease, border-color .15s ease, color .15s ease; }
.btn:hover { transform: translateY(-1px); }
.faq dt { transition: color .15s ease; }
.faq dt:hover { color: var(--accent); }

/* the decorative hero screen breathes, very slowly */
@keyframes tg-float { from { transform: translateY(0); } to { transform: translateY(-7px); } }
@keyframes tg-pulse {
  0%, 100% { transform: scale(1); opacity: .92; }
  50%      { transform: scale(1.06); opacity: 1; }
}
html.fx .tv { animation: tg-float 6s ease-in-out infinite alternate; }
html.fx .play { animation: tg-pulse 3.4s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  html.fx [data-reveal], html.fx .tv, html.fx .play, .scroll-progress {
    animation: none !important; transition: none !important;
    opacity: 1 !important; transform: none !important;
  }
}

/* ---------- menu bubble: all-round corners + an upward caret ---------- */
@media (max-width: 720px) {
  /* A caret needs a little air between the header and the panel, so the panel
     moves down 4px (round 3 had tucked it flush, which would hide the tip). */
  html.nav-js #site-nav {
    top: calc(100% + 4px);
    border-radius: 14px;                 /* four round corners, all sides */
  }

  /* The tip: a 45°-rotated square, so it can carry the panel's border and the
     top stop of its gradient instead of being a flat grey triangle. Centred
     20px from the panel's right edge, which is where the burger sits. */
  html.nav-js #site-nav::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 14px;                         /* 14 + 6 = tip centre 20px in */
    width: 12px;
    height: 12px;
    background: #23272C;                 /* matches the gradient's top colour */
    border-left: 1px solid rgba(255, 255, 255, .14);
    border-top: 1px solid rgba(255, 255, 255, .14);
    border-top-left-radius: 3px;
    transform: rotate(45deg);
  }
}

/* ---------- caret fix ---------- */
@media (max-width: 720px) {
  /* The panel (and therefore its ::before caret) must paint ABOVE the sticky
     header (z-index 70), otherwise the tip of the caret is clipped by the header
     and shows up as a detached fragment. */
  html.nav-js #site-nav { top: calc(100% + 2px); z-index: 80; }

  /* Smaller tip, moved in from the edge so it does not eat the 14px corner
     radius; its centre still lands near the burger/close button. */
  html.nav-js #site-nav::before {
    top: -6px;
    right: 17px;
    width: 10px;
    height: 10px;
    border-top-left-radius: 2px;
  }
}

/* ---------- icons in the menu rows ---------- */
/* Desktop keeps the text-only nav; the icons exist for the mobile panel. */
.nav-item-ico { display: none; }
@media (max-width: 720px) {
  html.nav-js #site-nav a {
    display: flex;
    align-items: center;
  }
  html.nav-js #site-nav .nav-item-ico {
    display: inline-block;
    width: 18px; height: 18px;
    margin-right: 12px;
    color: var(--accent);
  }
}

/* read-only display row (e.g. the version a build will come from) */
.readonly {
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px dashed var(--outline);
  background: rgba(255, 255, 255, .03);
  color: var(--on);
  font-variant-numeric: tabular-nums;
}
