/* ========================================
   星空留言墙 - 样式表
   ======================================== */

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

html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    color: #e8e8ff;
    background: #0a0a2e;
}

/* ========================================
   星空背景 Canvas
   ======================================== */
#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ========================================
   背景视频轮播层
   ======================================== */
#video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    transition: opacity 2s ease;
    pointer-events: none;
}

#video-overlay.active {
    opacity: 1;
}

#bg-image,
#bg-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.video-overlay-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(10, 10, 46, 0.4) 0%, rgba(10, 10, 46, 0.85) 100%);
}

/* ========================================
   主内容层
   ======================================== */
#app {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px 60px;
}

/* ========================================
   标题区域
   ======================================== */
#hero {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInDown 1.5s ease;
}

.hero-title {
    font-size: clamp(1.8rem, 5vw, 3.2rem);
    font-weight: 300;
    letter-spacing: 4px;
    text-shadow:
        0 0 20px rgba(138, 154, 255, 0.6),
        0 0 40px rgba(138, 154, 255, 0.3),
        0 0 80px rgba(138, 154, 255, 0.15);
    margin-bottom: 16px;
    background: linear-gradient(135deg, #c8d6ff 0%, #ffffff 40%, #a8b8ff 70%, #ffd6e8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: rgba(200, 210, 255, 0.7);
    letter-spacing: 2px;
    font-weight: 300;
}

/* ========================================
   搜索栏
   ======================================== */
#search-bar {
    width: 100%;
    max-width: 480px;
    margin: 0 auto 40px;
    animation: fadeInDown 1.2s ease 0.3s both;
    z-index: 30;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(20, 20, 70, 0.6);
    border: 1px solid rgba(138, 154, 255, 0.25);
    border-radius: 50px;
    padding: 4px 6px 4px 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-wrapper:focus-within {
    border-color: rgba(138, 154, 255, 0.6);
    box-shadow: 0 0 20px rgba(138, 154, 255, 0.15);
}

.search-icon {
    font-size: 16px;
    margin-right: 10px;
    opacity: 0.6;
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e8e8ff;
    font-size: 15px;
    padding: 10px 0;
    font-family: inherit;
}

#search-input::placeholder {
    color: rgba(200, 210, 255, 0.4);
}

.search-clear {
    background: rgba(138, 154, 255, 0.15);
    border: none;
    color: rgba(200, 210, 255, 0.6);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.search-clear:hover {
    background: rgba(138, 154, 255, 0.3);
    color: #fff;
}

.search-clear.hidden {
    display: none;
}

.search-hint {
    text-align: center;
    font-size: 12px;
    color: rgba(200, 210, 255, 0.35);
    margin-top: 8px;
    letter-spacing: 1px;
}

/* 搜索匹配高亮 */
.star.matched {
    animation: pulseMatch 1s ease infinite;
    z-index: 50;
}

.star.matched .star-dot {
    box-shadow: 0 0 20px 6px rgba(255, 220, 100, 0.8), 0 0 40px 12px rgba(255, 200, 80, 0.3);
}

.star.dimmed {
    opacity: 0.15;
    filter: grayscale(0.8);
    pointer-events: none;
}

@keyframes pulseMatch {
    0%, 100% { transform: scale(1.5); }
    50% { transform: scale(2); }
}

/* ========================================
   星星容器
   ======================================== */
#stars-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    min-height: 600px;
    flex: 1;
}

/* ========================================
   单颗星星
   ======================================== */
.star {
    position: absolute;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
    z-index: 20;
}

.star:hover {
    transform: scale(1.8) !important;
    filter: brightness(2) drop-shadow(0 0 12px rgba(255, 255, 200, 0.9));
}

.star-dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, #ffe88a 40%, rgba(255, 232, 138, 0) 70%);
    animation: twinkle var(--duration) ease-in-out infinite;
    animation-delay: var(--delay);
    box-shadow: 0 0 6px 2px rgba(255, 255, 200, 0.4);
}

