/* CSS Variables */
:root {
    /* カラーパレット */
    --primary-color: #4A90E2;        /* メインブルー */
    --secondary-color: #7ED321;      /* アクセントグリーン */
    --accent-color: #F5A623;         /* ハイライトオレンジ */
    --background-color: #F8FAFB;     /* 背景色 */
    --card-background: #FFFFFF;      /* カード背景 */
    --text-primary: #2C3E50;         /* メインテキスト */
    --text-secondary: #7F8C8D;       /* サブテキスト */
    --border-color: #E8EEF1;         /* ボーダー色 */
    
    /* シャドウ効果 */
    --shadow-light: 0 2px 12px rgba(74, 144, 226, 0.1);
    --shadow-medium: 0 4px 20px rgba(74, 144, 226, 0.15);
    
    /* Firebase関連カラー */
    --firebase-orange: #FF6B35;         /* Firebase ブランドカラー */
    --firebase-yellow: #FFCA28;         /* Firebase アクセント */
    --success-green: #27AE60;           /* 成功メッセージ */
    --error-red: #E74C3C;               /* エラーメッセージ */
    
    /* グラデーション */
    --gradient-primary: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    --gradient-secondary: linear-gradient(135deg, #7ED321 0%, #6BC503 100%);
    --gradient-accent: linear-gradient(135deg, #F5A623 0%, #E8950F 100%);
}

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

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    font-weight: 400;
}

/* =====================================================
   共通レイアウト
   ===================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =====================================================
   ヘッダーセクション
   ===================================================== */
.header {
    background: var(--gradient-primary);
    color: white;
    text-align: center;
    padding: 3rem 0;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><pattern id="pattern" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="20" fill="url(%23pattern)"/></svg>');
    opacity: 0.3;
}

.site-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.site-subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* メインコンテンツ */
.main {
    padding: 3rem 0;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* カウントダウンセクション */
.countdown-section {
    margin-bottom: 4rem;
}

.countdown-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
}

.countdown-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

.countdown-display {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.countdown-item {
    text-align: center;
}

.countdown-number {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.countdown-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 0.5rem;
    display: block;
}

.race-date {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-color);
}

/* 統計セクション */
.stats-section {
    margin-bottom: 4rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--card-background);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: 12px;
    color: white;
}

.stat-content {
    flex: 1;
}

.stat-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* 活動記録セクション */
.activity-section {
    margin-bottom: 4rem;
}

.activity-form-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.activity-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.8rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.submit-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    align-self: flex-start;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* 最近の活動一覧 */
.recent-activities-section {
    margin-bottom: 4rem;
}

.activities-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    background: var(--card-background);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
}

