/* =============================================================================
   QTEZH theme — base stylesheet
   Tokens extracted verbatim from _migration/design-tokens.md (Phase 0).
   Mobile-first. Breakpoints (min-width): 320 / 480 / 640 / 960 / 1200.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Design tokens (:root custom properties)
   ------------------------------------------------------------------------- */
:root {
  /* Colors — brand / core */
  --accent:        #d9ef06;            /* primary lime accent (CTA, marquee) */
  --accent-rgb:    217, 239, 6;
  --bg:            #0f0f0f;            /* primary dark page background */
  --bg-elevated:   #1d1d23;            /* elevated dark surface (header) */
  --bg-black:      #111111;            /* near-black (mobile menu bar) */
  --on-accent:     #000000;            /* text/icon on accent surfaces */
  --on-dark:       #ffffff;            /* primary text on dark */

  /* Colors — neutrals / secondary text */
  --text-muted:    #c7c7c7;
  --text-muted-2:  #c0bebe;
  --text-dim:      #525252;
  --text-pinkish:  #f5ebeb;            /* legal block text (rgb(245,235,235)) */

  /* Colors — links (Tilda contacts t573) */
  --link-orange:   #ff8562;            /* default link / contacts email */
  --link-telegram: #4995be;            /* Telegram text-link (rgb(73,149,190)) */
  --link-whatsapp: #21c252;            /* WhatsApp text-link (rgb(33,194,82)) */
  --surface-222:   #222222;
  --border-e6:     #e6e6e6;
  --border-light:  rgba(255, 255, 255, 0.2);
  --scrim-50:      rgba(0, 0, 0, 0.5);
  --overlay-60:    rgba(0, 0, 0, 0.6);

  /* Gradients */
  --card-gradient:   linear-gradient(to bottom, rgba(24,19,124,0.5), rgba(106,101,215,0.5));
  --card-gradient-2: linear-gradient(to bottom, rgba(17,13,109,0.50), rgba(106,101,215,0.20));
  --scrim:           linear-gradient(to bottom, rgba(0,0,0,0.5), rgba(0,0,0,0.5));

  /* Shadows */
  --shadow-card:  0px 10px 40px -2px rgba(0,11,48,0.3);
  --shadow-soft:  0px 10px 20px rgba(0,11,48,0.25);
  --shadow-xs:    0px 2px 3px rgba(0,11,48,0.25);
  --shadow-faint: 0px 0px 15px rgba(0,0,0,0.1);

  /* Border radii */
  --radius-pill: 50px;                 /* pills / primary CTA */
  --radius-card: 30px;                 /* cards */
  --radius-menu: 0 0 20px 20px;        /* header rounded bottom only */
  --radius-btn-hero: 10px;             /* hero T396 button */
  --radius-sm: 5px;

  /* Typography */
  /* TODO(fonts): self-host TildaSans + full-Cyrillic Inter (Phase 0 license
     check pending). Until then the stack falls back to Arial/system for
     Cyrillic coverage so the page renders correctly. */
  --font-base: 'TildaSans', 'Inter', Arial, sans-serif;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --fs-body: 16px;
  --fs-body-lg: 20px;
  --fs-caption: 14px;
  --fs-h3: 22px;
  --fs-h2: 36px;
  --fs-h1: 42px;

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-base: 1.55;

  /* Spacing scale (px) — dominant rhythm unit 15px */
  --space-1: 8px;
  --space-2: 15px;
  --space-3: 25px;
  --space-4: 30px;
  --space-5: 45px;
  --space-6: 60px;
  --space-7: 75px;
  --space-8: 90px;
  --space-9: 150px;

  /* Layout */
  --container-max: 1200px;
  --content-narrow: 960px;
  --content-reading: 640px;

  /* Breakpoints (reference values; used in media queries below) */
  --bp-xs: 320px;
  --bp-sm: 480px;
  --bp-md: 640px;
  --bp-lg: 960px;
  --bp-xl: 1200px;

  /* Header sizing */
  --header-h-mobile: 64px;
  --header-h-desktop: 100px;

  /* Motion */
  --transition: 0.2s ease-in-out;
}

/* ---------------------------------------------------------------------------
   2. Reset / normalize basics
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--on-dark);
  font-family: var(--font-base);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, svg { max-width: 100%; height: auto; display: block; }

ul, ol { margin: 0; padding: 0; list-style: none; }

button { font: inherit; cursor: pointer; }

a { color: inherit; text-decoration: none; transition: color var(--transition), opacity var(--transition); }
a:hover { opacity: 0.85; }

/* Account for sticky header when jumping to in-page anchors. */
[id] { scroll-margin-top: calc(var(--header-h-mobile) + 12px); }

