/* ============================================================
   SnackGerman — Telegram-native design system
   Flat surfaces that adapt to the user's Telegram theme (light/dark),
   a single confident blue accent, and warm gamification semantics.
   No glassmorphism, no mesh gradients, no glow. System fonts only.
   ============================================================ */

/* ---------- Tokens: LIGHT (also the non-Telegram fallback) ---------- */
:root {
  color-scheme: light dark;

  /* Brand accent (ours — stays consistent across every user & theme) */
  --accent: #2277cc;
  --accent-strong: #1f74c9;
  --accent-tint: rgba(34, 119, 204, 0.10);
  --accent-border: rgba(34, 119, 204, 0.38);
  --on-accent: #ffffff;

  /* Gamification / status semantics */
  --success: #1f9d57;
  --success-tint: rgba(31, 157, 87, 0.12);
  --danger: #d93a3f;
  --danger-tint: rgba(217, 58, 63, 0.10);
  --streak: #f0821e;          /* warm flame */
  --streak-tint: rgba(240, 130, 30, 0.12);
  --xp: #e0961a;              /* amber gold */
  --xp-tint: rgba(224, 150, 26, 0.12);

  /* Surfaces & text — Telegram themeParams first, tasteful fallback second */
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #f0f2f5);
  --surface: var(--tg-theme-section-bg-color, #ffffff);
  --surface-sunken: var(--tg-theme-secondary-bg-color, #f0f2f5);
  --header-bg: var(--tg-theme-header-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14181f);
  --hint: var(--tg-theme-hint-color, #7c828a);
  --separator: var(--tg-theme-section-separator-color, rgba(0, 0, 0, 0.08));
  --separator-strong: rgba(0, 0, 0, 0.14);
  --field: rgba(0, 0, 0, 0.04);
  --field-border: rgba(0, 0, 0, 0.12);
  --card-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);

  /* Shape scale (documented, consistent) */
  --r-card: 14px;
  --r-control: 12px;
  --r-chip: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;

  /* ---- Legacy aliases so existing inline var(--x) references restyle for free ---- */
  --primary: var(--accent);
  --primary-glow: var(--accent-tint);
  --secondary: var(--xp);
  --secondary-glow: var(--xp-tint);
  --error: var(--danger);
  --warning: var(--xp);
  --bg-main: var(--bg);
  --bg-panel: var(--surface);
  --bg-card: var(--surface);
  --bg-active: var(--accent-tint);
  --border: var(--separator);
  --border-active: var(--accent-border);
  --text-main: var(--text);
  --text-muted: var(--hint);
  --text-dark: #14181f;
}

/* ---------- Tokens: DARK (Telegram-dark palette as fallback) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #62a8ef;
    --accent-strong: #3d92e0;
    --accent-tint: rgba(98, 168, 239, 0.15);
    --accent-border: rgba(98, 168, 239, 0.42);

    --success: #3cc37f;
    --success-tint: rgba(60, 195, 127, 0.16);
    --danger: #f2585d;
    --danger-tint: rgba(242, 88, 93, 0.15);
    --streak: #ff9236;
    --streak-tint: rgba(255, 146, 54, 0.16);
    --xp: #f0b23a;
    --xp-tint: rgba(240, 178, 58, 0.16);

    --bg: var(--tg-theme-bg-color, #17212b);
    --bg-secondary: var(--tg-theme-secondary-bg-color, #131c26);
    --surface: var(--tg-theme-section-bg-color, #232e3c);
    --surface-sunken: var(--tg-theme-secondary-bg-color, #131c26);
    --header-bg: var(--tg-theme-header-bg-color, #232e3c);
    --text: var(--tg-theme-text-color, #f3f5f7);
    --hint: var(--tg-theme-hint-color, #8b98a6);
    --separator: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.09));
    --separator-strong: rgba(255, 255, 255, 0.16);
    --field: rgba(255, 255, 255, 0.06);
    --field-border: rgba(255, 255, 255, 0.14);
    --card-shadow: none;
    --text-dark: #f3f5f7;
  }
}

/* Explicit override when JS stamps the theme from Telegram's colorScheme */
:root[data-theme="dark"] {
  --accent: #62a8ef;
  --accent-strong: #3d92e0;
  --accent-tint: rgba(98, 168, 239, 0.15);
  --accent-border: rgba(98, 168, 239, 0.42);

  --success: #3cc37f;
  --success-tint: rgba(60, 195, 127, 0.16);
  --danger: #f2585d;
  --danger-tint: rgba(242, 88, 93, 0.15);
  --streak: #ff9236;
  --streak-tint: rgba(255, 146, 54, 0.16);
  --xp: #f0b23a;
  --xp-tint: rgba(240, 178, 58, 0.16);

  --bg: var(--tg-theme-bg-color, #17212b);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #131c26);
  --surface: var(--tg-theme-section-bg-color, #232e3c);
  --surface-sunken: var(--tg-theme-secondary-bg-color, #131c26);
  --header-bg: var(--tg-theme-header-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f3f5f7);
  --hint: var(--tg-theme-hint-color, #8b98a6);
  --separator: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.09));
  --separator-strong: rgba(255, 255, 255, 0.16);
  --field: rgba(255, 255, 255, 0.06);
  --field-border: rgba(255, 255, 255, 0.14);
  --card-shadow: none;
  --text-dark: #f3f5f7;
}

/* ---------- Base ---------- */
* {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  box-sizing: border-box;
  position: relative;
}

h1, h2, h3, h4 {
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Tabular numerals for stats (XP, streak, scores) */
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Surfaces (was .glass-panel — now flat & theme-aware) ---------- */
.glass-panel {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  box-shadow: var(--card-shadow);
}

/* Grouped-list section (Telegram/iOS settings feel) */
.tg-section {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  overflow: hidden;
}
.tg-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--hint);
  padding: 4px 4px 8px;
}

/* ---------- Buttons ---------- */
.btn-primary,
.btn-secondary {
  min-height: 48px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--r-control);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-strong);
  color: var(--on-accent);
  border: none;
}
.btn-primary:active { transform: scale(0.985); filter: brightness(0.95); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-sunken);
  color: var(--text);
  border: 1px solid var(--separator);
}
.btn-secondary:active { transform: scale(0.985); background: var(--field); }

