/* =========================================
   CSS 變數參數化設計
========================================= */
:root {
	--color-dark-teal:		#235347; /* 深青色 */
    --color-brown-light:    #6a3906; /* 淺咖啡色 */
    --color-gold:           #ffd700; /* 金色 */
    --color-white:          #ffffff; /* 純白色 */
    --color-black:          #000000; /* 純黑色 */
    --color-dark-blue:      #0f172a; /* 深藍色 */
    --color-cream:          #fffdf5; /* 奶油色/米白色 */
    --color-cream-dark:     #f2ebd9; /* 深奶油色/淺沙色 */
    --color-text-main:      #2c241b; /* 深棕灰色 */
    --color-text-sub:       #5d554a; /* 灰褐色 */

    --radius-sm:            0.5rem;
    --radius-md:            1rem;
    --radius-lg:            2rem;

    --ease-brand:           cubic-bezier(.25, .46, .45, .94); 
    --duration-fast:        0.2s;
    --duration-normal:      0.4s;
    --transition-base:      all var(--duration-normal) var(--ease-brand);

    --glass-shadow:         0 12px 40px rgba(0, 51, 102, 0.08);
	
	--spacing-container:    3rem;
    --spacing-section:      2rem;
}

*, *::before, *::after {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

img, video, iframe, canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

body {
    font-family: "Roboto", "Helvetica Neue", "Inter", "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--color-text-main);
    background: var(--color-cream);
    line-height: 1.6;
}

body.menu-open {
    overflow: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-base);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* =========================================
	返回按鈕 
========================================= */
.back-btn {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    color: white;
    text-decoration: none;
    font-size: 0.9375rem;
    padding: 0.625rem 1.25rem;
    border-radius: 1.875rem;
    transition: var(--transition-base); 
    z-index: 1000;
    background-color: rgba(5, 5, 5, 0.8);
    backdrop-filter: blur(4px);
}

.back-btn:hover {
    background-color: var(--color-black);
    transform: translateX(-3px);
}

@media (max-width: 48rem) {
	.back-btn {
		font-size: 0.6rem;
	}
}

/* =========================================
   Hero section
========================================= */
.health-page-main {
    background-color: var(--color-cream);
    min-height: calc(100vh - 300px);
}

.health-hero {
    background-color: var(--color-dark-teal);
    color: var(--color-white);
    padding: 4rem 0;
    text-align: center;
    border-bottom: 4px solid var(--color-gold);
    margin-bottom: 3rem;
}

.health-hero .page-title {
    font-size: 2.5rem;
    color: var(--color-gold);
    margin-bottom: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.health-hero .page-subtitle {
    font-size: 1.05rem;
    color: var(--color-cream-dark);
    opacity: 0.9;
}

/* =========================================
   Story Section (故事區)
========================================= */
.story-section {
    padding: 0 var(--spacing-container);
    margin-top: 5%;
    margin-bottom: var(--spacing-section);
    display: flex;
    justify-content: center;
}

.content-card {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 左圖右文 */
    width: 100%;
    max-width: 100%;
    min-height: 600px;
    border-radius: var(--radius-lg);
    background-color: transparent;
    overflow: hidden;
}

/* 反轉佈局：右圖左文 */
.story-section.reverse .content-card {
    direction: rtl; /* 簡單的技巧來反轉 Grid 順序 */
}
.story-section.reverse .content-card > * {
    direction: ltr; /* 內容轉回來 */
}

/* Image Wrapper (圖片區) */
.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    background-color: transparent;
    
    /* 圖片置中容器 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 圖片本身樣式：實現不裁切、不失真 */
.story-image {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    
    /* 這裡放比例！推薦 4/3 或 1/1 */
    aspect-ratio: 1 / 1; 
    
    /* 核心屬性：確保圖片完整顯示在容器內，不失真 */
    object-fit: contain; 
    
    /* 保持圖片的高級感，移除邊框或圓角 */
    border-radius: 0; 
    box-shadow: none;
}

/* Text Wrapper (文字區) */
.text-wrapper {
    padding: var(--spacing-container) var(--spacing-section);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chapter-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.0625rem;
    color: var(--color-brown-light);
    margin-bottom: 0.625rem;
}

.section-title {
    font-size: 3.5rem;
    margin-bottom: 2.5rem;
    font-weight: 600;
	color: var(--color-brown-light);
}

/* 動畫文字核心樣式 */
.reveal-text {
	--reveal-progress: 0;   /* 由 JS 動態更新 0 ~ 1 */
    --total-chars: 1;       /* 由 JS 自動填入 */
    
    position: relative;
    font-size: 2rem;
    line-height: 1.5;
    color: var(--color-text-main);
    isolation: isolate;
}

.reveal-text strong {
    color: var(--color-black);
    font-weight: 600;
}

/* 這是 JS 產生出來的 span 樣式 */
.char-span {
	display: inline;
    
    /* 計算每個字元在整段文字中的百分比位置 */
    --char-relative-pos: calc(var(--char-index) / var(--total-chars));
    
    /* 
       如果總進度 > 該字元位置，opacity 就會 > 0
       利用 clamp 確保數值維持在 0.1 到 1 之間
    */
    opacity: clamp(
        0.1, 
        calc((var(--reveal-progress) * 1.1 - var(--char-relative-pos)) * 20),
        1
    );

    /* 增加一點點平滑的顏色與位移變化，更有質感 */
    transition: opacity 0.3s ease-out, color 0.3s ease-out;
}

/* =========================================
   Closing Section (結語區塊)
========================================= */
.closing-section {
    padding: 6rem var(--spacing-container);
    display: flex;
    justify-content: center;
    text-align: center;
}

.closing-content {
    max-width: 800px;
    position: relative;
}

.closing-text {
    font-size: 2.8rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--color-dark-teal);
}

.closing-text strong {
    color: var(--color-gold);
    font-size: 2.2rem;
    font-style: italic;
}

/* RWD */
@media (max-width: 48rem) {
    
    /* 強制變為單欄垂直排列 */
    .content-card {
        grid-template-columns: 1fr; 
        min-height: auto; 
    }
    
    /* 處理 reverse 類別：確保在手機版依然是圖先文後 */
    .story-section.reverse .content-card {
        direction: ltr;        /* 重置掉桌面版的反轉技巧 */
        flex-direction: column; 
    }

    /* 圖片區調整：縮小高度避免手機畫面被單張圖佔滿 */
    .image-wrapper {
        min-height: 250px;
        height: auto;
        padding: 0;
        order: 1;              /* 強制圖片在第一順位 */
    }
    
    .story-image {
        max-height: 400px;
        object-fit: cover;     /* 在手機版通常 cover 效果比 contain 好，視需求調整 */
    }
    
    /* 文字區調整：縮減間距並確保在圖片下方 */
    .text-wrapper {
        padding: 2rem 0.5rem;
        order: 2;              /* 強制文字在第二順位 */
        text-align: center;    /* 選項：手機版文字置中通常較美觀 */
    }

    .section-title {
        font-size: 2.2rem;     /* 縮小手機版標題字體 */
        margin-bottom: 1.5rem;
    }

    .reveal-text {
        font-size: 1.15rem;    /* 縮小內文字體 */
        line-height: 1.6;
    }
	
	.closing-section {
        padding: 4rem 1.5rem;
    }
    
    .closing-text {
        font-size: 1.5rem;
    }
    
    .closing-text strong {
        font-size: 1.7rem;
    }
}

/* =========================================
   Floating UI (FAB & Back To Top)
========================================= */
.side-fab-group {
	position: fixed;
	right: 1.25rem;
	bottom: 1.875rem; 
	display: flex;
	flex-direction: column;
	gap: 1rem;
	z-index: 998;
	align-items: flex-end; 
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px);
	transition: all var(--duration-normal) ease;
}

