/* Button hover effects for navigation links */
.button-hover:hover {
    background-color: var(--mantine-primary-color-6) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.button-hover:active {
    transform: translateY(0px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.app-header-group {
    justify-content: space-between;
}

@media (min-width: 48em) {
    .app-header-group {
        justify-content: center;
    }
}

/* Flex children must shrink to the viewport, not carousel intrinsic width. */
#page-content { min-width: 0; }
.training-workspace {
    box-sizing: border-box;
    min-width: 0;
    max-width: 1100px;
    padding: 20px 12px 40px;
}
.training-workspace > * { min-width: 0; max-width: 100%; }
#explorer_image_carousel { min-width: 0; width: 100%; }
#explorer_image_carousel .mantine-Carousel-viewport { overflow: hidden; }
#explorer_image_carousel .mantine-Carousel-slide { min-width: 0; }
#explorer_image_carousel .mantine-Carousel-control {
    min-width: 44px;
    min-height: 44px;
    background: white;
    border: 1px solid var(--mantine-color-gray-3);
}

/* Width is limited by available height as well as viewport width. */
.video-modal-inner {
    --video-safe-top: max(12px, env(safe-area-inset-top));
    --video-safe-bottom: max(12px, env(safe-area-inset-bottom));
    --video-safe-left: max(12px, env(safe-area-inset-left));
    --video-safe-right: max(12px, env(safe-area-inset-right));
    --video-height: calc(100dvh - var(--video-safe-top) - var(--video-safe-bottom) - 80px);
    padding: var(--video-safe-top) var(--video-safe-right) var(--video-safe-bottom) var(--video-safe-left);
}
.video-modal-content {
    flex: 0 1 auto;
    width: min(960px, calc(100vw - var(--video-safe-left) - var(--video-safe-right)), calc(var(--video-height) * 1.777777 + 32px));
    max-height: calc(100dvh - var(--video-safe-top) - var(--video-safe-bottom));
    overflow: hidden;
}
.video-modal-header { height: 64px; min-height: 64px; box-sizing: border-box; padding: 10px 16px; }
.video-modal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-modal-header button { flex-shrink: 0; width: 44px; height: 44px; }
.video-modal-body { padding: 0 16px 16px; }
.video-player { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }

.planner-toolbar > button { min-height: 44px; }
.planner-toolbar .mantine-Button-label { white-space: normal; text-align: center; }
.planner-toolbar .mantine-Button-root { height: auto; padding-block: 10px; }
.planner-start-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.planner-output-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sequence-guidance { text-align: center; width: 100%; color: var(--mantine-color-gray-7); font-size: 0.875rem; }
.sequence-strip {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    align-items: center;
    box-sizing: border-box;
    border: 1px solid var(--mantine-color-gray-3);
    border-radius: 12px;
    background: white;
}
img.formation-image {
    min-width: 190px;
    height: auto;
    max-height: none;
    object-fit: contain;
    flex-shrink: 0;
}
.formation-card { flex: 0 0 190px; min-width: 190px; scroll-snap-align: start; }
/* Auto margins center short sequences without hiding the start of overflowing rows. */
.sequence-strip > .formation-card:first-child { margin-inline-start: auto; }
.sequence-strip > .formation-card:last-child { margin-inline-end: auto; }
.formation-video-button { width: 44px; min-width: 44px; min-height: 44px; padding: 0; }
@media (max-width: 48em) {
    .training-workspace { padding: 12px 0 28px; }
    .planner-toolbar > button { padding-inline: 8px; font-size: 13px; }
}

/* Persistent context and compact starting points. */
.training-context { margin: 16px 12px 0; max-width: 750px; overflow-wrap: anywhere; }
.home-workspace { width: 100%; max-width: 1040px; margin: 0 auto; padding: 24px 16px; }
.home-task-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; width: 100%; margin-top: 12px; }
.home-task-card { display: block; padding: 24px; border: 1px solid var(--mantine-color-gray-3); border-radius: 16px; color: var(--mantine-color-text); }
.home-task-card:hover { border-color: var(--mantine-primary-color-filled); background: var(--mantine-primary-color-light); text-decoration: none; }
.home-task-card:focus-visible, .program-details summary:focus-visible, .guest-save-signin:focus-visible { outline: 3px solid var(--mantine-primary-color-filled); outline-offset: 3px; }
.program-details summary { cursor: pointer; min-height: 44px; padding: 10px 0; font-size: 14px; }
.program-preview { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-size: 13px; }
.guest-save-signin { display: block; text-align: center; border-radius: 8px; background: var(--mantine-primary-color-filled); color: white; padding: 12px 16px; min-height: 44px; font-weight: 600; }
.guest-save-signin:hover { color: white; }
.quiz-workspace #quiz_questions_container { width: 100%; max-width: 750px; }
.quiz-code-review {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(180px, 1fr);
    gap: 24px;
    align-items: start;
    overflow-x: auto;
}
.quiz-code-review .mantine-Badge-root {
    height: auto;
    white-space: normal;
    text-align: center;
}
.quiz-code-review .mantine-Badge-label { white-space: normal; }
@media (max-width: 600px) {
    .home-task-grid { grid-template-columns: 1fr; gap: 12px; }
    .home-workspace { padding: 16px 8px; }
    .home-task-card { padding: 16px; }
    .home-workspace h1 { font-size: 28px; }
}

/* Route-aware navigation: desktop links, existing drawer below 62em. */
.header-brand { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; }
.primary-nav-link { min-height: 44px; border-radius: 8px; white-space: nowrap; }
.primary-nav-link[data-active] { font-weight: 700; box-shadow: inset 0 -3px var(--mantine-primary-color-filled); }
.header-utility { min-height: 44px; border-radius: 8px; white-space: nowrap; }
.header-utilities { margin-left: auto; border-left: 1px solid var(--mantine-color-gray-3); padding-left: 12px; }
#burger { min-width: 44px; min-height: 44px; }
#navbar { overflow-y: auto; }
#mobile_page_title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.header-brand:focus-visible, .primary-nav-link:focus-visible { outline: 3px solid var(--mantine-primary-color-filled); outline-offset: 2px; }
@media (max-width: 61.99em) { .app-header-group { justify-content: flex-start; } }

#mobile_nav_container .header-utility .mantine-Button-inner { justify-content: flex-start; }
.mantine-Modal-close, .mantine-Drawer-close { min-width: 44px; min-height: 44px; }

/* Shared options sidebar; the same controls remain mounted at every width. */
.responsive-workspace {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    width: 100%;
    max-width: 1400px;
}
.options-toolbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; }
.options-toolbar .training-context { margin: 0; text-align: left; }
.options-toggle, .options-close {
    cursor: pointer;
    color: var(--mantine-color-text);
    background: var(--mantine-color-body);
    border: 1px solid var(--mantine-color-default-border);
    border-radius: 8px;
    padding: 8px 16px;
    font: inherit;
}
.options-toggle { display: inline-flex; align-items: center; gap: 8px; }
.options-toggle::before { content: "›"; font-size: 20px; line-height: 1; }
.options-toggle[aria-expanded="true"]::before { content: "‹"; }
.options-toggle:hover, .options-close:hover { background: var(--mantine-color-default-hover); }
.options-toggle:focus-visible, .options-close:focus-visible { outline: 2px solid var(--mantine-primary-color-filled); outline-offset: 3px; }
.options-sidebar {
    position: sticky;
    top: 84px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    max-height: calc(100dvh - 104px);
    padding: 0 20px 16px 0;
    overflow: auto;
    color: var(--mantine-color-text);
    background: var(--mantine-color-body);
    border: 0;
    border-right: 1px solid var(--mantine-color-default-border);
    border-radius: 0;
}
.options-sidebar:not([open]) { display: none; }
.options-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.options-close { padding: 2px 10px; font-size: 24px; border: 0; }
.options-controls > .mantine-Flex-root { flex-direction: column; }
.options-controls .mantine-Select-root, .options-controls .mantine-NumberInput-root,
.options-controls .mantine-Group-root { width: 100%; min-width: 0; }
.training-results { min-width: 0; width: 100%; }
.responsive-workspace[data-options-open="false"] { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 61.99em) {
    .responsive-workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .options-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(360px, 92vw);
        height: 100dvh;
        max-height: 100dvh;
        max-width: 92vw;
        border-radius: 0;
        border: 0;
        padding: 20px;
        overscroll-behavior: contain;
    }
    .options-sidebar::backdrop { background: rgb(0 0 0 / 45%); }
    html.options-modal-open { overflow: hidden; }
}