/* Shared field styling helper */
.field {
  width: 100%;
  box-sizing: border-box;
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: var(--r-control);
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}
.field::placeholder { color: var(--hint); }
.field:focus { border-color: var(--accent); }

/* ---------- Layout utilities ---------- */
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-around { justify-content: space-around; }
.align-center { align-items: center; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }
.m-b-md { margin-bottom: 16px; }

/* ---------- Indeterminate progress (calm, accent, no glow) ---------- */
.progress-bar-container {
  width: 220px;
  height: 4px;
  background: var(--separator);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  margin-top: 8px;
}
.progress-bar-fill {
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  position: absolute;
  animation: progressLoop 1.4s infinite cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes progressLoop {
  0%   { left: -40%; }
  100% { left: 100%; }
}

/* Spinner (was referenced everywhere but never defined) */
@keyframes spin { to { transform: rotate(360deg); } }

/* Gentle "active" pulse for the record indicator — opacity only, no neon */
@keyframes pulseGlow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* Subtle content entrance */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.enter { animation: fadeSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1) both; }

/* Legacy decorative classes neutralised (kept so markup needn't change) */
.glow-effect { animation: none; }
.float-effect { animation: none; }

/* ---------- Vocab flip card ---------- */
.flip-card {
  perspective: 1000px;
  width: 100%;
  height: 240px;
  cursor: pointer;
  margin: 4px 0;
}
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  box-sizing: border-box;
}
.flip-card-front {
  background: var(--surface);
  border: 1px solid var(--separator);
  box-shadow: var(--card-shadow);
}
.flip-card-back {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  transform: rotateY(180deg);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .flip-card-inner { transition: none; }
}


/* ============================================================
   SnackGerman — static site chrome (blog + marketing pages)
   Appended after index.css (which provides the design tokens), so it
   reuses --accent, --text, --surface, etc. These pages ship ZERO JS:
   fast, SEO-friendly, and theme-adaptive via prefers-color-scheme.
   ============================================================ */

body { background: var(--bg); color: var(--text); }

a { color: var(--accent); }

.site {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
}
.site--wide { max-width: 1080px; }

