/*
|-------------------------------------------------------------
| home.css (依照 blade 區塊整理)
|-------------------------------------------------------------
*/

:root {
    --yellow-lighten: #fff7d1;
    --yellow-dark: #cbb780;
    --red: #ff0000;

    --bs-border-radius: .375rem;
}

/*
|-------------------------------------------------------------
| 版頭與主導覽列 (top-bar, header, logo)
|-------------------------------------------------------------
*/
.top-bar {
    background-color: #ffcc33;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #006400;
    font-weight: 700;
}

.logo {
    max-width: 235px;
}

.main-header {
    background-color: var(--yellow-lighten);
    padding: 10px 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-inner {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    height: 28px;
}

.header-left h1 {
    font-size: 20px;
    color: #007743;
    font-weight: 700;
}

.header-right {
    display: flex;
    gap: 10px;
}

/*
|-------------------------------------------------------------
| 課程橫條與內容區塊 (lesson-header, lesson-title, actions)
|-------------------------------------------------------------
*/
.lesson-header {
    padding: 16px 24px;
    border-radius: 0;
}

.lesson-title {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: .1rem;
    color: #222;
    margin: 0 0 10px;
}

.book-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: -0.325em;
    background: #222;
    mask: url('/images/icon/book-open.png') no-repeat center;
    -webkit-mask: url('/images/icon/book-open.png') no-repeat center;
    mask-size: contain;
    -webkit-mask-size: contain;
    content: "";
}

.lesson-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lesson-actions-inner-flex {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.lesson-actions-left-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.menu-pagination-flex {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
    flex-wrap: wrap;
    min-width: 0;
}


/* 調整 success-icon 圖示顯示方式 */
.menu-pagination-flex .item-btn.success-icon::after {
    content: "";
    position: absolute;
    top: -16px;
    right: -7px;
    transform: rotate(20deg);
    width: 30px;
    height: 26px;
    z-index: 2;
    pointer-events: none;
    background: url('/images/icon/crown.png') no-repeat center;
    background-size: contain;
}

.page-arrow-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: invert(1);
    vertical-align: middle;
}

.page-arrow-icon.right {
    background-image: url('/images/icon/sort-right.png');
}

.page-arrow-icon.left {
    background-image: url('/images/icon/sort-left.png');
}

.lesson-actions-right-group {
    display: flex;
    gap: 8px;
}

/*
|-------------------------------------------------------------
| 主要內容區塊 (main-content, lesson-board, board-inner)
|-------------------------------------------------------------
*/
.main-content {
    flex: 1 1 auto;
    padding-top: 8px;
    text-align: center;
    position: relative;
}

.lesson-board {
    position: relative;
    background-color: #fff;
    border: 2px solid #cbb780;
    border-radius: var(--bs-border-radius);
    box-shadow: 0 4px 12px rgba(150, 110, 0, 0.15);
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 24px 0 60px 0;
    width: 100%;
    min-height: 62vh;
    max-height: calc(100vh - 300px);
}

@media (max-width: 992px) {
    .lesson-board {
        min-height: 58vh;
    }
}

@media (max-width: 768px) {
    .lesson-board {
        min-height: 52vh;
    }
}

.board-inner {
    overflow-y: auto;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    height: 300px;
}

.zhuyin-img {
    width: 100%;
    height: auto;
    -o-object-fit: contain;
    object-fit: contain;
    transition: max-height 0.3s;
    max-height: 48vh;
    flex: 0 0 auto;
}

/*
|-------------------------------------------------------------
| 播放音檔 (audio-container, audio 樣式)
|-------------------------------------------------------------
*/
.audio-container {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translate(-50%);
    z-index: 10;
}

.audio-container audio,
.recorded-audio-container audio {
    max-height: 40px;
    border-radius: 50rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
    margin-bottom: 12px;
}

/*
|-------------------------------------------------------------
| 文字區塊與注音 (board-caption, board-text, zhuyin-text)
|-------------------------------------------------------------
*/
.board-caption {
    padding: 56px 72px 28px 72px;
    min-height: 2.5em;
    margin-top: 12px;
    overflow-x: auto;
    overflow-y: visible;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    word-break: break-all;
    max-width: 100%;
    max-height: 100%;
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
}

