:root {
  --bg-dark: rgba(0,0,0,0.4);
  --bg-light: #ebeae8;
  --text-light: #ffffff;
  --text-dark: #1a1a1a;
  --text-muted: #666666;
  --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    overflow: hidden;
    background-color: var(--bg-light);
    user-select: none;
}

/* Background Layer — full viewport */
.app-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-image: url('assets/bg.png');
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    /* Обратный ход (свет → дорога): полоса сужается обратно, деревья опускаются сверху */
    transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1),
                filter 1.2s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.7s ease 0.15s;
    /* Основание белой полосы дороги: зум от него раздувает полосу на весь экран,
       а верх кадра (деревья, горизонт) улетает вверх */
    transform-origin: 50% 100%;
    overflow: hidden;
    will-change: transform, filter, opacity;
}

/* Белая «заливка», поднимающаяся от основания полосы вверх — цвет 1:1 с фоном,
   поэтому переход полоса → фон бесшовный */
.app-bg::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(
        to top,
        #ebeae8 0%,
        #ebeae8 30%,
        rgba(235, 234, 232, 0) 100%
    );
    opacity: 0;
    transform: translateY(40%);
    transition: opacity 0.6s ease, transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

/* Прямой ход (дорога → свет): деревья улетают вверх, белая полоса
   раздувается от нижней кромки и становится фоном экрана */
.app-bg.zoom-in {
    transform: scale(6);
    filter: blur(4px) brightness(1.04) saturate(0.9);
    transition: transform 1.6s cubic-bezier(0.45, 0, 0.2, 1),
                filter 1.4s cubic-bezier(0.45, 0, 0.2, 1),
                opacity 0.5s ease 0.2s;
}

.app-bg.zoom-in::after {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.8s ease 0.3s, transform 1.6s cubic-bezier(0.45, 0, 0.2, 1);
}

.app-bg.blurred {
    filter: blur(15px) brightness(0.6);
}

.app-bg.hidden {
    opacity: 0;
}

/* Container — full viewport, no width limit */
.app-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Каскадное всплытие пунктов и карточек при появлении экрана */
@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(26px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen.active .menu-item,
.screen.active .submenu-item,
.screen.active .track-item,
.screen.active .video-item,
.screen.active .article-item {
    animation: riseIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.screen.active .menu-item:nth-child(1), .screen.active .submenu-item:nth-child(1),
.screen.active .track-item:nth-child(1), .screen.active .video-item:nth-child(1),
.screen.active .article-item:nth-child(1) { animation-delay: 0.05s; }

.screen.active .menu-item:nth-child(2), .screen.active .submenu-item:nth-child(2),
.screen.active .track-item:nth-child(2), .screen.active .video-item:nth-child(2),
.screen.active .article-item:nth-child(2) { animation-delay: 0.13s; }

.screen.active .menu-item:nth-child(3), .screen.active .submenu-item:nth-child(3),
.screen.active .track-item:nth-child(3), .screen.active .video-item:nth-child(3),
.screen.active .article-item:nth-child(3) { animation-delay: 0.21s; }

.screen.active .menu-item:nth-child(4), .screen.active .submenu-item:nth-child(4),
.screen.active .track-item:nth-child(4), .screen.active .video-item:nth-child(4),
.screen.active .article-item:nth-child(4) { animation-delay: 0.29s; }

.screen.active .menu-item:nth-child(n+5), .screen.active .submenu-item:nth-child(n+5),
.screen.active .track-item:nth-child(n+5), .screen.active .video-item:nth-child(n+5),
.screen.active .article-item:nth-child(n+5) { animation-delay: 0.37s; }

/* ========================================
   1. Home Screen
   ======================================== */
#screen-home {
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.logo-433-wrapper {
    position: relative;
    width: 320px;
    max-width: 400px;
    mix-blend-mode: screen;
    opacity: 0.9;
    transform: translateY(-25vh);
}

.logo-part {
    width: 100%;
    display: block;
    position: absolute;
    top: 0; left: 0;
}

.logo-left {
    position: relative;
    clip-path: polygon(0 0, 47% 0, 47% 100%, 0 100%);
}

.logo-right {
    clip-path: polygon(53% 0, 100% 0, 100% 100%, 53% 100%);
}

.logo-colon {
    clip-path: polygon(47% 0, 53% 0, 53% 100%, 47% 100%);
}

.blink {
    animation: blinker 2s step-start infinite;
}

@keyframes blinker {
    50% { opacity: 0; }
}

/* ========================================
   2. Menu Screen
   ======================================== */
#screen-menu {
    justify-content: center;
    align-items: center;
    color: var(--text-dark);
}

.menu-logo-img {
    cursor: pointer;
    z-index: 100;
}

.menu-433-topcenter {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    filter: invert(1);
    mix-blend-mode: multiply;
}

.search-box-wrapper {
    margin-bottom: 50px;
    width: 80%;
    max-width: 400px;
    position: relative;
}

.search-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.4);
    color: var(--text-dark);
    padding: 8px 8px 8px 35px;
    font-size: 18px;
    width: 100%;
    outline: none;
    font-family: var(--font-family);
    font-weight: 300;
    text-transform: uppercase;
}

