/* ==========================================
   guide.css — Live guide sidebar, channel rows, categories, and channel logos
   ========================================== */

/* ── Live Guide Sidebar Base ── */
.guide-shell {
    display: flex;
    flex-shrink: 0;
    overflow: hidden;
    z-index: 200;
    background: transparent !important;
    border-right: 0 !important;
    width: 280px;
    transition: width 0.24s var(--ease);
}

.guide-shell.closed {
    width: 68px;
}

.guide-rail {
    --guide-rail-gap: 6px;
    width: 58px;
    flex: 0 0 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--guide-rail-gap);
    padding: 8px 6px;
    margin: 8px 4px;
    min-height: calc(100dvh - 16px);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.028)),
        rgba(9, 12, 17, 0.82);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 18px 54px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(18px);
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail {
    width: 260px;
    flex-basis: 260px;
    display: grid;
    grid-template-columns: 42px 1fr;
    align-content: start;
    align-items: center;
    margin: 8px 6px;
    min-height: calc(100dvh - 16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 8px 10px 10px 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.022)),
        rgba(8, 10, 14, 0.9);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.11),
        0 22px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(18px);
    gap: 6px 8px;
}

.guide-rail-categories {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--guide-rail-gap);
    width: 100%;
}

.guide-rail-categories::before,
.guide-rail-categories::after {
    content: "";
    display: block;
    width: 34px;
    height: 1px;
    margin: 2px 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-categories {
    grid-column: 1 / -1;
    align-items: stretch;
    gap: 8px;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-categories::before,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-categories::after {
    display: none;
}

.guide-rail-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text2);
    font-size: 1.1rem;
    cursor: pointer;
    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
}

.guide-rail-icon {
    display: grid;
    place-items: center;
    justify-self: center;
}

.guide-rail-label,
.guide-rail-count,
.guide-rail-arrow {
    display: none;
}

.guide-rail-btn svg {
    width: 18px;
    height: 18px;
}

.guide-menu-icon-close {
    display: none;
}

.guide-shell:not(.closed) .guide-menu-icon-open {
    display: none;
}

.guide-shell:not(.closed) .guide-menu-icon-close {
    display: block;
}

.guide-rail-brand {
    display: none;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    height: 42px;
    padding-left: 4px;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-brand img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-brand span span {
    color: #6181ff;
    font-size: 0.68em;
    font-style: italic;
}

.guide-rail-vertical-brand {
    flex: 1;
    min-height: 112px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
    pointer-events: none;
}

.guide-rail-vertical-brand > span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: rgba(247, 248, 251, 0.42);
    font-size: 0.94rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    line-height: 1;
}