/* ---------------------------------------------------------------------------
   3. Base typography (roles from design-tokens.md §5)
   ------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--space-2); color: var(--on-dark); }

h1 { font-size: var(--fs-h1); font-weight: var(--fw-bold);     line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: 1.15; }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
h4 { font-size: 18px;          font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
h5 { font-size: 16px;          font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
h6 { font-size: 14px;          font-weight: var(--fw-semibold); line-height: var(--lh-snug); }

p  { margin: 0 0 var(--space-2); line-height: var(--lh-base); }

.page a, p a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

small, .caption { font-size: var(--fs-caption); color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   4. Layout — container utility
   ------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-2);
}

.page { padding-block: var(--space-5); }

/* ---------------------------------------------------------------------------
   5. Buttons / pills
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 12px 24px;
  border: none;
  font-size: var(--fs-body);
  font-weight: var(--fw-bold);
  line-height: var(--lh-base);
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: background-color var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              opacity var(--transition), transform var(--transition);
}
.btn:hover { opacity: 1; transform: translateY(-1px); }

.btn--pill   { border-radius: var(--radius-pill); }
.btn--accent { background-color: var(--accent); color: var(--on-accent); }
.btn--accent:hover { background-color: var(--accent); filter: brightness(1.05); }

/* ---------------------------------------------------------------------------
   6. Header — sticky dark bar, rounded bottom (--radius-menu)
   ------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg-elevated);
  border-radius: var(--radius-menu);
  box-shadow: var(--shadow-soft);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--header-h-mobile);
}

.site-header__logo {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.site-header__logo-img {
  display: block;
  width: 120px;
  height: auto;
  max-width: 100%;
}

/* Burger button (mobile only; toggle logic in site.js) */
.site-header__burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: transparent;
  border: none;
}
.site-header__burger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--on-dark);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
/* Animated X when open */
.site-header.is-nav-open .site-header__burger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header.is-nav-open .site-header__burger-bar:nth-child(2) { opacity: 0; }
.site-header.is-nav-open .site-header__burger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Nav — mobile: collapsible panel */
.site-nav {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  background-color: var(--bg-black);
  border-radius: var(--radius-menu);
  box-shadow: var(--shadow-soft);
}
.site-header.is-nav-open .site-nav { display: flex; }

.site-nav__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-nav__link {
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  color: var(--on-dark);
}
.site-nav__link:hover { color: var(--accent); }

.site-nav__cta { align-self: flex-start; }

/* ---------------------------------------------------------------------------
   7. Footer — navigation + legal + copyright (complements #contacts above)
   ------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--bg-elevated);
  color: var(--text-muted);
  margin-top: var(--space-8);
  padding-block: var(--space-6) var(--space-4);
}

/* Top area: brand + 3 link columns. Mobile-first single column. */
.site-footer__top {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

/* Brand column ---------------------------------------------------------- */
.site-footer__brand { display: flex; flex-direction: column; gap: var(--space-2); }

.site-footer__logo { display: inline-flex; align-items: center; }
.site-footer__logo-img {
  display: block;
  width: 140px;
  height: auto;
  max-width: 100%;
}

.site-footer__tagline {
  margin: 0;
  white-space: nowrap;
  font-size: var(--fs-caption);
  color: var(--text-muted-2);
  line-height: var(--lh-snug);
}

/* Social icon row ------------------------------------------------------- */
.site-footer__socials {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--space-1);
}
.site-footer__social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background-color: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  transition: color var(--transition), background-color var(--transition),
              border-color var(--transition), transform var(--transition);
}
.site-footer__social:hover,
.site-footer__social:focus-visible {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Link columns ---------------------------------------------------------- */
.site-footer__heading {
  font-size: 14px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-dark);
  margin: 0 0 var(--space-2);
}

.site-footer__list { display: flex; flex-direction: column; gap: 10px; }
.site-footer__link {
  display: inline-block;
  font-size: var(--fs-caption);
  color: var(--text-muted);
  line-height: var(--lh-snug);
  white-space: nowrap;
}
.site-footer__link:hover,
.site-footer__link:focus-visible { opacity: 1; color: var(--accent); }
.site-footer__link--strong { font-weight: var(--fw-semibold); color: var(--on-dark); }

.site-footer__cta {
  align-self: flex-start;
  margin-top: var(--space-2);
  padding: 10px 22px;
  font-size: var(--fs-caption);
}

/* Bottom bar: company legal + copyright --------------------------------- */
.site-footer__bottom {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-footer__legal {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: var(--lh-snug);
}
.site-footer__legal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--space-3);
  margin: 0;
}
.site-footer__legal-line { display: inline-block; }
.site-footer__legal-line--strong { color: var(--text-muted-2); font-weight: var(--fw-medium); }
.site-footer__rights {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: var(--lh-snug);
}

