/* 全局样式设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS变量定义 */
:root {
    --sidebar-width: 270px;
    --header-height: 70px;
    --container-max-width: 1000px;
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #3498db;
    --text-color: #333;
    --bg-color: #f8f9fa;
}

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
}

/* 主容器栅格布局 - sidebar-nav 和 main-content-wrapper 作为同级栅格项目 */
.main-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* 侧边栏样式 - 与 main-content-wrapper 同级 */
.sidebar-nav {
    background: #2c3e50;
    padding: 20px 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    width: 100%;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin: 0;
}

.sidebar-nav a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    transition: background 0.3s;
}

.sidebar-nav a:hover {
    background: #34495e;
}

.sidebar-nav a.active {
    background: #3498db;
}

/* 下拉按钮样式 */
.dropdown-btn {
    cursor: pointer;
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    font-size: 16px;
    text-align: left;
    transition: background 0.3s;
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-family: Arial, sans-serif;
    position: relative;
}

.dropdown-btn:hover {
    background: #34495e;
}

.dropdown-btn.active {
    background: #3498db;
}

.arrow {
    float: right;
    transition: transform 0.3s;
    font-size: 12px;
}

.dropdown-btn.active .arrow {
    transform: rotate(180deg);
}

.dropdown-container {
    background-color: #34495e;
    display: none;
    overflow: hidden;
    padding: 0;
    margin: 0;
    list-style: none;
}

.dropdown-container.show {
    display: block;
}

.dropdown-container a {
    padding: 10px 20px;
    text-decoration: none;
    color: white;
    display: block;
    transition: background 0.3s;
    font-family: Arial, sans-serif;
    text-align: left;
}

.dropdown-container a:hover {
    background: #2c3e50;
}

.dropdown-container a.active {
    background: #3498db;
}

/* 主内容区样式 - 与 sidebar-nav 同级 */
.main-content-wrapper {
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 2;
    width: 100%;
}

.main-content-wrapper .container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 30px auto;
    background: white;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.main-content {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 40px;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 40px 30px;
    text-align: left;
}

.profile-section {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 40px;
    flex-wrap: wrap;
}

.profile-img {
    flex: 0 0 auto;
}

.profile-img img {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.4);
    object-fit: cover;
    object-position: center top;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.profile-info {
    flex: 1;
    min-width: 300px;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.name {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: bold;
}

.title {
    font-size: 1.3em;
    margin-bottom: 20px;
    opacity: 0.9;
}

.contact-info p {
    margin: 8px 0;
    font-size: 1.1em;
}

.contact-info a {
    color: white;
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

.icon {
    margin-right: 10px;
    font-size: 1.2em;
}

.skills-tags {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.skill-tag {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 主要内容区域 */
.section-title {
    font-size: 1.8em;
    color: var(--primary-color);
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-color);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--secondary-color);
}

.about-section {
    margin-bottom: 40px;
}

.about-text {
    font-size: 1.1em;
    line-height: 1.8;
    text-align: justify;
}

/* 时间线通用样式 */
.timeline, .education-timeline {
    position: relative;
    padding-left: 30px;
    margin-bottom: 30px;
}

.timeline::before, .education-timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary-color);
}

.timeline-item, .education-timeline-item {
    position: relative;
    margin-bottom: 30px;
    padding-left: 20px;
}

.timeline-marker, .education-timeline-marker {
    position: absolute;
    left: -33px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid white;
    box-shadow: 0 0 0 3px var(--primary-color);
}