.search-input::placeholder {
    color: rgba(0,0,0,0.4);
}

.search-icon {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px; height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}

.menu-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.menu-item {
    font-size: 52px;
    font-weight: 300;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.2s, letter-spacing 0.3s;
}

.menu-item:hover {
    opacity: 0.7;
    letter-spacing: 4px;
}

.menu-bottom-arrow {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
}

.menu-bottom-arrow svg {
    width: 44px; height: 44px;
    fill: none;
    stroke: var(--text-dark);
    stroke-width: 1;
}

.menu-logo-img {
    position: absolute;
    bottom: 40px;
    right: 40px;
    width: 100px;
    height: auto;
    max-height: 100px;
    object-fit: contain;
    mix-blend-mode: multiply;
}

/* ========================================
   Light Screens (Submenus, Content)
   ======================================== */
.screen-light {
    background: var(--bg-light);
    color: var(--text-dark);
    box-shadow: inset 0 60px 80px -30px rgba(0,0,0,0.3);
    overflow-y: auto;
}

/* Header for light screens */
.header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 40px;
    position: relative;
    margin-top: 20px;
}

.back-btn {
    position: absolute;
    left: 40px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 10px;
    display: flex;
    align-items: center;
}

.back-btn svg {
    width: 32px; height: 32px;
    fill: none;
    stroke: var(--text-dark);
    stroke-width: 1.5;
}

.header-title {
    font-size: 48px;
    font-weight: 300;
    text-transform: uppercase;
}

.light-search {
    margin: 10px auto 50px;
    width: 80%;
    max-width: 500px;
}

.light-search .search-input {
    border-bottom: 1px solid rgba(0,0,0,0.3);
    color: var(--text-dark);
}

.light-search .search-input::placeholder {
    color: rgba(0,0,0,0.3);
}

.light-search .search-icon {
    stroke: var(--text-dark);
}

/* ========================================
   Submenu Lists
   ======================================== */
.submenu-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.submenu-item {
    font-size: 42px;
    font-weight: 300;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.2s, letter-spacing 0.3s;
}

.submenu-item:hover {
    opacity: 0.6;
    letter-spacing: 3px;
}

/* ========================================
   Track List
   ======================================== */
.track-list {
    padding: 0 40px 60px;
    display: flex;
    flex-direction: column;
    gap: 35px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.track-item {
    border-bottom: 1px solid var(--text-dark);
    padding-bottom: 20px;
}

.track-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.track-desc {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.5;
}

.track-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
}

.track-time {
    font-size: 16px;
    margin-right: 15px;
    font-weight: 400;
}

