/* ============================================
   朗讀練習 webapp — 暖意學習風
   色彩：米色背景 + 陶土橙重點 + 深棕文字
   字體：Noto Serif TC（中文）+ Inter（標註）
   ============================================ */

:root {
    /* 色彩系統 */
    --bg-base: #F8F3EA;          /* 暖米色背景 */
    --bg-paper: #FDFBF5;         /* 奶白卡片 */
    --bg-sentence-hover: #F5EDDD; /* 淡橙 hover */
    --bg-sentence-active: #FAEFE0; /* 播放中淺橙底 */

    --text-primary: #3D2E1F;     /* 深棕主文字 */
    --text-secondary: #6B5849;   /* 次要棕 */
    --text-muted: #9B8B7A;       /* 淡棕標註 */

    --accent: #C75B2C;           /* 陶土橙重點 */
    --accent-soft: #E8A07D;      /* 淡橙 */
    --accent-line: #D9744A;      /* 橙色豎線 */

    --decor-green: #5C6B4A;      /* 墨綠裝飾 */

    --border-soft: #E8DCC8;      /* 淡邊框 */
    --shadow-soft: 0 2px 8px rgba(61, 46, 31, 0.06);
    --shadow-card: 0 4px 20px rgba(61, 46, 31, 0.08);
}

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

html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Serif TC', 'Songti TC', serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.9;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* 紙紋背景 texture */
.paper-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' /%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.2 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 主容器 */
.reader {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 4rem 1.5rem 8rem;
}

/* ============================================
   文章標題區
   ============================================ */
.article-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.article-meta {
    margin-bottom: 1.2rem;
}

.article-source {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 500;
}

.article-title {
    font-family: 'Noto Serif TC', serif;
    font-size: 2.6rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    line-height: 1.3;
}

.article-author {
    font-family: 'Noto Serif TC', serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.1em;
}

.article-author::before {
    content: '— ';
    color: var(--text-muted);
}

/* 分隔線 */
.article-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2.5rem 0 0;
}

.divider-mark {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    position: relative;
}

.divider-mark::before,
.divider-mark::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 60px;
    height: 1px;
    background: var(--border-soft);
}

.divider-mark::before {
    right: 100%;
    margin-right: 12px;
}

.divider-mark::after {
    left: 100%;
    margin-left: 12px;
}

/* ============================================
   文章正文
   ============================================ */
.article-body {
    font-family: 'Noto Serif TC', serif;
    font-size: 1.15rem;
    line-height: 2.1;
    color: var(--text-primary);
    text-align: justify;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.sentence {
    display: inline;
    cursor: pointer;
    padding: 0.15em 0.25em;
    margin: 0 -0.05em;
    border-radius: 4px;
    transition: background-color 0.25s ease, color 0.25s ease;
    position: relative;
}

.sentence:hover {
    background: var(--bg-sentence-hover);
    color: var(--accent);
}

/* 播放中嘅句子 */
.sentence.playing {
    background: var(--bg-sentence-active);
    color: var(--accent);
    font-weight: 500;
}

.sentence.playing::before {
    content: '';
    position: absolute;
    left: -0.4em;
    top: 0.1em;
    bottom: 0.1em;
    width: 3px;
    background: var(--accent-line);
    border-radius: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 句子之間嘅段落分隔 */
.sentence[data-paragraph-end]::after {
    content: '';
    display: block;
    height: 1.2em;
}

/* ============================================
   底部控制列
   ============================================ */
.article-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(248, 243, 234, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-soft);
    padding: 1rem 1.5rem;
}

.controls {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
}

.ctrl-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-soft);
    background: var(--bg-paper);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-soft);
}

.ctrl-btn:hover:not(:disabled) {
    background: var(--bg-sentence-hover);
    color: var(--accent);
    border-color: var(--accent-soft);
    transform: translateY(-1px);
}

.ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctrl-btn-primary {
    width: 52px;
    height: 52px;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(199, 91, 44, 0.3);
}

.ctrl-btn-primary:hover:not(:disabled) {
    background: #B04E22;
    color: white;
    border-color: #B04E22;
}

.progress-info {
    max-width: 680px;
    margin: 0.6rem auto 0;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ============================================
   動畫
   ============================================ */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   響應式
   ============================================ */
@media (max-width: 640px) {
    html {
        font-size: 16px;
    }

    .reader {
        padding: 2.5rem 1.2rem 7rem;
    }

    .article-title {
        font-size: 2rem;
    }

    .article-body {
        font-size: 1.08rem;
        line-height: 2;
    }

    .ctrl-btn {
        width: 40px;
        height: 40px;
    }

    .ctrl-btn-primary {
        width: 48px;
        height: 48px;
    }
}

/* ============================================
   載入狀態
   ============================================ */
.loading {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.error {
    text-align: center;
    padding: 4rem 0;
    color: var(--accent);
}
