/* ===========================================================
   Course Unit — Mobile-First Redesign
   Adds a simplified mobile hero + fixed bottom nav + 3 drawers
   Activates only on phones (≤767px). Tablet/desktop unchanged.
   =========================================================== */

/* Hide new elements on desktop/tablet by default */
.cu-mobile-hero,
.cu-bottom-nav,
.cu-drawer {
    display: none;
}

/* ----------------------------------------------------------
   MOBILE (≤767px) — Activate new design
   ---------------------------------------------------------- */
@media (max-width: 767px) {

    /* --- Hide old complex mobile header (selectors, progress, etc.) --- */
    .unit-mobile-header {
        display: none !important;
    }

    /* Hide the orientation note + old hero bar on mobile (redundant now) */
    .unit-hero-bar {
        display: none !important;
    }
    .mobile-landscape-note {
        display: none !important;
    }

    /* Hide old floating button — replaced by bottom-nav clips icon */
    .mobile-video-fab {
        display: none !important;
    }

    /* Reserve space at bottom for the fixed nav */
    body.course-unit-body {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    /* --- New simplified mobile hero --- */
    .cu-mobile-hero {
        display: block;
        margin: 8px 12px 10px;
        padding: 14px 16px;
        border-radius: 18px;
        background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
        color: #ffffff;
        text-align: center;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    }
    .cu-mobile-hero__unit {
        display: block;
        font-size: 0.78rem;
        font-weight: 600;
        opacity: 0.78;
        margin-bottom: 6px;
        letter-spacing: 0.2px;
    }
    .cu-mobile-hero__lesson {
        font-size: 1.05rem;
        font-weight: 800;
        line-height: 1.45;
        margin: 0;
        color: #ffffff;
    }

    /* --- Bottom fixed navigation --- */
    .cu-bottom-nav {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.08);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .cu-bottom-nav__btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 9px 4px 8px;
        background: transparent;
        border: 0;
        cursor: pointer;
        color: #64748b;
        text-decoration: none;
        font-family: inherit;
        font-size: 0.68rem;
        font-weight: 600;
        line-height: 1.1;
        transition: color 0.18s ease, background 0.18s ease;
        min-height: 56px;
    }
    .cu-bottom-nav__btn svg {
        width: 22px;
        height: 22px;
        stroke-width: 2;
    }
    .cu-bottom-nav__btn:hover {
        color: #1d4ed8;
    }
    .cu-bottom-nav__btn:focus-visible {
        outline: 2px solid #2563eb;
        outline-offset: -2px;
        border-radius: 6px;
    }
    .cu-bottom-nav__btn.is-active {
        color: #1d4ed8;
        background: linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0));
    }
    .cu-bottom-nav__btn.is-active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 28px;
        height: 3px;
        background: #2563eb;
        border-radius: 0 0 3px 3px;
    }
    .cu-bottom-nav__btn { position: relative; }

    /* --- Drawer base --- */
    .cu-drawer {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 1200;
        flex-direction: column;
        justify-content: flex-end;
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.25s ease, visibility 0s linear 0.25s;
        pointer-events: none;
    }
    .cu-drawer.is-open {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transition: opacity 0.25s ease;
    }
    .cu-drawer__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .cu-drawer__panel {
        position: relative;
        background: #ffffff;
        border-top-left-radius: 22px;
        border-top-right-radius: 22px;
        box-shadow: 0 -16px 40px rgba(15, 23, 42, 0.22);
        max-height: 78vh;
        display: flex;
        flex-direction: column;
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.16, 1);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .cu-drawer.is-open .cu-drawer__panel {
        transform: translateY(0);
    }
    .cu-drawer__handle {
        width: 42px;
        height: 4px;
        background: #cbd5e1;
        border-radius: 999px;
        margin: 10px auto 4px;
    }
    .cu-drawer__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 10px 18px 12px;
        border-bottom: 1px solid #e5e7eb;
    }
    .cu-drawer__head-text {
        flex: 1;
        min-width: 0;
    }
    .cu-drawer__eyebrow {
        display: block;
        font-size: 0.72rem;
        font-weight: 600;
        color: #64748b;
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .cu-drawer__title {
        font-size: 1.05rem;
        font-weight: 800;
        color: #0f172a;
        margin: 0;
        line-height: 1.25;
    }
    .cu-drawer__close {
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: #f1f5f9;
        border: 0;
        cursor: pointer;
        color: #334155;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.18s ease, color 0.18s ease;
    }
    .cu-drawer__close:hover {
        background: #e2e8f0;
        color: #0f172a;
    }
    .cu-drawer__close svg {
        width: 16px;
        height: 16px;
    }
    .cu-drawer__body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 12px 14px 18px;
    }
    .cu-drawer__list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .cu-drawer__item {}
    .cu-drawer__item-link {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        background: #f8fafc;
        border: 1px solid transparent;
        border-radius: 14px;
        color: #0f172a;
        text-decoration: none;
        font-size: 0.92rem;
        font-weight: 600;
        line-height: 1.5;
        cursor: pointer;
        transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
        width: 100%;
        text-align: right;
    }
    .cu-drawer__item-link:hover {
        background: #eff6ff;
        border-color: #bfdbfe;
    }
    .cu-drawer__item.is-active .cu-drawer__item-link {
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
        color: #ffffff;
        border-color: transparent;
        box-shadow: 0 6px 14px rgba(37, 99, 235, 0.28);
    }
    .cu-drawer__item.is-complete .cu-drawer__item-link {
        background: linear-gradient(135deg, #ecfdf5, #d1fae5);
        border-color: #a7f3d0;
        color: #065f46;
    }
    .cu-drawer__item.is-locked .cu-drawer__item-link {
        opacity: 0.6;
    }
    .cu-drawer__item-link--disabled {
        background: #f1f5f9;
        color: #94a3b8;
        cursor: not-allowed;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border-radius: 14px;
        border: 1px dashed #cbd5e1;
        font-size: 0.92rem;
    }
    .cu-drawer__item-icon {
        flex-shrink: 0;
        width: 24px;
        text-align: center;
        font-size: 0.95rem;
    }
    .cu-drawer__item-text {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .cu-drawer__item-status {
        flex-shrink: 0;
        font-size: 0.7rem;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.18);
    }
    .cu-drawer__item-status--ok {
        background: #d1fae5;
        color: #065f46;
    }
    .cu-drawer__item-status--current {
        background: rgba(255, 255, 255, 0.25);
        color: #ffffff;
    }
    .cu-drawer__item.is-active .cu-drawer__item-status--ok {
        background: rgba(255, 255, 255, 0.25);
        color: #ffffff;
    }

    /* Clips drawer specific */
    .cu-drawer__list--clips {
        gap: 8px;
    }
    .cu-drawer__item--clip {}
    .cu-drawer__clip {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        background: #f8fafc;
        border: 1px solid transparent;
        border-radius: 14px;
        transition: background 0.18s ease, border-color 0.18s ease;
    }
    .cu-drawer__item--clip.is-active .cu-drawer__clip {
        background: linear-gradient(135deg, #eff6ff, #dbeafe);
        border-color: #93c5fd;
    }
    .cu-drawer__item--clip.is-complete .cu-drawer__clip {
        background: linear-gradient(135deg, #ecfdf5, #d1fae5);
        border-color: #a7f3d0;
    }
    .cu-drawer__item--clip.is-locked .cu-drawer__clip {
        opacity: 0.55;
    }
    .cu-drawer__clip-icon {
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        color: #2563eb;
    }
    .cu-drawer__item--clip.is-complete .cu-drawer__clip-icon {
        background: #10b981;
        color: #ffffff;
        border-color: transparent;
    }
    .cu-drawer__item--clip.is-active .cu-drawer__clip-icon {
        background: #2563eb;
        color: #ffffff;
        border-color: transparent;
    }
    .cu-drawer__clip-body {
        flex: 1;
        min-width: 0;
    }
    .cu-drawer__clip-title {
        font-size: 0.92rem;
        font-weight: 700;
        color: #0f172a;
        line-height: 1.35;
        margin-bottom: 6px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .cu-drawer__clip-progress {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .cu-drawer__clip-track {
        flex: 1;
        height: 4px;
        background: #e2e8f0;
        border-radius: 999px;
        overflow: hidden;
    }
    .cu-drawer__clip-bar {
        display: block;
        height: 100%;
        background: linear-gradient(90deg, #2563eb, #60a5fa);
        border-radius: 999px;
        transition: width 0.3s ease;
    }
    .cu-drawer__item--clip.is-complete .cu-drawer__clip-bar {
        background: linear-gradient(90deg, #10b981, #34d399);
    }
    .cu-drawer__clip-meta {
        flex-shrink: 0;
        font-size: 0.7rem;
        font-weight: 600;
        color: #64748b;
    }
    .cu-drawer__item--clip.is-complete .cu-drawer__clip-meta {
        color: #065f46;
    }
    .cu-drawer__empty {
        text-align: center;
        color: #94a3b8;
        font-size: 0.9rem;
        padding: 24px 0;
    }

    /* Body lock when drawer is open */
    body.cu-drawer-open {
        overflow: hidden;
    }

    /* --- Tall drawer for content (4 tabs inside) --- */
    .cu-drawer__panel--tall {
        max-height: 86vh;
    }

    /* --- Internal tabs (inside Content drawer) --- */
    .cu-drawer__tabs {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        background: #f8fafc;
        border-bottom: 1px solid #e5e7eb;
        position: sticky;
        top: 0;
        z-index: 2;
    }
    .cu-drawer__tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 10px 6px;
        background: transparent;
        border: 0;
        cursor: pointer;
        color: #64748b;
        font-family: inherit;
        font-size: 0.7rem;
        font-weight: 700;
        line-height: 1.1;
        transition: color 0.18s ease, background 0.18s ease;
        position: relative;
        min-height: 56px;
    }
    .cu-drawer__tab-icon {
        font-size: 1.05rem;
        line-height: 1;
    }
    .cu-drawer__tab-count {
        position: absolute;
        top: 6px;
        left: 8px;
        background: #2563eb;
        color: #fff;
        font-size: 0.6rem;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 999px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .cu-drawer__tab:hover {
        background: #f1f5f9;
        color: #0f172a;
    }
    .cu-drawer__tab.is-active {
        color: #1d4ed8;
        background: #ffffff;
    }
    .cu-drawer__tab.is-active::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 3px;
        background: #2563eb;
        border-radius: 3px 3px 0 0;
    }

    .cu-drawer__body--tabs {
        padding: 12px 14px 18px;
    }
    .cu-drawer__tab-panel {
        display: none;
    }
    .cu-drawer__tab-panel.is-active {
        display: block;
    }

    /* --- File card inside content drawer --- */
    .cu-drawer__file {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        background: #f8fafc;
        border: 1px solid transparent;
        border-radius: 14px;
        transition: background 0.18s ease, border-color 0.18s ease;
    }
    .cu-drawer__file:hover {
        background: #eff6ff;
        border-color: #bfdbfe;
    }
    .cu-drawer__file-icon {
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
    }
    .cu-drawer__file-body {
        flex: 1;
        min-width: 0;
    }
    .cu-drawer__file-title {
        font-size: 0.92rem;
        font-weight: 700;
        color: #0f172a;
        line-height: 1.4;
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .cu-drawer__file-meta {
        font-size: 0.68rem;
        font-weight: 700;
        color: #64748b;
        letter-spacing: 0.4px;
    }
    .cu-drawer__file-actions {
        display: flex;
        flex-direction: column;
        gap: 4px;
        flex-shrink: 0;
    }
    .cu-drawer__chip-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px 12px;
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
        color: #ffffff;
        text-decoration: none;
        font-size: 0.72rem;
        font-weight: 700;
        border-radius: 999px;
        border: 0;
        cursor: pointer;
        white-space: nowrap;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .cu-drawer__chip-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
    }
    .cu-drawer__chip-btn--ghost {
        background: transparent;
        color: #1d4ed8;
        border: 1px solid #93c5fd;
    }
    .cu-drawer__chip-btn--ghost:hover {
        background: #eff6ff;
        box-shadow: none;
    }

    /* --- Chat with teacher card --- */
    .cu-drawer__chat {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px;
        background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
        border: 1px solid #bae6fd;
        border-radius: 16px;
    }
    .cu-drawer__chat-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
        border: 2px solid #ffffff;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }
    .cu-drawer__chat-body {
        flex: 1;
        min-width: 0;
    }
    .cu-drawer__chat-name {
        font-size: 0.92rem;
        font-weight: 700;
        color: #0f172a;
        margin-bottom: 2px;
    }
    .cu-drawer__chat-role {
        font-size: 0.72rem;
        color: #64748b;
    }
}

/* ----------------------------------------------------------
   TABLET (768–1100px)
   Keep desktop hero, but allow new elements to remain hidden
   ---------------------------------------------------------- */
@media (min-width: 768px) {
    .cu-mobile-hero,
    .cu-bottom-nav,
    .cu-drawer {
        display: none !important;
    }
}
