@charset "UTF-8";

/* Единая иерархия слоев фундамента:
   Любой кастомный CSS, написанный вне @layer, автоматически имеет приоритет без !important */
@layer tokens, base, typography, layout, components, utilities;

/* Локальные вариативные шрифты (без внешних запросов к Google Fonts и 100% совместимо с CSP) */
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter-var-italic.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Unbounded';
  src: url('/static/fonts/unbounded-cyrillic.woff2') format('woff2');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Unbounded';
  src: url('/static/fonts/unbounded-latin.woff2') format('woff2');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

@property --screen-w {
  syntax: '<length>';
  initial-value: 0px;
  inherits: false;
}

@property --fluid {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}

@property --drawer-w {
  syntax: '<length>';
  initial-value: 0px;
  inherits: false;
}

@property --drawer-fluid {
  syntax: '<number>';
  initial-value: 0;
  inherits: false;
}

@property --scale {
  syntax: '<number>';
  initial-value: 1;
  inherits: false;
}

@property --press {
  syntax: '<number>';
  initial-value: 0;
  inherits: false;
}

/* ==========================================================================
   СЛОЙ 1: DESIGN TOKENS (Ядро ISO 9241-303 + Перцептивное пространство OKLCH)
   ========================================================================== */
@layer tokens {
  :root {
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;

    --font-features-base: "cv02", "cv03", "cv04", "cv11";

    --base-min: 1rem;
    --base-max: 1.1875rem;

    --scale-min: 1.200;
    --scale-max: 1.250;

    --screen-w: min(100vi, 135vb);
    --current-rem: tan(atan2(var(--screen-w), 1rem));
    --fluid: clamp(-0.15, calc((var(--current-rem) - 23.4375) / (90 - 23.4375)), 1);
    --fluid-pos: max(0, var(--fluid));

    --type-scale: calc(var(--scale-min) + (var(--scale-max) - var(--scale-min)) * var(--fluid));
    --step-0:     calc(var(--base-min) + (var(--base-max) - var(--base-min)) * var(--fluid));

    --step--2: max(
                 calc(0.75rem + (0.8125rem - 0.75rem) * var(--fluid-pos)),
                 calc(var(--step-0) * pow(var(--type-scale), -2))
               );
    --step--1: calc(var(--step-0) * pow(var(--type-scale), -1));
    --step-1:  calc(var(--step-0) * pow(var(--type-scale), 1));
    --step-2:  calc(var(--step-0) * pow(var(--type-scale), 2));
    --step-3:  calc(var(--step-0) * pow(var(--type-scale), 3));
    --step-4:  calc(var(--step-0) * pow(var(--type-scale), 4));
    --step-5:  calc(var(--step-0) * pow(var(--type-scale), 5));

    --space-2xs: calc(0.25rem + 0.125rem * var(--fluid-pos));
    --space-xs:  calc(0.5rem  + 0.25rem  * var(--fluid-pos));
    --space-sm:  calc(0.75rem + 0.25rem  * var(--fluid-pos));
    --space-md:  calc(0.875rem + 0.625rem * var(--fluid-pos));
    --space-lg:  calc(1.25rem + 1.25rem  * var(--fluid-pos));
    --space-xl:  calc(1.75rem + 1.75rem  * var(--fluid-pos));
    --space-2xl: calc(2.25rem + 3.25rem  * var(--fluid-pos));
    --space-3xl: calc(3rem    + 5rem     * var(--fluid-pos));

    --container-max: 84rem;
    --page-gutter:   clamp(0.75rem, 4vi, 1.5rem);
    --radius-sm:     0.5rem;
    --radius-md:     0.875rem;
    --radius-lg:     calc(1rem + 0.5rem * var(--fluid-pos));
    --radius-full:   9999px;

    --hue-neutral:         286;
    --hue-brand-primary:   40.8638;
    --hue-brand-secondary: 239.03;

    --color-brand-primary:   oklch(0.684862 0.211255 var(--hue-brand-primary));
    --color-brand-secondary: oklch(0.684862 0.1544   var(--hue-brand-secondary));
    --color-brand-orange:    var(--color-brand-primary);

    --color-ink-primary:     oklch(0.183 0.004 var(--hue-neutral));
    --color-ink-secondary:   oklch(0.412 0.013 var(--hue-neutral));
    --color-ink-muted:       oklch(0.541 0.014 var(--hue-neutral));
    --color-ink-inverse:     oklch(1 0 none);

    --color-surface-bg:      oklch(1 0 none);
    --color-surface-card:    oklch(0.965 0.005 var(--hue-neutral));
    --color-surface-inverse: oklch(0.183 0.004 var(--hue-neutral));
    --color-backdrop:        oklch(0 0 none / 0.5);

    --color-border-subtle:   oklch(0.920 0.006 var(--hue-neutral));
    --color-border-strong:   oklch(0.820 0.010 var(--hue-neutral));

    --color-status-success:  oklch(0.620 0.170 148);
    --color-status-warning:  oklch(0.750 0.160 75);
    --color-status-danger:   oklch(0.580 0.210 27);
  }

  @media (color-gamut: p3) {
    :root {
      --color-brand-primary:   oklch(0.684862 0.2388 var(--hue-brand-primary));
      --color-brand-secondary: oklch(0.684862 0.2018 var(--hue-brand-secondary));
      --color-status-success:  oklch(0.620 0.205 148);
      --color-status-warning:  oklch(0.750 0.185 75);
      --color-status-danger:   oklch(0.580 0.245 27);
    }
  }

  @media (prefers-contrast: more) {
    :root {
      --color-ink-primary:     oklch(0 0 none);
      --color-ink-secondary:   oklch(0.241 0.010 var(--hue-neutral));
      --color-ink-muted:       oklch(0.370 0.012 var(--hue-neutral));
      --color-surface-card:    oklch(0.930 0.008 var(--hue-neutral));
      --color-surface-inverse: oklch(0 0 none);
      --color-border-subtle:   oklch(0.750 0.012 var(--hue-neutral));
      --color-border-strong:   oklch(0.450 0.015 var(--hue-neutral));
    }
  }
}

