/* ===== CSS Variables ===== */
:root {
    --p-teal: #33CDCF;
    --p-teal-light: #5DDFE1;
    --p-teal-dark: #2AB5B7;
    --p-pink: #FF679A;
    --p-purple: #8B5CF6;

    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;

    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    transition: opacity 0.4s, visibility 0.4s;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Miku Loader Container */
.miku-loader-container {
    position: relative;
    width: min(400px, 60vw);
    aspect-ratio: 6 / 1;
    margin-bottom: 20px;
}

/* Common mask style for layers */
.miku-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-mask-image: url('/static/loading.webp');
    mask-image: url('/static/loading.webp');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

/* Base layer: light teal (unloaded) */
.miku-layer.base {
    background-color: #bfece8;
    opacity: 0.5;
    z-index: 1;
}

/* Progress wrapper */
.progress-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    overflow: hidden;
    z-index: 2;
    transition: width 0.3s ease-out;
}

/* Progress color layer */
.progress-color {
    width: min(400px, 60vw);
    height: 100%;
    background-color: #39c5bb;
    filter: drop-shadow(0 0 5px #39c5bb);
}

/* Phase 1: Fast loading to 90% */
.progress-wrapper.loading {
    animation: miku-load-fast 0.5s ease-out forwards;
}

/* Phase 2: Waiting at 90% */
.progress-wrapper.waiting {
    width: 90%;
}

/* Phase 3: Complete to 100% */
.progress-wrapper.complete {
    width: 100%;
}

@keyframes miku-load-fast {
    0% {
        width: 0%;
    }

    100% {
        width: 90%;
    }
}

.loading-text {
    color: #2a9d94;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 0.05em;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    height: 56px !important;
    max-height: 56px !important;
    min-height: 56px !important;
    overflow: hidden;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-link {
    display: block;
    height: 32px !important;
    line-height: 0;
}

.header-logo {
    display: block;
    height: 32px !important;
    max-height: 32px !important;
    width: auto !important;
    max-width: 120px !important;
    object-fit: contain;
}

.nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    padding: 8px 0;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--p-teal);
}

