:root {
    --bg-color: #121214;
    --text-primary: #e0e0e0;
    --accent-red: #ff5c5c; /* Matches your red border */
    --accent-gray: #555;
    
    /* Fonts from your screenshot */
    --font-en: "Black Ops One", system-ui;
    --font-zh: "Noto Sans SC", sans-serif;
}

/* Base Settings */
body {
    background-color: var(--bg-color);
    /* Subtle grid texture background */
    background-image: linear-gradient(#1a1a1a 1px, transparent 1px), linear-gradient(90deg, #1a1a1a 1px, transparent 1px);
    background-size: 40px 40px;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    margin: 0;
}

/* Font Switching Logic */
body.lang-en { font-family: var(--font-en); }
body.lang-zh { font-family: var(--font-zh); font-weight: 300; }

/* --- Draggable Language Tag (Rectangular HUD) --- */
#language-tag {
    position: fixed;
    top: 40px;
    right: 40px;
    width: 140px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #444;
    z-index: 1000;
    cursor: move;
    padding: 0;
    box-shadow: 0 0 10px rgba(0,0,0,0.8);
}

.tag-header {
    background: #222;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #444;
}

.led-light {
    width: 6px; height: 6px;
    background-color: var(--accent-red);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--accent-red);
}

.tag-title {
    font-family: var(--font-en); /* Always English for system label */
    font-size: 10px;
    color: #888;
    letter-spacing: 1px;
}

.tag-display {
    text-align: center;
    padding: 10px 0;
    font-size: 14px;
    color: #fff;
    letter-spacing: 1px;
}

.tag-controls {
    display: flex;
    border-top: 1px solid #444;
}

.lang-btn {
    flex: 1;
    background: none;
    border: none;
    color: #666;
    padding: 8px 0;
    font-size: 10px;
    cursor: pointer;
    transition: 0.2s;
    font-family: var(--font-en);
}

.lang-btn:hover {
    background: rgba(255, 92, 92, 0.2);
    color: #fff;
}

.divider { width: 1px; background: #444; }

/* --- Background Layer --- */
#bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* Puts it behind the text/grid */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.2; /* Low opacity so it doesn't clash with text */
    transition: background-image 0.5s ease-in-out, opacity 0.3s;
    filter: blur(2px); /* Optional: slight blur for depth */
}

/* --- Main Container --- */
#app-container {
    display: flex;
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    position: relative;
    overflow: hidden; /* Keeps the image inside the rounded corners if any */
    background: rgba(18, 18, 20, 0.8); /* Slight tint on top of image */
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border: 1px solid #333;
    min-height: 600px;
}

/* --- Sidebar (Filters) --- */
#sidebar {
    width: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.year-filter {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: 0.3s;
    letter-spacing: 2px;
    padding: 10px 0;
    font-family: var(--font-en); /* Keep numbers in Black Ops One */
}

.year-filter.active {
    color: var(--accent-red);
    text-shadow: 0 0 8px var(--accent-red);
    border-left: 2px solid var(--accent-red);
}

/* --- Grid Area (Inventory) --- */
#work-grid-area {
    flex: 0 0 60%; 
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 移除固定的 grid-template-rows，让它自动流动 */
    grid-auto-rows: min-content; 
    gap: 15px;
    
    /* 新增：限制最大宽度，防止宽屏下格子变得巨大导致高度溢出 */
    max-width: 900px; 
    margin: 0 auto; /* 居中 */

    /* 新增：确保高度溢出时显示滚动条，而不是被切掉 */
    height: 100%; 
    overflow-y: auto; 
    overflow-x: hidden;
    
    /* 增加底部内边距，防止最后一个格子贴底太紧 */
    padding-bottom: 60px; 
}

/* --- 自定义滚动条样式 (和谐版 - 中性科技灰) --- */
#work-grid-area::-webkit-scrollbar {
    width: 6px; /* 保持纤细 */
}
/* 滚动槽背景 - 几乎透明 */
#work-grid-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}
/* 滚动滑块 - 非常暗淡的红色，不抢眼 */
#work-grid-area::-webkit-scrollbar-thumb {
    /* 使用你的主题红，但是透明度极低 (0.2) */
    background: rgba(255, 92, 92, 0.2); 
    border-radius: 3px;
    transition: background 0.3s;
}

/* 鼠标悬停时 - 稍微变亮一点，但仍然克制 (0.5) */
#work-grid-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 92, 92, 0.5);
}

/* Card Structure */
.work-card {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Square aspect ratio */
    cursor: pointer;
}

/* Inner Content */
.work-card-inner {
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px; /* Spacing for border */
    overflow: hidden;
    background: #000;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.work-card-inner img {
    width: 100%; height: 100%;
    object-fit: cover;
    filter: grayscale(100%) contrast(1.2);
    transition: 0.3s;
}