/* ==========================================================================
   СЛОЙ 2: БАЗОВАЯ ГИГИЕНА, КИРИЛЛИЧЕСКИЕ ПЕРЕНОСЫ И ДОСТУПНОСТЬ
   ========================================================================== */
@layer base {
  *, *::before, *::after {
    box-sizing: border-box;
  }

  html {
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    scrollbar-gutter: stable;
    scroll-padding-top: var(--scroll-padding-top, 0);
    overflow-x: clip;
  }

  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  body {
    margin: 0;
    min-width: 17.5rem;
    overflow-x: clip;
    font-family: var(--font-sans);
    font-size: var(--step-0);
    font-weight: 420;
    line-height: calc(1.45 + 0.15 * var(--fluid-pos));
    color: var(--color-ink-primary);
    background-color: var(--color-surface-bg);

    font-optical-sizing: auto;
    font-feature-settings: var(--font-features-base);
    font-synthesis: none;
    overflow-wrap: break-word;
  }

  @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }
  }

  ::selection {
    background-color: var(--color-brand-primary);
    color: var(--color-ink-inverse);
  }

  :focus-visible {
    outline: 0.125rem solid var(--color-brand-primary);
    outline-offset: 0.1875rem;
  }

  h1, h2, h3, h4, h5, h6, p, blockquote, figure, dl, dd {
    margin: 0;
    padding: 0;
  }

  ul, ol {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  :where(ul, ol):where([class], [role="list"]) {
    padding: 0;
    list-style: none;
  }

  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
  }

  svg {
    flex-shrink: 0;
    fill: currentColor;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  sub, sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  sup { top: -0.5em; }
  sub { bottom: -0.25em; }

  button, input, textarea, select {
    font: inherit;
    color: inherit;
    max-width: 100%;
  }

  ::placeholder {
    color: var(--color-ink-muted);
    opacity: 1;
  }

  button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
  }

  :where(button, [data-spring]):is(:disabled, [aria-disabled="true"]) {
    cursor: not-allowed;
  }

  [hidden] {
    display: none !important;
  }
}

/* ==========================================================================
   СЛОЙ 3: 7 АРХЕТИПОВ ТИПОГРАФИКИ
   ========================================================================== */
