/* =================
   基礎設定
   ================= */
:root {
    --main-pink: #FFD6D6;
    --main-orange: #FFE4BC;
    --main-brown: #f3ab50;
    --bg-opacity: 1;
}

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(180deg, var(--main-pink) 0%, var(--main-orange) 80%, var(--main-brown) 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* 通用樣式 */
*, :before, :after {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    border: 0;
}

h4 {
    font-size: 1.2rem;
    font-weight: bold;
}

li {
    line-height: 1.7;
}

/* 顏色定義 */
.c1 { color: #e6663e; }
.c2 { color: #00a75b; }
.c3 { color: #65679d; }

/* =================
   頁面結構
   ================= */
/* 導航欄 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: all 0.3s ease;
    padding: 1rem 0;
}

.navbar-initial {
    background-color: transparent;
    backdrop-filter: none;
}

.navbar-scrolled {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.navbar .nav-link {
    color: #333;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: color 0.3s ease;
    font-size: 1.2rem;
}

.navbar-initial .nav-link {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.navbar-brand img {
    height: 40px;
    width: auto;
}

.navbar-toggler {
    border: none;
    padding: 0.25rem 0.75rem;
}

/* 固定背景 */
.fixed-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1;
}

.fixed-bg:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: url("image/landing_bg.png") no-repeat center;
    opacity: var(--bg-opacity);
    transition: opacity 0.3s ease;
    z-index: 1;
}

.fixed-bg:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--main-pink) 0%, var(--main-orange) 80%, var(--main-brown) 100%);
    z-index: 0;
}

/* 標題區域 */
.title-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.title-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.title01 {
    width: 100%;
    max-width: 200px;
}

.title02 {
    width: 100%;
    max-width: 350px;
    margin-left: -4em;
}

/* =================
   內容區塊基礎設定
   ================= */
.scroll-content {
    position: relative;
    z-index: 3;
    margin-top: 100vh;
}

.scroll-content > section {
    position: relative;
    width: 100%;
}

#carnival,
#activities,
#main,
#branch {
    scroll-margin-top: 80px;
    padding-top: 100px;
    margin-bottom: 50px;
    min-height: 100vh;
}

#activities {
    position: relative;
    clear: both;
    min-height: 100vh;
    margin-bottom: 10em;
}

#carnival {
    margin-left: auto;
    margin-right: auto;
    max-width: 100em;
}

/* 區塊標題 */
#activities h2,
#main h2,
#branch h2 {
    text-align: center;
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 1.5em;
}

/* =================
   書本樣式
   ================= */
.open-book {
    background: #fcfbf8;
    box-shadow: rgba(0,0,0,0.5) 0 1em 3em;
    color: #000;
    padding: 2em;
}

.open-book * {
    position: relative;
}

/* 書本頁首頁尾 */
.open-book header {
    padding-bottom: 1em;
}

.open-book header *,
.open-book footer * {
    font: 700 1em/1.25 'Playfair Display', sans-serif;
    letter-spacing: 0.125em;
    margin: 0;
}

.open-book header * {
    font-size: 0.75em;
    text-transform: uppercase;
}

.open-book footer {
    padding-top: 1em;
}

.open-book footer #page-numbers {
    display: none;
    list-style: none;
    padding: 0;
    text-align: left;
}

.open-book footer #page-numbers > li:last-child {
    text-align: right;
}

/* 書本標題 */
.open-book .chapter-title {
    /* 移除 vw 單位，改用固定尺寸 */
    font-family: '微軟正黑體', sans-serif;
    font-weight: 700;
    font-size: 2.2em;  /* 改用固定尺寸 */
    line-height: 1.25;
    letter-spacing: 0.125em;
    margin: 0 0 1em 0;
    padding: 1em 0;
    position: relative;
    text-align: center;
    text-transform: uppercase;
}

.open-book .chapter-title span {
    display: block;
    font-size: 18px;
    margin-top: 50px !important;
    line-height: 2;
    letter-spacing: 2px;
}

/* 書本內容 */
.open-book article {
    line-height: 1.7;
}

.open-book article *:not(.chapter-title):not(hr):not(dl) {
    margin: 0 auto;
    max-width: 38.125em;
}

.open-book article > ul,
.open-book article > ol {
    padding-left: 3em;
}

.open-book article > ul ul {
    padding-left: 1em;
}

.open-book article h3 {
    margin-bottom: 0.5em !important;
}

.open-book article h4 {
    font-size: 1.2rem;
    padding-bottom: 0.5rem;
    font-weight: bold;
}

.open-book article h4 + p {
    border-top: 1px solid #8b786d;
    padding-top: 0.5em;
}

/* 書本連結樣式 */
.open-book .line {
    background: url("image/blue.svg") bottom repeat-x;
    background-size: auto 0.25em;
    color: #2f2f2f;
    text-decoration: none;
}