.activity-date {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.activity-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.activity-type {
    font-weight: 600;
    color: var(--text-primary);
}

.activity-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.activity-distance {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.delete-activity-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.delete-activity-btn:hover {
    opacity: 1;
    background-color: rgba(231, 76, 60, 0.1);
    transform: scale(1.1);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ナビゲーション */
.navigation {
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    justify-content: center;
    padding: 1rem 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(74, 144, 226, 0.1);
}

.nav-link.active {
    color: var(--primary-color);
    background: var(--gradient-primary);
    color: white;
}

/* 記事関連スタイル */
.articles-section {
    padding: 2rem 0;
}

.articles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.write-btn {
    background: var(--gradient-secondary);
    color: white;
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.3s ease;
}

.write-btn:hover {
    transform: translateY(-2px);
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.article-card {
    background: var(--card-background);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.article-date {
    font-weight: 600;
}

.article-category {
    background: var(--gradient-primary);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.article-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.article-content {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.article-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.article-stats {
    display: flex;
    gap: 1.5rem;
}

.like-btn, .comment-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.like-btn:hover, .comment-toggle:hover {
    background-color: rgba(74, 144, 226, 0.1);
    color: var(--primary-color);
}

.like-btn.liked {
    color: #e74c3c;
}

.comment-toggle.active {
    color: var(--primary-color);
}

/* コメントセクション */
.comments-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: none;
}

.comments-section.show {
    display: block;
}

.comment-form {
    margin-bottom: 1.5rem;
}

.comment-input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 0.8rem;
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comment-submit {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.comment-submit:hover {
    transform: translateY(-1px);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment-item {
    background: rgba(74, 144, 226, 0.05);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.comment-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.comment-text {
    color: var(--text-primary);
    line-height: 1.6;
}

/* 記事投稿フォーム */
.write-article-section {
    padding: 2rem 0;
}

.article-form-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.article-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.cancel-btn {
    background: var(--text-secondary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.cancel-btn:hover {
    transform: translateY(-2px);
}

.empty-articles {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-articles h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.empty-articles p {
    margin-bottom: 2rem;
}

/* 管理者ページ */
.admin-section {
    padding: 2rem 0;
}

.admin-card {
    background: var(--card-background);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.admin-card h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
}

.admin-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.password-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.admin-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.admin-btn:hover {
    transform: translateY(-2px);
}

.export-btn {
    background: var(--gradient-secondary);
    color: white;
}

.danger-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.admin-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(74, 144, 226, 0.05);
    border-radius: 8px;
}

.stat-label {
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* 認証モーダル */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-modal {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-medium);
    width: 90%;
    max-width: 400px;
}

.auth-modal h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-error {
    background: #ffe6e6;
    color: #cc0000;
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 1rem;
}

.delete-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-left: 1rem;
    transition: transform 0.2s ease;
}

.delete-btn:hover {
    transform: translateY(-1px);
}

.delete-comment-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 1rem;
    transition: transform 0.2s ease;
}

.delete-comment-btn:hover {
    transform: translateY(-1px);
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* フッター */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .site-title {
        font-size: 2.2rem;
    }
    
    .site-subtitle {
        font-size: 1rem;
    }
    
    .countdown-display {
        gap: 1rem;
    }
    
    .countdown-number {
        font-size: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .activity-item {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 0.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .activity-form-card,
    .countdown-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .countdown-display {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .countdown-item {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-icon {
        font-size: 2rem;
        width: 50px;
        height: 50px;
    }
}

/* =====================================================
   Firebase関連スタイル
   ===================================================== */

/* Firebaseライブバッジ */
.firebase-badge {
    background: linear-gradient(135deg, var(--firebase-orange), var(--firebase-yellow));
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.3);
}

/* リアルタイム記事カード */
.article-card[data-firebase="true"] {
    border-left: 4px solid var(--firebase-orange);
    position: relative;
}

.article-card[data-firebase="true"]::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--firebase-orange);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* コメント投稿中状態 */
.comment-submit:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.comment-submit.posting {
    background: var(--firebase-orange);
    position: relative;
}

.comment-submit.posting::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 成功・エラーメッセージ */
.message-success {
    background: linear-gradient(135deg, var(--success-green), #2ECC71);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
}

.message-error {
    background: linear-gradient(135deg, var(--error-red), #C0392B);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.3);
}

/* オフライン状態表示 */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--text-secondary);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 0.875rem;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* 管理者専用バッジ */
.admin-only-badge {
    background: linear-gradient(135deg, var(--accent-color), #E8950F);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 10px;
    box-shadow: 0 2px 6px rgba(245, 166, 35, 0.3);
    animation: pulse 2s infinite;
}

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

/* 続きを読むボタンと記事表示制御 */
.content-text.collapsed {
    max-height: none;
    overflow: visible;
}

.content-text.expanded {
    max-height: none;
    overflow: visible;
}

.read-more-btn {
    background: linear-gradient(135deg, var(--primary-color), #357ABD);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.2);
}

.read-more-btn:hover {
    background: linear-gradient(135deg, #357ABD, #2C5282);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.read-more-btn:active {
    transform: translateY(0);
}