@layer typography {
  .display-mega {
    font-size: var(--step-5);
    font-weight: 800;
    line-height: 0.98;
    letter-spacing: -0.03em;
    text-wrap: balance;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  .display-hero {
    font-size: var(--step-4);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;
    text-wrap: balance;
    max-width: 18ch;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  .display-quote {
    font-size: var(--step-3);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.015em;
    text-wrap: balance;
    max-width: 28ch;
    overflow-wrap: anywhere;
  }

  .heading-page, :where(h1:not([class])) {
    font-size: var(--step-3);
    font-weight: 740;
    line-height: 1.15;
    text-wrap: balance;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  .heading-section, :where(h2:not([class])) {
    font-size: var(--step-2);
    font-weight: 680;
    line-height: 1.2;
    text-wrap: balance;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  .heading-modal, :where(h3:not([class])) {
    font-size: var(--step-1);
    font-weight: 620;
    line-height: 1.25;
    text-wrap: balance;
  }

  .heading-group, :where(h4, h5, h6):not([class]) {
    font-size: var(--step-0);
    font-weight: 640;
    line-height: 1.3;
  }

  .prose-lead {
    font-size: var(--step-1);
    font-weight: 420;
    line-height: 1.48;
    max-width: 54ch;
    text-wrap: pretty;
  }

  .prose-body, :where(p:not([class])) {
    font-size: var(--step-0);
    font-weight: 420;
    line-height: calc(1.45 + 0.15 * var(--fluid-pos));
    max-width: 65ch;
    text-wrap: pretty;
  }

  .prose-compact {
    font-size: var(--step--1);
    font-weight: 420;
    line-height: 1.5;
    color: var(--color-ink-secondary);
    max-width: 60ch;
    text-wrap: pretty;
  }

  :where(p:not([class]), li:not([class]), .prose-lead, .prose-body, .prose-compact, .system-legal) a:not([class]) {
    text-decoration: underline;
    text-decoration-thickness: from-font;
    text-underline-offset: 0.18em;
    text-decoration-skip-ink: auto;
    transition: color 0.15s ease;
  }

  @media (hover: hover) {
    :where(p:not([class]), li:not([class]), .prose-lead, .prose-body, .prose-compact, .system-legal) a:not([class]):hover {
      color: var(--color-brand-primary);
    }
  }

  .ui-nav-drawer {
    --drawer-w: min(100cqi, 35rem);
    --drawer-rem: tan(atan2(var(--drawer-w), 1rem));
    --drawer-fluid: clamp(0, calc((var(--drawer-rem) - 14) / (35 - 14)), 1);

    font-size: calc(1rem + (1.4375rem - 1rem) * var(--drawer-fluid));
    font-weight: 540;
    line-height: 1.25;
    text-align: left;
    text-wrap: balance;
    user-select: none;
    transition: color 0.2s ease;
  }

  @media (prefers-reduced-motion: no-preference) {
    .ui-nav-drawer {
      transition: color 0.2s ease, translate 0.2s ease;
    }
  }

  @media (hover: hover) {
    .ui-nav-drawer:hover {
      color: var(--color-brand-primary);
      translate: 0.25rem 0;
    }
  }

  .ui-nav-drawer--accent {
    font-weight: 640;
    color: var(--color-brand-primary);
  }

  .ui-nav-inline {
    font-size: var(--step-0);
    font-weight: 540;
    line-height: 1.1;
    user-select: none;
    white-space: nowrap;
  }

  .ui-button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    font-size: var(--step-0);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.01em;
    text-box: trim-both cap alphabetic;
    text-align: center;
    user-select: none;
    white-space: nowrap;
  }

  .ui-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    font-size: var(--step--1);
    font-weight: 580;
    line-height: 1.1;
    text-box: trim-both cap alphabetic;
    user-select: none;
    white-space: nowrap;
  }

  .ui-input {
    font-size: var(--step-0);
    font-weight: 420;
    line-height: 1.4;
  }

  .ui-label {
    display: block;
    font-size: var(--step--1);
    font-weight: 560;
    line-height: 1.3;
  }

  .data-price-lg {
    font-size: var(--step-2);
    font-weight: 740;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
  }

  .data-price-md {
    font-size: var(--step-1);
    font-weight: 660;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
  }

  .data-price-strike {
    font-size: var(--step--1);
    font-weight: 420;
    font-variant-numeric: tabular-nums;
    text-decoration: line-through;
    color: var(--color-ink-muted);
    white-space: nowrap;
  }

  .data-timer {
    font-size: var(--step-1);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
  }

  .data-code {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    font-weight: 500;
    font-feature-settings: normal;
    font-variant-numeric: tabular-nums slashed-zero;
    letter-spacing: 0.02em;
  }

  .data-metric {
    font-size: var(--step--1);
    font-weight: 540;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
  }

  .meta-card-title {
    font-size: var(--step-0);
    font-weight: 500;
    line-height: 1.35;
    text-wrap: balance;
  }

  .meta-eyebrow {
    font-size: var(--step--1);
    font-weight: 640;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.2;
  }

  .meta-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    font-size: var(--step--2);
    font-weight: 680;
    font-variant-numeric: tabular-nums;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
    text-box: trim-both cap alphabetic;
    white-space: nowrap;
  }

  .meta-status {
    font-size: var(--step--1);
    font-weight: 560;
    line-height: 1.25;
  }

  .meta-breadcrumb {
    font-size: var(--step--1);
    font-weight: 440;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    color: var(--color-ink-muted);
  }

  .system-legal {
    font-size: var(--step--1);
    font-weight: 400;
    line-height: 1.45;
    color: var(--color-ink-muted);
    hyphens: auto;
  }

  .system-tooltip {
    font-size: var(--step--2);
    font-weight: 480;
    line-height: 1.3;
    color: var(--color-ink-inverse);
    background-color: var(--color-surface-inverse);
    max-width: min(100%, 28ch);
  }

  .system-kbd, :where(kbd:not([class])) {
    display: inline-block;
    padding: 0.2em 0.45em;
    font-family: var(--font-mono);
    font-size: var(--step--2);
    font-weight: 500;
    font-feature-settings: normal;
    line-height: 1;
    background-color: var(--color-surface-card);
    border: 0.0625rem solid var(--color-border-strong);
    border-radius: 0.35rem;
    box-shadow: 0 0.0625rem 0 var(--color-border-strong);
  }
}

/* ==========================================================================
   СЛОЙ 4: РАСКЛАДКА И СЕТКИ
   ========================================================================== */
@layer layout {
  .container {
    width: min(100% - var(--page-gutter) * 2, var(--container-max));
    margin-inline: auto;
    padding-inline-start: env(safe-area-inset-left, 0);
    padding-inline-end: env(safe-area-inset-right, 0);
  }

  .grid-auto {
    --grid-min: 16rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--grid-min)), 1fr));
    gap: var(--space-md);
  }

  .stack {
    display: flex;
    flex-direction: column;
    gap: var(--stack-gap, var(--space-md));
    min-width: 0;
  }

  .cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--cluster-gap, var(--space-xs));
    min-width: 0;
  }

  :where(.grid-auto, .stack, .cluster) > * {
    min-width: 0;
    max-width: 100%;
  }
}