/* 任務標記 */
mark.mission-mark {
    background-image: url(image/bg-mark.svg);
    background-size: contain;
    color: #ffffff;
    text-align: center;
    font-weight: normal;
    font-size: 0.8rem;
    background-color: transparent;
    background-repeat: no-repeat;
    font-family: '微軟正黑體', serif;
    padding: 0.7rem 0.6rem 1em 0.7em;
    display: inline-block;
    float: right;
    margin-top: -10px !important;
    letter-spacing: 3px;
}

/* =================
   活動卡片樣式
   ================= */
.activity-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    border: none;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.activity-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
}

.activity-card:hover {
    transform: translateY(-5px);
}

.activity-card i {
    text-align: center;
    min-width: 1.5em;
}

/* 好書交換區塊 */
.exchange-books {
    padding: 2rem;
    background: #fff;
    border-radius: 15px;
}

.exchange-item {
    display: flex;
    padding: 1.25rem 0;
    border-top: 1px solid #8b786d;
}

.exchange-title {
    padding-top: 6px;
    flex: 0 0 50px;
    font-weight: bold;
    padding-right: 1rem;
    border-right: 1px solid #8b786d;
    line-height: 1.2;
    -webkit-writing-mode: vertical-rl;
    writing-mode: vertical-rl;
}

.exchange-content {
    flex: 1;
    padding-left: 1.25rem;
}

