/* =========================================================
   WWI THEME v2 — ОКОПНАЯ ВОЙНА
   Селекторы совпадают с прежней версией, HTML менять не нужно.
   Шрифты (необязательно, но сильно помогают) — добавьте в <head> project.html:
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Old+Standard+TT:ital,wght@0,400;0,700;1,400&family=PT+Serif:ital,wght@0,400;0,700;1,400&family=PT+Mono&display=swap" rel="stylesheet">
   Без них сработают запасные шрифты (Georgia / Courier New).
   ========================================================= */

body.theme-wwi {
    --ww1-bg: #12110f;
    --ww1-panel: rgba(34, 31, 26, 0.94);
    --ww1-paper: #d9cfba;
    --ww1-text: #d4c9b6;
    --ww1-muted: #a09482;          /* светлее прежнего: читаемость AA на тёмной панели */
    --ww1-accent: #8c5e3c;
    --ww1-accent-bright: #c2875a;
    --ww1-poppy: #a4262c;          /* красный мак — символ памяти о Первой мировой */
    --ww1-poppy-bright: #d0383f;
    --ww1-border: rgba(140, 94, 60, 0.32);

    --ww1-head: "Old Standard TT", Georgia, "Times New Roman", serif;
    --ww1-serif: "PT Serif", Georgia, "Times New Roman", serif;
    --ww1-type: "PT Mono", "Courier New", monospace;

    --ww1-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.10'/%3E%3C/svg%3E");
    --ww1-wire: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='36'%3E%3Cpath d='M10 0V36' stroke='%238c5e3c' stroke-width='1.5'/%3E%3Cpath d='M4 12L16 24M16 12L4 24' stroke='%238c5e3c' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");

    background-color: var(--ww1-bg);
    color: var(--ww1-text);
    font-family: var(--ww1-serif);
    scrollbar-color: var(--ww1-accent) var(--ww1-bg);
}

body.theme-wwi ::selection {
    background: var(--ww1-poppy);
    color: #fff;
}

/* ФОН: фото обесцвечено заранее в CSS через затемняющий градиент.
   Совет: сохраните cover.jpg уже ч/б и ужатым (до ~200 КБ) — тогда filter не нужен
   и страница не будет тормозить на слабых телефонах. */
body.theme-wwi::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(rgba(15, 14, 12, 0.86), rgba(15, 14, 12, 0.96)),
        url("../assets/projects/wwi/cover.webp");
    background-size: cover;
    background-position: center;
    filter: grayscale(100%) sepia(40%) contrast(1.15) brightness(0.55);
}

/* Виньетка + плёночное зерно */
body.theme-wwi::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(ellipse at center, transparent 28%, rgba(0, 0, 0, 0.75) 100%),
        var(--ww1-grain);
}

/* =========================================================
   ШАПКА
   ========================================================= */
body.theme-wwi .project-hero {
    background: transparent;
    border-bottom: 1px solid var(--ww1-border);
    padding: 100px 8% 70px;
    position: relative;
}

/* двойная линия-«рамка» внизу шапки, как на газетной полосе */
body.theme-wwi .project-hero::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 6px;
    border-bottom: 1px solid var(--ww1-border);
}

body.theme-wwi #project-title {
    font-family: var(--ww1-head);
    font-weight: 700;
    color: #eadfca;
    letter-spacing: 0.04em;
    text-shadow: 2px 2px 0 #000, 0 0 30px rgba(0, 0, 0, 0.6);
}

body.theme-wwi #project-title::before,
body.theme-wwi #project-title::after {
    content: "✠";
    color: var(--ww1-accent);
    font-size: 0.45em;
    margin: 0 18px;
    vertical-align: middle;
}

/* Метка — штамп «как поставили печатью» */
body.theme-wwi #project-label {
    display: inline-block;
    background: transparent;
    border: 2px solid var(--ww1-poppy);
    outline: 1px solid var(--ww1-poppy);
    outline-offset: 3px;
    color: var(--ww1-poppy-bright);
    font-family: var(--ww1-type);
    letter-spacing: 0.24em;
    text-transform: uppercase;
    padding: 6px 14px;
    transform: rotate(-2deg);
    opacity: 0.92;
}

/* =========================================================
   ТАЙМЛАЙН
   ========================================================= */
body.theme-wwi .timeline-section {
    padding: 80px 8% 120px;
    position: relative;
}