.timeline-content {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.time-period {
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 10px;
}

.description {
    color: #666;
}

/* 教育时间线特殊样式 */
.education-timeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* 技能部分 */
.skills-section {
    margin-bottom: 40px;
}

.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.skill-category {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.skill-category h3 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.skill-category ul {
    list-style: none;
}

.skill-category li {
    padding: 5px 0;
    position: relative;
    padding-left: 20px;
}

.skill-category li::before {
    content: '•';
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-size: 1.2em;
}

/* 项目部分 */
.project-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.project-item h3 {
    color: #333;
    margin-bottom: 10px;
}

.tech-used {
    color: var(--primary-color);
    font-weight: bold;
    margin-top: 10px;
}

/* 首页入口卡片（复用 .project-item 的卡片外观） */
.entry-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.entry-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.entry-link .project-item {
    margin-bottom: 0;
    transition: border-left-color 0.2s ease, transform 0.15s ease;
}

.entry-link:hover .project-item {
    border-left-color: var(--secondary-color);
    transform: translateX(4px);
}

/* 页脚 */
.footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 0.9em;
}

/* 移动端响应式布局 */
@media (max-width: 768px) {
    /* 移动端：切换为垂直堆叠布局 */
    .main-container {
        display: flex !important;
        flex-direction: column !important;
        min-height: 100vh;
    }

    /* 移动端：侧边栏变为顶部导航 */
    .sidebar-nav {
        position: sticky;
        top: 0;
        width: 100%;
        height: auto;
        min-height: auto;
        background: #2c3e50;
        padding: 10px 0;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 100;
        overflow: visible;
    }

    .sidebar-nav ul {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        overflow-y: visible;
        justify-content: flex-start;
        padding: 0;
        width: 100%;
        align-items: stretch;
    }

    .sidebar-nav li {
        flex: none;
        width: 100%;
        text-align: left;
        white-space: normal;
    }

    .sidebar-nav a {
        display: block;
        color: white;
        text-decoration: none;
        padding: 15px 20px;
        font-size: 14px;
        text-align: left;
        transition: background 0.3s;
        flex: none;
    }

    /* 下拉按钮在移动端 */
    .dropdown-btn {
        cursor: pointer;
        display: block;
        color: white;
        text-decoration: none;
        padding: 15px 20px;
        font-size: 14px;
        text-align: left;
        transition: background 0.3s;
        border: none;
        background: transparent;
        width: 100%;
        outline: none;
        font-family: Arial, sans-serif;
    }

    .dropdown-btn:hover {
        background: #34495e;
    }

    .dropdown-btn.active {
        background: #3498db;
    }

    .arrow {
        float: right;
        transition: transform 0.3s;
        font-size: 12px;
    }

    .dropdown-btn.active .arrow {
        transform: rotate(180deg);
    }

    .dropdown-container {
        background-color: #34495e;
        display: none !important;
        overflow: hidden;
        padding: 0;
        margin: 0;
        list-style: none;
        position: static;
        z-index: 99;
        width: 100%;
    }
    
    .dropdown-container.show {
        display: block !important;
    }

    .dropdown-container a {
        padding: 10px 20px;
        text-decoration: none;
        color: white;
        display: block;
        transition: background 0.3s;
        font-family: Arial, sans-serif;
        text-align: center;
    }

    .dropdown-container a:hover {
        background: #2c3e50;
    }

    .dropdown-container a.active {
        background: #3498db;
    }

    /* 内容区域适配移动端 */
    .main-content-wrapper {
        width: 100%;
        padding: 20px 10px 10px 10px;
        min-height: auto;
        display: block;
    }

    .main-content-wrapper .container {
        margin: 10px auto;
        border-radius: 5px;
        width: calc(100% - 20px);
        padding: 0;
    }

    .header {
        padding: 20px 15px;
        text-align: left;
    }

    .profile-section {
        display: flex;
        flex-direction: column;
        text-align: center;
        justify-content: center;
        gap: 20px;
        flex-wrap: nowrap;
    }

    .profile-img img {
        width: 120px;
        height: 120px;
    }

    .name {
        font-size: 1.8em;
    }

    .title {
        font-size: 1.1em;
    }

    .main-content {
        padding: 15px;
    }

    /* 移动端时间线调整 */
    .education-timeline {
        grid-template-columns: 1fr;
        padding-left: 15px;
    }

    .education-timeline::before {
        left: 5px;
    }

    .education-timeline-item {
        padding-left: 20px;
    }

    .education-timeline-marker {
        left: -15px;
    }

    /* 移动端技能容器调整 */
    .skills-container {
        grid-template-columns: 1fr;
    }

    /* 移动端时间线调整 */
    .timeline {
        padding-left: 15px;
    }

    .timeline::before {
        left: 5px;
    }

    .timeline-item {
        padding-left: 20px;
    }

    .timeline-marker {
        left: -15px;
    }
}

/* 桌面设备样式 */
.desktop-device .main-container {
    display: grid !important;
    grid-template-columns: var(--sidebar-width) 1fr !important;
    flex-direction: row !important;
}

.desktop-device .sidebar-nav {
    background: #2c3e50;
    padding: 20px 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    width: 100%;
}

.desktop-device .main-content-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
}