/* 星星名字标签 */
.star-label {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 13px;
    color: rgba(200, 210, 255, 0.9);
    text-shadow: 0 0 8px rgba(138, 154, 255, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    font-weight: 500;
    letter-spacing: 1px;
}

.star:hover .star-label {
    opacity: 1;
}

/* ========================================
   弹窗 Modal
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 30, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 1;
    transition: opacity 0.4s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    position: relative;
    border: 1px solid rgba(138, 154, 255, 0.3);
    border-radius: 20px;
    max-width: 480px;
    width: 90%;
    overflow: hidden;
    box-shadow:
        0 0 40px rgba(138, 154, 255, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.4s ease;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-card {
    transform: scale(0.85);
}

/* ========================================
   卡片背景层
   ======================================== */
.modal-bg {
    position: relative;
    width: 100%;
    max-height: 360px;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(25, 25, 80, 0.6), rgba(15, 15, 50, 0.8));
}

.modal-bg img {
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: contain;
    display: block;
}

.modal-bg video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 背景为空时的默认装饰 */
.modal-bg:empty::before {
    content: '✨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 64px;
    opacity: 0.15;
}

/* ========================================
   卡片内容层
   ======================================== */
.modal-content {
    position: relative;
    padding: 32px 36px 36px;
    text-align: center;
    background: linear-gradient(145deg, rgba(25, 25, 80, 0.95), rgba(15, 15, 50, 0.98));
}

/* 内容与背景衔接处的渐变遮罩 */
.modal-content::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 0;
    width: 100%;
    height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(25, 25, 80, 0.95));
    pointer-events: none;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: rgba(10, 10, 40, 0.5);
    border: none;
    color: rgba(200, 210, 255, 0.7);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s, background 0.2s;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-close:hover {
    color: #fff;
    background: rgba(10, 10, 40, 0.8);
    transform: rotate(90deg);
}

.modal-star-icon {
    font-size: 40px;
    margin-bottom: 12px;
    animation: floatStar 3s ease-in-out infinite;
}

.modal-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #ffe88a, #fff, #a8d8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}

.modal-message {
    font-size: 1rem;
    line-height: 1.8;
    color: rgba(200, 210, 255, 0.85);
    padding: 14px 18px;
    background: rgba(138, 154, 255, 0.08);
    border-radius: 12px;
    border-left: 3px solid rgba(138, 154, 255, 0.4);
    font-weight: 300;
}

.modal-decoration {
    margin-top: 16px;
    font-size: 14px;
    letter-spacing: 8px;
    color: rgba(200, 210, 255, 0.3);
}

/* ========================================
   底部寄语
   ======================================== */
#footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px 20px;
    animation: fadeInUp 1.5s ease 0.5s both;
}

#footer p {
    font-size: clamp(0.85rem, 2vw, 1.05rem);
    color: rgba(200, 210, 255, 0.5);
    letter-spacing: 2px;
    font-weight: 300;
}

.footer-year {
    margin-top: 8px;
    font-size: 0.8rem !important;
    color: rgba(200, 210, 255, 0.3) !important;
}

.footer-notice {
    margin-top: 12px;
    font-size: 0.7rem !important;
    color: rgba(200, 210, 255, 0.2) !important;
    letter-spacing: 1px;
}

.footer-gallery-link {
    margin-top: 10px;
}

.footer-gallery-link a {
    color: rgba(200, 210, 255, 0.5);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
    letter-spacing: 1px;
}

.footer-gallery-link a:hover {
    color: rgba(255, 220, 100, 0.8);
}

/* ========================================
   动画 Keyframes
   ======================================== */
@keyframes twinkle {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes floatStar {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ========================================
   响应式适配
   ======================================== */
@media (max-width: 768px) {
    #app {
        padding: 30px 16px 40px;
    }

    #hero {
        margin-bottom: 40px;
    }

    #stars-container {
        min-height: 500px;
    }

    .modal-card {
        padding: 40px 28px 32px;
    }

    .modal-star-icon {
        font-size: 36px;
    }

    .modal-name {
        font-size: 1.3rem;
    }

    .modal-message {
        font-size: 0.9rem;
    }

    .star-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        letter-spacing: 2px;
    }

    .modal-card {
        padding: 32px 20px 28px;
        border-radius: 16px;
    }
}
