/* ==========================================================================
   🐸 SDG6 青蛙村莊生態風 - 全域大自然重置與變數定義 (SS2.css)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Comic+Sans+MS&family=Ubuntu:wght@400;700&family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
    --frog-green: #52b788;       /* 翠綠青蛙色 */
    --frog-dark: #2d6a4f;        /* 深森林綠 */
    --frog-light: #d8f3dc;       /* 嫩荷葉綠 */
    --mud-brown: #6c584c;        /* 土壤木紋褐 */
    --soft-cream: #f4f9f4;       /* 舒適有機白 */
    --water-blue: #00b4d8;       /* 生態純淨水藍 */
    --water-glow: #90e0ef;       /* 水波發光色 */
}

/* 基礎設定 */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

header {
    background-color: #ffffff;
    padding: 15px 30px;
    box-shadow: 0 4px 15px rgba(45, 106, 79, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #52b788;
    z-index: 10;
}

body {
    margin: 0;
    padding: 0;
    /* 核心修改：每一頁都完美套用 bg01.png 背景圖 */
    background-image: linear-gradient(var(--bg-overlay), var(--bg-overlay)), url('../img/bg01.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: #3e2723; /* 深咖啡色字體，比純黑更溫柔 */
    font-size: var(--base-font-size);
    line-height: 1.8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* 為頂部固定導覽列預留空間，防止內容被擋住 */
    padding-top: 85px; 
}

/* 網頁捲軸美化（青蛙綠漸層） */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--frog-light); }
::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--frog-green), var(--frog-dark));
    border-radius: 20px;
}

/* ==========================================================================
   🟢 頂部導覽列 (Topbar)
   ========================================================================== */
.topbar {
    background: rgba(255, 255, 255, 0.85);
    padding: 0 40px;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--frog-green);
    box-shadow: 0 4px 15px rgba(45, 106, 79, 0.1);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 999;
}

.logo { 
    font-weight: 700; 
    font-size: 1.3rem;
    letter-spacing: 2px; 
    color: var(--frog-dark);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.status-area {
    font-size: 0.95rem;
    color: var(--mud-brown);
    font-weight: bold;
}
.status-area span {
    color: var(--frog-dark);
}

.blink { animation: blinker 1.5s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }

/* ==========================================================================
   📖 頁面 1：前導故事介紹頁排版 (Hero Section)
   ========================================================================== */
.hero-section {
    width: 100%;
    min-height: calc(100vh - 70px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.main-terminal-hub {
    width: 100%;
    max-width: 1350px;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    background: #ffffff;
    border: 5px solid var(--frog-green);
    border-radius: 40px; /* 超圓潤生物感圓角 */
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(45, 106, 79, 0.15);
}

.terminal-left-panel {
    padding: 50px;
    border-right: 2px dashed var(--frog-light);
}

.terminal-left-panel h1 {
    font-size: 2.4rem;
    margin-bottom: 15px;
    color: var(--frog-dark);
}

.subtitle-desc {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--mud-brown);
    margin-bottom: 30px;
    
    /* 核心修改：設定最大寬度，並讓左右外邊距自動平分（置中） */
    max-width: 600px;           /* 或是設定 width: 80% 等 */
    margin: 0 auto 35px auto;   /* 順序為：上 右 下 左 (保有原本的下邊距 35px) */
}

/* 規則與範例框全面改成木藤綠葉風 */
.rule-box, .example-box {
    background: var(--frog-light);
    border-left: 8px solid var(--frog-green);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 25px;
}

.rule-box h3, .example-box h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--frog-dark);
}

.rule-box ul { padding-left: 20px; }
.rule-box li { margin-bottom: 8px; line-height: 1.7; color: var(--mud-brown); }
.rule-box b { color: var(--frog-dark); }
.example-box p { margin-bottom: 8px; font-size: 0.95rem; line-height: 1.6; color: var(--mud-brown); }

/* 範例指令方塊改成亮水藍色河流感 */
.example-route {
    width: fit-content;
    padding: 10px 22px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--water-blue), #0077b6);
    font-family: 'Ubuntu', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 5px;
    margin-bottom: 15px;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.3);
}

/* 大青蛙出發按鈕 */
.start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    padding: 16px 40px;
    border-radius: 40px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 1px;
    border: 3px solid var(--frog-dark);
    background: var(--frog-green);
    transition: all 0.25s ease;
    box-shadow: 0 6px 15px rgba(45, 106, 79, 0.3);
}
.start-btn:hover {
    transform: translateY(-3px);
    background: var(--frog-dark);
    box-shadow: 0 8px 20px rgba(45, 106, 79, 0.4);
}

.terminal-right-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: var(--soft-cream);
}
.grand-map-view { width: 100%; text-align: center; }
.grand-map-img {
    width: 100%;
    max-width: 480px;
    height: auto;
    border-radius: 30px;
    border: 4px solid var(--mud-brown);
}

/* ==========================================================================
   🎛️ 頁面 2：主模擬器版面 (Simulation Layout)
   ========================================================================== */
.simulation-layout {
    display: flex;
    flex-wrap: wrap;
    padding: 25px;
    gap: 25px;
    min-height: calc(100vh - 70px);
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
}

/* 左側荷葉地圖面板 */
.map-panel {
    flex: 1.3;
    min-width: 500px;
    background: #ffffff;
    border: 5px solid var(--frog-green);
    border-radius: 40px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 12px 35px rgba(45, 106, 79, 0.15);
}

