/* ============================================================
   67 CC — index.css
   Design system: variables, reset, base layout, utilities.
   Single fixed dark theme (Telegram Night Blue).
   ============================================================ */

:root {
  --bg-primary:   #17212b;
  --bg-secondary: #0e1621;
  --bg-surface:   #1c2836;
  --bg-hover:     #1e2c3a;
  --bg-active:    #3d7ab8;
  --bg-input:     #242f3d;

  --text-primary:   #f5f5f5;
  --text-secondary: #708499;
  --text-tertiary:  #546778;
  --text-link:      #3d7ab8;

  --accent:        #3d7ab8;
  --accent-hover:  #4888c9;
  --accent-active: #2f6296;
  --accent-muted:  rgba(61, 122, 184, 0.16);

  --grad-hero: linear-gradient(160deg, #2f86d6 0%, #2b6fb5 55%, #255f9c 100%);
  --hero-on: #ffffff;

  --border-primary:   rgba(255, 255, 255, 0.08);
  --border-secondary: rgba(255, 255, 255, 0.05);

  --success: #4fae4e;
  --warning: #8b97a5;
  --danger:  #e06055;

  /* ── Semantic aliases — single source of truth ──
     Several components were authored against short token names that were
     never defined (so they silently fell back to invalid values and made
     those pages — FAQ, admin panel, captcha — look off-theme). These map
     them onto the canonical tokens so every page shares one palette. */
  --fg:         var(--text-primary);
  --fg-muted:   var(--text-secondary);
  --text-muted: var(--text-tertiary);
  --border:     var(--border-primary);

  --font-sans: 'Roboto', 'Roboto Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'Roboto Mono', 'Roboto Mono Fallback', 'SF Mono', Menlo, Monaco, monospace;
}

/* ── Metric-matched local fallbacks ──
   These synthesize a "Roboto Fallback" face from the platform system font
   (or Arial), but with size/ascent/descent/line-gap scaled to match
   Roboto's metrics. The browser only uses these when the real Roboto
   hasn't loaded yet — and because the metrics are matched, the swap
   from fallback → real Roboto causes zero visible reflow. Same trick
   for Roboto Mono → SF Mono / Menlo. */
@font-face {
  font-family: 'Roboto Fallback';
  src: local('Arial'), local('Helvetica');
  size-adjust: 100%;
  ascent-override: 92%;
  descent-override: 24%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Roboto Mono Fallback';
  src: local('SF Mono'), local('Menlo'), local('Monaco');
  size-adjust: 100%;
  ascent-override: 88%;
  descent-override: 22%;
  line-gap-override: 0%;
}

:root {
  --radius-btn: 8px;
  --radius-card: 12px;
  --radius-modal: 14px;
  --radius-pill: 999px;
  --radius: var(--radius-card);   /* alias used by some components */

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  --sidebar-w: 260px;
  --sidebar-w-collapsed: 64px;

  --shadow-card:  none;
  --shadow-modal: 0 8px 40px rgba(0, 0, 0, 0.5);

  --scroll-thumb: rgba(255, 255, 255, 0.12);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.2);

  /* ── Motion system — one shared vocabulary for every animation ──
     --t            micro-interactions (hover, press, color shifts)
     --ease-standard the canonical entrance/transition curve (smooth decelerate)
     --ease-out      legacy decelerate, kept as an alias of the standard feel
     --ease-spring   playful overshoot, reserved for toasts / mascot accents
     --dur-1/2/3     fast / base / slow durations */
  --t: 0.15s ease;
  --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out:    cubic-bezier(0.0, 0.0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-1: 0.15s;
  --dur-2: 0.25s;
  --dur-3: 0.4s;

  color-scheme: dark;
}

/* ── Eye Saver 3000: light theme ───────────────────────────────────────────
   Only overrides the palette variables — every component already consumes
   them, so layout/spacing/components are untouched. Enabled via
   <html data-theme="light"> (profile toggle, DEV_I_ANT & BOSS KFC only). */
html[data-theme="light"] {
  /* Warm sepia "reading mode" — no blinding white, no cold blue-grey glare. */
  --bg-primary:   #f7f2e7;
  --bg-secondary: #efe8d8;
  --bg-surface:   #fcf8ee;
  --bg-hover:     #e7dfcc;
  --bg-active:    #3d6a96;
  --bg-input:     #ece4d2;

  --text-primary:   #2a2417;
  --text-secondary: #5f563f;
  --text-tertiary:  #7d7357;
  --text-link:      #2f5f8f;

  --accent:        #2e6b9e;   /* deeper desaturated brand blue, no glare */
  --accent-hover:  #275d8a;
  --accent-active: #1f4e75;
  --accent-muted:  rgba(46, 107, 158, 0.14);

  --grad-hero: linear-gradient(160deg, #4a7fb5 0%, #3a6f9e 55%, #2f5f8a 100%);

  --border-primary:   rgba(60, 50, 30, 0.16);
  --border-secondary: rgba(60, 50, 30, 0.09);

  --success: #2e7d32;
  --warning: #9a6a12;
  --danger:  #b3402f;

  --scroll-thumb: rgba(60, 50, 30, 0.22);
  --scroll-thumb-hover: rgba(60, 50, 30, 0.34);

  --shadow-modal: 0 8px 40px rgba(40, 30, 10, 0.22);

  color-scheme: light;
}

/* Pastel badge/accent text authored for dark bg is unreadable on paper —
   deepen it under the light theme. Background alphas stay, they're fine. */
html[data-theme="light"] .badge-class--platinum  { color: #5f6b7a; }
html[data-theme="light"] .badge-class--signature { color: #5a51c9; }
html[data-theme="light"] .badge-class--infinite  { color: #c2447f; }
html[data-theme="light"] .badge-class--world     { color: #0f766e; }
html[data-theme="light"] .badge-class--business  { color: #b45309; }
html[data-theme="light"] .badge-class--standard  { background: rgba(60,50,30,0.07); border-color: rgba(60,50,30,0.14); }
html[data-theme="light"] .badge-subtype--credit    { color: #2563eb; }
html[data-theme="light"] .badge-subtype--debit     { color: #047857; }
html[data-theme="light"] .badge-subtype--prepaid   { color: #a16207; }
html[data-theme="light"] .badge-subtype--corporate { color: #7c3aed; }
html[data-theme="light"] .bulk-chip-blue { background: rgba(46,107,158,0.14); color: #2e6b9e; }
html[data-theme="light"] .bulk-tag--mastercard,
html[data-theme="light"] .bulk-net--mastercard { color: #b34a1e; }
html[data-theme="light"] .key-card__tool--done { color: #2e7d32; border-color: #2e7d32; }
html[data-theme="light"] .field-tag { color: #1a6b34; background: rgba(46,125,50,0.10); border-color: rgba(46,125,50,0.25); }
html[data-theme="light"] .profile-hero__role { color: #2e6b9e; border-color: rgba(46,107,158,0.3); }
html[data-theme="light"] .stock-indicator--in-stock { color: #2e7d32; }
html[data-theme="light"] .dash-order-status--sold,
html[data-theme="light"] .sd-order-status--sold { color: #2e7d32; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overscroll-behavior-y: none; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
/* iOS Safari: фокус на инпуте <16px принудительно зумит страницу —
   на тач-устройствах форсятся 16px, десктоп не трогаем. !important нужен,
   чтобы перебить классовые font-size (.modal-prompt-input и т.п.). */
@media (hover: none), (pointer: coarse), (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea, select { font-size: 16px !important; }
}
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  /* --app-h is set from window.innerHeight on load/resize/orientation — iOS
     Safari hands out a stale dvh right after rotation, which pushed the
     tabbar off-screen (the shell is overflow:hidden, so it clipped). */
  height: var(--app-h, 100dvh);
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg-secondary);
}
@media (min-width: 481px) {
  .app-shell { border-left: 1px solid var(--border-primary); border-right: 1px solid var(--border-primary); }
}
/* Auth mode — burst free of the narrow shell */
body.auth-mode .app-shell {
  max-width: none;
  border: none;
  background: none;
  /* Fixed height + internal scroller: this layout used to be height:auto /
     overflow:visible so the page scrolled via the DOCUMENT — iOS Safari
     silently refuses document scroll when body is height:100% with
     overflowing children, and rotation froze the auth page on the mascot.
     Scrolling .main-content matches the in-app model and is reliable. */
  height: var(--app-h, 100dvh);
  overflow: hidden;
}
body.auth-mode .main-content {
  overflow-y: auto;
  background: none;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-secondary);
  overflow: hidden;
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: 56px;
  padding: 0 var(--sp-6);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
}

.main-header h1, .main-header .page-title { font-size: 17px; font-weight: 700; }

.main-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: var(--sp-6);
  /* Колонка — чтобы .app-footer мог прибиться к низу на коротких страницах
     (margin-top:auto). flex-shrink:0 не даёт контенту сплющиться вместо
     скролла. */
  display: flex;
  flex-direction: column;
}
.main-body > *, .main-body__inner > * { flex-shrink: 0; width: 100%; }
.main-body__inner { display: flex; flex-direction: column; flex: 1 0 auto; }
/* Hero-страницы наследуют паддинги .main-body (sp-6 / responsive) — колонка
   ведёт себя ровно как на обычных страницах (Cards и т.д.). */
.main-body--hero .main-body__inner { padding: var(--sp-5) 0 0; }

/* ── Site footer — прибит к низу .main-body (flex-колонка выше): на коротких
   страницах висит у нижнего края экрана, на длинных скроллится с контентом ── */
.app-footer {
  display: flex; justify-content: center;
  margin: auto auto 0; padding-top: var(--sp-8);
  border-top: 1px dashed var(--border-primary);
  padding-bottom: var(--sp-4);
  max-width: 480px; width: 100%;
}
.app-footer-chip { padding: var(--sp-1) var(--sp-2); border-radius: var(--radius-card); }
.app-footer-chip:hover { background: var(--bg-hover); }

body.auth-mode .tabbar { display: none !important; }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-secondary);
}

@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut  { from { opacity: 1; } to { opacity: 0; } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(0.97) translateY(4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes authFormIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes orbFloat1 { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(40px,-30px) scale(1.08); } 66% { transform: translate(-20px,20px) scale(0.95); } }
@keyframes orbFloat2 { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(-50px,30px) scale(1.06); } 66% { transform: translate(30px,-40px) scale(0.97); } }
@keyframes orbFloat3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(20px,50px) scale(1.04); } }
@keyframes particleDrift { 0% { opacity:0; transform: translateY(0) scale(0); } 10% { opacity:1; } 90% { opacity:0.6; } 100% { opacity:0; transform: translateY(-120px) scale(1.2); } }

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

/* No page-enter animation anywhere: two nested enter fades (#main-content
   + .main-body) replayed on every navigation AND on every async re-render
   (loading→loaded), which read as a black flicker when switching pages.
   Routes now swap instantly — same as Tor mode always did. */

/* ── Tor mirror (.onion) — lite mode ───────────────────────────────────────
   Only transitions are snappier here. Animations run exactly as authored:
   the old rule that compressed them to 0.25s and forced iteration-count:3
   made every one-shot entrance animation replay three times at 4x speed —
   pages strobed on load, infinite pulses flickered, and some elements froze
   mid-keyframe. CSS animations cost no bandwidth, so the "lean" trade was
   pure breakage. (Heavy stuff stays off on onion: mascot webm never ships.) */
html.tor-mode *, html.tor-mode *::before, html.tor-mode *::after {
  transition-duration: 0.08s !important;
}
/* Mascot video never ships over onion — the static PNG already replaced it,
   this just guards any video node that still sneaks into the DOM. */
html.tor-mode video.mascot-loop-video { display: none !important; }

/* ── force-mobile (ставит boot.js): тач-устройство с физически маленьким
   экраном, но браузер отдал десктопную ширину (Safari "Request Desktop
   Website", глюк вьюпорта при перезагрузке). Откатываем десктопный шелл
   ≥900px обратно на мобильный. ─────────────────────────────────────────── */
html.force-mobile .app-shell { max-width: 480px; flex-direction: column; }
html.force-mobile .sidebar { display: none !important; }
html.force-mobile .tabbar { display: flex; }
html.force-mobile .home-hero { display: block; }
html.force-mobile .main-body--hero { max-width: 600px; margin: 0 auto; }
html.force-mobile .main-body--hero .main-body__hero,
html.force-mobile .main-body--hero .main-body__inner { max-width: none; }
html.force-mobile .main-header { padding: 0 var(--sp-4); height: 52px; }
html.force-mobile .main-body { padding: var(--sp-3); }
html.force-mobile body, html.force-mobile { font-size: 13px; }

@media (max-width: 1024px) { .main-body { padding: var(--sp-4); } }
@media (max-width: 768px) { .main-header { padding: 0 var(--sp-4); height: 52px; } .main-body { padding: var(--sp-3); } }
@media (max-width: 480px) { body { font-size: 13px; } .main-body { padding: var(--sp-2); } }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sidebar { display: none; }
body.auth-mode .sidebar { display: none !important; }

/* min-height gate: a phone in landscape (≥900px wide but only ~390–430px
   tall) must keep the mobile tabbar shell — the desktop sidebar layout is
   unusable at that height and was the rotation "break". */
@media (min-width: 900px) and (min-height: 500px) {
  .app-shell { max-width: none; flex-direction: row; }
  /* overflow-y auto lets a tall menu scroll to its end; overflow-x hidden
     still clips the labels during the collapse width transition. */
  .sidebar { display: flex; transition: width 0.25s var(--ease-out); overflow-y: auto; overflow-x: hidden; }
  .sidebar-collapse-btn { display: flex; }
  .tabbar { display: none; }
  .home-hero { display: none; }
  /* Full-width main column: content aligns to the sidebar on the left and the
     scrollbar reaches the right edge of the screen. */
  .main-body { width: 100%; }
  /* The hero scroll container stays full-width so the whole area between the
     sidebar and the right screen edge is scrollable (no dead side gutters);
     the 720px centering is applied to the INNER content blocks instead. */
  .main-body--hero { max-width: none; margin: 0; }
  .main-body--hero .main-body__hero,
  .main-body--hero .main-body__inner { max-width: 1400px; margin-left: auto; margin-right: auto; }
  .main-body--hero .app-hero { border-radius: var(--radius-card); overflow: hidden; }
  .main-body--hero .main-body__inner { padding-top: var(--sp-5); }
  .app-hero { padding-top: var(--sp-6); }
}

/* ≥1900px — как .home-page: колонка hero-страниц расширяется до 1680px */
@media (min-width: 1900px) {
  .main-body--hero .main-body__hero,
  .main-body--hero .main-body__inner { max-width: 1680px; }
}

/* ── Pull-to-refresh indicator (custom PTR → hard reload) ── */
.ptr-indicator {
  position: fixed;
  top: -64px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.ptr-indicator--visible { opacity: 1; }
.ptr-indicator--ready { color: var(--text-primary); border-color: var(--accent); }
.ptr-indicator__icon { display: inline-block; font-size: 16px; line-height: 1; transition: transform .1s linear; }
.ptr-indicator--ready .ptr-indicator__icon { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
