/* parent/shell.css — persistent chrome for authenticated parent pages.
   Load after parent.css. Login, PIN gate, and admin do not use this file.
   The sidebar appears at 1024px+; below that the same sections live in a
   fixed bottom tab bar. Each page keeps its own "back to learning" button. */

.app-shell {
    width: 100%;
    min-height: 100vh;
}

.app-shell-nav {
    display: none;
}

.app-shell-main {
    min-width: 0;
}

.app-shell-brand {
    display: block;
    text-decoration: none;
    color: inherit;
    margin-bottom: 8px;
    padding: 4px 8px;
}

.app-shell-brand-name {
    font-size: 16px;
    font-weight: var(--fw-title);
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.app-shell-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.app-shell-link {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-control);
    text-decoration: none;
    color: var(--n-700);
    font-size: 14px;
    font-weight: var(--fw-label);
    line-height: 1.3;
}

.app-shell-link:hover,
.app-shell-link:focus-visible {
    background: var(--primary-muted);
    color: var(--text-main);
    outline: none;
}

.app-shell-link.is-active {
    background: var(--primary-light);
    color: var(--primary-text);
    font-weight: var(--fw-title);
}

.app-shell-exit {
    margin-top: auto;
    color: var(--text-muted);
    font-size: 13px;
}

.app-shell-exit:hover,
.app-shell-exit:focus-visible {
    color: var(--text-main);
}

body.has-shell {
    padding: 0;
    display: block;
    align-items: stretch;
}

body.has-shell .app-shell-main {
    padding: 16px;
}

body.has-shell .app-shell-main > .container {
    max-width: var(--content-width);
    width: 100%;
    margin: 0 auto 32px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    text-align: left;
    display: block;
    align-items: stretch;
    animation: none;
    backdrop-filter: none;
}

body.has-shell .app-shell-main > .kp-wrap,
body.has-shell .app-shell-main > .guide-shell {
    max-width: var(--content-width);
    margin-inline: auto;
}

/* The guide keeps its own narrow reading column outside the shell; inside it
   the body should line up with the other detail pages. */
body.has-shell .app-shell-main > .guide-shell .guide-body {
    max-width: none;
}

.hub-section {
    width: 100%;
}

.hub-section .section-heading {
    margin-top: 28px;
}

/* ── Bottom tab bar (narrow screens) ── */

.app-shell-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    background: var(--surface-elevated);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}

.app-shell-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 7px 4px 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: var(--fw-label);
    line-height: 1.2;
}

.app-shell-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
}

.app-shell-tab-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-shell-tab.is-active {
    color: var(--primary-text);
    font-weight: var(--fw-title);
}

/* Clears the fixed bar so the last control stays reachable. */
body.has-shell .app-shell-main {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* Only Overview keeps in-page "back to learning". Shop / account / guide
   use that top-right slot for Edit, Sign out, and the language toggle. */
body.has-shell .hub-section,
body.has-shell #back-dashboard-btn {
    display: none;
}

@media (max-width: 640px) {
    body.has-shell {
        padding: 0;
    }
}

@media (min-width: 1024px) {
    body.has-shell .app-shell {
        display: flex;
        align-items: flex-start;
    }

    body.has-shell .app-shell-nav {
        display: flex;
        flex-direction: column;
        width: 220px;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        height: 100vh;
        box-sizing: border-box;
        padding: 24px 14px 16px;
        background: var(--surface-elevated);
        border-right: 1px solid var(--border);
    }

    body.has-shell .app-shell-main {
        flex: 1;
        padding: 24px 32px 40px;
    }

    body.has-shell .app-shell-tabbar,
    body.has-shell #back-hub-btn,
    body.has-shell .dashboard-header-actions {
        display: none;
    }
}