.board-caption .board-text {
    font-weight: 500;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    max-width: calc(100vw - 120px);
    overflow-x: auto;
    white-space: normal;
    display: block;
    box-sizing: border-box;
    padding-top: 4px;
    padding-bottom: 4px;
}

.zhuyin-text {
    font-family: "Noto Serif TC", "TWKaitiUYiXing", serif;
    font-size: 36px;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.zhuyin-text ruby {
    ruby-position: under;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.zhuyin-text rt {
    font-size: 16px;
    color: #444;
    line-height: 1.2;
    display: inline-block;
    text-align: center;
    transform: scale(0.9);
}

/*
|-------------------------------------------------------------
| 錄音按鈕 (record-btn)
|-------------------------------------------------------------
*/
/* 錄音按鈕 */
.record-btn {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffbf00;
    border: 2px solid #966e00;
    color: #fff;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

/* 錄音按鈕 disabled 樣式 */
.record-btn:disabled,
.record-btn.disabled {
    cursor: not-allowed;
    background-color: #9fa5aa;
    border-color: #9fa5aa;
    opacity: .8;
}

.record-btn:disabled::after,
.record-btn.disabled::after {
    content: "";
    width: 50px;
    height: 50px;
    mask: url('/images/icon/mic.png') no-repeat center;
    -webkit-mask: url('/images/icon/mic.png') no-repeat center;
    background: #fff;
    mask-size: contain;
    -webkit-mask-size: contain;
    display: block;
}

.record-btn.recording {
    background-color: #ff0000;
    border-color: #c20000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

.record-btn.recording::after {
    content: "";
    width: 48px;
    height: 48px;
    display: block;
    background: #fff;
    mask: url('/images/icon/record.png') no-repeat center;
    -webkit-mask: url('/images/icon/record.png') no-repeat center;
    mask-size: contain;
    -webkit-mask-size: contain;
}

.record-btn:not(.recording, :disabled)::after {
    content: "";
    width: 50px;
    height: 50px;
    mask: url('/images/icon/mic.png') no-repeat center;
    -webkit-mask: url('/images/icon/mic.png') no-repeat center;
    background: #4d5156;
    mask-size: contain;
    -webkit-mask-size: contain;
    display: block;
}

/* 正式錄音前的 loading 樣式 */
.record-btn.loading {
    background: rgba(105, 105, 105, 0.6);
    border-color: transparent;
    cursor: wait;
}

/* loading 狀態下顯示旋轉圈*/
.record-btn.loading:not(.recording)::after {
    content: "";
    width: 36px;
    height: 36px;
    border: 4px solid #fff;
    border-top: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: block;
    background: none;
    mask: none;
    -webkit-mask: none;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/*
|-------------------------------------------------------------
| 錄音完成按鈕
|-------------------------------------------------------------
*/
.audio-actions {
    gap: 12px;
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 72px;
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

/* 重新錄製 icon 樣式 */
.rotate-left-icon {
    display: block;
    width: 100%;
    height: 36px;
    background: #f06d45;
    -webkit-mask-image: url('/images/icon/rotate-left.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('/images/icon/rotate-left.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}

/* 試聽音檔 */
.recorded-audio-container {
    position: absolute;
    top: -64px;
    left: 50%;
    transform: translate(-50%);
    z-index: 10;
}

.recorded-audio-container audio {
    box-shadow: none !important;
}

/* checkbox */
.form-check {
    display: flex !important;
    align-items: center !important;
    gap: 0.7em !important;
}

.form-check.center {
    justify-content: center !important;
    width: 100%;
}

.form-check-input {
    margin-right: 0 !important;
}

.form-check-label {
    margin-left: 0 !important;
}

/*
|-------------------------------------------------------------
| 評分後樣式
|-------------------------------------------------------------
*/

/* 統計結果區 */
.lesson-result {
    background-color: var(--yellow-lighten);
    border: 2px solid var(--yellow-dark);
    border-radius: var(--bs-border-radius);
    box-shadow: 0 4px 12px rgba(150, 110, 0, 0.15);
    margin: 0 0 8px 0;
    width: 100%;
    padding: 12px;
    color: #333;
    font-family: "Noto Sans TC";
}

.result-status.fail p {
    font-weight: 600;
    color: var(--red);
    font-size: 1.8rem;
    margin-bottom: 0 !important;
}

.result-status span {
    font-weight: 550;
    color: #606065;
    font-size: 1.2rem;
}

.result-status i {
    font-size: 0.8em;
    position: relative;
    top: 1px;
}

/* popover */
.popover .popover-body {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 12px 16px;
    white-space: normal;
    word-break: break-word;
}

.popover {
    --bs-popover-bg: rgba(0, 0, 0, 0.8) !important;
    min-width: unset !important;
    max-width: 90vw;
}

.popover-rate-title {
    font-size: 0.85em;
    font-weight: bold;
    display: inline-block;
}

/* 圖例樣式 */
.legend.correct {
    color: #222;
}

/* .legend.lack {
    color: #b3b3b3;
}

.legend.error {
    color: #ff5b5b;
}

.legend.extra {
    color: #007dcc;
}

.zhuyin-text p {
    color: #222;
} */

/* 評測結果顏色 */
.capt-danger {
    color: #D81159;
}

.capt-good {
    color: #FFBC42;
}

.capt-excellent {
    color: #2EC4B6;
}

/* 缺少 */
/* .lose {
    background: #b0b0b080;
} */

/* 錯誤 */
/* .bad {
    background: #fe4e4e80;
} */

/* 多餘 */
/* .much {
    background: #0d6cbe80
} */

/*
|-------------------------------------------------------------
| 注音字級切換 (zhuyin-text 字級)
|-------------------------------------------------------------
*/
.zhuyin-text.lg-text ruby,
.zhuyin-text.lg-text p {
    font-size: 5rem;
}

.zhuyin-text.md-text ruby,
.zhuyin-text.md-text p {
    font-size: 2.65rem;
}

.zhuyin-text.sm-text ruby,
.zhuyin-text.sm-text p {
    font-size: 1.7rem;
}

.zhuyin-text.lg-text rt {
    font-size: 1.3rem !important;
}

.zhuyin-text.md-text rt {
    font-size: 1.1rem !important;
}

.zhuyin-text.sm-text rt {
    font-size: 0.9rem !important;
}

/*
|-------------------------------------------------------------
| 響應式 (RWD, media queries)
|-------------------------------------------------------------
*/
@media (max-width: 1040px),
(max-height: 576px) {
    .lesson-actions-inner-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .lesson-actions-right-group {
        justify-content: flex-end !important;
        display: flex !important;
    }

    .board-caption {
        padding: 20px 16px 20px 16px;
        max-height: 20vh;
    }

    .zhuyin-img {
        max-height: 28vh;
    }
}

@media (max-width: 726px),
(max-height: 576px) {
    .board-caption .lg-text {
        font-size: 2.2rem;
    }

    .board-caption .md-text {
        font-size: 1.3rem;
    }

    .board-caption .sm-text {
        font-size: 1rem;
    }

    .board-caption {
        padding: 16px 8px 16px 8px;
    }

    .zhuyin-img {
        max-height: 18vh;
    }
}

/*
|-------------------------------------------------------------
| 選單 (activity-menu, menu-list, 搜尋)
|-------------------------------------------------------------
*/
.activity-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: #fff7d1;
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.15);
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    font-family: "Noto Sans TC";
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(.4, 0, .2, 1);
}

.activity-menu.active {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1.5rem;
    color: #334155;
}

/* 搜尋 */
.menu-search-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 12px;
}

.menu-search-icon {
    position: absolute;
    right: 10px;
    top: 40%;
    transform: translateY(-50%);
    pointer-events: none;
    display: flex;
    align-items: center;
}

#menuSearch {
    width: 100%;
    padding: 8px 36px 8px 10px;
    border: 1px solid #77cef3;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}

#menuSearch:focus-visible {
    outline: none;
    border: 1px solid #77cef3;
}

/* 選單列表 */
.menu-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.menu-list summary {
    cursor: pointer;
    font-weight: 600;
    color: #444;
    margin: 4px 0;
}

.menu-list ul {
    list-style: none;
    padding-left: 20px;
    margin: 4px 0;
}

.menu-list a {
    text-decoration: none;
    color: #334155;
    padding: 8px 12px;
    border-radius: 5px;
    display: block;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.2s;
}

.menu-list li {
    width: 100%;
}

.menu-list li:hover a {
    background: #fff;
}

.menu-close {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 18px;
}