.map-wrapper {
    position: relative;
    width: 100%;
    max-width: 700px;
}
.city-map {
    width: 100%;
    display: block;
    filter: brightness(0.95) contrast(1.05); /* 讓生態地圖鮮豔明亮 */
}

#connection-svg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* 右側控制面板 */
.control-panel {
    flex: 0.8;
    min-width: 380px;
    background: #ffffff;
    border: 4px solid var(--mud-brown);
    border-radius: 40px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 12px 35px rgba(108, 88, 76, 0.15);
}

.mission-info h2 {
    color: var(--frog-dark);
    font-size: 1.5rem;
    margin-bottom: 10px;
}
.route-hint {
    font-size: 0.95rem;
    color: var(--mud-brown);
    margin-bottom: 6px;
}
.route-hint span {
    color: var(--water-blue);
    font-weight: bold;
}

/* 輸入框與按鈕組合 */
.input-container { margin-top: 5px; }
.input-label { display: block; margin-bottom: 10px; color: var(--frog-dark); font-weight: bold; font-size: 0.95rem; }
.route-input-wrapper { display: flex; gap: 12px; }

#routeInput {
    flex: 1;
    background: var(--soft-cream);
    border: 2px solid var(--mud-brown);
    border-radius: 12px;
    color: var(--mud-brown);
    padding: 14px;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: monospace;
    letter-spacing: 3px;
    transition: all 0.3s ease;
}
#routeInput:focus {
    outline: none;
    border-color: var(--frog-green);
    box-shadow: 0 0 12px rgba(82, 183, 136, 0.3);
}

#submitBtn, .btn-primary {
    background: linear-gradient(135deg, var(--frog-green), var(--frog-dark));
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    padding: 0 24px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}
#submitBtn:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(45, 106, 79, 0.4);
}
#submitBtn:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* ==========================================================================
   🔮 荷葉節點與亮藍色水流管道特效
   ========================================================================== */
.node-point {
    position: absolute;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    border: 2.5px dashed var(--frog-green);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 0 8px rgba(82, 183, 136, 0.2);
    transition: all 0.4s ease;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 點亮激活狀態：變為純淨亮水藍發光 */
.node-point.active {
    border-style: solid;
    border-color: var(--water-blue);
    background: rgba(0, 180, 216, 0.2);
    box-shadow: 0 0 12px var(--water-glow), inset 0 0 6px rgba(0, 180, 216, 0.3);
}

.node-point.active::before {
    color: var(--water-blue);
    text-shadow: 0 0 6px var(--water-glow); 
    animation: valveActive 1.2s linear infinite;
}
@keyframes valveActive {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

.node-point.endpoint {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}
.node-point.endpoint::before { display: none !important; }

/* 霓虹水流線條（保留原本極美的流動發光） */
.nav-line {
    stroke: var(--water-blue);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawWater 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    filter: drop-shadow(0 0 8px var(--water-blue)) drop-shadow(0 0 3px var(--water-glow));
}
@keyframes drawWater { to { stroke-dashoffset: 0; } }

/* ==========================================================================
   📊 水量儀表板與苔蘚岩石日誌
   ========================================================================== */
.water-budget-panel {
    background: var(--soft-cream);
    border: 2px solid var(--frog-light);
    border-radius: 16px;
    padding: 15px;
}
.budget-title {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--mud-brown);
    margin-bottom: 8px;
}
.budget-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--frog-green);
    display: flex;
    align-items: center;
}
.budget-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0077b6, var(--water-blue));
    box-shadow: 0 0 10px var(--water-glow);
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.budget-text {
    font-size: 0.85rem;
    text-align: right;
    color: var(--mud-brown);
    margin-top: 6px;
}
.budget-text b { color: var(--water-blue); font-size: 1.1rem; }

/* 生態岩石日誌（炭黑底配螢光苔蘚綠字） */
.log-container {
    background: #e7e9ff; 
    border: 3px dashed var(--frog-green);
    border-radius: 16px;
    padding: 15px;
    flex: 1;
    min-height: 160px;
}
.log-body {
    height: 100%;
    overflow-y: auto;
    font-size: 0.85rem;
    color: #1b7c47; /* 螢光苔蘚綠 */
    line-height: 1.7;
    font-family: monospace;
}

/* 返回首頁生態連結 */
.back-link-frog {
    display: block;
    text-align: center;
    padding: 12px;
    background: var(--soft-cream);
    color: var(--frog-dark);
    border: 2px solid var(--frog-green);
    text-decoration: none;
    border-radius: 15px;
    font-size: 0.95rem;
    font-weight: bold;
    transition: all 0.2s ease;
}
.back-link-frog:hover {
    background: var(--frog-green);
    color: white;
}

/* ==========================================================================
   📱 手機版響應式結構調整
   ========================================================================== */
@media(max-width: 1150px) {
    .main-terminal-hub { grid-template-columns: 1fr; }
    .terminal-left-panel { border-right: none; border-bottom: 2px dashed var(--frog-light); }
    .terminal-right-panel { min-height: auto; padding: 30px; }
    .grand-map-img { max-height: 380px; }
}

@media (max-width: 900px) {
    .simulation-layout { flex-direction: column; }
    .map-panel, .control-panel { width: 100%; min-width: 100%; }
}

@media(max-width: 700px) {
    .terminal-left-panel { padding: 30px 20px; }
    .terminal-left-panel h1 { font-size: 1.8rem; }
    .subtitle-desc { font-size: 0.95rem; }
    .example-route { font-size: 1.1rem; letter-spacing: 3px; }
    .start-btn { width: 100%; }
    .topbar { padding: 0 20px; }
}
