/* === LAYOUTS.CSS ===
 * /serverflow/assets/css/layouts.css
 * НАЗНАЧЕНИЕ: Layouts (header, footer, hero, sections, telegram mockup)
 * СВЯЗИ: после components.css
 * РАЗМЕР: ~500 строк
 */

@layer layouts;

@layer layouts {
    /* === HEADER === */
    .site-header {
        position: sticky;
        top: 0;
        z-index: var(--z-header);
        backdrop-filter: blur(16px) saturate(180%);
        -webkit-backdrop-filter: blur(16px) saturate(180%);
        background: color-mix(in oklch, var(--bg-primary) 75%, transparent);
        border-bottom: 1px solid var(--border);
        height: var(--header-height);
        display: flex;
        align-items: center;
    }

    .site-header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        width: 100%;
    }

    .site-logo {
        display: inline-flex;
        align-items: center;
        gap: var(--space-2);
        font-family: var(--font-display);
        font-size: 1.0625rem;
        font-weight: 700;
        color: var(--text-primary);
        flex-shrink: 0;
    }

    .site-logo-mark {
        width: 28px; height: 28px;
        display: inline-grid;
        place-items: center;
        border-radius: var(--radius-sm);
        background: var(--accent);
        color: var(--accent-text);
        font-size: 0.875rem;
        font-weight: 700;
    }

    .site-nav {
        display: flex;
        gap: var(--space-1);
        align-items: center;
    }

    .site-nav a {
        padding: var(--space-2) var(--space-3);
        color: var(--text-muted);
        font-size: 0.9375rem;
        font-weight: 500;
        border-radius: var(--radius-sm);
        transition: all var(--duration-fast) var(--ease-out-quart);
    }
    .site-nav a:hover {
        color: var(--text-primary);
        background: var(--bg-secondary);
    }
    .site-nav a[aria-current="page"] {
        color: var(--accent);
    }

    .site-actions {
        display: flex;
        align-items: center;
        gap: var(--space-2);
    }

    /* Mobile menu toggle */
    .menu-toggle {
        display: none;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-sm);
        color: var(--text-primary);
    }
    .menu-toggle:hover { background: var(--bg-secondary); }

    /* === MOBILE NAV (≤768px) === */
    @media (max-width: 768px) {
        .menu-toggle { display: inline-flex; }
        .site-nav {
            display: none;
            position: absolute;
            top: var(--header-height);
            left: 0; right: 0;
            flex-direction: column;
            background: var(--bg-elevated);
            border-bottom: 1px solid var(--border);
            padding: var(--space-3);
            gap: var(--space-1);
            box-shadow: var(--shadow-lg);
        }
        .site-nav[data-open="true"] { display: flex; }
        .site-nav a { padding: var(--space-3); }
        .site-actions .btn-text-mobile-hide { display: none; }
    }

    /* Theme toggle button */
    .theme-toggle {
        width: 40px; height: 40px;
        display: inline-grid;
        place-items: center;
        border-radius: var(--radius-sm);
        color: var(--text-primary);
        transition: background var(--duration-fast) var(--ease-out-quart);
    }
    .theme-toggle:hover { background: var(--bg-secondary); }

    .theme-toggle .icon-sun { display: block; }
    .theme-toggle .icon-moon { display: none; }
    html.light-theme .theme-toggle .icon-sun { display: none; }
    html.light-theme .theme-toggle .icon-moon { display: block; }

    /* Lang switcher */
    .lang-switcher {
        display: inline-flex;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-2) var(--space-3);
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-primary);
        font-family: var(--font-mono);
        font-size: 0.8125rem;
        font-weight: 600;
        text-transform: uppercase;
        cursor: pointer;
    }
    .lang-switcher:hover {
        border-color: var(--border-hover);
        background: var(--bg-card);
    }

    .lang-switcher {
        anchor-name: --lang-anchor;
    }

    .lang-switcher::after {
        content: '';
        width: 8px; height: 8px;
        border-right: 1.5px solid currentColor;
        border-bottom: 1.5px solid currentColor;
        transform: rotate(45deg);
        margin-top: -3px;
        opacity: 0.6;
    }

    /* Lang popover anchored to button (CSS Anchor Positioning + fallback) */
    #lang-popover {
        position: fixed;
        position-anchor: --lang-anchor;
        position-area: bottom span-left;
        margin-top: var(--space-2);
        min-width: 160px;
    }

    /* Fallback для браузеров без CSS Anchor Positioning */
    @supports not (position-anchor: --x) {
        #lang-popover {
            position: fixed;
            top: calc(var(--header-height) + 4px);
            right: var(--space-4);
            margin: 0;
        }
    }

    /* === FOOTER === */
    .site-footer {
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        padding-block: var(--space-12) var(--space-6);
        margin-top: var(--space-20);
    }

    .site-footer-grid {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr;
        gap: var(--space-8);
        margin-bottom: var(--space-8);
    }

    @media (max-width: 768px) {
        .site-footer-grid {
            grid-template-columns: 1fr;
            gap: var(--space-6);
        }
    }

    .site-footer-brand p {
        margin-top: var(--space-3);
        color: var(--text-muted);
        font-size: 0.9375rem;
        max-width: 360px;
    }

    .site-footer-col h4 {
        font-family: var(--font-mono);
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--text-subtle);
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-bottom: var(--space-3);
    }

    .site-footer-col a {
        display: block;
        padding: var(--space-1) 0;
        color: var(--text-muted);
        font-size: 0.9375rem;
        transition: color var(--duration-fast) var(--ease-out-quart);
    }
    .site-footer-col a:hover { color: var(--text-primary); }

    .site-footer-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-4);
        padding-top: var(--space-6);
        border-top: 1px solid var(--border);
        font-size: 0.8125rem;
        color: var(--text-subtle);
        flex-wrap: wrap;
    }

    /* === HERO === */
    .hero {
        position: relative;
        padding-block: clamp(var(--space-10), 8vw, var(--space-20)) var(--space-12);
    }

