/* ============================================================
   detail-mobile.css — NUR fuer public/detail.html

   Bewusst NICHT in mobile.css: die wird von 43 Seiten geladen, und
   Regeln wie "#userHeader { display: none }" oder ".container
   { padding-bottom: ... }" sind hier absichtlich seitenweit, waeren
   dort aber global — 30 Seiten haetten am Telefon keine Navigation mehr.
   ============================================================ */

/* ============================================================
   Mobile learning page (detail.html)
   App bar, bottom tab bar, tab sheet, drawer, language sheet, swipe cards.
   All colors come from /api/branding-css — no hex values, so the dark
   tenant (career.admissionlabs.eu) works with no extra stylesheet.
   ============================================================ */

:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --bottombar-h: 64px;
}

/* Desktop: the whole mobile chrome does not exist */
.m-appbar,
.m-tabbar,
.m-scrim,
.m-drawer,
.m-langsheet {
    display: none;
}

@media (max-width: 768px) {

    /* ---- desktop header out, app bar in ---------------------------------- */
    /* Hiding #userHeader also hides the hamburger mobile-menu.js injects into it,
       so the two drawers cannot collide. mobile-menu.js itself stays untouched. */
    #userHeader,
    .header-nav {
        display: none !important;
    }

    .m-appbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 6px 6px 6px 2px;
        background: var(--gradient-primary);
        color: var(--on-primary, #fff);
    }

    .m-appbar__back,
    .m-appbar__menu {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: 22px;
        background: none;
        color: inherit;
        font-size: 20px;
        line-height: 1;
        text-decoration: none;
        cursor: pointer;
    }

    .m-appbar__back { font-size: 26px; }

    .m-appbar__title {
        flex: 1;
        min-width: 0;
    }

    .m-appbar__name {
        font-size: 15px;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .m-appbar__meta {
        font-size: 11.5px;
        opacity: .82;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .m-appbar__level {
        flex: 0 0 auto;
        padding: 3px 8px;
        border-radius: 20px;
        background: rgba(255, 255, 255, .2);
        font-size: 11.5px;
        font-weight: 700;
    }

    .container {
        padding-left: 12px;
        padding-right: 12px;
        padding-bottom: calc(var(--bottombar-h) + var(--safe-bottom) + 16px);
    }

    /* ---- bottom tab bar -------------------------------------------------- */

    .m-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        display: flex;
        height: calc(var(--bottombar-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: var(--surface-card, #fff);
        border-top: 1px solid var(--border-soft, #e2e8f0);
    }

    .m-tabbar__item {
        flex: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 44px;
        border: 0;
        background: none;
        color: var(--text-muted, #a0aec0);
        font: inherit;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .m-tabbar__icon {
        font-size: 20px;
        line-height: 1;
    }

    .m-tabbar__item em {
        font-style: normal;
        font-size: 10.5px;
        font-weight: 700;
    }

    .m-tabbar__item.is-active { color: var(--color-primary); }

    .m-tabbar__item.is-active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 26px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--gradient-primary);
    }

    /* ---- the existing 11-button nav becomes the "More" sheet -------------- */

    .learning-tabs > .tab-navigation {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        flex-direction: column;
        gap: 2px;
        max-height: 76vh;
        overflow-y: auto;
        padding: 14px 12px calc(22px + var(--safe-bottom));
        background: var(--surface-card, #fff);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
        transform: translateY(105%);
        transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    }

    .learning-tabs > .tab-navigation.is-open { transform: translateY(0); }

    .learning-tabs > .tab-navigation .tab-button {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        width: 100%;
        min-height: 56px;
        padding: 8px 10px;
        border: 0;
        border-radius: 12px;
        background: none;
    }

    .learning-tabs > .tab-navigation .tab-button.active {
        background: rgba(var(--color-primary-rgb), .12);
    }

    .learning-tabs > .tab-navigation .tab-label {
        display: block;
        font-size: 15px;
        font-weight: 600;
    }

    .learning-tabs > .tab-navigation .tab-badge {
        position: static;
        margin-left: auto;
    }

    /* ---- scrim ----------------------------------------------------------- */

    .m-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(15, 18, 25, .45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s cubic-bezier(.4, 0, .2, 1);
    }

    .m-scrim.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    /* ---- drawer ---------------------------------------------------------- */

    .m-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 60;
        width: min(300px, 84vw);
        overflow-y: auto;
        background: var(--surface-card, #fff);
        box-shadow: 8px 0 30px rgba(0, 0, 0, .18);
        transform: translateX(-104%);
        transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    }

    .m-drawer.is-open { transform: translateX(0); }

    .m-drawer__head {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: calc(18px + var(--safe-top)) 18px 16px;
        background: var(--gradient-primary);
        color: var(--on-primary, #fff);
    }

    .m-drawer__logo {
        width: 34px;
        height: 34px;
        padding: 2px;
        border-radius: 8px;
        background: #fff;
        object-fit: contain;
    }

    .m-drawer__logo:not([src]) { display: none; }

    .m-drawer__brand {
        font-size: 13.5px;
        font-weight: 700;
    }

    .m-drawer__user {
        font-size: 11.5px;
        opacity: .85;
    }

    .m-lang {
        display: flex;
        align-items: center;
        gap: 11px;
        margin: 10px 10px 4px;
        padding: 8px 12px;
        min-height: 56px;
        border: 0;
        border-radius: 12px;
        background: var(--surface-muted, #eef1f6);
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .m-lang__flag { font-size: 20px; }

    .m-lang__text {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .m-lang__text em {
        font-style: normal;
        font-size: 10.5px;
        font-weight: 700;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--text-muted, #a0aec0);
    }

    .m-lang__text strong {
        font-size: 14px;
        color: var(--text-heading, #2d3748);
    }

    .m-lang__cta {
        font-size: 13px;
        font-weight: 600;
        color: var(--color-primary);
    }

    .m-drawer__nav {
        display: flex;
        flex-direction: column;
        padding: 4px 8px 16px;
    }

    .m-drawer__nav a,
    .m-drawer__nav button {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 48px;
        padding: 0 12px;
        border: 0;
        border-radius: 10px;
        background: none;
        font-size: 14.5px;
        font-weight: 600;
        color: var(--text-body, #4a5568);
        text-align: left;
        text-decoration: none;
        cursor: pointer;
    }

    /* ---- language sheet -------------------------------------------------- */

    .m-langsheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 65;
        max-height: 80vh;
        overflow-y: auto;
        padding: 14px 12px calc(22px + var(--safe-bottom));
        background: var(--surface-card, #fff);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
        transform: translateY(105%);
        transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    }

    .m-langsheet.is-open { transform: translateY(0); }

    .m-langsheet button {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 52px;
        padding: 6px 10px;
        border: 0;
        border-radius: 12px;
        background: none;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .m-langsheet button.is-active {
        background: rgba(var(--color-primary-rgb), .12);
    }

    .m-langsheet__flag {
        width: 28px;
        text-align: center;
        font-size: 22px;
    }

    .m-langsheet__text {
        flex: 1;
        min-width: 0;
    }

    .m-langsheet__text strong {
        display: block;
        font-size: 14.5px;
        font-weight: 600;
        color: var(--text-heading, #2d3748);
    }

    .m-langsheet__text small {
        font-size: 12px;
        color: var(--text-muted, #a0aec0);
    }

    .m-langsheet__check { color: var(--color-primary); }

    /* ---- video only in the video tab ------------------------------------- */

    .tab-pane:not(.active) .video-player-wrapper { display: none !important; }

    /* ---- swipe cards (Vokabeln, single word) ----------------------------- */

    .practice-card {
        position: relative;
        touch-action: none;
        user-select: none;
        will-change: transform;
    }

    .practice-card__hint {
        position: absolute;
        top: 14px;
        padding: 5px 9px;
        border-radius: 8px;
        font-size: 11.5px;
        font-weight: 800;
        letter-spacing: .06em;
        text-transform: uppercase;
        opacity: 0;
        pointer-events: none;
    }

    .practice-card__hint--left  { left: 14px;  border: 2px solid #e3342f; color: #e3342f; }
    .practice-card__hint--right { right: 14px; border: 2px solid #28a745; color: #28a745; }
    .practice-card__hint--up {
        left: 50%;
        transform: translateX(-50%);
        border: 2px solid var(--color-primary);
        color: var(--color-primary);
    }

    .practice-rating-buttons { gap: 8px; }
    .practice-rate-btn { min-height: 56px; }

    /* ---- minimum sizes --------------------------------------------------- */

    button,
    .btn,
    .box-tab,
    .cefr-btn,
    .vocab-source-btn,
    .cloze-type-btn,
    .typing-mode-btn,
    .vorlesen-source-btn {
        min-height: 44px;
    }

    /* 16px stops iOS Safari from zooming on focus */
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .question-options > *,
    .cloze-options > * {
        min-height: 52px;
    }

    /* chip rows scroll instead of wrapping */
    .box-tabs,
    .cefr-tabs-row,
    #cefrButtons,
    .cloze-type-buttons {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px 2px;
        scrollbar-width: none;
    }

    .box-tabs::-webkit-scrollbar,
    .cefr-tabs-row::-webkit-scrollbar,
    #cefrButtons::-webkit-scrollbar,
    .cloze-type-buttons::-webkit-scrollbar {
        display: none;
    }

    .box-tab,
    .cloze-type-btn {
        flex: 0 0 auto;
        min-width: auto;
    }

    /* two columns for cards, one for everything else */
    .vocab-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .agent-cards-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .typing-widget-stats > div {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
    }

    /* ---- schwebende Widgets ueber die Leiste heben --------------------- */
    /* #micSelectWidget (mic-select.js, z-index 100000) sitzt mit bottom:14px
       genau auf dem ersten Tab. Nur die Position wird korrigiert - das Modul
       selbst bleibt unangetastet. */
    #micSelectWidget {
        bottom: calc(var(--bottombar-h) + var(--safe-bottom) + 14px) !important;
    }

    /* Bei offenem Sheet/Drawer ganz ausblenden - sonst liegt es darueber. */
    body.m-overlay-open #micSelectWidget {
        opacity: 0;
        pointer-events: none;
    }
}
