/* ==========================================================================
   🐸 SDG6 青蛙自來水管網鋪設 - 森林草綠大自然風格 (water_network.css)
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-card: #ffffff;
    --primary: #2d6a4f;       /* 深森林綠 */
    --primary-hover: #40916c; /* 亮森林綠 */
    --accent: #52b788;        /* 嫩草綠 */
    --text-main: #1b4332;     /* 墨綠黑文字 */
    --text-muted: #6c584c;    /* 原木褐文字 */
    --success: #1b4332;       /* 成功通水深綠 */
    --warning: #d97706;       /* 警告暗橘 */
    --danger: #b7094c;        /* 錯誤暗紅 */
    --border: rgba(45, 106, 79, 0.12);
    
    /* 核心修改：放大基礎字級，讓繪本風更清晰 */
    --base-font-size: 21px; 
}

body {
    margin: 0;
    padding: 0;
    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;
    align-items: center;       /* 核心修改：確保子元件在畫面水平置中 */
    padding-top: 85px; 
    
    /* 核心修改：讓全頁的文字預設通通置中 */
    text-align: center;
}

header {
    width: 100%;
    max-width: 1200px;         /* 讓頂部標題列與下方主容器同寬 */
    margin: 0 auto 25px auto;  /* 頂部標題列水平置中 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--accent);
    padding-bottom: 15px;
}

header h1 {
    font-size: 28px;           /* 放大的可愛字級 */
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 雙欄排版（1 1）整組在網頁正中央 */
.main-container {
    width: 100%;
    max-width: 1200px;         /* 限制最大寬度，讓兩張卡片在中間凝聚 */
    margin: 0 auto 40px auto;  /* 靠左右 auto 讓「整組雙欄」在螢幕正中央 */
    
    display: grid;
    grid-template-columns: 1.1fr 1fr; /* 保持左右雙欄並排 ( 1  1 ) */
    gap: 30px;
}

/* 繪本佈告欄風卡片外框 */
.card {
    background-color: var(--bg-card);
    border-radius: 24px;
    border: 2px solid #b7e4c7;
    padding: 28px;
    box-shadow: 0 8px 25px rgba(45, 106, 79, 0.08);
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: transform 0.3s ease;
}
.card:hover {
    transform: translateY(-2px);
}

/* 卡片裡面的大標題：維持置中，讓視覺有焦點 */
.card-title {
    font-size: 21px;           
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 6px solid var(--primary);
    padding-left: 12px;
    justify-content: center;   /* 標題維持置中 */
}

/* 核心修改：卡片內的敘述文字「完全靠左對齊」 */
p {
    font-size: 16.5px;         /* 保持放大的舒適字級 */
    line-height: 1.7;
    color: var(--text-muted);
    text-align: left;          /* 修正：改回靠左對齊，方便閱讀 */
    width: 100%;
}

/* 核心修改：潛在鋪設管線與檢查清單文字也「靠左對齊」 */
.cost-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: #edf7ed;
    padding: 15px;
    border-radius: 16px;
    border: 1px dashed var(--accent);
    width: 100%;
    text-align: left;          /* 修正：確保清單內文字靠左 */
}

.text-cost-list li {
    font-size: 16px;           /* 保持放大字級 */
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-weight: bold;
    position: relative;
    padding-left: 24px;
    text-align: left;          /* 修正：項目文字靠左 */
}

.tag-sdg {
    background: linear-gradient(135deg, #52b788, #2d6a4f);
    color: white;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(45, 106, 79, 0.2);
}


.card-title.sub-title { border-left-color: var(--accent); }
.card-title.kruskal-title { border-left-color: #90e0ef; }


p b {
    background-color: #edf7ed;
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--primary);
}
.guide-text {
    background-color: #f4f9f4;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid #e8f5e9;
}

.text-cost-list li::before {
    content: "🪵";
    position: absolute;
    left: 0;
    font-size: 13px;
}

/* 演算法邊緣檢查表項目樣式 */
.algo-guide-list li {
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #5c677d;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.algo-guide-list li.success-step {
    color: #1b4332;
    background-color: #d8f3dc;
    font-weight: bold;
}
.algo-guide-list li.discard-step {
    text-decoration: line-through;
    color: #94a3b8;
    background-color: #f1f5f9;
}

/* 互動式圖形區域 */
.visualization-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ffffff 0%, #edf7ed 100%);
    border-radius: 20px;
    padding: 15px;
    position: relative;
    border: 2px solid #d8f3dc;
    min-height: 380px;
    box-shadow: inset 0 4px 10px rgba(45, 106, 79, 0.03);
}

