/* ========================================
   Magazine Style - 數位時代風格
   全寬大圖 + 文字疊加 + 黑色半透明遮罩
   ======================================== */

/* CSS Variables */
:root {
    --primary: #0891b2;
    --bg-dark: #1a1a1a;
    --text-white: #ffffff;
    --text-gray: #e5e7eb;
    --overlay-dark: rgba(0, 0, 0, 0.6);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-screen p {
    margin-top: 20px;
    color: white;
    font-size: 16px;
}

/* App Container */
.app-container {
    min-height: 100vh;
    background-color: #ffffff;
}

/* Header Bar */
.header-bar {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-align: center;
}

.header-date {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 2px;
    align-self: flex-end;
}

/* News Feed */
.news-feed {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* Magazine Card - 數位時代風格 */
.magazine-card {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.magazine-card:active {
    transform: scale(0.98);
}

/* Card Image */
.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card Overlay (黑色半透明遮罩) */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, 
        rgba(0, 0, 0, 0.3) 0%, 
        rgba(0, 0, 0, 0.5) 50%,
        rgba(0, 0, 0, 0.8) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px;
}

/* Category Tag */
.card-category {
    position: absolute;
    top: 16px;
    left: 16px;
    background-color: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Card Content */
.card-content {
    color: white;
}

/* Country Badge */
.card-country {
    display: inline-block;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 8px;
}

/* Card Title */
.card-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Card Summary */
.card-summary {
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 12px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Card Footer */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.card-source {
    font-weight: 600;
}

.card-time {
    opacity: 0.8;
}

/* Featured Card (首則新聞更高) */
.magazine-card.featured {
    height: 500px;
}

.magazine-card.featured .card-title {
    font-size: 26px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}

/* ========================================
   單篇新聞閱讀頁面
   ======================================== */

/* 返回按鈕 */
.back-button {
    position: fixed;
    top: 16px;
    left: 16px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    z-index: 200;
    backdrop-filter: blur(10px);
    transition: background-color 0.3s ease;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* 單篇新聞容器 */
.news-feed.single-news {
    padding: 0;
}

.single-news-article {
    background-color: white;
    min-height: 100vh;
}

/* Hero 大圖 */
.single-news-hero {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, 
        rgba(0, 0, 0, 0.2) 0%, 
        rgba(0, 0, 0, 0) 100%);
}

.hero-category {
    position: absolute;
    top: 70px;
    left: 16px;
    background-color: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 新聞內容 */
.single-news-content {
    padding: 24px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.news-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

.meta-country {
    background-color: #f3f4f6;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.meta-time {
    color: #999;
}

.news-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 16px;
    color: #1a1a1a;
}

.news-source-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.source-name {
    font-weight: 600;
    color: var(--primary);
}

.news-content {
    font-size: 16px;
    line-height: 1.8;
    color: #4b5563;
    margin-bottom: 32px;
    white-space: pre-wrap;  /* 保留換行 */
}

/* 動作按鈕 */
.news-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.action-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.primary:active {
    transform: scale(0.97);
}

.action-btn.secondary {
    background-color: #f3f4f6;
    color: #4b5563;
}

.action-btn.secondary:active {
    transform: scale(0.97);
    background-color: #e5e7eb;
}

/* ========================================
   語音播放器頁面
   ======================================== */

.news-feed.audio-player-page {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.audio-player-container {
    max-width: 500px;
    margin: 60px auto 0;
}

.audio-player-card {
    background-color: white;
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    text-align: center;
}

.audio-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.audio-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1a1a1a;
}

.audio-news-title {
    font-size: 16px;
    color: #4b5563;
    margin-bottom: 24px;
    line-height: 1.5;
}

.audio-controls {
    margin: 24px 0;
}

.audio-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.audio-btn:active {
    transform: scale(0.95);
}

.voice-selector {
    margin: 24px 0;
    text-align: left;
}

.voice-selector label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #4b5563;
}

.voice-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    background-color: white;
}

.playback-options {
    margin: 24px 0;
    text-align: left;
}

.playback-options label {
    display: block;
    margin: 8px 0;
    font-size: 15px;
    cursor: pointer;
}

.playback-options input[type="radio"] {
    margin-right: 8px;
}

.audio-note {
    margin-top: 24px;
    font-size: 14px;
    color: #999;
}

/* 播報員資訊卡片 */
.speaker-info {
    margin: 16px 0;
}

.speaker-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 8px;
}

.speaker-avatar {
    font-size: 32px;
}

.speaker-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.speaker-details strong {
    font-size: 15px;
    color: #1a1a1a;
}

.speaker-details span {
    font-size: 13px;
    color: #6c757d;
}

/* 記住選擇 Checkbox */
.remember-choice {
    margin: 16px 0;
    text-align: left;
}

.remember-choice label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4b5563;
    cursor: pointer;
}

.remember-choice input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

/* 音訊播放器包裝 */
.audio-player-wrapper {
    margin-top: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
}

.audio-player-wrapper audio {
    width: 100%;
    border-radius: 8px;
}

.audio-status {
    margin-top: 12px;
    font-size: 14px;
    color: #4b5563;
    text-align: center;
}

/* 播放按鈕狀態 */
.audio-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: #a0a0a0;
}