.icon-btn {
    cursor: pointer;
    background: none;
    border: none;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.15);
}

.icon-btn svg {
    width: 36px; height: 36px;
    fill: none;
    stroke: var(--text-dark);
    stroke-width: 1.5;
}

/* ========================================
   Video List
   ======================================== */
.video-list {
    padding: 0 40px 60px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 35px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.video-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.video-thumb {
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 */
    background: #ccc;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    transition: transform 0.3s, box-shadow 0.3s;
}

.video-thumb:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.video-thumb img,
.video-thumb video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    font-weight: 300;
    letter-spacing: 2px;
}

.video-time {
    position: absolute;
    bottom: 10px; left: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 4px;
}

.video-info {
    padding: 5px 0;
}

.video-title {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
}

/* ========================================
   Text Article List
   ======================================== */
.article-list {
    padding: 0 40px 60px;
    display: flex;
    flex-direction: column;
    gap: 50px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.article-item {
    border-bottom: 1px solid rgba(0,0,0,0.2);
    padding-bottom: 25px;
}

.article-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 18px;
}

.article-text {
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-line;
    margin-bottom: 30px;
}

.article-controls {
    display: flex;
    justify-content: center;
}

/* ========================================
   Image Grids
   ======================================== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 0 40px 60px;
    max-width: 1200px;
    margin: 0 auto;
}

.photo-item {
    width: 100%;
    aspect-ratio: 3/4;
    background: #ccc;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 4px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.photo-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.18);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    padding: 0 40px 60px;
    max-width: 1200px;
    margin: 0 auto;
}

.card-item {
    width: 100%;
    height: auto;
    background: #ccc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 4px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.18);
}

.card-item img {
    width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   Login / Registration Form
   ======================================== */
.form-container {
    padding: 0 40px 40px;
    max-width: 450px;
    margin: 60px auto 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 40px;
}

.form-input {
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.3);
    background: transparent;
    padding: 12px 5px;
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: -20px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-btn {
    background: transparent;
    border: none;
    font-size: 28px;
    font-family: var(--font-family);
    font-weight: 300;
    cursor: pointer;
    margin-top: 20px;
    transition: opacity 0.2s;
}

.form-btn:hover {
    opacity: 0.6;
}

.form-link {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.form-link:hover {
    opacity: 0.6;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 768px) {

    /* Menu: positioned in upper half */
    #screen-menu {
        justify-content: flex-start;
        padding-top: 12vh;
    }

    .search-box-wrapper {
        margin-bottom: 30px;
    }

    /* Smaller menu items */
    .menu-item {
        font-size: 28px;
        gap: 18px;
    }
    .menu-list {
        gap: 18px;
    }
    
    .menu-433-topcenter {
        top: 25px;
        left: 50%;
        transform: translateX(-50%);
        width: 100px;
    }

    /* Submenu items smaller */
    .submenu-item {
        font-size: 28px;
    }

    /* Header titles smaller */
    .header-title {
        font-size: 32px;
    }

    .header {
        padding: 15px 20px;
    }

    .back-btn {
        left: 20px;
    }

    /* Content areas */
    .track-title {
        font-size: 18px;
    }
    .track-desc {
        font-size: 13px;
    }
    .article-title {
        font-size: 18px;
    }
    .article-text {
        font-size: 14px;
    }

    /* Logo on home screen (scoped: must not override .menu-433-topcenter transform) */
    #screen-home .logo-433-wrapper {
        width: 200px;
        transform: translateY(-25vh);
    }
}

/* ============================================== */
/* API-интеграция: авторизация, лайки, комментарии */
/* ============================================== */

.hidden {
    display: none !important;
}

.form-status {
    margin-top: 15px;
    font-size: 14px;
    color: #2e7d32;
    min-height: 20px;
    text-align: center;
}

.form-status.error {
    color: #c62828;
}

.form-file {
    padding: 12px;
    cursor: pointer;
}