.hero-grid {
        display: grid;
        grid-template-columns: 1.05fr 0.95fr;
        gap: var(--space-12);
        align-items: center;
    }

    @media (max-width: 960px) {
        .hero-grid {
            grid-template-columns: 1fr;
            gap: var(--space-8);
        }
    }

    .hero-eyebrow {
        display: inline-flex;
        align-items: center;
        gap: var(--space-2);
        padding: 6px var(--space-3);
        background: var(--success-soft);
        color: var(--success);
        border: 1px solid oklch(70% 0.16 165 / 0.3);
        border-radius: var(--radius-pill);
        font-family: var(--font-mono);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: var(--space-5);
    }
    .hero-eyebrow::before {
        content: '';
        width: 6px; height: 6px;
        background: currentColor;
        border-radius: 50%;
        animation: blink 1.6s ease-in-out infinite;
    }

    .hero-title {
        font-family: var(--font-display);
        font-size: clamp(2rem, 5.5vw, 3.5rem);
        font-weight: 700;
        line-height: 1.1;
        letter-spacing: -0.025em;
        margin-bottom: var(--space-5);
        color: var(--text-primary);
    }

    .hero-title-accent {
        color: var(--accent);
    }

    .hero-subtitle {
        font-size: clamp(1rem, 2vw, 1.125rem);
        color: var(--text-muted);
        line-height: 1.55;
        margin-bottom: var(--space-6);
        max-width: 560px;
    }

    .hero-actions {
        display: flex;
        gap: var(--space-3);
        flex-wrap: wrap;
        margin-bottom: var(--space-8);
    }

    .hero-stats {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-4);
    }

    @media (max-width: 560px) {
        .hero-stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
    }

    .hero-stat {
        padding: var(--space-3) 0;
    }
    .hero-stat .stat-value {
        font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    }

    /* === TELEGRAM MOCKUP === */
    .tg-mockup {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-xl);
        overflow: hidden;
        box-shadow: var(--shadow-xl);
        max-width: 440px;
        margin-inline: auto;
        font-family: var(--font-body);
        position: relative;
    }

    .tg-mockup::before {
        content: '';
        position: absolute;
        inset: -1px;
        background: linear-gradient(135deg, var(--accent-soft) 0%, transparent 50%, var(--success-soft) 100%);
        border-radius: var(--radius-xl);
        z-index: -1;
        opacity: 0.6;
    }

    .tg-header {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border);
    }

    .tg-avatar {
        width: 36px; height: 36px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent), var(--success));
        display: grid;
        place-items: center;
        color: var(--accent-text);
        font-weight: 700;
        flex-shrink: 0;
        font-family: var(--font-display);
    }

    .tg-meta {
        flex: 1;
        min-width: 0;
    }

    .tg-name {
        font-weight: 600;
        font-size: 0.9375rem;
        color: var(--text-primary);
        display: flex;
        align-items: center;
        gap: var(--space-2);
    }

    .tg-status {
        font-size: 0.75rem;
        color: var(--success);
    }

    .tg-body {
        padding: var(--space-3);
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
        background: var(--bg-card);
        max-height: 420px;
        overflow-y: auto;
    }

    .tg-msg {
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
        padding: var(--space-3);
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        border-left: 3px solid var(--success);
        font-size: 0.875rem;
        line-height: 1.5;
        animation: fadeInUp var(--duration-slow) var(--ease-out-quart) both;
    }

    .tg-msg-warning { border-left-color: var(--warning); }
    .tg-msg-info    { border-left-color: var(--info); }
    .tg-msg-danger  { border-left-color: var(--danger); }

    .tg-msg-title {
        font-weight: 600;
        color: var(--text-primary);
        font-size: 0.9375rem;
    }

    .tg-msg-row {
        display: flex;
        align-items: baseline;
        gap: var(--space-2);
        color: var(--text-muted);
    }
    .tg-msg-row strong { color: var(--text-primary); font-weight: 600; }

    .tg-msg-time {
        font-family: var(--font-mono);
        font-size: 0.6875rem;
        color: var(--text-subtle);
        align-self: flex-end;
    }

    /* === SECTIONS === */
    .section {
        padding-block: clamp(var(--space-12), 8vw, var(--space-20));
    }

    .section-header {
        text-align: center;
        max-width: 720px;
        margin: 0 auto var(--space-10);
    }

    .section-title {
        font-family: var(--font-display);
        font-size: clamp(1.75rem, 4vw, 2.5rem);
        font-weight: 700;
        margin-bottom: var(--space-3);
        color: var(--text-primary);
        letter-spacing: -0.02em;
    }

    .section-title-accent { color: var(--accent); }

    .section-subtitle {
        color: var(--text-muted);
        font-size: 1.0625rem;
        line-height: 1.55;
    }

    /* === GRID === */
    .grid {
        display: grid;
        gap: var(--space-4);
    }

    .grid-1 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }

    @media (max-width: 960px) {
        .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    }
    @media (max-width: 600px) {
        .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    }

    /* === CONTAINER QUERIES (компонентная адаптивность) === */
    .cq-container { container-type: inline-size; }

    /* === FLEX UTILS === */
    .flex     { display: flex; }
    .flex-col { display: flex; flex-direction: column; }
    .items-center { align-items: center; }
    .items-baseline { align-items: baseline; }
    .justify-between { justify-content: space-between; }
    .justify-center { justify-content: center; }
    .gap-1 { gap: var(--space-1); }
    .gap-2 { gap: var(--space-2); }
    .gap-3 { gap: var(--space-3); }
    .gap-4 { gap: var(--space-4); }
    .gap-5 { gap: var(--space-5); }
    .gap-6 { gap: var(--space-6); }
    .flex-wrap { flex-wrap: wrap; }
    .flex-1 { flex: 1; }

    .mt-1 { margin-top: var(--space-1); }
    .mt-2 { margin-top: var(--space-2); }
    .mt-3 { margin-top: var(--space-3); }
    .mt-4 { margin-top: var(--space-4); }
    .mt-6 { margin-top: var(--space-6); }
    .mt-8 { margin-top: var(--space-8); }

    .mb-1 { margin-bottom: var(--space-1); }
    .mb-2 { margin-bottom: var(--space-2); }
    .mb-3 { margin-bottom: var(--space-3); }
    .mb-4 { margin-bottom: var(--space-4); }
    .mb-6 { margin-bottom: var(--space-6); }
    .mb-8 { margin-bottom: var(--space-8); }

    .w-full { width: 100%; }

    /* === HIDE ON MOBILE === */
    @media (max-width: 600px) {
        .hide-on-mobile { display: none !important; }
    }
    @media (min-width: 601px) {
        .show-on-mobile { display: none !important; }
    }
}