/* ========================================
   儲存文章頁面
   ======================================== */

.news-feed.save-page {
    padding: 20px;
    background: linear-gradient(135deg, #43e97b 0%, #38d66c 100%);
    min-height: 100vh;
}

.save-container {
    max-width: 500px;
    margin: 60px auto 0;
}

.save-card {
    background-color: white;
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    text-align: center;
}

.save-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.save-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1a1a1a;
}

.save-news-title {
    font-size: 16px;
    color: #4b5563;
    margin-bottom: 24px;
    line-height: 1.5;
}

.save-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
}

.save-btn {
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn.supabase {
    background-color: #3ecf8e;
    color: white;
}

.save-btn.notion {
    background-color: #000000;
    color: white;
}

.save-btn.minio {
    background-color: #c72c48;
    color: white;
}

.save-btn:active {
    transform: scale(0.97);
}

.save-note {
    margin-top: 24px;
    font-size: 14px;
    color: #999;
}

.back-to-list-btn {
    margin-top: 24px;
    padding: 12px 32px;
    background-color: #f3f4f6;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.back-to-list-btn:hover {
    background-color: #e5e7eb;
}

/* Responsive */
@media (max-width: 768px) {
    .magazine-card {
        height: 350px;
    }
    
    .magazine-card.featured {
        height: 450px;
    }
    
    .card-title {
        font-size: 20px;
    }
    
    .magazine-card.featured .card-title {
        font-size: 24px;
    }
    
    .single-news-hero {
        height: 300px;
    }
    
    .news-title {
        font-size: 24px;
    }
    
    .audio-player-container,
    .save-container {
        margin-top: 40px;
    }
}

/* ========================================
   播報員選擇卡片樣式
   ======================================== */

.speaker-selector-label {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 20px 0 15px 0;
    text-align: left;
}

.speaker-cards {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.speaker-card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 120px;
}

.speaker-card-item:hover {
    border-color: #a78bfa;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.speaker-card-item.selected {
    border-color: #8b5cf6;
    background: #fff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
    transform: scale(1.12);
    z-index: 10;
}

/* 當有選中的卡片時，其他未選中的卡片縮小 */
.speaker-cards:has(.selected) .speaker-card-item:not(.selected) {
    transform: scale(0.88);
    opacity: 0.85;
}

.speaker-photo {
    width: 80px;
    height: 100px;
    overflow: hidden;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.speaker-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
}

/* 預設：顯示靜態圖片，隱藏動畫 */
.speaker-card-item .speaker-animated {
    display: none;
}

/* 選中時：隱藏靜態圖片，顯示動畫 */
.speaker-card-item.selected .speaker-img {
    display: none;
}

.speaker-card-item.selected .speaker-animated {
    display: block;
    background: #fff;
}

/* 選中時圖片區域白色背景 */
.speaker-card-item.selected .speaker-photo {
    background: #fff;
}

.speaker-name {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-align: center;
    margin-bottom: 4px;
}

.speaker-desc {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    line-height: 1.3;
}

/* 響應式 - 手機 */
@media (max-width: 480px) {
    .speaker-cards {
        gap: 10px;
    }
    
    .speaker-card-item {
        width: 100px;
        padding: 12px 8px;
    }
    
    .speaker-photo {
        width: 65px;
        height: 85px;
    }
    
    .speaker-name {
        font-size: 12px;
    }
    
    .speaker-desc {
        font-size: 10px;
    }
}