/* 資訊列樣式 */
.info-time,
.info-place,
.info-note {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.info-time:last-child,
.info-place:last-child,
.info-note:last-child {
    margin-bottom: 0;
}

/* 資訊圖示 */
.info-time::before,
.info-place::before,
.info-note::before {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 0;
    top: 0.2rem;
}

.info-time::before { content: '\f017'; }
.info-place::before { content: '\f124'; }
.info-note::before { content: '\f05a'; }

/* =================
   互動元件
   ================= */
/* Modal 樣式 */
.modal {
    z-index: 1050 !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

.modal-content {
    background: #ded1c6;
}

.modal-header {
    border-bottom: 0;
}

/* Tab 樣式 */
.nav-tabs .nav-link {
    color: #333;
    border: 0px solid transparent;
}

.nav-tabs .nav-link:hover {
    color: #e6663e;
    border-color: transparent;
}

.nav-tabs .nav-link:focus {
    outline: none;
    box-shadow: none;
}

.nav-tabs .nav-link.active {
    color: #000 !important;
    background-color: #FFD6D6 !important;
    border-color: #dee2e6 #dee2e6 #fff;
}

.nav-tabs {
    border-bottom: 1px solid #FFD6D6;
}

/* 表格樣式 */
.tab-pane .table a {
    text-decoration: none;
    color: #dc3545;
}

.tab-pane .table th:first-child,
.table td:first-child {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

.tab-pane table th,
.tab-pane table td {
    border: 0;
}

/* 頁尾樣式 */
footer {
    position: relative;
    z-index: 4;
    text-align: center;
    padding-top: 1em;
}

/* 電話連結樣式 */
.phone-link {
    color: inherit;
    text-decoration: none;
}

/* =================
   動畫效果
   ================= */
/* 精靈元素 */
.green-elf {
    position: fixed;
    bottom: 0.5rem;
    left: 30%;
    transform: translateX(-50%);
    width: 180px;
    z-index: 2;
    transition: opacity 0.15s ease;
}

/* 落葉動畫 */
.leaf {
    position: fixed;
    width: var(--size, 32px);
    height: var(--size, 32px);
    left: var(--start-left, 50%);
    top: -50px;
    z-index: 2;
    pointer-events: none;
    animation: 
        fade var(--fall-duration, 8s) infinite linear,
        drop var(--fall-duration, 8s) infinite linear;
    animation-delay: var(--delay, 0s);
    border: 0 !important;
}

.leaf img {
    position: absolute;
    width: 100%;
    height: 100%;
    animation: counterclockwiseSpinAndFlip var(--spin-duration, 4s) infinite alternate ease-in-out;
    transform-origin: center center;
    border: 0 !important;
}

@keyframes counterclockwiseSpinAndFlip {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fade {
    0% { opacity: 0; }
    5% { opacity: 1; }
    95% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes drop {
    0% { transform: translate(0px, -50px); }
    100% { transform: translate(calc(var(--random-x, 0) * 100px), calc(100vh + 50px)); }
}

/* AOS 動畫優化 */
[data-aos] {
    transition-timing-function: cubic-bezier(.25,.1,.25,1);
}

/* Sticky 效果 */
.sticky-image {
    position: sticky;
    top: 100px;
    margin-bottom: 2rem;
}

/* =================
   響應式設計
   ================= */
@media only screen and (min-width: 50em) {
    /* 書本寬螢幕樣式 */
    .open-book {
        margin: 1em;
        position: relative;
    }

    .open-book:before {
        background-color: #007a26;
        border-radius: 0.25em;
        bottom: -1em;
        content: '';
        left: -1em;
        position: absolute;
        right: -1em;
        top: -1em;
        z-index: -1;
    }

    .open-book:after {
        background: linear-gradient(to right, transparent 0%,rgba(0,0,0,0.2) 46%,rgba(0,0,0,0.5) 49%,rgba(0,0,0,0.6) 50%,rgba(0,0,0,0.5) 51%,rgba(0,0,0,0.2) 52%,transparent 100%);
        bottom: -1em;
        content: '';
        left: 50%;
        position: absolute;
        top: -1em;
        transform: translate(-50%,0);
        width: 4em;
        z-index: 1;
    }

    .open-book > * {
        column-count: 2;
        column-gap: 6em;
        position: relative;
        z-index: 1;
    }

    /* 頁首頁尾背景 */
    .open-book header:before,
    .open-book header:after,
    .open-book footer:before,
    .open-book footer:after {
        background: #fcfbf8;
        border-radius: 25%;
        content: '';
        height: 2em;
        position: absolute;
        z-index: -1;
        width: calc(50% + 2em);
    }

    .open-book header:before,
    .open-book footer:before,
    .open-book footer:after {
        border-top-left-radius: 0;
    }

    .open-book header:after,
    .open-book footer:before,
    .open-book footer:after {
        border-top-right-radius: 0;
    }

    .open-book header:before,
    .open-book header:after,
    .open-book footer:after {
        border-bottom-right-radius: 0;
    }

    .open-book header:before,
    .open-book header:after,
    .open-book footer:before {
        border-bottom-left-radius: 0;
    }

    .open-book header:before,
    .open-book header:after {
        top: -2.65em;
    }

    .open-book header:before,
    .open-book footer:before {
        right: 50%;
    }

    .open-book header:before {
        transform: rotate(-2deg);
    }

    .open-book header:after,
    .open-book footer:after {
        left: 50%;
    }

    .open-book header:after {
        transform: rotate(2deg);
    }

    .open-book footer:before,
    .open-book footer:after {
        bottom: -2.65em;
    }

    .open-book footer:before {
        transform: rotate(2deg);
    }

    .open-book footer:after {
        transform: rotate(-2deg);
    }

    .open-book header > *:last-child,
    .open-book footer > *:last-child {
        text-align: right;
    }

    .open-book footer #page-numbers {
        display: block;
    }
}

@media (min-width: 992px) {
    .navbar-toggler {
        display: none;
    }
    
    .navbar-collapse {
        display: flex !important;
    }
    
    .navbar-nav {
        flex-direction: row;
    }
}

@media (max-width: 1199.98px) {
    .sticky-image {
        position: relative;
        top: 0;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: rgba(255, 255, 255, 0.95);
        border-radius: 0.5rem;
        margin-top: 1rem;
        padding: 1rem;
    }
    
    .navbar-initial .navbar-collapse .nav-link {
        color: #333;
        text-shadow: none;
    }

    .title01 {
        max-width: 30%;
    }
    .title02 {
        max-width: 50%;
        margin-left: -4em;
    }
    .green-elf {
        width: 150px;
    }
}

@media (max-width: 576px) {
    .phone-link {
        color: #007bff;
        text-decoration: underline;
    }

    .title-group {
        gap: 0.5rem;
    }
    .title01 {
        max-width: 30%;
    }
    .title02 {
        max-width: 50%;
        margin-left: -2em;
    }
    .green-elf {
        display: none;
    }
    
    .exchange-books {
        padding: 1rem;
    }
    .exchange-item {
        padding: 0.75rem 0;
    }
    .exchange-title {
        flex: 0 0 60px;
        font-size: 0.9rem;
    }
    .exchange-content {
        padding-left: 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 375px) {
    .exchange-books {
        padding: 0.75rem;
    }
    .exchange-title {
        flex: 0 0 50px;
    }
    .exchange-content {
        padding-left: 0.75rem;
    }
}

@media (min-width: 1399px) {
    #mycolor {
        min-height: 16em;
    }
}


.btn-close {
  box-sizing: content-box;
  width: 1em;
  height: 1em;
  padding: 0.25em 0.25em;
  color: #000;
  background: transparent url(/image/close-button.svg) center/1em auto no-repeat;
  border: 0;
  border-radius: 0.375rem;
  opacity: 0.5;
}

.bounce-button {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.bounce-button:hover {
    animation: none;
    transform: translateY(-5px);
    transition: transform 0.3s ease;
}