.guide-rail-vertical-brand span span {
    color: rgba(97, 129, 255, 0.78);
    font-size: 0.68em;
    font-style: italic;
    letter-spacing: 0.12em;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-vertical-brand {
    display: none;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn {
    width: 100%;
    display: grid;
    grid-template-columns: 42px 1fr auto 18px;
    grid-column: 1 / -1;
    align-items: center;
    justify-items: stretch;
    gap: 10px;
    padding: 0 6px 0 0;
    text-align: left;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-btn {
    height: 42px;
    border-radius: 12px;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn {
    width: 100%;
    height: 42px;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail > .guide-rail-btn:not(.guide-rail-menu):not(.guide-rail-category-btn) {
    width: 100%;
    display: grid;
    grid-template-columns: 42px 1fr;
    grid-column: 1 / -1;
    align-items: center;
    justify-items: stretch;
    gap: 10px;
    padding: 0 6px 0 0;
    text-align: left;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail > .guide-rail-btn:not(.guide-rail-menu):not(.guide-rail-category-btn) > svg {
    justify-self: center;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-icon {
    width: 42px;
    height: 42px;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-label,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-count,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-arrow {
    display: inline-flex;
    align-items: center;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail > .guide-rail-btn:not(.guide-rail-menu):not(.guide-rail-category-btn) .guide-rail-label {
    display: inline-flex;
    align-items: center;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-label {
    color: var(--text2);
    font-size: 0.85rem;
    font-weight: 600;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail > .guide-rail-btn:not(.guide-rail-menu):not(.guide-rail-category-btn) .guide-rail-label {
    color: var(--text2);
    font-size: 0.85rem;
    font-weight: 600;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-count,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn .guide-rail-arrow {
    color: var(--text3);
    font-size: 0.75rem;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn:hover .guide-rail-label,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn:focus-visible .guide-rail-label {
    color: var(--text);
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail > .guide-rail-btn:not(.guide-rail-menu):not(.guide-rail-category-btn):hover .guide-rail-label,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail > .guide-rail-btn:not(.guide-rail-menu):not(.guide-rail-category-btn):focus-visible .guide-rail-label {
    color: var(--text);
}

.guide-rail-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    outline: 0;
}

.guide-rail-btn:focus-visible {
    color: var(--text);
    outline: 0;
    background: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.14),
        0 0 0 5px rgba(53, 214, 164, 0.12);
}

.guide-rail-menu {
    background: rgba(53, 214, 164, 0.14);
    color: var(--accent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 28px rgba(53, 214, 164, 0.12);
}

.guide-rail-btn[aria-current="page"] {
    background: rgba(255, 255, 255, 0.16);
    color: var(--text);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 12px 30px rgba(0, 0, 0, 0.28);
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn:hover,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn:focus-visible,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn.is-active,
body.guide-categories-open .guide-shell:not(.closed) .guide-rail-category-btn[aria-current="true"] {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

body.guide-category-open .guide-shell:not(.closed) .guide-rail-category-btn.is-active,
body.guide-category-open .guide-shell:not(.closed) .guide-rail-category-btn[aria-current="true"] {
    background: transparent;
    box-shadow: none;
}

body.guide-category-open .guide-shell:not(.closed) .guide-rail-category-btn.is-active .guide-rail-icon,
body.guide-category-open .guide-shell:not(.closed) .guide-rail-category-btn[aria-current="true"] .guide-rail-icon {
    border-radius: 16px;
    background: rgba(53, 214, 164, 0.13);
    color: var(--accent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 1px rgba(53, 214, 164, 0.18),
        0 12px 30px rgba(53, 214, 164, 0.08);
}

body.guide-categories-open .guide-shell:not(.closed) .guide-rail-menu {
    width: 42px;
    align-self: flex-start;
    justify-self: center;
}

@media (min-width: 769px) and (max-height: 820px) {
    body.is-watching .guide-rail {
        --guide-rail-gap: 6px;
        padding: 8px;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
    }

    body.is-watching .guide-rail::-webkit-scrollbar {
        display: none;
    }

    body.is-watching .guide-rail-btn,
    body.is-watching .guide-rail-category-btn .guide-rail-icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    body.is-watching .guide-rail-btn svg {
        width: 20px;
        height: 20px;
    }

    body.is-watching .guide-rail-vertical-brand {
        display: none;
    }

    body.is-watching .guide-head {
        min-height: 56px;
        padding: 10px 12px;
    }

    body.is-watching .ch-scroll {
        padding: 6px 0 10px;
    }

    body.is-watching .ch-item {
        min-height: 52px;
        gap: 12px;
        padding: 8px 16px;
    }

    body.is-watching .ch-logo-box--guide {
        width: 42px;
        height: 42px;
    }
}

.guide-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

body.guide-category-open .guide-shell:not(.closed),
body.guide-searching .guide-shell:not(.closed) {
    width: 320px;
}

body.guide-category-open .guide-shell:not(.closed) .guide-panel,
body.guide-searching .guide-shell:not(.closed) .guide-panel {
    margin: 8px 6px 8px 0;
    min-height: calc(100dvh - 16px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
        rgba(8, 10, 14, 0.9);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 22px 60px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(18px);
}

.guide-shell.closed .guide-panel {
    display: none;
}

body.guide-categories-open .guide-shell:not(.closed) .guide-panel {
    display: none;
}

/* ── Mobile: fixed overlay toggled via transform ── */
@media (max-width: 768px) {
    .guide-shell {
        position: fixed;
        top: 0;
        left: 0;
        bottom: var(--nav-h);
        width: min(290px, 85vw);
        transition: transform 0.28s var(--ease);
        transform: translateX(-100%);
    }

    .guide-shell:not(.closed) {
        transform: translateX(0);
    }
}

@media (max-width: 480px) {
    .guide-shell {
        width: min(290px, 92vw);
    }
}

.guide-head {
    min-height: 64px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

body.guide-category-open .guide-head,
body.guide-searching .guide-head {
    min-height: 58px;
    padding: 10px 14px;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.guide-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.guide-back-btn {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 1.15rem;
    cursor: pointer;
}

.guide-back-btn:hover,
.guide-back-btn:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: 0;
}

.guide-meta-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-count {
    font-size: 0.7rem;
    color: var(--text2);
    background: var(--surface);
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.ch-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 20px;
}

body.guide-category-open .ch-scroll,
body.guide-searching .ch-scroll {
    padding: 8px 8px 18px;
}

.guide-search-wrap {
    display: none;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.guide-searching .guide-search-wrap {
    display: block;
}

.guide-category-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px 18px;
}

.guide-category-btn {
    width: 100%;
    min-height: 52px;
    display: grid;
    grid-template-columns: 34px 1fr auto 18px;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 12px;
    padding: 8px 10px;
    background: transparent;
    color: var(--text2);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.guide-category-btn:hover,
.guide-category-btn:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    outline: 0;
    transform: translateX(2px);
}

.guide-category-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 1.05rem;
}

.guide-category-icon svg {
    width: 20px;
    height: 20px;
}

.guide-category-name {
    font-size: 0.94rem;
    font-weight: 600;
}

.guide-category-count,
.guide-category-arrow {
    color: var(--text3);
    font-size: 0.8rem;
}

.guide-category-arrow svg {
    width: 18px;
    height: 18px;
}

body.guide-category-open .guide-category-list,
body.guide-searching .guide-category-list,
body.guide-categories-open .ch-scroll {
    display: none;
}

body.guide-category-open .ch-scroll,
body.guide-searching .ch-scroll,
body.guide-categories-open .guide-category-list {
    display: block;
}

/* Category labels — now scroll normally, no sticky */
.cat-label {
    padding: 16px 20px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text3);
    background: transparent;
}

body.guide-category-open .cat-label {
    display: none !important;
}

.ch-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    min-height: 56px;
}

body.guide-category-open .ch-item,
body.guide-searching .ch-item {
    min-height: 58px;
    margin: 2px 0;
    border: 1px solid transparent;
    border-left: 0;
    border-radius: 12px;
    padding: 8px 10px;
}

.ch-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(2px);
}

body.guide-category-open .ch-item:hover,
body.guide-searching .ch-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    transform: none;
}

.ch-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.ch-item.active {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--red);
}

body.guide-category-open .ch-item.active,
body.guide-searching .ch-item.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow:
        inset 3px 0 0 var(--accent),
        0 12px 28px rgba(0, 0, 0, 0.24);
}

/* ── Channel Logos ── */
.ch-logo-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #ffffff;
    border-radius: 10px;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.ch-item:hover .ch-logo-box {
    transform: scale(1.02);
}

.ch-logo-box--guide {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.ch-logo-box--tile {
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    padding: 8px 12px;
}

.ch-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
    user-drag: none;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

.ch-logo-fallback {
    display: none;
    width: 100%;
    height: 100%;
    place-items: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--red);
}

.ch-logo-box--guide .ch-logo-fallback {
    font-size: 0.65rem;
}

.ch-logo-box--tile .ch-logo-fallback {
    font-size: 1.2rem;
}

.ch-logo-box.logo-failed .ch-logo-img {
    display: none;
}

.ch-logo-box.logo-failed .ch-logo-fallback {
    display: grid;
}

.ch-info {
    flex: 1;
    min-width: 0;
}

.ch-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ch-item.active .ch-name {
    color: var(--text);
    font-weight: 600;
}

.ch-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.ch-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text3);
}

.ch-item.active .ch-live-dot {
    background: var(--red);
    animation: blink 1.6s ease-in-out infinite;
}

.q-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}

.q-badge.fhd {
    color: var(--blue);
    background: rgba(62, 166, 255, 0.12);
}

.q-badge.hd {
    color: var(--text2);
    background: var(--surface);
}

.q-badge.sd {
    color: var(--orange);
    background: rgba(251, 146, 60, 0.12);
}


.ch-initials {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--red);
}

.no-results {
    padding: 40px 20px;
    font-size: 0.85rem;
    color: var(--text3);
    text-align: center;
    display: none;
}

.guide-meta-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-offline-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text3);
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all var(--transition-fast);
}

.toggle-offline-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.toggle-offline-btn svg {
    display: block;
}

.toggle-offline-btn svg.hidden {
    display: none;
}
