/* ============================================================
   База дизайн-системы «Закон и адвокатура».
   Сетка, типографика, компоненты, адаптив.
   Темы переопределяют CSS-переменные в :root и раскладку.
   ============================================================ */

:root {
    /* Тема по умолчанию (horizontal-classic) — переопределяется файлом темы */
    --bg: #f5f1e8;
    --surface: #ffffff;
    --surface-2: #efe9db;
    --text: #1e2430;
    --muted: #6b7280;
    --accent: #1b2a4a;
    --accent-2: #d4af37;
    --on-accent: #ffffff;
    --border: #d8d2c2;
    --danger: #b91c1c;
    --ok: #166534;
    --font-body: system-ui, "Segoe UI", Arial, sans-serif;
    --font-head: Georgia, "Times New Roman", serif;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(20, 25, 40, .08);
    --container: min(92vw, 1800px);
}

* { box-sizing: border-box; }

html { font-size: clamp(15px, .9vw + .55rem, 19px); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-head);
    line-height: 1.25;
    margin: 0 0 .6em;
}
h1 { font-size: clamp(1.8rem, 3.2vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.2vw, 2rem); }
h3 { font-size: clamp(1.1rem, 1.5vw, 1.35rem); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video, audio, iframe { max-width: 100%; }

.container {
    width: var(--container);
    margin-inline: auto;
}
.container-narrow { width: min(92vw, 900px); }

.muted { color: var(--muted); font-size: .92em; }

/* ---------- Сетка ---------- */
.grid { display: grid; gap: 1.2rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Компоненты ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
    box-shadow: var(--shadow);
}
.card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: .55rem 1.2rem;
    font: inherit;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-ghost {
    background: transparent;
    color: var(--accent);
}
.btn-ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.form { display: grid; gap: 1rem; max-width: 30rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; }
.form input, .form textarea, .form select {
    font: inherit;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.form input:focus, .form textarea:focus, .form select:focus {
    outline: 2px solid var(--accent-2);
    outline-offset: 1px;
}

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; }
th { background: var(--surface-2); }

.badge {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .82em;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.badge-pos { background: var(--ok); border-color: var(--ok); color: #fff; }
.badge-neg { background: var(--danger); border-color: var(--danger); color: #fff; }

.flash {
    border-radius: var(--radius);
    padding: .7rem 1rem;
    margin: 1rem 0;
    border: 1px solid;
}
.flash-ok { background: #e7f6ec; border-color: var(--ok); color: var(--ok); }
.flash-error { background: #fdecec; border-color: var(--danger); color: var(--danger); }

.price { font-size: 1.25rem; font-weight: 700; color: var(--accent); }

/* ---------- Шапка (horizontal) ---------- */
.site-header {
    background: var(--accent);
    color: var(--on-accent);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-block: .8rem;
}
.logo {
    font-family: var(--font-head);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-2);
    white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.site-nav { flex: 1; }
.nav-list {
    display: flex;
    gap: 1.2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-list a {
    color: var(--on-accent);
    opacity: .85;
    padding-block: .3rem;
}
.nav-list a:hover, .nav-list a.active { opacity: 1; text-decoration: none; border-bottom: 2px solid var(--accent-2); }
.header-user { display: flex; align-items: center; gap: .6rem; }
.header-user .btn { padding: .35rem .9rem; }
.header-user .btn-ghost { color: var(--on-accent); border-color: color-mix(in srgb, var(--on-accent) 45%, transparent); }
.userbox-name { color: var(--on-accent); font-weight: 600; }
.userbox-login { opacity: .7; font-weight: 400; font-size: .85em; }
.inline-form { display: inline; margin: 0; }

/* ---------- Бургер ---------- */
.burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: 0;
    cursor: pointer;
    padding: .4rem;
}
.burger span {
    width: 26px;
    height: 3px;
    background: var(--on-accent);
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}
.burger-float {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 60;
    background: var(--accent);
    border-radius: var(--radius);
}

/* ---------- Вертикальная раскладка ---------- */
.layout-vertical { display: flex; }
.site-sidebar {
    width: 270px;
    flex-shrink: 0;
    min-height: 100vh;
    background: var(--accent);
    color: var(--on-accent);
    padding: 1.4rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.site-sidebar .nav-list { flex-direction: column; gap: .4rem; }
.site-sidebar .nav-list a { display: block; padding: .45rem .6rem; border-radius: var(--radius); }
.site-sidebar .nav-list a:hover, .site-sidebar .nav-list a.active {
    background: color-mix(in srgb, var(--on-accent) 12%, transparent);
    border-bottom: 0;
}
.sidebar-user { margin-top: auto; display: grid; gap: .5rem; }
.sidebar-user .btn-ghost { color: var(--on-accent); border-color: color-mix(in srgb, var(--on-accent) 45%, transparent); }
.sidebar-user .userbox-name { color: var(--on-accent); }
.site-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.site-content { flex: 1; padding-block: 2rem; }

/* Кнопка сворачивания колонки: по умолчанию скрыта, включается темой (vertical-light) */
.sidebar-toggle { display: none; }
body.sidebar-collapsed .site-sidebar { width: 88px; padding-inline: .7rem; }
body.sidebar-collapsed .site-sidebar .logo { font-size: 1rem; }
body.sidebar-collapsed .site-sidebar .nav-list a,
body.sidebar-collapsed .site-sidebar .userbox-name,
body.sidebar-collapsed .site-sidebar .btn {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
}

/* vertical-right: колонка справа */
.theme-vertical-right.layout-vertical { flex-direction: row-reverse; }

/* ---------- 3D / author шапки ---------- */
.hero-header .header-top {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-block: .8rem;
}
.hero-block { text-align: center; padding: 3rem 0 3.5rem; }
.logo-big { font-size: clamp(2rem, 4vw, 3.2rem); }
.hero-sub { color: var(--on-accent); opacity: .8; margin: .4rem 0 0; }

.author-header { padding-block: 1rem; }
.author-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .8rem;
    text-align: center;
}
.author-inner .nav-list { justify-content: center; }

/* ---------- Контент главной ---------- */
.hero {
    text-align: center;
    padding: clamp(2rem, 6vw, 5rem) 1rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 2rem;
}
.hero-lead { max-width: 46rem; margin: 0 auto 1.4rem; color: var(--muted); }
.hero-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

.section { margin-block: 2.5rem; }
.question-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }

.auth-box { max-width: 26rem; margin: 3rem auto; }
.error-page { text-align: center; padding: 4rem 1rem; }

/* ---------- Подвал ---------- */
.site-footer {
    margin-top: 3rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-block: 1.6rem;
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}
.footer-brand { max-width: 24rem; }
.theme-switcher-title { display: block; font-weight: 600; margin-bottom: .5rem; }
.theme-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .5rem;
}
.theme-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    width: 92px;
    background: var(--surface);
}
.theme-preview:hover { text-decoration: none; border-color: var(--accent); }
.theme-preview.active { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2); }
.tp-color { height: 22px; }
.tp-label {
    grid-column: 1 / -1;
    font-size: .68rem;
    text-align: center;
    padding: .15rem .1rem;
    color: var(--text);
    line-height: 1.15;
}
.footer-copy { margin-top: 1rem; color: var(--muted); font-size: .85em; }

/* ---------- 3D-эффекты (управляются темами/JS) ---------- */
.tilt { transform-style: preserve-3d; transition: transform .2s ease; will-change: transform; }

/* ---------- Адаптив: бургер-меню ---------- */
@media (max-width: 900px) {
    .burger { display: flex; }
    .layout-horizontal .site-nav,
    .layout-horizontal .header-user,
    .layout-3d .site-nav,
    .layout-3d .header-user,
    .layout-author .site-nav,
    .layout-author .header-user {
        display: none;
    }
    body.nav-open .layout-horizontal .site-nav,
    body.nav-open .layout-horizontal .header-user,
    body.nav-open .layout-3d .site-nav,
    body.nav-open .layout-3d .header-user,
    body.nav-open .layout-author .site-nav,
    body.nav-open .layout-author .header-user {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    body.nav-open .header-inner,
    body.nav-open .header-top,
    body.nav-open .author-inner { flex-wrap: wrap; }
    body.nav-open .nav-list { flex-direction: column; width: 100%; }

    /* вертикальные темы: колонка уезжает за экран */
    .layout-vertical .site-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .theme-vertical-right.layout-vertical .site-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }
    body.nav-open .layout-vertical .site-sidebar { transform: translateX(0); }

    .theme-grid { grid-template-columns: repeat(4, 1fr); }
    .hero-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------- Этап 2: хлебные крошки, табы, пагинация ---------- */
.breadcrumbs { margin-bottom: 1rem; font-size: .9em; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.crumb-sep { margin-inline: .4rem; }
.crumb-current { color: var(--text); }

.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.tab { padding: .5rem 1rem; border-bottom: 3px solid transparent; color: var(--muted); }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent-2); font-weight: 600; }

.pagination { display: flex; gap: .35rem; margin-top: 1.5rem; flex-wrap: wrap; }
.page-link {
    min-width: 2.2rem; text-align: center; padding: .35rem .5rem;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.page-link.current { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
a.page-link:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- Каталог ---------- */
.subcat-list { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .3rem; }
.subcat-inline { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.item-cover { border-radius: var(--radius); margin-bottom: 1rem; }
.item-intro { font-size: 1.1em; color: var(--muted); }
.item-body, .article-body, .question-body { margin-block: 1.2rem; }
.article-body img, .item-body img { border-radius: var(--radius); margin-block: .8rem; }
.paywall { text-align: center; padding: 2rem; margin-block: 1.5rem; }
.media-block { margin: 1.2rem 0; }
.media-block iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: var(--radius); }
.media-block video, .media-block audio { width: 100%; border-radius: var(--radius); }
.media-block figcaption { color: var(--muted); font-size: .9em; margin-top: .3rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; margin-block: 1.2rem; }
.gallery-item { display: block; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.gallery-item img { width: 100%; height: 140px; object-fit: cover; display: block; transition: transform .2s ease; }
.gallery-item:hover img { transform: scale(1.04); }

.article-sources {
    margin-top: 2rem; padding: 1rem 1.4rem;
    background: var(--surface-2); border-radius: var(--radius); border-left: 4px solid var(--accent-2);
    font-size: .92em;
}

/* ---------- Аккордеон (FAQ) ---------- */
.accordion { display: grid; gap: .6rem; }
.accordion-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.accordion-item summary { cursor: pointer; padding: .9rem 1.2rem; font-weight: 600; list-style: none; }
.accordion-item summary::before { content: "+ "; color: var(--accent-2); font-weight: 700; }
.accordion-item[open] summary::before { content: "− "; }
.accordion-body { padding: 0 1.2rem 1rem; }

/* ---------- Комментарии ---------- */
.comments { margin-top: 2.5rem; }
.comment-thread { margin-bottom: 1rem; }
.comment {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem 1.1rem; margin-bottom: .5rem;
}
.comment-child { margin-left: clamp(1rem, 4vw, 3rem); background: var(--surface-2); }
.comment-lawyer { border-left: 4px solid var(--accent-2); }
.comment-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.comment-body { margin-block: .4rem; }
.comment-foot { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; font-size: .88em; color: var(--muted); }
.badge-lawyer { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.vote-box { display: inline-flex; align-items: center; gap: .4rem; }
.vote-btn {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: var(--radius); padding: .1rem .5rem; cursor: pointer; font: inherit;
}
.vote-btn:hover { border-color: var(--accent); color: var(--accent); }
.vote-down:hover { border-color: var(--danger); color: var(--danger); }
.vote-sum { font-weight: 700; }
.lawyer-rate-form select { font: inherit; padding: .1rem .3rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.btn-sm { padding: .25rem .8rem; font-size: .88em; }
.form-compact { gap: .5rem; margin-block: .5rem; }
.reply-box { margin: 0 0 1rem clamp(1rem, 4vw, 3rem); }
.reply-box summary { cursor: pointer; color: var(--accent); font-size: .9em; }
.comment-form { margin-top: 1.5rem; }
.new-question { margin-bottom: 1.5rem; }
.new-question summary { cursor: pointer; }
.new-question .form { margin-top: 1rem; }

/* ---------- Лайтбокс ---------- */
.lightbox-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0, 0, 0, .85);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
.lightbox-overlay img { max-width: 92vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 10px 60px rgba(0,0,0,.5); }
.lightbox-caption { position: absolute; bottom: 1.2rem; left: 0; right: 0; text-align: center; color: #fff; opacity: .8; }

/* ---------- Логотип (картинка + название) ---------- */
.logo { display: inline-flex; align-items: center; gap: .55rem; }
.logo-img { width: 2.1em; height: 2.1em; flex: none; display: block; }
.logo-big .logo-img { width: 1.6em; height: 1.6em; }
.sidebar-collapsed .logo-text { display: none; }

/* ---------- Плашка «сайт в разработке» ---------- */
.dev-bar {
    background: repeating-linear-gradient(-45deg, #b45309 0 14px, #d97706 14px 28px);
    color: #fff;
    text-align: center;
    font-size: .92rem;
    font-weight: 600;
    padding: .35rem 1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

/* ---------- Новостная карусель (главная) ---------- */
.news-carousel {
    position: relative;
    margin: 0 0 2rem;
    border-radius: var(--radius);
}
.news-viewport { position: relative; min-height: 9.5rem; }
.news-slide {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: .5rem;
    padding: 1.4rem 3.4rem;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    opacity: 0; visibility: hidden;
    transform: translateX(2rem);
    transition: opacity .5s ease, transform .5s ease, visibility 0s linear .5s;
}
.news-slide.active {
    opacity: 1; visibility: visible;
    transform: translateX(0);
    transition: opacity .5s ease, transform .5s ease;
    position: relative;
}
.news-badge {
    font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--on-accent); background: var(--accent);
    border-radius: 999px; padding: .15rem .7rem;
}
.news-slide h3 { margin: 0; }
.news-slide p { margin: 0; color: var(--muted); max-width: 46rem; }
.news-more { margin-top: .3rem; }
.news-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    z-index: 2;
    width: 2.2rem; height: 2.2rem;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--surface); color: var(--accent);
    font-size: 1rem; line-height: 1; cursor: pointer;
    box-shadow: var(--shadow);
}
.news-arrow:hover { filter: brightness(1.08); }
.news-prev { left: .6rem; }
.news-next { right: .6rem; }
.news-dots {
    position: absolute; bottom: .55rem; left: 0; right: 0;
    display: flex; justify-content: center; gap: .45rem;
    z-index: 2;
}
.news-dot {
    width: .55rem; height: .55rem; padding: 0;
    border: none; border-radius: 50%;
    background: var(--muted); opacity: .45; cursor: pointer;
    transition: opacity .2s, transform .2s;
}
.news-dot.active { opacity: 1; transform: scale(1.25); background: var(--accent); }
@media (max-width: 700px) {
    .news-slide { padding: 1.2rem 2.6rem 1.8rem; }
    .news-viewport { min-height: 12rem; }
}
@media (prefers-reduced-motion: reduce) {
    .news-slide, .news-slide.active { transition: none; }
}

/* ---------- Новостная строка в шапке (тикер) ---------- */
.news-ticker {
    display: flex; align-items: center; gap: .8rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .3rem 1rem;
    font-size: .88rem;
    overflow: hidden;
}
.news-ticker-label {
    flex: none;
    font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--on-accent); background: var(--accent);
    border-radius: 999px; padding: .12rem .6rem;
    animation: ticker-pulse 2.6s ease-in-out infinite;
}
@keyframes ticker-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
    50%      { box-shadow: 0 0 0 6px transparent; }
}
.news-ticker-viewport { position: relative; flex: 1; min-height: 1.4em; }
.news-ticker-item {
    position: absolute; inset: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text);
    opacity: 0; transform: translateY(60%);
    transition: opacity .45s ease, transform .45s ease;
    pointer-events: none;
}
.news-ticker-item.active { opacity: 1; transform: none; pointer-events: auto; }
.news-ticker-item:hover { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
    .news-ticker-label { animation: none; }
    .news-ticker-item { transition: none; }
}

/* ---------- Переключатель светлая/тёмная (строгий дизайн) ---------- */
.strict-mode-toggle {
    font-size: .82rem;
    padding: .3rem .75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    white-space: nowrap;
    transition: color .2s, border-color .2s;
}
.strict-mode-toggle:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