svg {
    width: 100%;
    max-width: 500px;
    height: auto;
}

/* 站點網格樣式設計 */
.node-group {
    cursor: pointer;
    pointer-events: all;
}
.node {
    fill: #ffffff;
    stroke: var(--primary);
    stroke-width: 3;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.1));
    transition: all 0.3s ease;
}

/* 站點文字基礎樣式 */
.node-text {
    fill: var(--text-main);
    font-family: 'Ubuntu', sans-serif;
    font-size: 13px;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
.node-text.text-emoji {
    font-size: 15px;
}

/* 隱形大點擊環 */
.click-trigger {
    fill: transparent;
    cursor: pointer;
    pointer-events: all;
}

.node-group:hover .node {
    fill: #e8f5e9;
    stroke: var(--primary-hover);
    r: 26px;
}

/* 精準控制站點選取高亮狀態 */
.node-group.active-node .node {
    fill: #52b788 !important;
    stroke: #2d6a4f !important;
    r: 26px;
}

/* 線段（竹管管線）基礎與施工樣式 */
.edge {
    stroke: #b7e4c7; /* 未鋪設前為枯木淡色 */
    stroke-width: 6;
    stroke-linecap: round;
    cursor: pointer;
    transition: all 0.3s;
}
.edge:hover {
    stroke: #74c69d;
    stroke-width: 8;
}
.edge.selected {
    stroke: #2d6a4f; /* 完工後呈現生機盎然的深綠色 */
    stroke-width: 8;
    filter: drop-shadow(0px 2px 4px rgba(45,106,79,0.2));
}
.edge.cycle {
    stroke: var(--danger); /* 形成環路警示 */
    stroke-dasharray: 6;
    animation: pipelineDash 1s linear infinite;
}
@keyframes pipelineDash {
    to { stroke-dashoffset: -12; }
}

.edge-weight-bg {
    fill: #ffffff;
    rx: 6;
    stroke: #b7e4c7;
    stroke-width: 1;
}
.edge-weight-text {
    fill: var(--primary);
    font-size: 13px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* 即時狀態提示欄 */
.dashboard-status {
    display: flex;
    justify-content: space-between;
    background: #f4f9f4;
    padding: 16px 20px;
    border-radius: 16px;
    border: 1px solid #e8f5e9;
    font-size: 14.5px;
    font-weight: bold;
}
.status-value {
    font-weight: 800;
    color: var(--primary);
}

/* 重新整理按鈕 */
.btn-secondary {
    background: #ffffff;
    border: 2px solid var(--text-muted);
    color: var(--text-muted);
    padding: 14px 20px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-secondary:hover {
    background: var(--text-muted);
    color: white;
}

/* 遊戲結果反饋訊息框 */
.feedback-box {
    padding: 18px;
    border-radius: 16px;
    font-weight: bold;
    font-size: 14.5px;
    line-height: 1.6;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}
.feedback-box.correct {
    background-color: #d8f3dc;
    border: 2px solid #52b788;
    color: #1b4332;
}
.feedback-box.wrong {
    background-color: #fde2e4;
    border: 2px solid #ffb3c1;
    color: #5c0d12;
}

/* 🐸 純文字青蛙工程師 SVG 核心動態 */
#frog-engineer {
    pointer-events: none;
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
.frog-text {
    font-size: 32px;
    text-anchor: middle;
    dominant-baseline: central;
    animation: frogJumpEffect 0.6s ease-in-out infinite alternate;
}
@keyframes frogJumpEffect {
    0% { transform: scale(1); }
    100% { transform: scale(1.15) translateY(-3px); }
}

/* 徽章 Badge 基礎樣式 */
.badge {
    background-color: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
}
.badge.success {
    background-color: #dcfce7;
    color: #15803d;
}
.badge.danger {
    background-color: #fee2e2;
    color: #b91c1c;
}

.edge-click-trigger {
    stroke: transparent;
    stroke-width: 18;
    stroke-linecap: round;
    cursor: pointer;
    pointer-events: all;
}
