/**
 * ZipNation — responsive breakpoints
 * Mobile:   0–767px
 * Tablet:   768–1023px
 * Desktop:  1024px+
 * Large:    1440px+
 */

:root {
    --bp-tablet: 768px;
    --bp-desktop: 1024px;
    --bp-large: 1440px;
    --container-max: 1280px;
    --container-wide: 1400px;
}

/* ===== BASE: mobile-first body ===== */
body {
    padding-bottom: 0;
}

@media (max-width: 767px) {
    body {
        padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    }
}

/* Visibility utilities — mobile-first; do not override component display on mobile */
.hide-mobile { display: none !important; }

@media (min-width: 768px) {
    .hide-mobile { display: flex !important; }
    .hide-desktop { display: none !important; }
    body { padding-bottom: 0; }
}

/* Bottom nav must stay flex row on mobile (hide-desktop sets block otherwise) */
@media (max-width: 767px) {
    .bottom-nav.hide-desktop {
        display: flex !important;
    }
}

/* Block-level hide-mobile (nav links, footer) */
@media (min-width: 768px) {
    footer.hide-mobile,
    nav.desktop-main-nav.hide-mobile { display: flex !important; }
    .header-icon-btn.hide-mobile { display: flex !important; }
}

@media (max-width: 767px) {
    .jutsu-footer { display: none; }
}

.container-wide {
    width: 100%;
    max-width: var(--container-wide);
    margin: 0 auto;
    padding: 0 1.25rem;
}

@media (min-width: 1440px) {
    .container { max-width: var(--container-wide); }
}

/* ===== DESKTOP HEADER NAV ===== */
.desktop-main-nav {
    display: none;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1.5rem;
    flex: 1;
}

@media (min-width: 768px) {
    .desktop-main-nav {
        display: flex !important;
    }
}

.dnav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-pill);
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.dnav-link:hover,
.dnav-link.active {
    color: var(--text);
    background: var(--bg-card);
}

@media (min-width: 1024px) {
    :root {
        --nav-height: 64px;
    }

    .site-header .header-row {
        min-height: 64px;
    }

    .logo-jutsu {
        font-size: 1.35rem;
    }

    .profile-avatar-btn,
    .header-icon-btn {
        width: 40px;
        height: 40px;
    }

    .desktop-main-nav {
        gap: 0.35rem;
        margin-left: 2rem;
    }

    .dnav-link {
        font-size: 0.95rem;
        padding: 0.5rem 1rem;
    }
}

@media (min-width: 1024px) {
    .container,
    .container-wide {
        max-width: var(--container-wide);
    }
}

@media (min-width: 768px) {
    .header-spacer { display: none; }
}

/* Admin form grids — mobile single column */
.page-admin .form-row-2,
.page-admin .form-row-3,
.page-admin .form-row-4 {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .page-admin .form-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-admin .form-row-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== HOME: HERO DESKTOP ===== */
.hero-wrap {
    width: 100%;
    max-width: var(--container-wide);
    margin: 0 auto;
    position: relative;
}

@media (min-width: 1024px) {
    .hero-section {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        min-height: 480px;
        max-height: 600px;
    }

    .hero-wrap {
        border-radius: 20px;
        overflow: hidden;
    }

    .hero-carousel,
    .hero-slide {
        min-height: 480px;
    }

    .hero-content {
        min-height: 480px;
        max-width: 640px;
        padding-bottom: 3rem;
    }

    .hero-title {
        font-size: 2.75rem;
        max-width: 600px;
    }

    .hero-desc {
        font-size: 1rem;
        max-width: 520px;
    }

    .hero-bg {
        background-position: center center;
    }

    .hero-overlay {
        background: linear-gradient(
                90deg,
                rgba(10, 10, 12, 0.97) 0%,
                rgba(10, 10, 12, 0.75) 35%,
                rgba(10, 10, 12, 0.25) 70%,
                rgba(10, 10, 12, 0.15) 100%
            ),
            linear-gradient(0deg, var(--bg) 0%, transparent 45%);
    }

    .hero-dots {
        bottom: 1.5rem;
        right: 1.25rem;
    }

    .home-sections {
        padding-top: 0.5rem;
    }

    .home-cats {
        flex-wrap: wrap;
        overflow: visible;
        gap: 0.65rem;
    }

    .row-head h2 {
        font-size: 1.35rem;
    }
}

@media (min-width: 1440px) {
    .hero-section {
        min-height: 520px;
        max-height: 600px;
    }

    .hero-title {
        font-size: 3rem;
    }
}

/* ===== HOME: CONTENT GRIDS ===== */
.home-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, 1fr);
}

.home-grid .jcard-compact {
    flex: none;
    width: auto;
    scroll-snap-align: unset;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .home-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (min-width: 900px) and (max-width: 1023px) {
    .home-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .home-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 1.15rem;
    }
}