/* --- CUSTOM PNG BORDERS --- */
.border-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    transition: opacity 0.2s;
}

/* 1. Default Border (White) */
.border-default {
    background-image: url('img/IMG_7396.PNG'); 
    opacity: 0.5;
}

/* 2. Active Border (Red) */
.border-active {
    background-image: url('img/IMG_7395.PNG');
    opacity: 0;
    filter: drop-shadow(0 0 5px var(--accent-red));
}

/* Hover/Active States */
.work-card:hover .border-default, .work-card.active .border-default { opacity: 0; }
.work-card:hover .border-active, .work-card.active .border-active { opacity: 1; }
.work-card:hover img, .work-card.active img { filter: grayscale(0%); }
.work-card:hover .work-card-inner, .work-card.active .work-card-inner { opacity: 1; }


/* --- Detail Panel (Right Side) --- */
#detail-panel {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
}

#work-title {
    font-size: 42px;
    line-height: 1.1;
    color: #fff;
    margin-bottom: 10px;
    /* Font is inherited from body class */
}

#work-time {
    font-family: var(--font-en); /* Time usually looks better in number font */
    color: var(--accent-red);
    font-size: 18px;
    margin-bottom: 20px;
}

.divider-line {
    width: 100%;
    height: 2px;
    background: #333;
    margin-bottom: 20px;
}

.section-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
}

#work-intro-text {
    font-size: 16px;
    line-height: 1.6;
    color: #ccc;
    margin-bottom: 40px;
    min-height: 100px;
    /* Font inherited from body */
}

/* Custom Detail Button */
#view-detail-btn {
    align-self: flex-start;
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 10px 30px;
    font-size: 18px;
    cursor: pointer;
    position: relative;
    font-family: inherit; /* Matches current lang */
    transition: 0.3s;
}

#view-detail-btn:hover {
    background: var(--accent-red);
    color: #000;
}

/* Frame decoration for button (Optional, based on sketch) */
.btn-frame {
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border: 1px solid rgba(255, 92, 92, 0.3);
    pointer-events: none;
}

/* --- Footer --- */
#footer-nav {
    position: fixed;
    bottom: 30px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 0 100px;
}

.footer-btn {
    color: #666;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font-en); /* Navigation implies system labels */
    text-transform: uppercase;
    transition: 0.3s;
    text-decoration: none;
}

.footer-btn:hover {
    color: var(--accent-red);
    text-shadow: 0 0 5px var(--accent-red);
}

/* --- Dropdown/Popup Menu Logic --- */

/* Wrapper for the button + menu */
.nav-group {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    cursor: pointer;
    /* Added padding to increase hit area */
    padding: 0 10px; 
}

/* The Floating Menu Box */
.popup-menu {
    position: absolute;
    bottom: 100%; /* Positions it above the footer */
    left: 50%;
    /* Start closer to the text so the jump isn't as far */
    transform: translateX(-50%) translateY(5px); 
    
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid #444;
    min-width: 120px;
    padding: 5px 0;
    
    opacity: 0; /* Hidden by default */
    pointer-events: none; /* Cannot click when hidden */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
    z-index: 200;
}

/* Show menu only when the 'active' class is added by JavaScript */
.nav-group.active .popup-menu {
    opacity: 1;
    pointer-events: auto;
    /* Move up into position */
    transform: translateX(-50%) translateY(-10px); 
}

/* Keep the "VIDEOS" text glowing red while the menu is open */
.nav-group.active .footer-btn {
    color: var(--accent-red);
    text-shadow: 0 0 5px var(--accent-red);
}

.nav-group:hover .footer-btn {
    color: var(--accent-red);
    text-shadow: 0 0 5px var(--accent-red);
}

/* --- THE FIX: THE INVISIBLE BRIDGE --- */
/* This creates a transparent block below the menu that connects it to the button */
.popup-menu::before {
    content: '';
    position: absolute;
    top: 100%; /* Attached to the bottom of the menu */
    left: 0;
    width: 100%;
    height: 30px; /* Extends down invisibly to cover the gap */
    background: transparent;
}

/* Decorative arrow (Keep this as is) */
.popup-menu::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px; height: 10px;
    background: #222;
    border-right: 1px solid #444;
    border-bottom: 1px solid #444;
}

/* Links inside the popup */
.popup-link {
    display: block; /* 修改这里：强制居中 */
    text-align: center; 
    width: 100%; /* 确保占满容器宽度 */    
    padding: 10px 0;
    color: #888;
    font-family: var(--font-en);
    font-size: 12px;
    text-decoration: none;
    letter-spacing: 1px;
    transition: 0.2s;
    border-bottom: 0.8px solid #333;
}