/* ---------- Shared nav ---------- */
.site-nav {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.site-brand img { height: 38px; width: auto; display: block; }
.site-nav-links { display: flex; align-items: center; gap: 20px; }
.site-nav-links a {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}
.site-nav-links a:hover { color: var(--accent); }
.site-nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-chip);
  background: var(--accent-strong);
  color: var(--on-accent) !important;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- Blog index ---------- */
.blog-head {
  text-align: center;
  padding: 40px 0 8px;
}
.blog-head .eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 6px 12px;
  border-radius: var(--r-chip);
  margin-bottom: 16px;
}
.blog-head h1 {
  font-size: clamp(32px, 5vw, 46px);
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.blog-head p { color: var(--hint); font-size: 18px; margin: 0 auto; max-width: 520px; }

.post-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px 0 56px;
}
.post-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  padding: 22px 24px;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.post-card:hover { border-color: var(--accent-border); transform: translateY(-2px); }
.post-card .meta { font-size: 13px; color: var(--hint); font-weight: 600; margin-bottom: 8px; }
.post-card h2 { font-size: 21px; margin: 0 0 6px; letter-spacing: -0.02em; }
.post-card p { font-size: 15px; color: var(--hint); line-height: 1.5; margin: 0; }
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 3px 9px;
  border-radius: var(--r-chip);
  margin-right: 6px;
}

/* ---------- Article ---------- */
.article-head { padding: 32px 0 8px; }
.article-head .meta { font-size: 14px; color: var(--hint); font-weight: 600; margin-bottom: 14px; }
.article-head .meta a { color: var(--hint); text-decoration: none; }
.article-head .meta a:hover { color: var(--accent); }
.article-head h1 {
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.article-head .lede { font-size: 19px; color: var(--hint); line-height: 1.5; margin: 0; }

.article {
  font-size: 17px;
  line-height: 1.72;
  color: var(--text);
  padding: 8px 0 24px;
}
.article > *:first-child { margin-top: 0; }
.article h2 { font-size: 26px; letter-spacing: -0.02em; margin: 40px 0 12px; }
.article h3 { font-size: 20px; letter-spacing: -0.01em; margin: 28px 0 8px; }
.article p { margin: 0 0 18px; }
.article ul, .article ol { margin: 0 0 18px; padding-left: 24px; }
.article li { margin: 6px 0; }
.article a { text-decoration: underline; text-underline-offset: 2px; }
.article img { max-width: 100%; height: auto; border-radius: var(--r-card); margin: 12px 0; }
.article blockquote {
  margin: 20px 0;
  padding: 2px 20px;
  border-left: 2px solid var(--separator-strong);
  color: var(--hint);
  font-style: italic;
}
.article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-sunken);
  border: 1px solid var(--separator);
  border-radius: 6px;
  padding: 1px 6px;
}
.article pre {
  background: var(--surface-sunken);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 18px;
}
.article pre code { background: none; border: none; padding: 0; font-size: 14px; }
.article hr { border: none; border-top: 1px solid var(--separator); margin: 32px 0; }

/* End-of-article CTA */
.article-cta {
  margin: 8px 0 56px;
  padding: 28px 24px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-card);
  text-align: center;
}
.article-cta h3 { margin: 0 0 6px; font-size: 21px; letter-spacing: -0.02em; }
.article-cta p { margin: 0 0 16px; color: var(--hint); }
.article-cta a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 22px;
  border-radius: var(--r-control);
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}

.back-link {
  display: inline-block;
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--hint);
  text-decoration: none;
}
.back-link:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--separator);
  margin-top: 8px;
}
.site-footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-sizing: border-box;
}
.site-footer .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); }
.site-footer .brand img { height: 30px; width: auto; }
.site-footer .links { display: flex; gap: 20px; flex-wrap: wrap; }
.site-footer .links a { color: var(--hint); text-decoration: none; font-size: 14px; font-weight: 600; }
.site-footer .links a:hover { color: var(--accent); }
.site-footer .copy { color: var(--hint); font-size: 13px; width: 100%; }

@media (max-width: 620px) {
  .site-nav-links { gap: 14px; }
  .site-nav-links .nav-only-wide { display: none; }
}