/* Desktop sidebar fills the space below the app header, independently of results. */
@media (min-width: 62em) {
    #page-content:has(.responsive-workspace) { margin: 0 !important; }
    .responsive-workspace {
        --workspace-header-height: var(--app-shell-header-height, 64px);
        max-width: none;
        min-height: calc(100dvh - var(--workspace-header-height));
        padding: 0;
        grid-template-rows: max-content 1fr;
        column-gap: 24px;
        row-gap: 16px;
    }
    .responsive-workspace .options-sidebar {
        grid-column: 1;
        grid-row: 1 / 3;
        top: var(--workspace-header-height);
        height: calc(100dvh - var(--workspace-header-height));
        max-height: calc(100dvh - var(--workspace-header-height));
        padding: 24px 20px;
        overscroll-behavior: contain;
    }
    .responsive-workspace .options-toolbar {
        grid-column: 2;
        grid-row: 1;
        padding: 24px 24px 0 0;
    }
    .responsive-workspace .training-results {
        grid-column: 2;
        grid-row: 2;
        padding: 0 24px 32px 0;
    }
    .responsive-workspace[data-options-open="false"] .options-toolbar,
    .responsive-workspace[data-options-open="false"] .training-results {
        grid-column: 1;
        padding-left: 24px;
    }
}
