@font-face {
    font-family: "Buttons";
    src: url("/static/fonts/Buttons.ttf2") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Card";
    src: url("/static/fonts/Card.woff2") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Title";
    src: url("/static/fonts/Title.woff2") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Title";
    src: url("/static/fonts/Card_Medium.woff2") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #ffffff;
    --text: #000000;
    --radius: 26px;
    --gutter: 16px;
    --ads-gap: 15px;
    --vh: 100vh;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: "Card", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-y: hidden;
}

.btn,
.btn-show-more,
.modal__close,
.search {
    font-family: "Buttons", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.section-title,
.modal__title {
    font-family: "Title", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.card-overlay,
.p-caption {
    font-family: "Title", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.project-title {
    font-family: "Card", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.project-price {
    font-family: "Card_Medium", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
    padding-top: calc(var(--tg-safe-area-inset-top) + 46px + 16px);
    min-height: 100vh;
    height: var(--vh);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Header */
.topbar {
    padding: 12px var(--gutter) 6px;
    background: var(--bg);
}

.topbar__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.topbar__actions a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
}

.search {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 12px 10px 35px;
    border-radius: 999px;
    border: 0;

    background: #5F5F5F url('../static/images/lupa.svg') no-repeat 14px center;

    color: #f5f5f5;
    outline: none;
    font: inherit;
    cursor: pointer;
}

.search::placeholder {
    color: #C2C2C2;
    font-size: 12px;
}

.btn {
    padding: 10px 30px;
    justify-content: center;
    border-radius: 999px;
    border: 0;
    background: #5F5F5F;
    color: #C2C2C2;
    font: inherit;
    font-weight: 700;
    margin: 0;
    cursor: pointer;
}

.btn:active {
    background: #333;
}

/* Главная карусель с Swiper */
.carousel {
    padding: 20px 0;
    overflow: visible;
    position: relative;
}

.swiper {
    width: 100%;
    overflow: visible !important;
}

.swiper-wrapper {
    display: flex;
    align-items: center;
}

.swiper-slide {
    width: 260px !important;
    height: auto;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.card {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius);
    overflow: hidden;
    background: #1a1a1a;
    position: relative;
    text-decoration: none;
    color: inherit;
    transition: transform 0.35s ease;
    transform: translateZ(0) scale(0.9);
}

.card.is-center {
    transform: translateZ(0) scale(1.05);
    opacity: 1;
    z-index: 10;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.card-overlay {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    color: #fff;
    font-weight: 900;
    font-size: 16px;
    line-height: 1.05;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0,0,0,0.8);
}

/* Секции каруселей */
.section-carousel {
    margin-bottom: 32px;
}

.section-carousel__header {
    display: flex;
    align-items: center;
    padding: 0 var(--gutter);
    margin-bottom: 16px;
    margin-top: 0px;
    gap: 10px;
}

.section-title {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    gap: 10px;
}


.info-btn {
    background: none;
    border: none;
    color: var(--text);
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

/* Горизонтальные карусели */
.swiper-top,
.swiper-new {
    overflow: visible;
    padding: 0 var(--gutter);
}

.swiper-top .swiper-wrapper,
.swiper-new .swiper-wrapper {
    display: flex;
    align-items: flex-start;    /* ✅ ПО ВЕРХУ вместо center */
}

.swiper-top .swiper-slide,
.swiper-new .swiper-slide {
    width: 180px !important;
    height: auto;
    vertical-align: top;        /* ✅ Дополнительное выравнивание */
    align-self: flex-start;     /* ✅ По верху */
}

.swiper-top .project-card,
.swiper-new .project-card {
    display: block;
    width: 100%;
    height: 100%;
}

/* Секция проектов (сетка 2 в ряд) */
.projects-section {
    padding: 0 var(--gutter) 32px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.project-card {
    display: none;
    border-radius: 18px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex !important;           /* ✅ Flexbox */
    flex-direction: column !important;  /* ✅ Вертикально */
    min-height: 280px;                  /* ✅ Минимум */
}

.project-card.visible {
    display: flex !important;
}

.project-card:active {
    transform: scale(0.98);
}

.project-img {
    width: 100%;
    height: 220px;                      /* ✅ Фиксировано 220px */
    object-fit: cover;
    border-radius: 18px;
    flex-shrink: 0;                     /* ✅ Не сжимается */
}

.project-content {
    position: static !important;        /* ✅ НЕ absolute */
    flex: 1 !important;                 /* ✅ Занимает ВСЁ место */
    padding: 12px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.project-price {
    color: #000000;
    font-size: 14px;
    font-weight: 700;
    font-style: italic;
    line-height: 1.4;
}

.project-flag {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0;
}

.project-title {
    color: #000000;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.btn-show-more {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 0;
    background: #2a2a2a;
    color: #f5f5f5;
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-show-more:active {
    background: #333;
}

.btn-show-more.hidden {
    display: none;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 var(--gutter) 24px;
}

.grid .tile {
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 280px;
}

.grid .tile:active {
    transform: scale(0.97);
}

.grid .tile-img {
    width: 100%;
    height: 220px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 18px;
}

.grid .tile-title {
    color: #000;
    font-weight: 800;
    font-size: 14px;
}

.grid .project-content {
    flex: 1;
    padding: 12px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.search-overlay .header-bar {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 1001;
    height: calc(var(--tg-safe-area-inset-top) + 46px + 16px);
}

.search-overlay::before {
    content: "";
    height: calc(var(--tg-safe-area-inset-top) + 46px + 16px);
    display: block;
}

.search-overlay .topbar {
    box-sizing: content-box;
}

.search-overlay.is-open {
    display: flex;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    padding: 16px;
    z-index: 10000;
}

.modal.is-open {
    display: block;
}

.modal__panel {
    height: 100%;
    background: #1a1a1a;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal__top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #0f0f0f;
}

.modal__close {
    border: 0;
    background: #2a2a2a;
    color: #f5f5f5;
    padding: 10px 12px;
    border-radius: 999px;
    font-weight: 800;
    cursor: pointer;
}

.modal__close:active {
    background: #333;
}

.modal__title {
    font-weight: 900;
}

.modal__footer {
    padding: 0 14px 14px;
    color: #6b7280;
}

.p-carousel {
    padding: 14px 0;
}

.p-track {
    display: flex;
    gap: 12px;
    overflow-x: scroll;
    padding: 0 14px 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.p-track::-webkit-scrollbar {
    display: none;
}

.p-slide {
    flex: 0 0 280px;
    aspect-ratio: 3 / 4;
    border-radius: 16px;
    overflow: hidden;
    background: #111827;
    position: relative;
    scroll-snap-align: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.p-slide:active {
    transform: scale(0.98);
}

.p-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.92;
}

.p-caption {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    color: #fff;
    font-weight: 900;
    text-shadow: 0 2px 12px rgba(0,0,0,0.8);
}

.header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--tg-safe-area-inset-top) + 46px + 16px);
    background: rgba(0, 0, 0, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(20px);
}

.header-text {
    font-family: "Title", sans-serif !important;
    font-size: 11px !important;
    font-weight: 700;
    color: #ffffff !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1;
    padding-top: 24px !important;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
