/* ========== Общие предохранители ========== */
html, body { overflow-x: clip; }

.site-content h1,
.site-content h2,
.site-content h3 {
    font-family: "Volkhov", serif;
}

.site-content h2,
.site-content h3 {
    color: #bcad74;
    font-family: "Volkhov", serif;
}

.cstf-actions {
    padding-bottom: 25px;
    padding-top: 15px;
}

/* ========== Edge-to-edge секции (без горизонтального скролла) ========== */
.cstf-hero,
.cstf-woodbelt {
    position: relative;
    width: 100dvw;
    margin-left: calc(50% - 50dvw);
    margin-right: calc(50% - 50dvw);
}
@supports not (width: 100dvw) {
    .cstf-hero,
    .cstf-woodbelt {
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
    }
}
.cstf-hero {
    max-height: 500px;
    overflow: hidden;
    z-index: 1;
}
.cstf-hero img {
    display: block;
    width: 100%;
    height: 500px;
    object-fit: cover;
}

/* ===== Деревянная подложка под героем ===== */
.cstf-woodbelt {
    border-top: 5px solid #BCAD74;
    background: #faf9f5 url("https://cornerstonetimberframes.com/wp-content/uploads/2022/09/wood-grain.jpg") center top/cover no-repeat;
}
.cstf-woodbelt__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 26px 16px 22px;
}
.cstf-woodbelt h1 {
    margin: 0;
    text-align: center;
    line-height: 1.15;
    font-size: clamp(28px, 4vw, 44px);
    font-family: "Volkhov", serif;
}
@media (max-width: 768px) {
    .cstf-woodbelt__inner {
        padding: 20px 12px 18px;
    }
    .cstf-woodbelt h1 {
        font-size: clamp(24px, 6vw, 34px);
    }
}

/* ===== Контент и блоки ===== */
.cstf-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Атрибуты портфолио */
.cstf-attrs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 14px 0 18px;
}
.cstf-attrs .row {
    display: grid;
    grid-template-rows: auto auto;
    background: #f8f8f8;
    border: 1px solid #e9e9e9;
    border-radius: 10px;
    padding: 12px 14px;
}
.cstf-attrs dt {
    margin: 0;
    color: #bcad74;
    font-weight: 400;
    font-size: 16px;
    letter-spacing: .02em;
}
.cstf-attrs dd {
    margin: 4px 0 0 0;
    color: #2e3331;
}
@media (max-width: 992px) {
    .cstf-attrs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 600px) {
    .cstf-attrs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Галерея (портфолио, не блог) */
.cstf-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 22px 0;
}
.cstf-gallery a { display: block; }
.cstf-gallery img {
    width: 100%;
    height: 210px;
    object-fit: cover;
    border-radius: 6px;
}

/* ===== Лента “ещё проекты” ===== */
.cstf-woodband {
    position: relative;
    margin: 40px 0 0;
    padding: 28px 0;
    z-index: 0;
}
.cstf-woodband::before {
    content: "";
    position: absolute;
    inset: 0;
    left: 50%;
    width: 100dvw;
    margin-left: -50dvw;
    background: #faf9f5 url('/wp-content/uploads/core/bg-home-top.jpg') center/cover no-repeat;
    z-index: -1;
}
@supports not (width: 100dvw) {
    .cstf-woodband::before {
        width: 100vw;
        margin-left: -50vw;
    }
}

.cstf-woodband__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

.cstf-woodband .reel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 18px;
    overflow: visible;
}

.cstf-woodband .card {
    display: block;
    flex: 0 1 320px;
    background: #ffffffcc;
    border-radius: 2px;
    box-shadow: 0 3px 10px rgba(0,0,0,.08);
    overflow: hidden;
    text-decoration: none;
    transition: transform .25s ease, box-shadow .25s ease;
}
.cstf-woodband .card:hover {
    transform: translateY(-15px);
    box-shadow: 0 6px 16px rgba(0,0,0,.12);
}

.cstf-woodband .card img {
    display: block;
    width: 100%;
    aspect-ratio: 16/9;
    height: auto;
    object-fit: cover;
}

.cstf-woodband .card .t {
    padding: 10px 12px 12px;
    color: #ffffff;
    font-weight: 400;
    line-height: 1.25;
    text-align: center;
    height: 60px;
    background: var(--cstf-gold);
}
.cstf-woodband .card:hover .t,
.cstf-woodband .card:focus .t {
    text-decoration: none;
    text-decoration-thickness: 1px;
    color: #2e3331 !important;
}