body.theme-wwi .timeline-wrapper {
    position: relative;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    counter-reset: ww1-event;
}

/* Линия времени — колючая проволока */
body.theme-wwi .timeline-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 20px;
    transform: translateX(-50%);
    background: var(--ww1-wire) repeat-y center top;
    opacity: 0.55;
}

body.theme-wwi .timeline-event {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
    grid-template-areas: "photo dot card";
    align-items: center;
    gap: 24px;
    min-height: 240px;
    margin-bottom: 80px;
    counter-increment: ww1-event;
}

body.theme-wwi .timeline-event:nth-child(even) {
    grid-template-areas: "card dot photo";
}

/* Точка-ромб */
body.theme-wwi .timeline-dot {
    grid-area: dot;
    justify-self: center;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ww1-accent);
    background: var(--ww1-bg);
    transform: rotate(45deg);
    box-shadow: 0 0 0 5px rgba(140, 94, 60, 0.14);
    transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    z-index: 1;
}

body.theme-wwi .timeline-event.pf-event-active .timeline-dot {
    background: var(--ww1-poppy-bright);
    border-color: var(--ww1-poppy-bright);
    box-shadow: 0 0 0 5px rgba(164, 38, 44, 0.22), 0 0 18px var(--ww1-poppy-bright);
}

/* =========================================================
   ФОТО — «карточка из архива»
   ========================================================= */
body.theme-wwi .timeline-photo {
    grid-area: photo;
    justify-self: center;
    position: relative;
    width: 100%;
    max-width: 340px;
    height: 220px;
    overflow: hidden;
    border: 7px solid var(--ww1-paper);
    border-bottom-width: 20px;          /* белое поле снизу, как у старого снимка */
    background: #111;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.85);
    padding: 0;
    transform: rotate(-1.6deg);
    transition: transform 0.5s ease, box-shadow 0.5s ease;
}

body.theme-wwi .timeline-event:nth-child(even) .timeline-photo {
    transform: rotate(1.6deg);
}

/* Внутренняя виньетка на снимке */
body.theme-wwi .timeline-photo::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 45px rgba(0, 0, 0, 0.55);
}

body.theme-wwi .timeline-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: sepia(0.7) grayscale(0.5) contrast(1.1) brightness(0.85);
    transition: filter 0.5s ease, transform 0.8s ease;
}

body.theme-wwi .timeline-photo:hover {
    transform: rotate(0deg) scale(1.02);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.9);
}

body.theme-wwi .timeline-photo:hover img {
    filter: sepia(0.4) grayscale(0.2) contrast(1.2) brightness(0.98);
    transform: scale(1.05);
}

/* =========================================================
   КАРТОЧКА — «полевое донесение»
   ========================================================= */
body.theme-wwi .timeline-card {
    grid-area: card;
    justify-self: stretch;
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 24px 28px 26px;
    background-color: var(--ww1-panel);
    background-image: var(--ww1-grain);
    border: 1px solid var(--ww1-border);
    border-left: 3px solid var(--ww1-accent);
    box-shadow: 4px 6px 18px rgba(0, 0, 0, 0.65);
    font-family: var(--ww1-type);
    cursor: pointer;
    transition: transform 0.3s ease, border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Автонумерация событий: ДОНЕСЕНИЕ № 01, 02, 03… */
body.theme-wwi .timeline-card::before {
    content: "ДОНЕСЕНИЕ № " counter(ww1-event, decimal-leading-zero);
    display: block;
    font-family: var(--ww1-type);
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    color: var(--ww1-muted);
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 1px dashed var(--ww1-border);
}

body.theme-wwi .timeline-event:nth-child(even) .timeline-card {
    justify-self: end;
    border-left: 1px solid var(--ww1-border);
    border-right: 3px solid var(--ww1-accent);
    text-align: right;
}

body.theme-wwi .timeline-card:hover,
body.theme-wwi .timeline-card:focus-visible {
    background-color: rgba(46, 41, 34, 0.97);
    border-color: var(--ww1-accent-bright);
    transform: translateY(-4px);
    box-shadow: 6px 12px 26px rgba(0, 0, 0, 0.75);
    outline: none;
}

body.theme-wwi .timeline-card:focus-visible {
    outline: 2px solid var(--ww1-poppy-bright);
    outline-offset: 3px;
}

/* Год и дата */
body.theme-wwi .timeline-year {
    display: block;
    font-family: var(--ww1-head);
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--ww1-accent-bright);
    margin-bottom: 6px;
    line-height: 1;
    letter-spacing: 0.02em;
}