/* Payment systems row — intentionally dimmed, brighten on hover */
.site-footer__pay {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--text-muted-2);
  opacity: 0.5;
  transition: opacity var(--transition);
}
.site-footer__pay:hover { opacity: 0.9; }
.site-footer__pay-label { font-size: 12px; color: var(--text-dim); }
.site-footer__pay-marks { display: inline-flex; align-items: center; gap: 16px; }
.pay-mark { display: inline-flex; align-items: center; height: 22px; }
.pay-mark--visa {
  font-style: italic;
  font-weight: var(--fw-bold);
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--on-dark);
}
.pay-mark--mc { width: 30px; height: 18px; }
.pay-mark--robo {
  font-weight: var(--fw-semibold);
  font-size: 15px;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------------------
   8. Error page
   ------------------------------------------------------------------------- */
.error-page { text-align: center; padding-block: var(--space-8); }
.error-page h1 { font-size: 64px; }

/* ---------------------------------------------------------------------------
   8b. Legal / document pages (Оферта, Политика конфиденциальности, Соглашение)
   Long-form legal text on the dark theme: constrained measure, clear
   hierarchy, lime accents. Businesslike, readable, on-brand.
   ------------------------------------------------------------------------- */
.legal-page { padding-block: var(--space-5) var(--space-7); }

.legal {
  max-width: 900px;            /* comfortable reading measure */
  margin-inline: auto;
  color: var(--text-muted);
  font-size: var(--fs-body);
  line-height: var(--lh-base);
  text-wrap: pretty;
}

/* Document title block */
.legal > h1 {
  margin: 0 0 var(--space-4);
  padding: 0 0 var(--space-3) var(--space-3);
  border-left: 4px solid var(--accent);
  border-bottom: 1px solid var(--border-light);
  font-size: clamp(28px, 6vw, var(--fs-h1));
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  color: var(--on-dark);
}
/* Lead line right after the title (e.g. "ДОГОВОР-ОФЕРТА") */
.legal > h1 + p {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--on-dark);
}

/* Section + subsection headings */
.legal h2 {
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  color: var(--on-dark);
}
.legal h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  color: var(--on-dark);
}

/* Body copy */
.legal p { margin: 0 0 var(--space-2); }
.legal strong, .legal b { color: var(--on-dark); font-weight: var(--fw-semibold); }

.legal a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.legal a:hover, .legal a:focus-visible { filter: brightness(1.12); }

/* Lists */
.legal ul, .legal ol { margin: 0 0 var(--space-3); padding-left: var(--space-3); }
.legal li { margin-bottom: var(--space-1); }
.legal li::marker { color: var(--accent); }

/* Tables (rate cards, term tables) */
.legal table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0;
  font-size: var(--fs-caption);
}
.legal th, .legal td {
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
}
.legal th { background: var(--bg-elevated); color: var(--on-dark); font-weight: var(--fw-semibold); }

/* Misc */
.legal hr { margin: var(--space-5) 0; border: 0; border-top: 1px solid var(--border-light); }
.legal blockquote {
  margin: var(--space-3) 0;
  padding: var(--space-1) var(--space-3);
  border-left: 3px solid var(--accent);
  color: var(--text-muted-2);
}

/* ===========================================================================
   9. Responsive — mobile-first min-width breakpoints
   ========================================================================== */

/* >= 480px (large phone): brand stays full-width, link columns pair up */
@media (min-width: 480px) {
  .site-footer__top {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5) var(--space-4);
  }
  .site-footer__brand { grid-column: 1 / -1; }
}

/* >= 640px (tablet): brand + first two columns */
@media (min-width: 640px) {
  .site-footer__top {
    grid-template-columns: 1.6fr 1fr 1fr;
  }
  .site-footer__brand { grid-column: auto; }
  /* Contacts column wraps under documents/help on this width */
  .site-footer__bottom {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }
  .site-footer__pay { align-items: flex-end; text-align: right; }
  .site-footer__rights { text-align: right; max-width: 38ch; }
}

/* >= 960px (desktop): full 4-column row (brand + 3 columns) */
@media (min-width: 960px) {
  .site-footer__top {
    grid-template-columns: 1.6fr 1fr 1.2fr 1fr;
    gap: var(--space-6) var(--space-5);
  }
}

/* >= 960px (laptop / desktop): full horizontal nav, taller header */
@media (min-width: 960px) {
  :root { --fs-h1: 42px; --fs-h2: 36px; }

  [id] { scroll-margin-top: calc(var(--header-h-desktop) + 12px); }

  .site-header__inner { min-height: var(--header-h-desktop); }

  .site-header__burger { display: none; }

  .site-nav {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
  .site-nav__list { flex-direction: row; gap: var(--space-4); }
  .site-nav__cta { align-self: center; }

  .container { padding-inline: var(--space-3); }
}

/* <= 639px (large phone) typographic step-down per tokens §5 */
@media (max-width: 639px) {
  :root { --fs-h1: 36px; --fs-body-lg: 18px; }
}

/* <= 479px (phone) */
@media (max-width: 479px) {
  :root { --fs-body-lg: 16px; --lh-base: 1.45; }
}
