@layer base, components, utilities, animations;

@layer base {
  :root {
    color-scheme: light;
    --bg: #f8fafc;
    --bg-secondary: #f1f5f9;
    --surface: #ffffff;
    --surface-strong: #f7f5ef;
    --text: #222328;
    --text-muted: #5d6470;
    --accent: #2f4c67;
    --accent-strong: #23384b;
    --accent-soft: rgba(47, 76, 103, 0.12);
    --brand: #0077ad;
    --border: #d4cec2;
    --border-strong: #bdb4a7;
    --shadow: 0 18px 48px rgba(27, 32, 38, 0.08);
    --shadow-hover: 0 24px 56px rgba(27, 32, 38, 0.12);
    --radius: 20px;
    --radius-sm: 14px;
    --radius-xs: 10px;
    --container: 1120px;
    --header-height: 78px;
    
    --price-bg: #e6f2ff;
  }

  html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171b1f;
    --bg-secondary: #1d2329;
    --surface: #21282f;
    --surface-strong: #252e36;
    --text: #ece7dc;
    --text-muted: #b2bac5;
    --accent: #8ea7be;
    --accent-strong: #b3c5d6;
    --accent-soft: rgba(142, 167, 190, 0.14);
    --brand: #78caff;
    --border: #39424c;
    --border-strong: #4d5965;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
    --shadow-hover: 0 24px 56px rgba(0, 0, 0, 0.32);
    --price-bg: rgba(142, 167, 190, 0.1);
  }

  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }

  body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    background:
      radial-gradient(circle at top left, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 28rem),
      linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg) 220px);
    color: var(--text);
    min-width: 320px;
    line-height: 1.6;
  }

  h1, h2, h3, h4 {
    font-family: Georgia, serif;
    letter-spacing: -0.01em;
    line-height: 1.15;
    margin: 0;
    font-weight: 700;
  }

  h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
  h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
  
  p { margin: 0; color: var(--text-muted); }
  
  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  a { color: inherit; text-decoration: none; }
  button { font: inherit; cursor: pointer; border: none; background: none; padding: 0; }

  .inline-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  :focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
  }

  input,
  textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    padding: 14px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  textarea {
    min-height: 140px;
    resize: vertical;
  }

  input::placeholder,
  textarea::placeholder {
    color: var(--text-muted);
  }

  input:focus,
  textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
}