.side-fab-group.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.fab-item {
    display: flex;
    align-items: center;
    justify-content: flex-end; 
    width: 3rem; height: 3rem;
    padding: 0 0.75rem; 
    background: var(--color-gold); 
    color: var(--color-dark-teal);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.4);
    border-radius: 2rem; 
    cursor: pointer; border: none;
    overflow: hidden; white-space: nowrap;
    transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color var(--duration-normal) ease;
}

.fab-item svg {
	width: 1.5rem;
	height: 1.5rem;
	flex-shrink: 0;
	transition: transform 0.3s ease;
}

.fab-item::before {
	content: attr(title);
	margin-right: 0.75rem;
	font-size: 0.95rem;
	font-weight: 600;
	opacity: 0;
	transform: translateX(10px);
	transition: all 0.3s ease;
}

.back-to-top {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- RWD --- */
@media (min-width: 48rem) {
	.fab-item:hover {
		width: 9rem;
		background-color: #ffe066;
	}

	.fab-item:hover::before {
		opacity: 1;
		transform: translateX(0);
		transition-delay: 0.1s;
	}

	/* BackToTop 不延展寬度 */
	.fab-item.back-to-top:hover {
		width: 3rem;
		background-color: #ffe066;
		transform: translateY(-4px);
	}

	.fab-item.back-to-top::before {
		display: none;
	}
}

@media (max-width: 48rem) {
	.fab-item {
		width: 2.75rem;
		height: 2.75rem;
		justify-content: center;
		padding: 0;
	}

	.fab-item::before {
		display: none;
	}

	.side-fab-group {
		bottom: 1.25rem;
		right: 0.9375rem;
	}
}

/* =========================================
   Footer
========================================= */
footer {
	background-color: var(--color-dark-teal);
	color: var(--color-white);
	padding-top: 1rem;
}

.footer-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 3rem;
	padding-bottom: 1rem;
	align-items: start;
}

.footer-heading {
	color: var(--color-gold);
	font-size: 1.25rem;
	margin-bottom: 1.5rem;
}

.footer-contact p {
	margin-bottom: 0.8rem;
	color: rgba(255, 255, 255, 0.9);
}

.nhi-logo-wrapper {
	margin-top: 1rem;
	display: inline-block;
}

.footer-bottom {
	background-color: rgba(0, 0, 0, 0.2);
	padding: 1rem 0;
}

.copyright-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.9rem;
	color: rgba(255, 255, 255, 0.6);
}

/* --- RWD --- */
@media (max-width: 48rem) {
	.footer-grid {
		grid-template-columns: 1fr;
		gap: 2.5rem;
		text-align: center;
	}

	.copyright-row {
		flex-direction: column;
		gap: 0.5rem;
	}
}