/* ==========================================================================
   СЛОЙ 5: ФИЗИЧЕСКИЕ ПРИМИТИВЫ И ПОВЕРХНОСТИ (Material 3 Springs)
   ========================================================================== */
@layer components {
  [data-spring] {
    --scale: 1;
    --press: 0;

    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  [data-spring][data-spring-active] {
    scale: var(--scale);
  }

  .btn, .ui-button {
    --btn-shadow-color: oklch(0.183 0.004 var(--hue-neutral) / 0.2);

    transform-origin: center center;
    box-shadow:
      0
      calc((1 - var(--press)) * 0.35rem)
      calc((1 - var(--press)) * 1rem)
      var(--btn-shadow-color);
  }

  :is(.btn, .ui-button)[data-spring-active] {
    filter: brightness(calc(1 - var(--press) * 0.15));
  }

  .card {
    --card-shadow-color: oklch(0 0 none / 0.08);

    min-width: 0;
    background-color: var(--color-surface-card);
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow:
      0
      calc((1 - var(--press)) * 0.5rem)
      calc((1 - var(--press)) * 1.5rem)
      var(--card-shadow-color);
  }

  .ui-input {
    width: 100%;
    padding: 0.75em 1em;
    background-color: var(--color-surface-bg);
    border: 0.0625rem solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .ui-input:focus-visible {
    outline: none;
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 0.1875rem color-mix(in oklch, var(--color-brand-primary) 22%, transparent);
  }

  .ui-input:is(:user-invalid, [aria-invalid="true"]) {
    border-color: var(--color-status-danger);
  }

  .backdrop {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-backdrop);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 100;
    touch-action: none;
  }

  /* Симметричные боковые шторки без постоянного will-change в закрытом состоянии */
  .drawer, .drawer-menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: min(85vi, 24rem);
    max-width: calc(100vi - 2.5rem);
    height: 100%;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background-color: var(--color-surface-bg);
    box-shadow:
      -6rem 0 0 0 var(--color-surface-bg),
      0.5rem 0 2rem oklch(0 0 none / 0.15);
    z-index: 101;
    container-type: inline-size;
    container-name: drawer;
    transform-origin: left center;
    transform: translate3d(-100%, 0, 0);
    visibility: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    overscroll-behavior: contain;
  }

  .drawer[data-menu-side="right"] {
    left: auto;
    right: 0;
    box-shadow:
      6rem 0 0 0 var(--color-surface-bg),
      -0.5rem 0 2rem oklch(0 0 none / 0.15);
    transform-origin: right center;
    transform: translate3d(100%, 0, 0);
  }
}

/* ==========================================================================
   СЛОЙ 6: УТИЛИТЫ
   ========================================================================== */
@layer utilities {
  .tabular-nums       { font-variant-numeric: tabular-nums; }
  .diagonal-fractions { font-variant-numeric: diagonal-fractions; }
  .superscript        { font-variant-position: super; }

  .text-primary          { color: var(--color-ink-primary); }
  .text-secondary        { color: var(--color-ink-secondary); }
  .text-muted            { color: var(--color-ink-muted); }
  .text-inverse          { color: var(--color-ink-inverse); }
  .text-accent           { color: var(--color-brand-primary); }
  .text-accent-secondary { color: var(--color-brand-secondary); }
  .text-success          { color: var(--color-status-success); }
  .text-warning          { color: var(--color-status-warning); }
  .text-danger           { color: var(--color-status-danger); }

  .truncate-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .line-clamp-2 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  .line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }
}