@layer components {
  .skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1000;
    transform: translateY(-140%);
    border-radius: var(--radius-xs);
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    font-weight: 700;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
  }

  .skip-link:focus-visible {
    transform: translateY(0);
  }

  .sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .container {
    width: min(calc(100% - 40px), var(--container));
    margin: 0 auto;
  }

  .section {
    padding: 32px 0;
  }

  .section--tight {
    padding: 24px 0;
  }

  .section--spacious {
    padding: 40px 0;
  }

  .section-heading {
    max-width: 760px;
  }

  .section-heading--offer {
    max-width: none;
    display: grid;
    gap: 8px;
  }

  .section-heading--offer .small-caps {
    justify-self: center;
  }

  .section-heading--offer h2,
  .section-heading--offer p,
  .section-heading--center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }

  .section-heading--center {
    display: grid;
    gap: 8px;
  }

  .section-heading--offer p {
    max-width: 760px;
  }

  /* Header & Brand */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-bottom: 1px solid var(--border);
  }

  .header-inner {
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
  }

  .brand-logo {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
  }

  .brand-domain {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(56vw, 520px);
  }

  .site-nav {
    display: flex;
    gap: 8px;
  }

  .site-nav a {
    position: relative;
    padding: 8px 16px;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s ease;
  }

  .site-nav a::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.25s ease;
    transform: translateX(-50%);
  }

  .site-nav a:hover::after,
  .site-nav a.is-active::after {
    width: 20px;
  }

  .site-nav a:hover,
  .site-nav a.is-active {
    color: var(--accent);
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .theme-toggle, .menu-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--text);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  }

  .theme-toggle:hover {
    background: var(--surface-strong);
    border-color: var(--border-strong);
  }

  .menu-toggle.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .menu-toggle { display: none; }

  .mobile-panel {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: max-height 0.28s ease, opacity 0.2s ease, transform 0.2s ease;
  }

  .mobile-panel[hidden] {
    display: none;
  }

  .mobile-panel nav {
    display: grid;
    gap: 8px;
    padding-top: 4px;
  }

  .mobile-panel nav a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface);
    font-weight: 600;
    text-align: left;
  }

  .mobile-panel nav a.is-active {
    color: var(--accent);
    border-color: var(--accent);
  }

  .mobile-panel.is-open {
    max-height: 420px;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  /* Buttons */
  .button, .button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 28px;
    border-radius: 999px;
    font-weight: 600;
    transition: background-color 0.22s ease, border-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
  }

  .button {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
  }

  .button-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
  }

  /* Cards */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .price-badge {
    margin-top: auto;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-strong);
    background: var(--price-bg);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    width: fit-content;
  }

  /* Footer - Refined & Corrected */
  .site-footer {
    padding: 64px 0 48px;
    background: var(--bg-secondary);
    color: var(--text);
  }

  .footer-brand {
    display: flex;
    flex-direction: row; /* В ОДНУ СТРОКУ */
    align-items: center;
    justify-content: center; /* ПО ЦЕНТРУ */
    gap: 16px;
    margin-bottom: 24px;
  }

  .footer-brand .brand-logo {
    width: 48px;
    height: 48px;
  }

  .footer-brand .brand-domain {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: -0.02em;
  }

  .footer-nav {
    display: flex;
    flex-direction: row; /* В ОДНУ СТРОКУ */
    justify-content: center; /* ПО ЦЕНТРУ */
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 48px;
  }

  .footer-nav a {
    font-size: 0.875rem; /* НЕ КРУПНО */
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s ease;
  }

  .footer-nav a:hover {
    color: var(--accent);
  }

  .footer-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr; /* ДВА БЛОКА */
    gap: 40px;
    padding-top: 12px;
    max-width: var(--container);
    margin: 0 auto;
  }

  .footer-block-left {
    text-align: left; /* СМЕЩЕНИЕ ВЛЕВО */
  }

  .footer-block-right {
    text-align: right; /* СМЕЩЕНИЕ ВПРАВО */
  }

  .footer-text {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0;
  }

  .footer-contacts-link {
    display: block;
    font-weight: 700;
    color: var(--text);
    font-size: 1.1rem;
    margin-bottom: 4px;
    text-decoration: none;
  }

  .page-hero {
    padding: 26px 0 18px;
  }

  .page-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.78fr);
    align-items: center;
    gap: 40px;
  }

  .page-hero-content {
    display: grid;
    gap: 10px;
  }

  .page-hero-content p {
    max-width: 680px;
  }

  .page-hero-media {
    margin: 0;
    border-radius: var(--radius);
    overflow: hidden;
    background: transparent;
  }

  .page-hero-media img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }

  .page-hero-v {
    gap: 14px;
    padding-top: 0;
  }

  .about-brand-title {
    font-family: Inter, system-ui, -apple-system, sans-serif;
    color: var(--brand);
    font-weight: 800;
    letter-spacing: -0.035em;
  }

  .page-hero-v .breadcrumbs {
    margin: -4px 0 0;
  }

  .page-hero-v .hero-image {
    max-width: 800px;
  }

  .contact-phones {
    display: grid;
    gap: 16px;
  }

  .contact-phone-item p {
    margin-top: 2px;
  }

  .contact-phone-link {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    display: block;
    transition: color 0.2s ease;
  }

  .contact-phone-link:hover {
    color: var(--accent-strong);
  }

  .contact-phone-link--sm {
    font-size: 1.1rem;
  }

  .contact-email-link {
    font-size: 1.2rem;
    font-weight: 600;
    display: block;
    transition: color 0.2s ease;
  }

  .contact-email-link:hover {
    color: var(--accent);
  }

  .consent-check {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: left;
  }

  .consent-check input {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--accent);
  }

  .form-feedback {
    display: none;
    font-weight: 600;
  }

  .form-feedback.is-visible {
    display: block;
  }

  .form-feedback.is-success {
    color: #16a34a;
  }

  .form-feedback.is-error {
    color: #dc2626;
  }

  .contact-form.is-loading button[type="submit"] {
    opacity: 0.6;
    pointer-events: none;
  }

  .contact-form button[disabled] {
    cursor: wait;
  }

  .privacy-grid .card {
    gap: 12px;
  }
}

@layer animations {
  @keyframes fade-in-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
  }

  html.js .reveal {
    opacity: 0;
    transform: translateY(24px);
  }

  html.js .reveal.is-visible {
    animation: fade-in-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

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

    html.js .reveal {
      opacity: 1;
      transform: none;
    }
  }
}

