/* ==========================================================
   ONE DESIGN — стили
   Современный CSS: cascade layers, light-dark(), nesting,
   container queries, :has(), scroll-driven animations,
   popover API, view transitions.
   ========================================================== */

/* Шрифт Manrope (variable, self-hosted) */
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(../fonts/manrope-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(../fonts/manrope-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(../fonts/manrope-latin.woff2) format("woff2");
  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;
}

@layer reset, tokens, base, layout, components, sections, utilities;

/* ---------- RESET ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, video { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  p, h1, h2, h3 { overflow-wrap: break-word; }
  h1, h2, h3 { text-wrap: balance; }
  p { text-wrap: pretty; }
}

/* ---------- TOKENS ---------- */
@layer tokens {
  :root {
    color-scheme: light;

    --navy: #1f2f6e;
    --blue: #0f6fe8;
    --sky: #22a8ff;
    --grad: linear-gradient(120deg, #1157d9 0%, #1e8cff 55%, #22a8ff 100%);

    --bg:        light-dark(#ffffff, #0b1330);
    --bg-alt:    light-dark(#f4f7fd, #0f1a3d);
    --surface:   light-dark(#ffffff, #132048);
    --surface-2: light-dark(#eef3fc, #1a2a5a);
    --text:      light-dark(#14204a, #e9eefc);
    --muted:     light-dark(#55618a, #a3b0d6);
    --border:    light-dark(#e2e8f5, #24356b);
    --accent:    light-dark(#0a5fcc, #4fb4ff);
    --accent-ink:#ffffff;
    --logo-dark: light-dark(#1f2f6e, #dbe5ff);
    --ring:      light-dark(#0a5fcc, #7cc8ff);
    --shadow-sm: 0 1px 2px rgb(16 32 80 / .06), 0 2px 8px rgb(16 32 80 / .05);
    --shadow-lg: 0 24px 60px -20px rgb(16 40 120 / .35);

    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --step--1: clamp(.85rem, .82rem + .15vw, .94rem);
    --step-0:  clamp(1rem, .96rem + .2vw, 1.125rem);
    --step-1:  clamp(1.2rem, 1.1rem + .45vw, 1.45rem);
    --step-2:  clamp(1.6rem, 1.3rem + 1.4vw, 2.6rem);
    --step-3:  clamp(2.6rem, 1.8rem + 4vw, 5.25rem);

    --radius: 18px;
    --radius-lg: 28px;
    --gutter: clamp(16px, 4vw, 40px);
    --container: 1200px;
    --header-h: 72px;
    --ease-out: cubic-bezier(.22, 1, .36, 1);
  }

  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"]  { color-scheme: dark; }
}

/* ---------- BASE ---------- */
@layer base {
  html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
    hanging-punctuation: first last;
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
    }
  }

  body {
    font-family: var(--font);
    font-size: var(--step-0);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: clip;
  }

  h1, h2, h3 { line-height: 1.1; letter-spacing: -.02em; font-weight: 800; }
  h2 { font-size: var(--step-2); }
  h3 { font-size: var(--step-1); font-weight: 700; letter-spacing: -.01em; }

  a { color: inherit; text-decoration: none; }
  :focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: 6px; }
  ::selection { background: var(--accent); color: #fff; }

  svg:not([fill]) { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  svg.brand-mark, svg.hero-logo { stroke: none; }
}

/* ---------- LAYOUT ---------- */
@layer layout {
  .container {
    width: min(100% - 2 * var(--gutter), var(--container));
    margin-inline: auto;
  }
  .section { padding-block: clamp(72px, 10vw, 128px); }
  .section-alt { background: var(--bg-alt); }
  .section-head {
    max-width: 680px;
    margin-bottom: clamp(36px, 5vw, 56px);
    & h2 { margin-top: 12px; }
  }
}

/* ---------- COMPONENTS ---------- */
@layer components {
  .skip-link {
    position: fixed; top: 12px; left: 12px; z-index: 100;
    padding: 10px 16px; border-radius: 10px;
    background: var(--accent); color: #fff; font-weight: 700;
    translate: 0 -200%;
    transition: translate .2s;
    &:focus { translate: 0 0; }
  }

  .eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: var(--step--1); font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--accent);
    & svg { width: 16px; height: 16px; }
  }

  .grad-text {
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
  }

  /* Кнопки */
  .btn {
    --_bg: var(--surface-2);
    --_fg: var(--text);
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 48px; padding: 12px 22px;
    border: 1px solid transparent; border-radius: 999px;
    background: var(--_bg); color: var(--_fg);
    font-weight: 700; font-size: var(--step-0); line-height: 1.2;
    cursor: pointer; white-space: nowrap;
    transition: transform .25s var(--ease-out), box-shadow .25s, background-color .25s;
    & svg { width: 20px; height: 20px; flex: none; transition: translate .25s var(--ease-out); }
    &:hover svg:last-child { translate: 3px 0; }
    &:active { transform: scale(.98); }
  }
  .btn-primary {
    --_bg: var(--grad); --_fg: #fff;
    background: var(--grad);
    box-shadow: 0 10px 24px -10px rgb(17 87 217 / .65);
    &:hover { box-shadow: 0 16px 32px -12px rgb(17 87 217 / .75); transform: translateY(-1px); }
  }
  .btn-ghost {
    background: transparent;
    border-color: var(--border);
    &:hover { background: var(--surface-2); }
  }
  .btn-lg { min-height: 56px; padding: 14px 28px; }
  .btn-block { width: 100%; }

  .icon-btn {
    display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); cursor: pointer;
    transition: background-color .2s;
    &:hover { background: var(--surface-2); }
    & svg { width: 20px; height: 20px; }
  }

  /* Логотип */
  .brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 800; letter-spacing: .02em; font-size: 1.1rem;
    color: var(--text);
  }
  .brand-mark { width: 40px; height: 30px; }

  /* Карточки */
  .cards {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  }
  .card {
    padding: 28px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform .35s var(--ease-out), box-shadow .35s, border-color .35s;
    & h3 { margin: 20px 0 8px; }
    & p { color: var(--muted); }
    &:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
  }
  .card-icon {
    display: grid; place-items: center; flex: none;
    width: 52px; height: 52px; border-radius: 14px;
    background: color-mix(in oklab, var(--accent) 12%, transparent);
    color: var(--accent);
    & svg { width: 26px; height: 26px; }
  }

  /* Поля формы */
  .field {
    display: grid; gap: 6px;
    & label { font-size: var(--step--1); font-weight: 600; color: var(--muted); }
    & .opt { font-weight: 400; opacity: .8; }
  }
  .field input, .field select, .field textarea {
    width: 100%; min-height: 50px;
    padding: 12px 16px;
    border: 1px solid var(--border); border-radius: 14px;
    background: var(--bg);
    transition: border-color .2s, box-shadow .2s;
    &::placeholder { color: color-mix(in oklab, var(--muted) 70%, transparent); }
    &:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 20%, transparent); }
    &:user-invalid { border-color: #e5484d; box-shadow: 0 0 0 4px rgb(229 72 77 / .15); }
  }
  .field textarea { resize: vertical; min-height: 96px; field-sizing: content; }
  .field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
}

/* ---------- SECTIONS ---------- */
@layer sections {

  /* Шапка */
  .site-header {
    position: sticky; top: 0; z-index: 50;
    height: var(--header-h);
    display: flex; align-items: center;
    background: color-mix(in oklab, var(--bg) 78%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color .3s, box-shadow .3s;
    &.is-scrolled { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }
  }
  .header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .header-actions { display: flex; align-items: center; gap: 8px; }
  .header-phone {
    display: none; align-items: center; gap: 8px;
    font-weight: 700; padding: 10px 14px; border-radius: 12px;
    & svg { width: 18px; height: 18px; color: var(--accent); }
    &:hover { background: var(--surface-2); }
  }

  [data-theme-toggle] .t-moon { display: none; }
  :root[data-theme="dark"] [data-theme-toggle] .t-sun { display: none; }
  :root[data-theme="dark"] [data-theme-toggle] .t-moon { display: block; }

  /* Навигация: на мобильных — popover, на десктопе — обычная строка */
  .nav {
    & ul { display: flex; gap: 4px; }
    & ul a {
      display: block; padding: 10px 14px; border-radius: 12px;
      font-weight: 600; color: var(--muted);
      transition: color .2s, background-color .2s;
      &:hover, &[aria-current="true"] { color: var(--text); background: var(--surface-2); }
    }
  }
  .nav-close, .nav-cta { display: none; }

  @media (width < 960px) {
    .nav[popover] {
      position: fixed; inset: 0 0 0 auto;
      width: min(360px, 100%); height: 100dvh; max-height: none;
      margin: 0; padding: 24px;
      border: 0; border-left: 1px solid var(--border);
      background: var(--bg); color: var(--text);
      flex-direction: column; gap: 24px;
      translate: 100% 0;
      transition: translate .4s var(--ease-out), display .4s allow-discrete, overlay .4s allow-discrete;
      &:popover-open { display: flex; translate: 0 0; @starting-style { translate: 100% 0; } }
      &::backdrop { background: rgb(5 10 30 / .5); backdrop-filter: blur(3px); }
      & ul { flex-direction: column; gap: 4px; }
      & ul a { font-size: var(--step-1); padding: 14px 16px; color: var(--text); }
      & .nav-close { display: grid; align-self: flex-end; }
      & .nav-cta { display: inline-flex; margin-top: auto; }
    }
  }
  @media (width >= 960px) {
    .nav[popover] {
      display: block; position: static; inset: auto;
      margin: 0; padding: 0; border: 0; background: none; color: inherit;
      width: auto; height: auto; overflow: visible;
    }
    .menu-btn { display: none; }
    .header-phone { display: inline-flex; }
  }

  /* Hero */
  .hero {
    position: relative; isolation: isolate;
    padding-block: clamp(48px, 8vw, 110px) clamp(64px, 9vw, 120px);
    overflow: clip;
  }
  .hero-bg {
    position: absolute; inset: 0; z-index: -1;
    background:
      radial-gradient(60% 55% at 85% 20%, color-mix(in oklab, var(--sky) 22%, transparent), transparent 70%),
      radial-gradient(45% 50% at 10% 90%, color-mix(in oklab, var(--blue) 14%, transparent), transparent 70%),
      linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 56px 56px,
      linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 56px 56px;
    mask-image: radial-gradient(ellipse 90% 80% at 60% 40%, #000 30%, transparent 80%);
    opacity: .9;
  }
  .hero-grid {
    display: grid; align-items: center;
    gap: clamp(40px, 6vw, 72px);
    grid-template-columns: 1fr;
    @media (width >= 900px) { grid-template-columns: 1.1fr .9fr; }
  }
  .hero h1 { font-size: var(--step-3); margin-block: 16px 20px; letter-spacing: -.035em; }
  .lead { font-size: var(--step-1); color: var(--muted); max-width: 34ch; line-height: 1.5; }
  .hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

  .hero-facts {
    display: grid; grid-template-columns: repeat(3, auto); justify-content: start;
    gap: 12px clamp(20px, 4vw, 44px);
    margin-top: 44px; padding-top: 28px;
    border-top: 1px solid var(--border);
    & dt { font-size: var(--step--1); color: var(--muted); }
    & dd { font-weight: 800; font-size: var(--step-1); margin: 0; }
    & small { font-size: .7em; font-weight: 600; color: var(--muted); }
    @media (width < 520px) { grid-template-columns: 1fr 1fr; & > :first-child { grid-column: 1 / -1; } }
  }

  .hero-visual {
    position: relative;
    max-width: 520px; width: 100%;
    justify-self: center;
  }
  .hero-card {
    aspect-ratio: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
    padding: 12%;
    border-radius: var(--radius-lg);
    background:
      radial-gradient(80% 80% at 50% 0%, color-mix(in oklab, var(--sky) 16%, transparent), transparent),
      var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: float 8s ease-in-out infinite;
  }
  .hero-logo { width: 100%; aspect-ratio: 680 / 480; filter: drop-shadow(0 18px 30px rgb(17 87 217 / .3)); }
  .hero-wordmark {
    font-weight: 800; letter-spacing: .12em;
    font-size: clamp(1.2rem, 1rem + 1.5vw, 2rem);
    color: var(--logo-dark);
  }
  .float-badge {
    position: absolute;
    display: inline-flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 14px;
    font-size: var(--step--1); font-weight: 700;
    background: color-mix(in oklab, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    & svg { width: 20px; height: 20px; color: var(--accent); }
  }
  .fb-1 { left: -6%; bottom: -22px; animation: float 7s ease-in-out -2s infinite; }
  .fb-2 { right: -4%; top: 10%; animation: float 9s ease-in-out -4s infinite; }
  @media (width < 600px) { .fb-1 { left: 0; bottom: -18px; } .fb-2 { right: 0; top: -18px; } }

  @keyframes float { 50% { translate: 0 -10px; } }

  /* Услуги */
  .services {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
  .service {
    container-type: inline-size;
    position: relative; overflow: hidden;
    padding: 32px 28px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: transform .35s var(--ease-out), box-shadow .35s;
    & h3 { margin: 28px 0 8px; }
    & p { color: var(--muted); }
    &::after {
      content: ""; position: absolute; inset: auto 0 0 0; height: 4px;
      background: var(--grad);
      scale: 0 1; transform-origin: left;
      transition: scale .5s var(--ease-out);
    }
    &:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); &::after { scale: 1 1; } }
  }
  .service-num {
    position: absolute; top: 20px; right: 24px;
    font-weight: 800; font-size: 2.6rem; line-height: 1;
    color: color-mix(in oklab, var(--accent) 14%, transparent);
  }
  .service-icon { width: 44px; height: 44px; color: var(--accent); stroke-width: 1.5; }
  @container (width > 360px) { .service h3 { font-size: 1.6rem; } }

  /* Калькулятор */
  .calc {
    display: grid; gap: clamp(32px, 5vw, 64px); align-items: center;
    @media (width >= 900px) { grid-template-columns: 1fr 1fr; }
  }
  .calc-copy {
    & h2 { margin: 12px 0 16px; }
    & p { color: var(--muted); max-width: 46ch; }
    & strong { color: var(--text); }
  }
  .calc-box {
    display: grid; gap: 16px;
    padding: clamp(24px, 4vw, 40px);
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .calc-label { font-weight: 700; color: var(--muted); font-size: var(--step--1); text-transform: uppercase; letter-spacing: .06em; }
  .calc-area {
    display: flex; align-items: baseline; gap: 8px;
    & input {
      -moz-appearance: textfield;
      width: 3ch; border: 0; background: none; padding: 0;
      font-size: clamp(2.6rem, 2rem + 2.5vw, 3.6rem); font-weight: 800; letter-spacing: -.03em;
      font-variant-numeric: tabular-nums;
      min-width: 1.2ch;
      &:focus-visible { outline: none; text-decoration: underline 3px var(--accent); text-underline-offset: 6px; }
      &::-webkit-inner-spin-button { display: none; }
    }
    & span { font-size: var(--step-1); font-weight: 700; color: var(--muted); }
  }
  input[type="range"] {
    --_p: 17%;
    appearance: none; width: 100%; height: 8px; border-radius: 99px; cursor: pointer;
    background: linear-gradient(90deg, var(--blue), var(--sky)) 0 0 / var(--_p) 100% no-repeat, var(--surface-2);
    &::-webkit-slider-thumb {
      appearance: none; width: 28px; height: 28px; border-radius: 50%;
      background: #fff; border: 6px solid var(--blue);
      box-shadow: 0 4px 12px rgb(17 87 217 / .4);
      transition: scale .2s;
    }
    &::-moz-range-thumb {
      width: 16px; height: 16px; border-radius: 50%;
      background: #fff; border: 6px solid var(--blue);
      box-shadow: 0 4px 12px rgb(17 87 217 / .4);
    }
    &:active::-webkit-slider-thumb { scale: 1.15; }
  }
  .calc-scale { display: flex; justify-content: space-between; font-size: var(--step--1); color: var(--muted); }
  .calc-result {
    display: grid; gap: 4px;
    margin-top: 8px; padding: 20px 24px;
    border-radius: var(--radius);
    background: color-mix(in oklab, var(--accent) 9%, transparent);
  }
  .calc-result-label { font-size: var(--step--1); color: var(--muted); font-weight: 600; }
  .calc-result-value {
    font-size: var(--step-2); font-weight: 800; letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    & b { color: var(--accent); }
  }
  .calc-note { font-size: var(--step--1); color: var(--muted); text-align: center; }

  /* Этапы */
  /* Блок «Этапы» — светлый */
  .section-dark {
    background:
      radial-gradient(60% 80% at 100% 0%, color-mix(in oklab, var(--sky) 14%, transparent), transparent 60%),
      radial-gradient(50% 70% at 0% 100%, color-mix(in oklab, var(--blue) 10%, transparent), transparent 60%),
      var(--bg-alt);
  }
  .steps {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    counter-reset: step;
  }
  .step {
    position: relative;
    padding: 28px 24px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    & h3 { margin: 20px 0 8px; font-size: 1.25rem; }
    & p { color: var(--muted); font-size: var(--step--1); }
  }
  .step-n {
    display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--grad); color: #fff; font-weight: 800;
    box-shadow: 0 0 0 6px rgb(34 168 255 / .15);
  }
  @media (width >= 1100px) {
    .step:not(:last-child)::after {
      content: ""; position: absolute; top: 49px; left: calc(24px + 44px + 12px); right: -8px;
      height: 2px;
      background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 50%, transparent), transparent);
    }
  }

  /* Контакты */
  .contact {
    display: grid; gap: clamp(32px, 5vw, 64px); align-items: start;
    @media (width >= 900px) { grid-template-columns: .9fr 1.1fr; }
  }
  .contact-copy {
    & h2 { margin: 12px 0 16px; }
    & > p { color: var(--muted); }
  }
  .contact-phone {
    display: inline-flex; align-items: center; gap: 16px;
    margin-top: 32px; padding: 16px 24px 16px 16px;
    border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    font-size: var(--step-1); font-weight: 800;
    transition: border-color .2s, box-shadow .2s;
    & small { display: block; font-size: var(--step--1); font-weight: 600; color: var(--muted); }
    &:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
  }
  .contact-meta {
    display: flex; align-items: center; gap: 8px; margin-top: 20px; color: var(--muted);
    & svg { width: 18px; height: 18px; }
  }
  .lead-form {
    display: grid; gap: 16px;
    padding: clamp(24px, 4vw, 40px);
    border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    & h3 { margin-bottom: 4px; }
  }
  .field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
  .form-note {
    font-size: var(--step--1); color: var(--muted); text-align: center;
    &.is-error { color: #e5484d; font-weight: 600; }
    &.is-ok { color: #16a34a; font-weight: 600; }
  }

  /* Подвал */
  .site-footer {
    padding-block: 40px calc(40px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--muted); font-size: var(--step--1);
  }
  .footer-inner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px;
    & a:not(.brand) { font-weight: 700; color: var(--text); }
  }

  /* Плавающая кнопка звонка (мобильные) */
  .fab {
    position: fixed; z-index: 40;
    right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
    display: grid; place-items: center;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--grad); color: #fff;
    box-shadow: 0 12px 30px -8px rgb(17 87 217 / .7);
    & svg { width: 26px; height: 26px; }
    &::before {
      content: ""; position: absolute; inset: 0; border-radius: inherit;
      border: 2px solid var(--sky);
      animation: pulse 2.4s var(--ease-out) infinite;
    }
    @media (width >= 960px) { display: none; }
  }
  @keyframes pulse { from { scale: 1; opacity: .8; } to { scale: 1.6; opacity: 0; } }
}

/* ---------- UTILITIES / АНИМАЦИИ ПОЯВЛЕНИЯ ---------- */
@layer utilities {
  /* Прогрессивное улучшение: scroll-driven animations, где поддерживаются */
  @media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: view()) {
      .reveal {
        animation: reveal linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 40%;
      }
    }
    /* Фолбэк через IntersectionObserver (класс ставит JS) */
    @supports not (animation-timeline: view()) {
      .js .reveal { opacity: 0; translate: 0 28px; transition: opacity .7s var(--ease-out), translate .7s var(--ease-out); }
      .js .reveal.is-visible { opacity: 1; translate: 0 0; }
    }
  }
  @keyframes reveal { from { opacity: 0; translate: 0 32px; } to { opacity: 1; translate: 0 0; } }

  /* View Transitions при смене темы */
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
  ::view-transition-new(root) { animation: theme-in .6s var(--ease-out); }
  @keyframes theme-in { from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); } to { clip-path: circle(150vmax at var(--vt-x, 100%) var(--vt-y, 0)); } }
}

/* ==========================================================
   БЛОГ
   ========================================================== */
@layer sections {
  .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .section-tight { padding-block: clamp(48px, 7vw, 88px); }
  .section-head-row {
    max-width: none;
    display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 20px;
  }

  /* Карточки статей */
  .posts {
    display: grid; gap: 24px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  }
  .post-card { display: flex; }
  .post-card-link {
    display: flex; flex-direction: column; width: 100%;
    border-radius: var(--radius); overflow: hidden;
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform .35s var(--ease-out), box-shadow .35s, border-color .35s;
    &:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
    &:hover .post-cover svg { scale: 1.08; rotate: -4deg; }
    &:hover h2, &:hover h3 { color: var(--accent); }
  }
  .post-card-body {
    display: flex; flex-direction: column; gap: 10px; flex: 1;
    padding: 22px 24px 24px;
    & h2, & h3 { font-size: 1.25rem; line-height: 1.25; transition: color .2s; }
    & > p:not(.post-meta) { color: var(--muted); font-size: var(--step--1); flex: 1; }
    & time { font-size: var(--step--1); color: var(--muted); }
  }

  /* Обложки — генеративные, по рубрике */
  .post-cover {
    --c1: #1157d9; --c2: #22a8ff;
    position: relative; aspect-ratio: 16 / 9;
    display: grid; place-items: center; overflow: hidden;
    background:
      linear-gradient(rgb(255 255 255 / .12) 1px, transparent 1px) 0 0 / 28px 28px,
      linear-gradient(90deg, rgb(255 255 255 / .12) 1px, transparent 1px) 0 0 / 28px 28px,
      radial-gradient(circle at 80% 15%, rgb(255 255 255 / .35), transparent 45%),
      linear-gradient(135deg, var(--c1), var(--c2));
    color: #fff;
    & svg { width: 30%; max-width: 120px; height: auto; aspect-ratio: 1; stroke-width: 1.2; filter: drop-shadow(0 10px 20px rgb(0 0 0 / .25)); transition: scale .5s var(--ease-out), rotate .5s var(--ease-out); }
    &[data-cat="repair"] { --c1: #1f2f6e; --c2: #1e8cff; }
    &[data-cat="tips"]   { --c1: #0a7d8c; --c2: #36c6d9; }
    &[data-cat="build"]  { --c1: #3b2a8f; --c2: #4f7dff; }
  }
  .post-cover-lg {
    aspect-ratio: 21 / 7; border-radius: var(--radius-lg);
    & svg { width: 14%; max-width: 160px; }
    @media (width < 600px) { aspect-ratio: 16 / 8; & svg { width: 26%; } }
  }

  .post-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
    font-size: var(--step--1); color: var(--muted);
    & span, & time { display: inline-flex; align-items: center; gap: 6px; }
    & svg { width: 16px; height: 16px; }
  }
  .tag {
    --t: #0a5fcc;
    padding: 3px 10px; border-radius: 999px;
    font-weight: 700; font-size: .8rem;
    color: var(--t); background: color-mix(in oklab, var(--t) 12%, transparent);
    &[data-cat="repair"] { --t: light-dark(#1f3f9e, #8fb2ff); }
    &[data-cat="tips"]   { --t: light-dark(#06606c, #5fd6e6); }
    &[data-cat="build"]  { --t: light-dark(#4b35b8, #a99bff); }
    &[data-cat="design"] { --t: light-dark(#0a5fcc, #5cc0ff); }
  }

  /* Шапка блога */
  .blog-hero {
    position: relative; isolation: isolate; overflow: clip;
    padding-block: clamp(48px, 7vw, 96px) clamp(16px, 3vw, 32px);
    & h1 { font-size: clamp(2.2rem, 1.5rem + 3.5vw, 4.25rem); letter-spacing: -.035em; margin: 14px 0 18px; }
    & .lead { max-width: 52ch; }
  }
  .blog-list { padding-top: clamp(24px, 4vw, 40px); }

  /* Фильтр рубрик: radio + :has(), без JS */
  .filters {
    display: flex; flex-wrap: wrap; gap: 8px;
    border: 0; padding: 0; margin: 0 0 32px;
    & label {
      display: inline-flex; align-items: center; gap: 8px;
      padding: 10px 18px; border-radius: 999px; cursor: pointer;
      border: 1px solid var(--border); background: var(--surface);
      font-weight: 700; font-size: var(--step--1);
      transition: background-color .2s, color .2s, border-color .2s;
      &:hover { border-color: var(--accent); }
      &:has(:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
      &:has(:focus-visible) { outline: 3px solid var(--ring); outline-offset: 3px; }
      & small { opacity: .75; font-weight: 600; }
      &:has(:checked) small { opacity: 1; }
    }
    & input { position: absolute; opacity: 0; pointer-events: none; }
  }
  .blog-list:has(input[value="design"]:checked) .post-card:not([data-cat="design"]),
  .blog-list:has(input[value="repair"]:checked) .post-card:not([data-cat="repair"]),
  .blog-list:has(input[value="tips"]:checked)   .post-card:not([data-cat="tips"]),
  .blog-list:has(input[value="build"]:checked)  .post-card:not([data-cat="build"]) { display: none; }

  /* CTA-полоса */
  .cta-band {
    display: grid; gap: 28px; align-items: center;
    padding: clamp(28px, 5vw, 56px);
    border-radius: var(--radius-lg);
    color: #fff;
    background:
      radial-gradient(60% 120% at 100% 0%, rgb(255 255 255 / .22), transparent 60%),
      linear-gradient(120deg, #0f5fd8, #1e8cff);
    box-shadow: var(--shadow-lg);
    & h2 { color: #fff; }
    & p { color: rgb(255 255 255 / .92); margin-top: 10px; max-width: 52ch; }
    @media (width >= 900px) { grid-template-columns: 1fr auto; }
  }
  .cta-band-actions { display: flex; flex-wrap: wrap; gap: 12px; }
  .btn-light { background: #fff; color: #0f5fd8; &:hover { transform: translateY(-1px); } }
  .btn-outline-light { background: transparent; color: #fff; border-color: rgb(255 255 255 / .4); &:hover { background: rgb(255 255 255 / .1); } }

  /* Статья */
  .read-progress {
    position: fixed; inset: 0 0 auto 0; z-index: 60; height: 3px;
    background: var(--grad);
    transform-origin: left; scale: 0 1;
    display: none;
  }
  @supports (animation-timeline: scroll()) {
    .read-progress { display: block; animation: progress linear both; animation-timeline: scroll(root); }
  }
  @keyframes progress { to { scale: 1 1; } }

  .article-head {
    position: relative; isolation: isolate; overflow: clip;
    padding-block: clamp(28px, 5vw, 56px) clamp(28px, 4vw, 40px);
    & h1 { font-size: clamp(2rem, 1.4rem + 3vw, 3.6rem); letter-spacing: -.03em; margin: 18px 0 18px; max-width: 22ch; }
    & .lead { max-width: 60ch; }
  }
  .breadcrumbs {
    margin-bottom: 22px;
    & ol { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--step--1); color: var(--muted); }
    & li:not(:last-child)::after { content: "/"; margin-left: 6px; opacity: .5; }
    & a:hover { color: var(--accent); }
    & [aria-current] { color: var(--text); display: inline-block; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
  }

  .article-layout {
    display: grid; gap: 48px;
    padding-block: clamp(32px, 5vw, 56px) clamp(64px, 8vw, 104px);
    @media (width >= 1000px) { grid-template-columns: 260px minmax(0, 1fr); gap: 64px; }
  }
  .toc {
    align-self: start;
    padding: 22px; border-radius: var(--radius);
    background: var(--bg-alt); border: 1px solid var(--border);
    @media (width >= 1000px) { position: sticky; top: calc(var(--header-h) + 24px); }
    & ol { display: grid; gap: 2px; counter-reset: toc; }
    & li { counter-increment: toc; }
    & a {
      display: grid; grid-template-columns: 22px 1fr; gap: 4px;
      padding: 7px 8px; border-radius: 10px;
      font-size: var(--step--1); color: var(--muted); line-height: 1.4;
      &::before { content: counter(toc); font-weight: 800; color: var(--accent); }
      &:hover { background: var(--surface); color: var(--text); }
    }
  }
  .toc-title { font-weight: 800; margin-bottom: 10px; }
  .share-btn { width: 100%; margin-top: 16px; min-height: 44px; font-size: var(--step--1); }

  .prose {
    max-width: 72ch;
    font-size: clamp(1.02rem, .98rem + .2vw, 1.14rem);
    line-height: 1.75;
    & > * + * { margin-top: 1.1em; }
    & h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.95rem); margin-top: 2em; scroll-margin-top: calc(var(--header-h) + 20px); }
    & h2 + * { margin-top: .7em; }
    & ul { padding-left: 1.2em; display: grid; gap: .5em; }
    & li::marker { color: var(--accent); }
    & strong { color: var(--text); font-weight: 700; }
    & p, & li { color: color-mix(in oklab, var(--text) 88%, var(--muted)); }
    & > p:first-child { font-size: 1.12em; color: var(--text); }
  }
  .tip {
    padding: 18px 22px; border-radius: 16px;
    background: color-mix(in oklab, var(--accent) 8%, transparent);
    border-left: 4px solid var(--accent);
    font-size: .95em;
    & strong { color: var(--accent); }
  }
  .article-cta {
    display: grid; gap: 18px; align-items: center;
    margin-top: 3em !important; padding: 24px;
    border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    & p { margin: 0; font-size: var(--step--1); color: var(--muted); }
    & .article-cta-title { font-weight: 800; color: var(--text); font-size: 1.1rem; margin-bottom: 4px; }
    @media (width >= 700px) { grid-template-columns: auto 1fr auto; }
  }
  .back-link {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 700; color: var(--accent);
    & svg { width: 18px; height: 18px; transition: translate .25s var(--ease-out); }
    &:hover svg { translate: -3px 0; }
  }
}

/* ---------- SEO-доработки: hero, услуги, FAQ, 404 ---------- */
@layer sections {
  .hero h1 { font-size: clamp(2.3rem, 1.4rem + 3.4vw, 4.3rem); }
  .service { display: flex; flex-direction: column; & p { flex: 1; } }
  .service-link {
    margin-top: 16px; font-weight: 700; font-size: var(--step--1); color: var(--accent);
    position: relative; z-index: 1;
    &:hover { text-decoration: underline; text-underline-offset: 4px; }
  }

  .faq {
    display: grid; gap: 32px 64px;
    @media (width >= 960px) { grid-template-columns: .8fr 1.2fr; align-items: start; & .section-head { position: sticky; top: calc(var(--header-h) + 32px); } }
  }
  .faq-sub { margin-top: 16px; color: var(--muted); & a { color: var(--accent); font-weight: 700; } }
  .faq-list { display: grid; gap: 12px; }
  .faq-item {
    border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    transition: border-color .25s, box-shadow .25s;
    &[open] { border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); box-shadow: var(--shadow-sm); }
    & summary {
      display: flex; justify-content: space-between; align-items: center; gap: 16px;
      padding: 20px 24px; cursor: pointer; list-style: none;
      font-weight: 700; font-size: 1.08rem; line-height: 1.35;
      &::-webkit-details-marker { display: none; }
      &::after {
        content: ""; flex: none; width: 28px; height: 28px; border-radius: 50%;
        background:
          linear-gradient(var(--accent), var(--accent)) center / 12px 2px no-repeat,
          linear-gradient(var(--accent), var(--accent)) center / 2px 12px no-repeat,
          color-mix(in oklab, var(--accent) 10%, transparent);
        transition: rotate .3s var(--ease-out);
      }
    }
    &[open] summary::after { rotate: 45deg; }
    &::details-content { block-size: 0; overflow: clip; transition: block-size .35s var(--ease-out), content-visibility .35s allow-discrete; }
    &[open]::details-content { block-size: auto; }
  }
  :root { interpolate-size: allow-keywords; }
  .faq-a {
    padding: 0 24px 22px; color: var(--muted);
    & a { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
  }

  .not-found { padding-block: clamp(80px, 14vw, 180px); & .hero-cta { margin-top: 32px; } }
}
@layer sections {
  .prose a:not(.btn):not(.back-link) {
    color: var(--accent); font-weight: 600;
    text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
    &:hover { text-decoration-thickness: 2px; }
  }
}

/* ---------- Мультиязычность, страницы услуг, подвал ---------- */
@layer sections {
  .lang-switch {
    display: grid; place-items: center;
    min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface);
    font-weight: 800; font-size: .85rem; letter-spacing: .04em; color: var(--text);
    transition: background-color .2s, border-color .2s, color .2s;
    &:hover { border-color: var(--accent); color: var(--accent); }
  }

  /* Карточка услуги целиком кликабельна */
  .service { cursor: pointer; }
  .service .stretched {
    color: inherit;
    &::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
    &:focus-visible { outline: none; }
    &:focus-visible::after { outline: 3px solid var(--ring); outline-offset: 3px; }
  }
  .service:hover h3 { color: var(--accent); }

  /* Шапка страницы услуги */
  .page-hero {
    position: relative; isolation: isolate; overflow: clip;
    padding-block: clamp(28px, 5vw, 56px) clamp(56px, 8vw, 96px);
    & h1 { font-size: clamp(2.1rem, 1.4rem + 3vw, 3.8rem); letter-spacing: -.03em; margin: 14px 0 18px; }
    & .lead { max-width: 52ch; }
    & .hero-facts { margin-top: 36px; }
  }
  .page-hero-grid {
    display: grid; gap: 40px; align-items: center;
    @media (width >= 960px) { grid-template-columns: 1.25fr .75fr; }
  }
  .page-hero-cover {
    aspect-ratio: 1; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    max-width: 420px; width: 100%; justify-self: center;
    & svg { width: 42%; max-width: 180px; }
    @media (width < 960px) { display: none; }
  }

  /* Вступление + состав работ */
  .svc-intro {
    display: grid; gap: 40px 64px; align-items: start;
    @media (width >= 960px) { grid-template-columns: .9fr 1.1fr; & .prose { position: sticky; top: calc(var(--header-h) + 32px); } }
    & h2 { margin-bottom: 24px; }
  }
  .includes {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    & li {
      display: grid; grid-template-columns: 32px 1fr; gap: 14px; align-items: start;
      padding: 20px; border-radius: var(--radius);
      background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    }
    & h3 { font-size: 1.05rem; margin-bottom: 4px; }
    & p { color: var(--muted); font-size: var(--step--1); }
  }
  .includes-check {
    width: 32px; height: 32px; border-radius: 10px;
    background:
      no-repeat center / 16px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E"),
      var(--grad);
  }
  .includes-note { margin-top: 16px; font-size: var(--step--1); color: var(--muted); }

  /* Цена для услуг без калькулятора */
  .price-card {
    display: grid; gap: 24px; align-items: center;
    padding: clamp(28px, 5vw, 48px); border-radius: var(--radius-lg);
    background:
      radial-gradient(60% 100% at 100% 0%, color-mix(in oklab, var(--sky) 18%, transparent), transparent 60%),
      var(--surface);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    & h2 { margin: 10px 0 12px; }
    & p:not(.eyebrow) { color: var(--muted); max-width: 62ch; }
    @media (width >= 900px) { grid-template-columns: 1fr auto; }
  }

  /* Подвал */
  .footer-grid {
    display: grid; gap: 32px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    & ul { display: grid; gap: 8px; }
    & a:not(.brand):hover { color: var(--accent); }
    & .copy { grid-column: 1 / -1; padding-top: 24px; border-top: 1px solid var(--border); }
  }
  .footer-brand p { margin-top: 14px; max-width: 32ch; }
  .footer-title { font-weight: 800; color: var(--text); margin-bottom: 12px; font-size: var(--step-0); }
  .footer-phone { font-weight: 800; color: var(--text); font-size: 1.05rem; }
}