/* 移动设备检测样式 */
.mobile-device .main-container {
    display: flex !important;
    flex-direction: column !important;
}

.mobile-device .sidebar-nav {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    min-height: auto;
    z-index: 100;
    background: #2c3e50;
    padding: 10px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: visible;
}

.mobile-device .sidebar-nav ul {
    display: flex;
    flex-direction: column;
    padding: 0;
    width: 100%;
    align-items: stretch;
}

.mobile-device .sidebar-nav li {
    width: 100%;
    text-align: left;
}

.mobile-device .sidebar-nav a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    text-align: left;
}

.mobile-device .main-content-wrapper {
    width: 100%;
    padding: 20px 10px;
}

/* 微信浏览器特殊处理 */
.wechat-browser .main-container {
    display: flex !important;
    flex-direction: column !important;
}

.wechat-browser .sidebar-nav {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    min-height: auto;
    z-index: 100;
    background: #2c3e50;
    padding: 10px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: visible;
}

.wechat-browser .sidebar-nav ul {
    display: flex;
    flex-direction: column;
    padding: 0;
    width: 100%;
    align-items: stretch;
}

.wechat-browser .sidebar-nav li {
    width: 100%;
    text-align: left;
}

.wechat-browser .sidebar-nav a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    text-align: left;
}

.wechat-browser .main-content-wrapper {
    width: 100%;
    padding: 20px 10px;
}

/* 计算器样式 */
.calculator-section {
    padding: 40px 0;
    background-color: #f9f9f9;
}

.calculator-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 0 20px;
}

.calculator {
    background-color: #333;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.calculator input#display {
    width: 100%;
    height: 80px;
    font-size: 2.5rem;
    text-align: right;
    padding: 0 15px;
    border: none;
    border-radius: 5px;
    background-color: #222;
    color: white;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.calculator .buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.calculator button {
    height: 70px;
    font-size: 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: white;
}

.calculator .btn-number {
    background-color: #555;
}

.calculator .btn-number:hover {
    background-color: #666;
}

.calculator .btn-operator {
    background-color: #f39c12;
}

.calculator .btn-operator:hover {
    background-color: #e67e22;
}

.calculator .btn-clear {
    background-color: #e74c3c;
}

.calculator .btn-clear:hover {
    background-color: #c0392b;
}

.calculator .btn-delete {
    background-color: #95a5a6;
}

.calculator .btn-delete:hover {
    background-color: #7f8c8d;
}

.calculator .btn-equals {
    background-color: #2ecc71;
    grid-row: span 2;
}

.calculator .btn-equals:hover {
    background-color: #27ae60;
}

.calculator .btn-zero {
    grid-column: span 2;
    background-color: #555;
}

.calculator .btn-zero:hover {
    background-color: #666;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .calculator {
        padding: 15px;
    }
    
    .calculator input#display {
        height: 60px;
        font-size: 2rem;
    }
    
    .calculator button {
        height: 60px;
        font-size: 1.2rem;
    }
}

/* 2048游戏样式 */
.game-section {
    padding: 40px 0;
    background-color: #f9f9f9;
}

.game-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
}