@layer utilities {
  /* 8pt Grid System */
  .mt-8 { margin-top: 8px; }
  .mt-10 { margin-top: 10px; }
  .mt-16 { margin-top: 16px; }
  .mt-20 { margin-top: 20px; }
  .mt-24 { margin-top: 24px; }
  .mt-32 { margin-top: 32px; }
  
  .mb-8 { margin-bottom: 8px; }
  .mb-10 { margin-bottom: 10px; }
  .mb-16 { margin-bottom: 16px; }
  .mb-20 { margin-bottom: 20px; }
  .mb-24 { margin-bottom: 24px; }
  .mb-32 { margin-bottom: 32px; }
  
  .gap-8 { gap: 8px; }
  .gap-14 { gap: 16px; }
  .gap-16 { gap: 16px; }
  .gap-24 { gap: 24px; }
  .gap-32 { gap: 32px; }

  .text-small { font-size: 0.875rem; }
  .text-muted { color: var(--text-muted); }
  .grid { display: grid; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .w-fit { width: fit-content; }
  .surface-strong { background: var(--surface-strong); }
  .small-caps { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--accent); }
  .list-clean { list-style: none; padding: 0; margin: 0; }
  .list-clean li { margin-bottom: 8px; }
  .breadcrumbs { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 16px; }
  .breadcrumbs a { color: var(--accent); }

  /* Hero Vertical Stack */
  .hero-v {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    padding: 16px 0 0;
  }

  .hero-v h1 {
    font-size: clamp(2rem, 5vw, 3.4rem);
    width: 100%;
    margin-bottom: 0;
    line-height: 1.1;
  }

  .home-page .hero-v h1 + .hero-image,
  .page-hero-v h1 + .hero-image {
    margin-top: -28px;
  }

  .hero-v .hero-image {
    max-width: 100%;
    position: relative;
    z-index: 2;
    background: transparent;
  }

  .hero-v .hero-image img {
    margin: 0 auto;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 62vh;
    object-fit: contain;
  }

  .hero-v .hero-description {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.125rem;
    line-height: 1.6;
  }

  .hero-v .hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 8px 0 12px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .button:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--accent-strong);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  }

  .button-secondary:hover {
    background: var(--surface-strong);
    transform: translateY(-2px);
  }

  .card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
  }
}

@media (max-width: 1024px) {
  /* Tablet Breakpoint */
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .header-inner { gap: 14px; }
  .brand-domain { font-size: 1.1rem; max-width: 42vw; }
}

@media (max-width: 900px) {
  .site-nav { display: none; }
  .menu-toggle { display: flex; }
  .brand-domain { max-width: 54vw; }
}

@media (max-width: 768px) {
  /* Mobile Breakpoint */
  .container { width: min(calc(100% - 24px), var(--container)); }
  .hero-grid, .page-hero-grid, .grid-2, .grid-3, .footer-grid { grid-template-columns: 1fr; text-align: center; }
  .footer-block-left, .footer-block-right { text-align: center; }
  .header-inner { min-height: 68px; gap: 8px; }
  .brand { gap: 10px; }
  .brand-logo { width: 40px; height: 40px; }
  .brand-domain { font-size: 0.82rem; max-width: 44vw; }
  .header-actions { gap: 8px; }
  .theme-toggle, .menu-toggle { width: 44px; height: 44px; }
  .mobile-panel {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
  }
  .section { padding: 24px 0; }
  .section--tight { padding: 18px 0; }
  .section--spacious { padding: 28px 0; }
  .page-hero { padding: 20px 0 12px; }
  .card { padding: 20px; gap: 12px; }
  .home-page .hero-v h1 + .hero-image,
  .page-hero-v h1 + .hero-image { margin-top: -12px; }
  
  .hero-v { gap: 14px; padding: 8px 0 0; }
  .hero-v h1 { font-size: clamp(1.55rem, 8vw, 2rem); }
  .hero-v .hero-image img { max-height: 34vh; }
  .hero-v .hero-description { font-size: 1rem; line-height: 1.5; }
  .hero-v .hero-actions { flex-direction: column; width: 100%; }
  .contact-phone-link { font-size: 1.15rem; }
  .contact-phone-link--sm { font-size: 1rem; }
  .contact-email-link { font-size: 1rem; }
  .footer-brand { flex-direction: column; gap: 8px; }
  .footer-brand .brand-domain { font-size: 1rem; max-width: 100%; }
  .footer-nav { gap: 12px; margin-bottom: 32px; }
  .footer-contacts-link { font-size: 1rem; }
  .button, .button-secondary { width: 100%; }
  .w-fit { width: 100%; }

  body.menu-open {
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .brand-domain { display: none; }
}