body.theme-wwi .timeline-date {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ww1-muted);
    margin-bottom: 14px;
}

body.theme-wwi .timeline-card h3 {
    font-family: var(--ww1-head);
    font-size: 1.4rem;
    color: #f2eadb;
    margin: 0 0 12px;
    line-height: 1.28;
}

body.theme-wwi .timeline-card p {
    font-family: var(--ww1-serif);
    font-size: 0.96rem;
    color: var(--ww1-muted);
    line-height: 1.65;
    margin-bottom: 18px;
}

body.theme-wwi .timeline-read-more {
    display: inline-block;
    color: var(--ww1-accent-bright);
    font-family: var(--ww1-type);
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.08em;
    border-bottom: 1px solid transparent;
    transition: color 0.25s ease, border-color 0.25s ease, letter-spacing 0.25s ease;
}

body.theme-wwi .timeline-card:hover .timeline-read-more {
    color: var(--ww1-poppy-bright);
    border-color: var(--ww1-poppy-bright);
    letter-spacing: 0.14em;
}

/* =========================================================
   ПЛАВНОЕ ПОЯВЛЕНИЕ ПРИ СКРОЛЛЕ (только CSS, без JS)
   В браузерах без поддержки событие просто видно сразу.
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: view()) {
        body.theme-wwi .timeline-event {
            animation: ww1-rise linear both;
            animation-timeline: view();
            animation-range: entry 0% cover 30%;
        }
    }
}

@keyframes ww1-rise {
    from { opacity: 0; transform: translateY(46px); }
    to   { opacity: 1; transform: none; }
}

/* =========================================================
   МОДАЛКА — лист документа
   ========================================================= */
body.theme-wwi .modal-content {
    background-color: #1c1a16;
    background-image: var(--ww1-grain);
    border: 1px solid var(--ww1-accent);
    border-top: 3px solid var(--ww1-poppy);
    border-radius: 0;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85);
}

body.theme-wwi #modal-title {
    font-family: var(--ww1-head);
    color: #f2eadb;
    line-height: 1.25;
}

body.theme-wwi #modal-body {
    font-family: var(--ww1-serif);
    font-size: 1.05rem;
    line-height: 1.8;
    color: #cfc7b5;
}

/* Заголовки, выделения и ссылки в тексте: общие стили (css/style.css) красят их тёмным
   под светлое окно, на тёмном листе они не читались */
body.theme-wwi #modal-body h1,
body.theme-wwi #modal-body h2,
body.theme-wwi #modal-body h3,
body.theme-wwi #modal-body h4 {
    font-family: var(--ww1-head);
    color: #f2eadb;
    line-height: 1.25;
}

body.theme-wwi #modal-body h2 {
    margin-top: 1.8em;
    padding-top: 0.9em;
    border-top: 1px solid var(--ww1-border);
}

body.theme-wwi #modal-body h3,
body.theme-wwi #modal-body h4 {
    color: #e6d3b8;
}

body.theme-wwi #modal-body strong,
body.theme-wwi #modal-body b,
body.theme-wwi #modal-body th {
    color: #f2eadb;
}

body.theme-wwi #modal-body em {
    color: #ddd3bf;
}

body.theme-wwi #modal-body a {
    color: var(--ww1-accent-bright);
    text-decoration: underline;
    text-underline-offset: 3px;
}

body.theme-wwi #modal-body a:hover {
    color: #e0a877;
}

body.theme-wwi #modal-body code {
    background: rgba(217, 207, 186, 0.1);
    color: #e6d3b8;
}

body.theme-wwi #modal-body hr {
    border: 0;
    border-top: 1px solid var(--ww1-border);
}

body.theme-wwi #modal-body td,
body.theme-wwi #modal-body th {
    border-color: var(--ww1-border);
}

body.theme-wwi #modal-body figcaption {
    color: var(--ww1-muted);
}

body.theme-wwi .modal-date {
    color: var(--ww1-muted);
}

body.theme-wwi .pf-modal-toc {
    color: #e0d6c1;
    border-left-color: var(--ww1-accent-bright);
}

/* буквица на первом абзаце, как в старых книгах; не ставится на строку справки
   «Дата: … Место: …», которая начинается с выделения */
