/* ============================
   图学堂 - 组件样式
   版本：v1.0
   说明：卡片、按钮、徽章等
   ============================ */

/* ============================
   学段卡片
   ============================ */
.level-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    border-radius: var(--radius-xl);
    padding: clamp(1.5rem, 5vw, 3rem);
    width: 100%;
    max-width: 500px;
    min-height: 200px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 卡片顶部彩色条 */
.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* 学段颜色变体 */
.level-card.primary::before {
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

.level-card.middle::before {
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

.level-card.high::before {
    background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%);
}

/* 禁用状态 */
.level-card--disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 触摸反馈 */
.level-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

/* 桌面端 hover（仅支持 hover 的设备） */
@media (hover: hover) {
    .level-card:hover {
        transform: translateY(-20px) scale(1.03);
        box-shadow: var(--shadow-lg);
    }

    .level-card:hover .card-button {
        transform: scale(1.05);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }
}

/* ============================
   卡片元素
   ============================ */
.card-icon {
    font-size: clamp(3rem, 8vw, 5rem);
    text-align: center;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: var(--text-xl);
    color: #333;
    text-align: center;
    margin-bottom: var(--space-xs);
    font-weight: bold;
}

.card-subtitle {
    font-size: var(--text-sm);
    color: #666;
    text-align: center;
    margin-bottom: var(--space-md);
}

.card-description {
    font-size: var(--text-base);
    color: #888;
    line-height: 1.8;
    text-align: center;
    margin-bottom: var(--space-md);
}

/* ============================
   卡片按钮
   ============================ */
.card-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    min-width: 120px;
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 按钮颜色变体 */
.level-card.primary .card-button {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.level-card.middle .card-button {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.level-card.high .card-button {
    background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%);
}

/* 按钮触摸反馈 */
.card-button:active {
    transform: scale(0.96);
}

/* ============================
   徽章
   ============================ */
.badge {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #ff6b6b;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    z-index: 1;
}

.badge.coming-soon {
    background: #ffd93d;
    color: #333;
}

/* ============================
   页脚
   ============================ */
.site-footer {
    text-align: center;
    margin-top: var(--space-xl);
    padding: var(--space-md);
}

.site-footer a {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

@media (hover: hover) {
    .site-footer a:hover {
        color: rgba(255, 255, 255, 0.9);
    }
}

/* ============================
   项目卡片（学段页面内的卡片）
   ============================ */
.project-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: cardFadeIn 0.8s ease-out;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

/* 触摸反馈 */
.project-card:active {
    transform: scale(0.97);
}

@media (hover: hover) {
    .project-card:hover {
        transform: translateY(-10px) scale(1.02);
        box-shadow: var(--shadow-lg);
    }
}

/* 卡片图片头部 */
.project-card__image {
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5em;
    position: relative;
    overflow: hidden;
}

.project-card__image::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite;
}

/* 卡片内容区 */
.project-card__content {
    padding: var(--space-md);
}

.project-card__title {
    font-size: var(--text-lg);
    color: #333;
    margin-bottom: var(--space-xs);
    font-weight: bold;
}

.project-card__desc {
    color: #666;
    font-size: var(--text-sm);
    line-height: 1.6;
    margin-bottom: var(--space-sm);
}

/* 标签组 */
.project-card__tags {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
}

.tag.math {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.tag.physics {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.tag.geometry {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.tag.function {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* 即将推出状态 */
.project-card--pending {
    opacity: 0.6;
    cursor: not-allowed;
}

.project-card--pending .project-card__image {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
}

/* ============================
   手机端：项目卡片紧凑模式
   ============================ */
@media (max-width: 768px) {
    /* 卡片改为横向布局：图标在左，内容在右 */
    .project-card {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }

    /* 图标区缩小为左侧条 */
    .project-card__image {
        width: 80px;
        min-width: 80px;
        height: auto;
        font-size: 2em;
        flex-shrink: 0;
    }

    /* 内容区紧凑 */
    .project-card__content {
        padding: 12px 14px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-width: 0;
    }

    /* 标题适中 */
    .project-card__title {
        font-size: 1rem;
        margin-bottom: 4px;
    }

    /* 描述单行截断 */
    .project-card__desc {
        font-size: 0.8rem;
        line-height: 1.4;
        margin-bottom: 6px;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* tag 更小 */
    .tag {
        padding: 3px 10px;
        font-size: 0.7rem;
        border-radius: 12px;
    }
}

/* ============================
   难度星级
   ============================ */
.difficulty-stars {
    display: inline-flex;
    gap: 2px;
    font-size: 0.85rem;
    letter-spacing: 1px;
    margin-top: 8px;
}
.difficulty-stars .star-filled { color: var(--star-filled); }
.difficulty-stars .star-empty { color: var(--star-empty); }

/* 难度标签 */
.difficulty-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: 6px;
}
.difficulty-badge.easy { background: var(--difficulty-easy-bg); color: var(--difficulty-easy-color); }
.difficulty-badge.medium { background: var(--difficulty-medium-bg); color: var(--difficulty-medium-color); }
.difficulty-badge.hard { background: var(--difficulty-hard-bg); color: var(--difficulty-hard-color); }

/* ============================
   学段页面文字页脚
   ============================ */
.page-footer {
    text-align: center;
    color: white;
    margin-top: var(--space-xl);
    padding: var(--space-md);
    font-size: var(--text-base);
    opacity: 0.9;
}

/* ============================
   Coming-Soon 页面（内容开发中）
   ============================ */
.coming-soon-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: clamp(2rem, 6vw, 3.75rem);
    max-width: 700px;
    width: 100%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
    margin: var(--space-md);
}

.coming-soon-icon {
    font-size: clamp(4rem, 10vw, 8rem);
    margin-bottom: var(--space-md);
    animation: bounce 2s infinite;
}

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

.coming-soon-title {
    font-size: var(--text-2xl);
    color: #333;
    margin-bottom: var(--space-md);
}

.coming-soon-subtitle {
    font-size: var(--text-lg);
    color: var(--color-primary);
    margin-bottom: var(--space-md);
    font-weight: bold;
}

.coming-soon-desc {
    font-size: var(--text-base);
    color: #666;
    line-height: 1.8;
    margin-bottom: var(--space-xl);
}

.features-box {
    background: #f0f4ff;
    border-left: 5px solid var(--color-primary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xl);
    text-align: left;
}

.features-box h3 {
    color: var(--color-primary);
    font-size: var(--text-lg);
    margin-bottom: var(--space-sm);
}

.features-box ul {
    list-style: none;
    padding: 0;
}

.features-box li {
    color: #555;
    font-size: var(--text-base);
    margin: 12px 0;
    padding-left: 30px;
    position: relative;
}

.features-box li:before {
    content: "🔜";
    position: absolute;
    left: 0;
}

/* Coming-Soon 按钮组 */
.cs-button-group {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

.cs-btn {
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    min-height: 48px;
    min-width: 120px;
}

.cs-btn:active {
    transform: scale(0.96);
}

@media (hover: hover) {
    .cs-btn:hover {
        transform: translateY(-5px);
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    }
}

.cs-btn--primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.cs-btn--secondary {
    background: #f0f4ff;
    color: #667eea;
    border: 3px solid #667eea;
}

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin: var(--space-md) 0;
}

.progress-fill {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    animation: progressAnim 2s ease-in-out infinite;
}

@keyframes progressAnim {
    0% { width: 0%; }
    50% { width: 30%; }
    100% { width: 0%; }
}

/* ============================
   3D 页面通用样式（canvas/控制面板）
   ============================ */

/* 3D 主容器 */
.three-container {
    display: flex;
    gap: clamp(16px, 3vw, 30px);
    max-width: 1400px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

/* Canvas 外容器 */
.three-canvas-box {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    flex: 1;
    min-width: 0;           /* 关键：允许收缩，不溢出 */
    max-width: 650px;
    width: 100%;
}

.three-canvas-box__title {
    text-align: center;
    font-size: var(--text-xl);
    color: #333;
    margin-bottom: var(--space-sm);
    font-weight: bold;
}

.three-canvas-box canvas {
    width: 100%;
    height: 400px;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: move;
}

/* 控制面板 */
.three-controls {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    min-width: 280px;
    max-width: 400px;
    width: 100%;
}

.control-group {
    margin-bottom: var(--space-md);
}

.control-group label {
    display: block;
    font-size: var(--text-base);
    color: #333;
    margin-bottom: 8px;
    font-weight: bold;
}

.value-display {
    text-align: right;
    color: var(--color-primary);
    font-weight: bold;
    margin-top: 5px;
}

.info-box {
    background: #f0f4ff;
    border-left: 4px solid var(--color-primary);
    padding: var(--space-sm);
    margin-top: var(--space-md);
    border-radius: 5px;
}

.info-box h3 {
    color: var(--color-primary);
    margin-bottom: 10px;
}

.info-box p {
    color: #555;
    line-height: 1.6;
}

/* ============================
   3D 实验页面通用样式
   ============================ */

.main-container {
    max-width: 1400px;
    margin: 0 auto;
}

.demo-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.section-title {
    font-size: var(--text-xl);
    color: #333;
    text-align: center;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

/* Canvas 对排放置 */
.canvas-wrapper {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
    margin: var(--space-sm) 0;
}

/* 每个形状的容器 */
.shape-display {
    flex: 1;
    min-width: 0;              /* 关键：允许收缩 */
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.shape-title {
    font-size: var(--text-lg);
    color: var(--color-primary);
    margin-bottom: 10px;
    font-weight: bold;
}

/* Canvas 容器（实验页面） */
.canvas-container {
    position: relative;
}

.canvas-container canvas {
    width: 100%;
    height: 300px;
    border: 3px solid #e0e0e0;
    border-radius: var(--radius-md);
    cursor: move;
    background: #f8f9fa;
}

.canvas-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (hover: hover) {
    .canvas-container:hover .canvas-hint {
        opacity: 0.7;
    }
}

/* ============================
   控制区 & 滑块
   ============================ */
.controls-section {
    background: #fff5f5;
    border: 2px solid #ffd4d4;
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin: var(--space-sm) 0;
}

.control-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin: 10px 0;
    flex-wrap: wrap;
}

.control-label {
    font-size: var(--text-base);
    color: #333;
    font-weight: bold;
    min-width: 100px;
}

/* 手机端紧凑布局：标签+滑块+数值在一行 */
@media (max-width: 480px) {
    .control-row {
        flex-wrap: nowrap;
        gap: 8px;
    }
    .control-label {
        min-width: 65px;
        font-size: 0.85em;
    }
    input[type="range"] {
        min-width: 0;
        height: 36px;
    }
    input[type="range"]::-webkit-slider-thumb {
        width: 22px;
        height: 22px;
        margin-top: -6px;
    }
    input[type="range"]::-moz-range-thumb {
        width: 22px;
        height: 22px;
    }
    .value-box {
        min-width: 50px;
        padding: 5px 8px;
        font-size: 0.8em;
    }
}

/* 触摸友好滑块 */
input[type="range"] {
    flex: 1;
    min-width: 150px;
    height: 44px;            /* 触摸友好 */
    border-radius: 5px;
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 10px;
    background: #ddd;
    border-radius: 5px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;             /* 触摸友好 */
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    margin-top: -9px;
}

input[type="range"]::-moz-range-track {
    height: 10px;
    background: #ddd;
    border-radius: 5px;
}

input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
}

.value-box {
    background: var(--color-primary);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: var(--text-base);
    min-width: 80px;
    text-align: center;
}

/* 功能按钮组 */
.three-btn-group {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    margin: var(--space-md) 0;
    flex-wrap: wrap;
}

/* 通用按钮变体 */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.three-btn {
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: 10px;
    font-size: var(--text-base);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-height: 48px;
    min-width: 100px;
}

.three-btn:active {
    transform: translateY(-1px);
}

@media (hover: hover) {
    .three-btn:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    }
}

/* ============================
   信息面板 & 表格
   ============================ */
.info-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    margin: var(--space-md) 0;
}

@media (min-width: 768px) {
    .info-panel {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

.info-card {
    background: #f0f4ff;
    border-left: 5px solid var(--color-primary);
    padding: var(--space-md);
    border-radius: 10px;
}

.info-card h3 {
    color: var(--color-primary);
    margin-bottom: 10px;
    font-size: var(--text-lg);
}

.info-card p {
    color: #555;
    line-height: 1.8;
    font-size: var(--text-base);
}

.animation-status {
    text-align: center;
    font-size: var(--text-base);
    color: var(--color-primary);
    margin: var(--space-sm) 0;
    padding: var(--space-sm);
    background: #f0f4ff;
    border-radius: 10px;
    font-weight: bold;
}

.key-point {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border: 3px solid #f39c12;
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin: var(--space-sm) 0;
    font-size: var(--text-base);
}

.key-point strong {
    color: #d63031;
    font-size: var(--text-lg);
}

.highlight {
    color: #ff6b6b;
    font-weight: bold;
    font-size: var(--text-base);
}

/* 公式框 */
.formula-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    text-align: center;
    margin: var(--space-sm) 0;
    font-size: var(--text-base);
}

.formula-box .formula {
    font-size: var(--text-xl);
    margin: 10px 0;
    font-weight: bold;
}

/* 数据对比表 */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
    font-size: var(--text-sm);
}

.comparison-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px;
    text-align: center;
}

.comparison-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.comparison-table tr:nth-child(even) {
    background: #f8f9fa;
}

@media (hover: hover) {
    .comparison-table tr:hover {
        background: #e8ecff;
    }
}

/* 实验选择容器（volume-experiment/index） */
.experiments-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(20px, 4vw, 40px);
    max-width: 1200px;
    width: 100%;
    padding: 0 var(--space-sm);
    margin: 0 auto;
}

@media (min-width: 768px) {
    .experiments-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .experiments-container {
        grid-template-columns: repeat(3, 1fr);
    }
}
