/* Basic Page Setting */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    --page-padding: clamp(18px, 2.35vw, 32px);
    --toolbar-size: clamp(42px, 3.4vw, 48px);
    --toolbar-gap: clamp(7px, 0.8vw, 10px);
    --nav-gap: clamp(8px, 2.6vw, 34px);
    --control-font: clamp(0.9rem, 1.2vw, 1rem);
    --action-padding-y: clamp(9px, 1vw, 12px);
    --action-padding-x: clamp(22px, 3vw, 44px);
}

body {
    margin: 0;
    background-color: #e6f0f8; /* lightblue background */
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    padding: 0;
}

@media (min-width: 768px) {
    html {
        font-size: clamp(14px, 1.12vw, 15.5px);
    }
}

/* Page Container */

/* Toolbar */
.toolbar {
    position: absolute;
    top: clamp(14px, 1.7vw, 20px);
    left: clamp(14px, 1.7vw, 20px);
    display: flex;
    flex-direction: column;
    gap: var(--toolbar-gap);
    z-index: 1000;
}

.toolbar-btn {
    width: var(--toolbar-size);
    height: var(--toolbar-size);
    border: none;
    border-radius: 50%;
    background-color: #76c893;
    color: white;
    font-size: clamp(16px, 1.4vw, 18px);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    background-color: #5ba67a;
}

.toolbar-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mobile-back-btn {
    display: none;
}


/* limit the size to pretend to be a slide page */
.page-container {
    width: min(90vw, 1240px);
    max-width: 1240px;
    height: min(90vh, 860px);
    max-height: 860px;
    background-color: #fff;
    border-radius: clamp(14px, 1.5vw, 18px);
    padding: var(--page-padding);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Main Content */
.content-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: clamp(12px, 1.5vw, 18px);
}

/* 统一导航 */
.unified-navigation {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(8px, 1vw, 10px) clamp(12px, 1.5vw, 16px);
    margin-bottom: clamp(12px, 1.5vw, 18px);
    flex-shrink: 0;
}

/* Navigate Bar */
.navbar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(7px, 0.8vw, 10px) var(--nav-gap);
    margin-bottom: clamp(12px, 1.5vw, 18px);
    flex-shrink: 0;
}

.nav-item {
    color: #334e68;
    font-weight: bold;
    cursor: pointer;
    padding: clamp(6px, 0.7vw, 8px) clamp(12px, 1.4vw, 16px);
    font-size: var(--control-font);
    text-decoration: none;
    white-space: nowrap;
}

.nav-item.active {
    background-color: #76c893; /* green highlighting */
    color: white;
    border-radius: 50px;
}

/* Heading */
.main-title {
    text-align: center;
    color: #2c4a7c;
    font-size: clamp(1.5rem, 2vw, 1.85rem);
    margin: 0 0 clamp(10px, 1.2vw, 14px) 0;
}

/* button */
.end-btn {
    display: block;
    margin: 0 auto;
    background-color: #76c893;
    color: white;
    border: none;
    padding: var(--action-padding-y) var(--action-padding-x);
    font-size: clamp(1rem, 1.45vw, 1.15rem);
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.end-btn:hover {
    transform: scale(1.05); /* enlarge when hover */
}
.end-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px #52a46e;
}

/* Responsive Design - Stack cards vertically on smaller screens */
@media (max-width: 1180px) {
    .page-container {
        width: min(94vw, 1080px);
        height: min(94vh, 820px);
        padding: clamp(16px, 2.3vw, 24px);
    }

    .navbar {
        margin-bottom: 12px;
    }

    .main-title {
        font-size: clamp(1.4rem, 2.2vw, 1.7rem);
    }
}

@media (max-width: 767px) and (pointer: coarse) {
    .toolbar-btn:hover,
    .toolbar-btn:active,
    .end-btn:hover,
    .end-btn:active {
        transform: none;
    }

    body {
        align-items: stretch;
        background: #c8dff0;
    }

    .page-container {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding: 0;
        background: #e6f0f8;
    }

    .toolbar {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        height: 56px;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
        padding: 6px 14px;
        background: #ffffff;
        border-bottom: 2px solid #d7e6f6;
        box-shadow: none;
        z-index: 10;
    }

    .toolbar-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
        box-shadow: none;
    }

    body.course-mobile-shell .mobile-back-btn {
        display: flex;
        margin-right: auto;
        background: #fdeceb;
        color: #b0362f;
        font-size: 14px;
        font-weight: bold;
    }

    body.course-mobile-shell .unified-navigation {
        margin: 0;
        padding: 8px 16px;
        min-height: 60px;
        background: #ffffff;
        border-top: 2px solid #d7e6f6;
        gap: 10px;
        align-items: center;
    }

    body.course-mobile-shell footer {
        display: none;
    }

    .navbar {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
        overflow-x: hidden;
        margin: 0;
        padding: 8px 10px;
        background: #f6fbff;
        border-bottom: 1px solid #d7e6f6;
    }

    .nav-item {
        display: inline-flex;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        padding: 6px 10px;
        font-size: 0.86rem;
        border-radius: 999px;
    }

    .main-title {
        font-size: 1.55rem;
        margin: 0;
        padding: 10px 16px;
        background: #e6f0f8;
    }

    .content-card {
        justify-content: flex-start;
        margin: 0;
        padding: 10px 12px;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

    .end-btn {
        min-width: 150px;
        min-height: 44px;
        padding: 10px 30px;
        font-size: 16px;
        border-radius: 25px;
    }

    footer {
        flex-shrink: 0;
        padding: 8px 16px;
        background: #ffffff;
        border-top: 2px solid #d7e6f6;
    }
}

@media (max-width: 480px) and (pointer: coarse) {
    .toolbar {
        gap: 8px;
        height: 54px;
        padding: 5px 12px;
    }

    .toolbar-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .page-container {
        padding: 0;
    }

    .nav-item {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
}