body.theme-wwi #modal-body > p:first-of-type:not(:has(> strong:first-child))::first-letter {
    float: left;
    font-family: var(--ww1-head);
    font-size: 3.6em;
    line-height: 0.85;
    padding: 6px 10px 0 0;
    color: var(--ww1-accent-bright);
}

body.theme-wwi #modal-body blockquote {
    margin: 1.4em 0;
    padding: 0.4em 1.2em;
    border-left: 3px solid var(--ww1-poppy);
    font-style: italic;
    color: #e0d6c1;
}

body.theme-wwi #modal-body img {
    max-width: 100%;
    height: auto;
    border: 5px solid var(--ww1-paper);
    filter: sepia(0.5) grayscale(0.4);
}

/* =========================================================
   МОБИЛЬНАЯ ВЕРСИЯ
   ========================================================= */
@media (max-width: 760px) {
    body.theme-wwi .project-hero {
        padding: 80px 6% 50px;
    }

    body.theme-wwi #project-title::before,
    body.theme-wwi #project-title::after {
        display: none;    /* кресты на узком экране ломают заголовок */
    }

    body.theme-wwi .timeline-event,
    body.theme-wwi .timeline-event:nth-child(even) {
        grid-template-columns: 28px minmax(0, 1fr);
        grid-template-areas:
            "dot card"
            "dot photo";
        gap: 16px;
        margin-bottom: 54px;
    }

    body.theme-wwi .timeline-dot {
        justify-self: start;
        margin-left: 5px;
        margin-top: 20px;
    }

    body.theme-wwi .timeline-wrapper::before {
        left: 12px;
    }

    body.theme-wwi .timeline-card,
    body.theme-wwi .timeline-event:nth-child(even) .timeline-card {
        justify-self: stretch;
        text-align: left;
        border-left: 3px solid var(--ww1-accent);
        border-right: 1px solid var(--ww1-border);
        max-width: none;
        padding: 20px 20px 22px;
    }

    body.theme-wwi .timeline-photo,
    body.theme-wwi .timeline-event:nth-child(even) .timeline-photo {
        justify-self: stretch;
        max-width: none;
        height: auto;
        aspect-ratio: 16 / 9;
        transform: rotate(0deg);
    }
}

/* Уважаем настройку «уменьшить анимацию» */
@media (prefers-reduced-motion: reduce) {
    body.theme-wwi *,
    body.theme-wwi *::before,
    body.theme-wwi *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* =========================================================
   ГЛОБУС — «старинная штабная карта»
   (общая разметка и раскладка — .pf-map в theme-wwii.css,
   цвета самого шара — MAP_STYLES.wwi в js/project.js)
   ========================================================= */
body.theme-wwi .pf-map {
    --map-ink: var(--ww1-paper);
    --map-muted: var(--ww1-muted);
    --map-accent: var(--ww1-accent-bright);
    --map-hot: var(--ww1-poppy-bright);
    --map-bg: rgba(24, 22, 18, 0.96);
    --map-line: var(--ww1-border);
}

body.theme-wwi .pf-map-launch,
body.theme-wwi .pf-map-label,
body.theme-wwi .pf-map-year,
body.theme-wwi .pf-map-legend,
body.theme-wwi .pf-map-hint,
body.theme-wwi .pf-map-status {
    font-family: var(--ww1-type);
}

body.theme-wwi .pf-map-launch {
    border-radius: 2px;
}

body.theme-wwi .pf-map-launch svg {
    color: var(--ww1-poppy-bright);
}

body.theme-wwi .pf-map-panel {
    border-radius: 2px;
    background: var(--ww1-grain), var(--map-bg);
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.8),
        inset 0 0 0 3px rgba(24, 22, 18, 0.96),
        inset 0 0 0 4px rgba(194, 135, 90, 0.25);
}

body.theme-wwi .pf-map-head,
body.theme-wwi .pf-map-legend,
body.theme-wwi .pf-map-caption {
    border-color: var(--ww1-border);
}

body.theme-wwi .pf-map-tool {
    border-color: var(--ww1-border);
    border-radius: 2px;
}

body.theme-wwi .pf-map-frame {
    background: radial-gradient(ellipse at center, rgba(194, 135, 90, 0.12), transparent 70%);
}

body.theme-wwi .pf-map-year {
    color: var(--ww1-poppy-bright);
}

body.theme-wwi .pf-map-place {
    font-family: var(--ww1-head);
}