@media (max-width: 600px) {
    .cstf-woodband { padding: 22px 0; }
    .cstf-woodband .card {
        flex-basis: 100%;
        max-width: 520px;
    }
}

/* Шапка блога без h1 (заголовок уже в .cstf-woodbelt) */
.cstf-blog-head {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 16px;
}

/* ===== Кнопка (единый стиль) ===== */
.cstf-btn-subscribe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.2rem;
    border-radius: 5px;
    background: #bcad74 !important;
    border: 1px solid #a4985b !important;
    color: #ffffff !important;
    text-decoration: none !important;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: .06em;
    box-shadow: 0 2px 0 rgba(0,0,0,.06);
    transition: background-color .2s ease, border-color .2s ease, transform .02s;
    width: 100%;
}
.cstf-btn-subscribe:hover {
    background: #e6d590 !important;
    border-color: #bcad74 !important;
    color: #2e3331 !important;
}
.cstf-btn-subscribe:active { transform: translateY(1px); }

/* ===== Media bar (плеер + PDF) ===== */
.cstf-media-bar {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 35px;
    align-items: center;
    margin-top: 12px;
}
.cstf-media-bar > :last-child .cstf-btn-subscribe { width: 100%; }
@media (max-width: 900px) {
    .cstf-media-bar {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ===== Кастомный аудиоплеер ===== */
.cstf-player {
    display: grid;
    grid-template-columns: auto auto 1fr auto auto auto 110px;
    gap: 10px;
    align-items: center;
    background: #fff;
    border: 1px solid #a4985b;
    border-radius: 5px;
    padding: 8px 12px;
    width: 100%;
}
@media (max-width: 900px) {
    .cstf-player {
        grid-template-columns: auto auto 1fr auto auto;
        grid-auto-rows: auto;
    }
    .cstf-player .cstf-volume { display: none; }
}
.cstf-player audio { display: none; } /* скрыть нативный */

.cstf-plr-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 20%;
    background: #bcad74;
    border: 0;
    cursor: pointer;
    transition: transform .05s ease, filter .2s ease;
}
.cstf-plr-btn:hover { filter: brightness(1.05); }
.cstf-plr-btn:active { transform: translateY(1px); }

.cstf-plr-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    position: relative;
    top: -2px;
    left: -8px;
}
.cstf-plr-btn svg,
.cstf-plr-btn svg * {
    fill: #fff !important;
    stroke: #fff !important;
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}
.cstf-time {
    color: #a4985b;
    font-weight: 600;
    font-size: 12px;
    min-width: 42px;
    text-align: center;
}
.cstf-seek {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #dee2e6;
    border-radius: 6px;
    outline: none;
    width: 100%;
}
.cstf-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e6d590;
    border: 1px solid #a4985b;
    cursor: pointer;
}
.cstf-seek::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e6d590;
    border: 1px solid #a4985b;
    cursor: pointer;
}
.cstf-volume {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #dee2e6;
    border-radius: 6px;
    outline: none;
    width: 110px;
}
.cstf-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #bcad74;
    border: 1px solid #a4985b;
    cursor: pointer;
}
.cstf-volume::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #bcad74;
    border: 1px solid #a4985b;
    cursor: pointer;
}

/* ===== Лайтбокс ===== */
.cstf-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.cstf-lightbox-overlay img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 8px;
}
.cstf-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    line-height: 0;
}
.cstf-lightbox-prev { left: 20px; }
.cstf-lightbox-next { right: 20px; }
.cstf-lightbox-nav::before {
    font-size: 45px;
    line-height: 1;
    color: #3E413E;
    display: block;
    transform: translate(2px,-6px);
}
.cstf-lightbox-prev::before { content: "\2039"; } /* ‹ */
.cstf-lightbox-next::before { content: "\203A"; } /* › */
.cstf-lightbox-nav:hover { background: #f6f6f6; }
.cstf-lightbox-nav:active { transform: translateY(-50%) scale(.98); }

/* ===== Галерея картинок в постах (flex) ===== */
.cstf-post-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* базово (мобильный) — одна картинка */
.cstf-post-gallery-item {
    flex: 1 1 100%;
    max-width: 100%;
}

/* планшет (~>=700px) — две колонки */
@media (min-width: 700px) {
    .cstf-post-gallery-item {
        flex: 1 1 calc(50% - 1.75rem);
        max-width: calc(50% - 1.75rem);
    }
}

/* десктоп (~>=1000px) — три колонки + лёгкая шахматка */
@media (min-width: 1000px) {
    .cstf-post-gallery-item {
        flex: 1 1 calc(33.333% - 1.75rem);
        max-width: calc(33.333% - 1.75rem);
    }

    .cstf-post-gallery-item:nth-child(odd) {
        margin-top: 1.5rem;
    }
}

.cstf-post-gallery-link {
    display: block;
    cursor: pointer;
    text-decoration: none;
}

/* форсируем нормальный размер превью */
.cstf-post-gallery-item img,
.entry-content .cstf-post-gallery-item img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    display: block;
    border-radius: 6px;
    object-fit: cover;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cstf-post-gallery-item:hover img {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}

/* дополнительно глушим стандартные thumbnail-классы WP */
.wp-block-image img,
img.size-thumbnail,
img.attachment-thumbnail {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
}

/* ===== Модальное окно галереи ===== */
.cstf-post-gallery-modal .modal-dialog {
    max-width: 1100px;
    margin: 1.5rem auto;
}
.cstf-post-gallery-modal .modal-body {
    padding: 0; background: rgba(255, 255, 255, 0.15);
}
.cstf-post-gallery-modal .carousel-inner img {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 180px);
    object-fit: contain;
}

