/* MINI_APP_CSS_V1 (2026-05-16) — Mini-App-specific layout + safe-area handling.
   Built on top of symptex.css design tokens (--navy-*, --warm-*, etc.).
   No yellow. Navy primary, warm-white surfaces, no chrome navbar. */

:root {
  /* Telegram-provided insets — defaults to 0 outside Telegram */
  --tg-content-top:    0px;
  --tg-content-bottom: 0px;
  --tg-safe-top:       0px;
  --tg-safe-bottom:    0px;
  --tg-viewport-h:     100vh;
}

body.tg-mini-app {
  background: var(--bg-page);
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
}

.tg-app-shell {
  min-height: var(--tg-viewport-h, 100dvh);
  /* Safe-area combines Telegram's contentSafeAreaInset with iOS env() so both
     fullscreen-mode and inline/menu-button modes lay out correctly. */
  padding-top:    max(var(--tg-content-top),    env(safe-area-inset-top));
  padding-bottom: max(var(--tg-content-bottom), env(safe-area-inset-bottom));
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
  display: flex;
  flex-direction: column;
}

/* ── Auth container ────────────────────────────────────────────────── */
.tg-auth-wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tg-logo {
  text-align: center;
  margin: 12px 0 28px;
  font-family: var(--font-logo);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: var(--tracking-logo);
  color: var(--navy-500);
}

.tg-h1 {
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin: 0 0 8px;
  color: var(--text-primary);
}

.tg-sub {
  font-size: var(--text-sm);
  color: var(--text-body);
  margin: 0 0 24px;
  line-height: var(--leading-normal);
}

/* ── Form fields ──────────────────────────────────────────────────── */
.tg-form-row {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.tg-form-row label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.tg-input {
  padding: 14px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow   var(--dur-fast) var(--ease-standard);
  min-height: 48px;
  width: 100%;
  -webkit-appearance: none;
}

.tg-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.tg-input::placeholder {
  color: var(--text-tertiary);
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.tg-btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  min-height: 48px;
  background: var(--navy-500);
  color: var(--white);
  font-size: var(--text-base);
  font-weight: 600;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
  text-decoration: none;
  text-align: center;
  -webkit-appearance: none;
  font-family: var(--font-sans);
}

.tg-btn-primary:hover { background: var(--navy-600); color: var(--white); text-decoration: none; }
.tg-btn-primary:active { background: var(--navy-700); transform: translateY(0.5px); }
.tg-btn-primary:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.tg-btn-primary[disabled] { opacity: 0.5; cursor: not-allowed; }

.tg-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  min-height: 48px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: background var(--dur-fast) var(--ease-standard);
  font-family: var(--font-sans);
}

.tg-btn-secondary:hover { background: var(--warm-75); text-decoration: none; }
.tg-btn-secondary:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.tg-btn-secondary svg { width: 18px; height: 18px; }

/* ── Divider ──────────────────────────────────────────────────────── */
.tg-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  margin: 20px 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tg-or::before, .tg-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ── OTP entry ────────────────────────────────────────────────────── */
.tg-otp-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0 20px;
}

.tg-otp-row input {
  width: 44px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  font-family: var(--font-sans);
}

.tg-otp-row input:focus {
  outline: 0;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* ── Tertiary text + links ────────────────────────────────────────── */
.tg-link {
  color: var(--text-link);
  font-size: var(--text-sm);
  text-decoration: none;
}

.tg-link:hover { color: var(--text-link-hover); text-decoration: underline; }

.tg-tertiary {
  text-align: center;
  margin-top: 16px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Messages ─────────────────────────────────────────────────────── */
.tg-err {
  color: var(--status-danger);
  font-size: var(--text-sm);
  padding: 10px 12px;
  background: var(--status-danger-bg);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.tg-info {
  color: #1F5048;
  font-size: var(--text-sm);
  padding: 10px 12px;
  background: var(--mint);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

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

/* ── Telegram dark theme adaptation ───────────────────────────────── */
@media (prefers-color-scheme: dark) {
  body.tg-mini-app { background: var(--warm-900); }
  .tg-input { background: var(--warm-700); color: var(--white); border-color: var(--warm-300); }
  .tg-btn-secondary { background: var(--warm-700); color: var(--white); border-color: var(--warm-300); }
  .tg-h1 { color: var(--white); }
}