select.form-input {
    cursor: pointer;
    appearance: none;
}

/* Лайки */
.icon-btn.liked svg path {
    fill: #e53935;
    stroke: #e53935;
}

.like-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 4px;
    vertical-align: middle;
}

/* Плееры */
.media-audio {
    width: 100%;
    margin: 10px 0;
    height: 36px;
}

.video-thumb-player video,
.video-thumb-player img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* Фото с сервера */
.photo-item-real {
    background-size: cover;
    background-position: center;
    position: relative;
}

.photo-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    padding: 4px 8px;
}

.fav-photo {
    max-width: 100%;
    max-height: 240px;
    display: block;
    margin: 10px 0;
    border-radius: 8px;
}

/* Комментарии */
.comments-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.comments-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.comment-item {
    font-size: 13px;
    color: var(--text-dark);
    padding: 4px 0;
}

.comment-form {
    display: flex;
    gap: 8px;
}

.comment-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: var(--font-family);
    font-size: 13px;
    background: transparent;
    outline: none;
}

.comment-send {
    border: none;
    background: var(--text-dark);
    color: #fff;
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 16px;
}

.empty-note {
    font-size: 14px;
    color: var(--text-muted);
    padding: 10px 0;
}

/* Админ: редактирование и удаление */
.js-edit svg, .js-delete svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.js-delete:hover svg {
    stroke: #c62828;
}

.edit-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-block .comment-input {
    width: 100%;
    background: #fff;
}

.edit-actions {
    display: flex;
    gap: 8px;
}

.edit-actions .comment-send {
    padding: 8px 14px;
    font-size: 13px;
}

.edit-cancel {
    background: transparent;
    color: var(--text-dark);
    border: 1px solid rgba(0, 0, 0, 0.3);
}

/* Форма редактирования поверх фото-плитки */
.photo-item-real .edit-block {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    margin: 0;
    border-top: none;
    z-index: 2;
}

/* ============================================== */
/* Биография автора */
/* ============================================== */

.bio-container {
    width: 80%;
    max-width: 640px;
    margin: 10px auto 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.bio-logo {
    width: 180px;
    max-width: 60%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.bio-text {
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-line;
    text-align: center;
}

@media (max-width: 768px) {
    .bio-logo {
        width: 140px;
    }

    .bio-text {
        font-size: 14px;
    }
}

/* ============================================== */
/* Поиск */
/* ============================================== */

.search-sections {
    margin-bottom: 30px;
}

.search-sections .submenu-item {
    font-size: 24px;
}

#search-results {
    padding-bottom: 60px;
}

.search-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
    font-size: 13px;
}

.search-section-link {
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
}

.search-section-link:hover {
    color: var(--text-dark);
}

.search-tags {
    color: var(--text-muted);
}

/* ============================================== */
/* Лайтбокс: просмотр фото в полном размере */
/* ============================================== */

.photo-item-real,
.fav-photo {
    cursor: zoom-in;
}

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    padding: 24px;
    align-items: center;
    justify-content: center;
}

.lightbox.open {
    display: flex;
    animation: lightboxFade 0.2s ease;
}

@keyframes lightboxFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 24px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================== */
/* Текстовые посты (Читать / Учить / Идеи) */
/* ============================================== */

.article-cover {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 18px;
    cursor: zoom-in;
    display: block;
}

/* свёрнутый длинный текст */
.article-text-fold {
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-more {
    background: transparent;
    border: none;
    padding: 0;
    margin: -18px 0 24px;
    color: var(--text-muted);
    text-decoration: underline;
    font-size: 14px;
    cursor: pointer;
}

.article-more:hover {
    color: var(--text-dark);
}

.article-tags {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 18px;
}

/* поле ввода текста в форме загрузки и редактирования */
#upload-text,
.edit-text {
    resize: vertical;
    min-height: 90px;
    line-height: 1.6;
    font-family: inherit;
}

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: -6px 0 4px;
}