.game-info {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.game-info p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.game-info ul {
    margin-left: 20px;
}

.game-info li {
    margin-bottom: 5px;
}

.game-wrapper {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.game-header h3 {
    font-size: 2.5rem;
    font-weight: bold;
    color: #776e65;
    margin: 0;
}

.game-stats {
    display: flex;
    gap: 15px;
}

.score, .best {
    background-color: #bbada0;
    padding: 10px 20px;
    border-radius: 5px;
    color: white;
    min-width: 80px;
}

.score-label, .best-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.score-value, .best-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 15px;
    background-color: #bbada0;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.tile {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    font-size: 2rem;
    font-weight: bold;
    color: #776e65;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 5px;
    z-index: -1;
}

.tile-empty {
    background-color: #cdc1b4;
}

.tile-empty::before {
    background-color: #cdc1b4;
}

.tile-2 {
    background-color: #eee4da;
}

.tile-2::before {
    background-color: #eee4da;
}

.tile-4 {
    background-color: #ede0c8;
}

.tile-4::before {
    background-color: #ede0c8;
}

.tile-8 {
    background-color: #f2b179;
    color: white !important;
}

.tile-8::before {
    background-color: #f2b179;
}

.tile-16 {
    background-color: #f59563;
    color: white !important;
}

.tile-16::before {
    background-color: #f59563;
}

.tile-32 {
    background-color: #f67c5f;
    color: white !important;
}

.tile-32::before {
    background-color: #f67c5f;
}

.tile-64 {
    background-color: #f65e3b;
    color: white !important;
}

.tile-64::before {
    background-color: #f65e3b;
}

.tile-128 {
    background-color: #edcf72;
    color: white !important;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.1429);
}

.tile-128::before {
    background-color: #edcf72;
}

.tile-256 {
    background-color: #edcc61;
    color: white !important;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3174), inset 0 0 0 1px rgba(255, 255, 255, 0.1905);
}

.tile-256::before {
    background-color: #edcc61;
}

.tile-512 {
    background-color: #edc850;
    color: white !important;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3968), inset 0 0 0 1px rgba(255, 255, 255, 0.2381);
}

.tile-512::before {
    background-color: #edc850;
}

.tile-1024 {
    background-color: #edc53f;
    color: white !important;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4762), inset 0 0 0 1px rgba(255, 255, 255, 0.2857);
    font-size: 1.5rem !important;
}

.tile-1024::before {
    background-color: #edc53f;
}

.tile-2048 {
    background-color: #edc22e;
    color: white !important;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5556), inset 0 0 0 1px rgba(255, 255, 255, 0.3333);
    font-size: 1.5rem !important;
}

.tile-2048::before {
    background-color: #edc22e;
}

/* 移动端方向按钮 */
.mobile-controls {
    margin-bottom: 30px;
    display: none;
}

.mobile-controls .up {
    display: block;
    margin: 0 auto 10px;
}

.mobile-controls .control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    width: 80px;
    height: 80px;
    font-size: 1.5rem;
    font-weight: bold;
    background-color: #bbada0;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.control-btn:hover {
    background-color: #a89c8e;
}

.game-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.reset-btn, .how-to-btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn {
    background-color: #8f7a66;
    color: white;
}

.reset-btn:hover {
    background-color: #7f6a56;
}

.how-to-btn {
    background-color: #bbada0;
    color: white;
}

.how-to-btn:hover {
    background-color: #a89c8e;
}

.how-to-play {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
}

.how-to-play h3 {
    color: #776e65;
    margin-bottom: 15px;
}

.how-to-play ul {
    margin-left: 20px;
}

.how-to-play li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* 响应式布局 */
@media (max-width: 768px) {
    .game-wrapper {
        padding: 20px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 20px;
    }
    
    .game-board {
        grid-gap: 10px;
        padding: 10px;
        max-width: 300px;
    }
    
    .tile {
        font-size: 1.5rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 1.2rem !important;
    }
    
    .mobile-controls {
        display: block;
    }
    
    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 0 10px;
    }
    
    .game-wrapper {
        padding: 15px;
    }
    
    .game-header h3 {
        font-size: 2rem;
    }
    
    .game-board {
        max-width: 250px;
    }
    
    .tile {
        font-size: 1.2rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 1rem !important;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
    
    .game-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .reset-btn, .how-to-btn {
        width: 100%;
    }
}