/* ===== Main ===== */
.main {
    flex: 1;
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, #E0F7FA 0%, #F3E5F5 50%, #FFF3E0 100%);
    padding: 48px 16px;
    position: relative;
    overflow: hidden;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--p-teal), var(--p-purple), var(--p-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.hero-decoration {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.floating-note {
    position: absolute;
    font-size: 24px;
    opacity: 0.3;
    animation: float 6s ease-in-out infinite;
}

.note-1 {
    top: 20%;
    left: 10%;
    color: var(--p-teal);
}

.note-2 {
    top: 60%;
    right: 15%;
    color: var(--p-pink);
    animation-delay: 2s;
}

.note-3 {
    bottom: 20%;
    left: 20%;
    color: var(--p-purple);
    animation-delay: 4s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

/* ===== Events Section ===== */
.events-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 16px 48px;
}

.section-header {
    text-align: center;
    margin-bottom: 24px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Search ===== */
.search-container {
    max-width: 400px;
    margin: 0 auto 24px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    height: 40px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: var(--p-teal);
    box-shadow: 0 0 0 2px rgba(51, 205, 207, 0.15);
}

.search-icon {
    color: var(--text-muted);
    margin-right: 8px;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    background: transparent;
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-stats {
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== No Results ===== */
.no-results {
    text-align: center;
    padding: 48px 16px;
    display: none;
}

.no-results.visible {
    display: block;
}

.no-results-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.no-results-text {
    font-size: 18px;
    margin-bottom: 4px;
}

.no-results-hint {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Events Grid ===== */
.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.events-grid.hidden {
    display: none;
}

/* ===== Event Card ===== */
.event-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.event-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.event-card.hidden {
    display: none;
}

.event-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #667eea, #764ba2);
    overflow: hidden;
}

.event-card-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.event-card:hover .event-card-bg {
    transform: scale(1.05);
}

.event-card-logo-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 2;
}

.event-card-logo {
    max-width: 70%;
    max-height: 55%;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.logo-fallback {
    display: none;
    font-size: 40px;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.event-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent 60%);
    z-index: 1;
}

.event-card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.event-card-id {
    font-size: 11px;
    font-weight: 600;
    color: var(--p-teal);
    background: rgba(51, 205, 207, 0.1);
    padding: 2px 6px;
    border-radius: 999px;
    margin-bottom: 4px;
    width: fit-content;
}

.event-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    line-height: 1.4;
}

.event-card-title-jp {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.event-card-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.event-card-chapters {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.event-card-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
}

.status-completed {
    background: #D1FAE5;
    color: #059669;
}

.status-pending {
    background: #FEF3C7;
    color: #D97706;
}

/* ===== Event Detail ===== */
.event-hero {
    position: relative;
    min-height: 280px;
    background-color: #1a1a2e;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.7));
}

.event-hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: white;
    padding: 32px 16px;
}

.event-logo {
    max-width: 280px;
    max-height: 100px;
    margin: 0 auto 16px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.event-id-badge {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 10px;
    border-radius: 999px;
    margin-bottom: 8px;
}

.event-title {
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 4px;
}

.event-title-jp {
    font-size: 16px;
    opacity: 0.9;
}

.event-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* ===== Event Info ===== */
.event-info {
    margin-bottom: 32px;
}

.event-info-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.info-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--p-teal-dark);
    margin-bottom: 12px;
}

.info-content {
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-line;
    font-size: 15px;
}

.info-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.info-summary h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.info-summary p {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 15px;
}

/* ===== Chapters ===== */
.chapters-section .section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    margin-bottom: 16px;
}

.title-icon {
    font-size: 20px;
}

.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 章节卡片 - 统一横向布局 */
.chapter-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.chapter-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--p-teal-light);
}

.chapter-number {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: linear-gradient(135deg, var(--p-teal), var(--p-teal-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.chapter-content {
    flex: 1;
    min-width: 0;
}

.chapter-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chapter-title-jp {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.chapter-summary {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

/* 章节缩略图 - 始终小图在右侧 */
.chapter-image {
    width: 100px;
    height: 56px;
    min-width: 100px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}

.chapter-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== Back Button ===== */
.back-button-container {
    margin-top: 32px;
    text-align: center;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.back-button:hover {
    background: var(--p-teal);
    border-color: var(--p-teal);
    color: white;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 24px 16px;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.footer-logo-img {
    display: block;
    height: 32px !important;
    max-height: 32px !important;
    width: auto !important;
    max-width: 100px !important;
}

.footer-org {
    font-size: 12px;
    color: var(--text-secondary);
}

.footer-text {
    font-size: 12px;
    color: var(--text-muted);
}

.footer-disclaimer {
    margin-top: 4px;
    font-size: 11px;
}

/* ===== 图片错误处理 ===== */
.img-hidden {
    display: none !important;
}

.event-card-logo.img-hidden+.logo-fallback {
    display: block;
}

/* ===== Responsive ===== */
@media (min-width: 640px) {

    .header,
    .header-container {
        height: 64px !important;
        max-height: 64px !important;
        min-height: 64px !important;
    }

    .header-logo {
        height: 36px !important;
        max-height: 36px !important;
    }

    .hero {
        padding: 64px 24px;
    }

    .hero-title {
        font-size: 40px;
    }

    .events-section {
        padding: 48px 24px;
    }

    .section-title {
        font-size: 28px;
    }

    .event-hero {
        min-height: 350px;
    }

    .event-logo {
        max-width: 350px;
        max-height: 120px;
    }

    .event-title {
        font-size: 36px;
    }

    .chapter-image {
        width: 140px;
        height: 79px;
        min-width: 140px;
    }

    .footer-logo-img {
        height: 40px !important;
        max-height: 40px !important;
    }
}