/* ===== Override стандартной WP gallery, чтобы наша сетка была широкой ===== */
.entry-content .gallery {
    display: block;
    margin-left: 0;
    margin-right: 0;
}

.entry-content .gallery.gallery-columns-3 .gallery-item,
.entry-content .gallery .gallery-item {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.entry-content .gallery .gallery-item > .cstf-post-gallery-grid {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
}

/* ===== Печать (включая галерею) ===== */
@media print {
    @page { margin: 12mm; }
    html, body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    header, nav, .site-header, .site-footer,
    .elementor-location-header, .elementor-location-footer,
    .cstf-actions, .cstf-media-bar, .cstf-player, .cstf-btn-subscribe,
    .cstf-lightbox-overlay {
        display: none !important;
    }

    #cstf-print-area { position: static !important; }
    .cstf-wrap { padding: 0 !important; }

    .cstf-hero {
        position: static !important;
        margin: 0 0 12px 0 !important;
        width: 100% !important;
        max-height: none !important;
        overflow: visible !important;
        border: 0 !important;
        left: auto !important;
    }
    .cstf-hero img {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        object-fit: contain !important;
        page-break-inside: avoid !important;
    }

    .cstf-woodbelt {
        border: 0 !important;
        background: none !important;
        margin: 0 0 10px 0 !important;
        left: auto !important;
        width: auto !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .cstf-woodbelt__inner { padding: 0 !important; }
    .cstf-woodbelt h1,
    .cstf-title, .cstf-blog-head h1, .entry-title {
        color: #000 !important;
        margin: 0 0 10px 0 !important;
        padding: 0 !important;
        text-align: left !important;
        font-size: 20pt !important;
        line-height: 1.2 !important;
        font-weight: 700 !important;
        page-break-after: avoid !important;
    }

    .cstf-attrs {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }
    .cstf-attrs .row {
        border: 0 !important;
        padding: 0 !important;
    }
    .cstf-attrs dt {
        display: inline !important;
        font-style: italic !important;
    }
    .cstf-attrs dd {
        display: inline !important;
        margin-left: .4rem !important;
    }

    .cstf-wrap::before,
    .cstf-wrap::after {
        display: none !important;
    }

    /* ---- Галерея в постах при печати ---- */

    .gallery.gallery-columns-3 .gallery-item,
    .gallery.gallery-columns-4 .gallery-item,
    .gallery .gallery-item {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        margin: 0 0 6mm 0 !important;
    }

    .cstf-post-gallery-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* две колонки на печати */
        gap: 6mm;
        margin: 6mm 0 8mm 0;
    }

    .cstf-post-gallery-item {
        max-width: 100% !important;
        flex: none !important;
        margin: 0 !important;
        page-break-inside: avoid;
    }

    .cstf-post-gallery-item img {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

/* ===== Жёсткий оверрайд для WP-галереи ТОЛЬКО при печати ===== */
@media print {

  /* Делаем саму галерею flex-контейнером */
  .entry-content .gallery {
    display: flex !important;
    flex-wrap: wrap !important;
    margin: 6mm 0 8mm 0 !important;
  }

  /* Каждый gallery-item занимает 50% ширины (2 колонки) */
  .entry-content .gallery .gallery-item {
    width: 50% !important;
    max-width: 50% !important;
    float: none !important;
    margin: 0 0 6mm 0 !important;
    padding-right: 3mm;
    box-sizing: border-box;
  }

  /* Картинка тянется на всю ширину своего блока */
  .entry-content .gallery .gallery-item img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
  }
}