@media (min-width: 1280px) {
    .home-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1440px) {
    .home-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .home-grid .jcard-compact .jcard-poster {
        border-radius: 14px;
    }

    .home-grid .jcard-compact .jcard-title {
        font-size: 0.92rem;
    }

    .content-row {
        margin-bottom: 2.5rem;
    }
}

@media (min-width: 768px) {
    .home-grid.row-scroll {
        display: grid;
        overflow: visible;
        scroll-snap-type: none;
        padding-bottom: 0;
    }
}

@media (max-width: 767px) {
    .home-grid.row-scroll {
        display: grid;
        overflow: visible;
        scroll-snap-type: none;
    }
}

/* ===== CATALOG PAGE ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    .catalog-grid-pro {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .catalog-grid-pro {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 1.25rem 1rem !important;
    }

    .catalog-main {
        padding-top: 1.5rem;
    }

    .catalog-head h1 {
        font-size: 2rem;
    }
}

@media (min-width: 1440px) {
    .catalog-grid-pro {
        grid-template-columns: repeat(7, 1fr) !important;
    }
}

/* ===== ADMIN CMS DASHBOARD ===== */
.page-admin .admin-page,
.page-admin main.container {
    max-width: var(--container-wide);
}

.admin-mobile-nav {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
}
.admin-mobile-nav .admin-nav-item {
    flex: 1 0 auto;
    min-width: 3rem;
    text-align: center;
    padding: 0.55rem 0.65rem;
    font-size: 1.1rem;
}
.admin-poster-block {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}
.admin-poster-img {
    width: 120px;
    aspect-ratio: 2/3;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.admin-poster-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.ep-q-tag {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    margin: 0.1rem;
    border-radius: 6px;
    background: var(--bg-elevated);
    font-size: 0.75rem;
    font-weight: 600;
}

@media (max-width: 767px) {
    .page-admin .admin-editor-panel {
        width: 100%;
        max-width: none;
        min-height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .page-admin .admin-page { padding-bottom: 4rem; }
    .page-admin .admin-cards-grid { display: flex; flex-direction: column; gap: 1rem; }
    .page-admin .form-row-2,
    .page-admin .form-row-3 { grid-template-columns: 1fr !important; }
    .page-admin .content-list { grid-template-columns: 1fr !important; }
}

@media (min-width: 1024px) {
    .page-admin .admin-page {
        padding-top: calc(var(--nav-height) + 2.5rem);
    }

    .page-admin .admin-header h1 {
        font-size: 1.75rem;
    }

    .page-admin .stats-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 1.25rem;
    }

    .page-admin .stat-card {
        padding: 1.5rem;
    }

    .page-admin .stat-card .value {
        font-size: 2rem;
    }

    .page-admin .admin-cards-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
        align-items: start;
    }

    .page-admin .admin-cards-grid .admin-card {
        margin-bottom: 0;
        height: 100%;
    }

    .page-admin .admin-card-full {
        grid-column: 1 / -1;
    }

    .page-admin .form-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-admin .form-row-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .page-admin .form-row-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .page-admin .content-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-admin .admin-tabs {
        margin-bottom: 2rem;
    }

    .page-admin .admin-tab {
        padding: 0.65rem 1.35rem;
        font-size: 0.95rem;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .page-admin .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .page-admin .form-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .page-admin .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .detail-root {
        padding-bottom: 2rem;
    }

    .page-watch {
        padding-bottom: 2rem;
    }
}

@media (min-width: 1024px) {
    .page-watch .watch-page {
        padding-bottom: 3rem;
    }
}

/* ===== DETAIL PAGE DESKTOP ===== */
@media (min-width: 1024px) {
    .detail-hero-inner {
        max-width: var(--container-wide);
        margin: 0 auto;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .detail-body {
        max-width: var(--container-wide);
        margin: 0 auto;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
}

/* ===== ADMIN EDITOR ===== */
body.page-admin.bare-layout .jutsu-footer,
body.page-admin.bare-layout .bottom-nav {
    display: none !important;
}

.admin-editor {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    justify-content: flex-end;
}

.admin-editor.hidden {
    display: none;
}

.admin-editor-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
}

.admin-editor-panel {
    position: relative;
    width: min(720px, 100vw);
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    z-index: 1;
}

.admin-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
}

.admin-editor-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
}

.admin-editor-body {
    padding: 1rem 1.25rem 2rem;
}

.admin-editor-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.admin-ep-table .ep-inp {
    width: 100%;
    font-size: 0.75rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text);
}

.admin-ep-table .ep-fid {
    min-width: 100px;
    font-family: monospace;
    font-size: 0.68rem;
}

body.admin-editor-open {
    overflow: hidden;
}
