/* 探秘编码世界 - 样式表 */
/* 紫金色主题 #6B2D8E / #C9A227 */

:root {
    --primary: #6B2D8E;
    --primary-light: #8B4DBE;
    --primary-dark: #4A1D6E;
    --secondary: #C9A227;
    --secondary-light: #E8C84A;
    --bg: #f8f6fb;
    --card-bg: #ffffff;
    --text: #2d2d2d;
    --text-light: #666;
    --border: #e8e0f0;
    --shadow: 0 4px 20px rgba(107, 45, 142, 0.1);
    --shadow-hover: 0 8px 30px rgba(107, 45, 142, 0.15);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* 顶部导航 */
.top-nav {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-brand a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.nav-brand a:hover {
    color: var(--secondary);
}

.nav-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.nav-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}

/* 标签导航 */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    background: white;
    border-bottom: 2px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.tab-item {
    padding: 16px 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    position: relative;
}

.tab-item:hover {
    color: var(--primary);
    background: rgba(107, 45, 142, 0.03);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--secondary);
    background: rgba(107, 45, 142, 0.05);
}

.tab-item i {
    font-size: 18px;
}

/* 模块区域 */
.module-section {
    display: none;
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 20px;
    animation: fadeIn 0.5s ease;
}

.module-section.active {
    display: block;
}

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

/* 模块头部 */
.module-header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    margin-bottom: 32px;
    color: white;
}

.module-header h1 {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--secondary);
}

.module-header h1 i {
    margin-right: 12px;
}

.module-header p {
    font-size: 16px;
    color: rgba(255,255,255,0.8);
}

/* 活动卡片 */
.activity-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.activity-card:hover {
    box-shadow: var(--shadow-hover);
}

.activity-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.activity-num {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.activity-title h2 {
    font-size: 22px;
    color: var(--primary);
}

.activity-desc {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 20px;
    padding-left: 50px;
}

/* 互动区域 */
.interactive-box {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 24px;
    margin-top: 16px;
}

/* 提示框 */
.hint-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(201, 162, 39, 0.1);
    border-left: 4px solid var(--secondary);
    padding: 14px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text);
}

.hint-box i {
    color: var(--secondary);
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.hint-box strong {
    color: var(--primary);
}

/* ========== 图像编码样式 ========== */

/* 放大镜 */
.magnifier-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.magnifier-container img {
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
}

.magnifier-lens {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 3px solid var(--secondary);
    border-radius: 50%;
    display: none;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    background-repeat: no-repeat;
    background-color: white;
    z-index: 10;
}

/* RGB调色实验室 */
.rgb-lab {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.color-preview {
    width: 180px;
    height: 180px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    color: #666;
    background: rgb(128, 128, 128);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transition: background 0.1s ease;
    flex-shrink: 0;
}

.sliders-panel {
    flex: 1;
    min-width: 280px;
}

.slider-group {
    margin-bottom: 16px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.red-label { color: #e74c3c; }
.green-label { color: #27ae60; }
.blue-label { color: #3498db; }

.slider {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.red-slider { background: linear-gradient(to right, #330000, #ff0000); }
.green-slider { background: linear-gradient(to right, #003300, #00ff00); }
.blue-slider { background: linear-gradient(to right, #000033, #0000ff); }

.rgb-code-box {
    background: white;
    padding: 16px;
    border-radius: var(--radius-sm);
    text-align: center;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.code-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.rgb-code {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

.hex-code {
    font-size: 14px;
    color: var(--text-light);
    font-family: 'Courier New', monospace;
    margin-top: 4px;
}

/* 预设颜色 */
.preset-colors {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.preset-colors span {
    font-size: 14px;
    color: var(--text-light);
}

.preset-btn {
    width: 32px;
    height: 32px;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.preset-btn:hover {
    transform: scale(1.2);
    border-color: var(--secondary);
}

/* 分辨率对比 */
.resolution-compare {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.res-card {
    background: white;
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    flex: 1;
    min-width: 260px;
    max-width: 320px;
}

.res-image {
    width: 100%;
    height: 150px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    background-size: cover;
    background-position: center;
}

.low-res {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50"><rect fill="%236B2D8E" width="25" height="25"/><rect fill="%23C9A227" x="25" width="25" height="25"/><rect fill="%23C9A227" y="25" width="25" height="25"/><rect fill="%236B2D8E" x="25" y="25" width="25" height="25"/></svg>');
    image-rendering: pixelated;
}

.high-res {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><defs><linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color:%236B2D8E"/><stop offset="50%" style="stop-color:%23C9A227"/><stop offset="100%" style="stop-color:%236B2D8E"/></linearGradient></defs><rect fill="url(%23g)" width="200" height="200"/></svg>');
}

.res-info h4 {
    color: var(--primary);
    margin-bottom: 8px;
}

.res-info p {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.res-vs {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.pixel-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 1px;
    margin-top: 12px;
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
}

.pixel-cell {
    aspect-ratio: 1;
    border-radius: 1px;
}

/* ========== 音频编码样式 ========== */

#waveCanvas, #sampleCanvas {
    width: 100%;
    max-width: 700px;
    height: 250px;
    background: white;
    border-radius: var(--radius-sm);
    display: block;
    margin: 0 auto;
}

#sampleCanvas {
    height: 200px;
}

.wave-controls, .frame-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-wave, .btn-frame {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-wave:hover, .btn-frame:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
}

.freq-control, .fps-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
}

.freq-control label, .fps-control label {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.wave-legend {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-line {
    width: 30px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.analog { background: var(--primary); }
.legend-line.digital { background: var(--secondary); }

.sample-demo {
    text-align: center;
}

.sample-controls {
    margin-top: 16px;
}

.rate-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

.rate-labels span {
    flex: 1;
}

.sample-info {
    margin-top: 20px;
}

.info-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.info-card h4 {
    color: var(--primary);
    margin-bottom: 8px;
}

/* ========== 文字编码样式 ========== */

.text-encoder {
    background: white;
    padding: 24px;
    border-radius: var(--radius-sm);
}

.encode-input {
    margin-bottom: 20px;
}

.encode-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary);
}

.encode-input input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 18px;
    outline: none;
    transition: var(--transition);
}

.encode-input input:focus {
    border-color: var(--primary);
}

.encode-table {
    overflow-x: auto;
}

.encode-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.encode-char {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.encode-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.encode-dec {
    font-size: 14px;
    color: var(--text);
}

.encode-bin {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--primary);
    background: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.encode-hex {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--secondary);
}

.binary-demo {
    margin-top: 20px;
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-sm);
}

.binary-demo h4 {
    color: var(--primary);
    margin-bottom: 12px;
}

.binary-display {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    line-height: 2;
    word-break: break-all;
}

.binary-bit {
    display: inline-block;
    padding: 2px 4px;
    margin: 1px;
    border-radius: 3px;
    background: white;
    border: 1px solid var(--border);
}

.binary-bit.one {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.binary-bit.zero {
    background: white;
    color: var(--text-light);
}

/* ASCII表 */
.ascii-table {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 2px;
    background: var(--border);
    padding: 4px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    max-width: 100%;
}

.ascii-cell {
    background: white;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    min-width: 36px;
}

.ascii-cell:hover {
    background: var(--primary);
    color: white;
}

.ascii-cell.selected {
    background: var(--secondary);
    color: white;
}

.ascii-cell .char {
    font-weight: 700;
    font-size: 14px;
}

.ascii-cell .code {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

.ascii-cell:hover .code,
.ascii-cell.selected .code {
    color: rgba(255,255,255,0.8);
}

.ascii-detail {
    margin-top: 20px;
    background: white;
    padding: 24px;
    border-radius: var(--radius-sm);
    text-align: center;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-placeholder {
    color: var(--text-light);
    font-size: 14px;
}

.detail-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.detail-char {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
}

.detail-info {
    font-size: 14px;
    color: var(--text);
    line-height: 1.8;
}

/* ========== 视频编码样式 ========== */

.frame-player {
    text-align: center;
}

.frame-display {
    position: relative;
    width: 300px;
    height: 200px;
    margin: 0 auto;
    background: #222;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.frame-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 0.1s;
}

.frame-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.frame-strip {
    display: flex;
    gap: 4px;
    margin-top: 16px;
    overflow-x: auto;
    padding: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.frame-thumb {
    width: 60px;
    height: 40px;
    background: #333;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
}

.frame-thumb:hover,
.frame-thumb.active {
    border-color: var(--secondary);
}

.compression-demo {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.compress-before,
.compress-after {
    background: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.compress-before h4,
.compress-after h4 {
    color: var(--primary);
    margin-bottom: 12px;
}

.data-blocks {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 12px;
}

.data-block {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--primary);
}

.data-block.delta {
    background: var(--secondary);
}

.data-block.empty {
    background: var(--border);
}

.compressed .data-block {
    background: var(--secondary);
}

.compressed .data-block:first-child {
    background: var(--primary);
}

.data-size {
    font-size: 14px;
    color: var(--text);
}

.data-size strong {
    color: var(--primary);
    font-size: 16px;
}

.compress-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--secondary);
    font-size: 14px;
    font-weight: 600;
}

.compress-arrow i {
    font-size: 24px;
}

.compress-explain {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.explain-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.key-frame {
    color: var(--primary);
    font-size: 20px;
}

.delta-frame {
    color: var(--secondary);
    font-size: 20px;
}

/* ========== 知识卡片 ========== */

.knowledge-section {
    margin-top: 40px;
}

.knowledge-section h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 24px;
    font-size: 22px;
}

.knowledge-section h2 i {
    margin-right: 8px;
    color: var(--secondary);
}

.knowledge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.knowledge-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.knowledge-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.k-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.knowledge-card h3 {
    color: var(--primary);
    font-size: 16px;
    margin-bottom: 10px;
}

.knowledge-card p {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
}

/* ========== 测验样式 ========== */

.quiz-box {
    margin-top: 24px;
    padding: 24px;
    background: white;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.quiz-box h3 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 18px;
}

.quiz-box h3 i {
    margin-right: 8px;
    color: var(--secondary);
}

.quiz-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.quiz-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.quiz-q {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.quiz-option:hover {
    background: rgba(107, 45, 142, 0.08);
}

.quiz-option input {
    cursor: pointer;
}

.quiz-option.correct {
    background: rgba(39, 174, 96, 0.15);
    border: 2px solid #27ae60;
}

.quiz-option.wrong {
    background: rgba(231, 76, 60, 0.15);
    border: 2px solid #e74c3c;
}

.quiz-feedback {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: none;
}

.quiz-feedback.show {
    display: block;
}

.quiz-feedback.correct {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    border-left: 4px solid #27ae60;
}

.quiz-feedback.wrong {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border-left: 4px solid #e74c3c;
}

/* 页脚 */
.page-footer {
    text-align: center;
    padding: 32px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    margin-top: 40px;
}

.page-footer p {
    margin-bottom: 4px;
    font-size: 14px;
}

.page-footer p:first-child {
    color: var(--secondary);
    font-weight: 600;
    font-size: 16px;
}

/* 响应式 */
@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }

    .nav-title {
        font-size: 20px;
    }

    .tab-item {
        padding: 12px 16px;
        font-size: 13px;
    }

    .tab-item span {
        display: none;
    }

    .module-header h1 {
        font-size: 24px;
    }

    .activity-card {
        padding: 20px 16px;
    }

    .rgb-lab {
        flex-direction: column;
        align-items: center;
    }

    .color-preview {
        width: 150px;
        height: 150px;
    }

    .resolution-compare {
        flex-direction: column;
    }

    .res-vs {
        transform: rotate(90deg);
    }

    .compression-demo {
        flex-direction: column;
    }

    .compress-arrow {
        transform: rotate(90deg);
    }

    .ascii-table {
        grid-template-columns: repeat(8, 1fr);
    }

    .knowledge-grid {
        grid-template-columns: 1fr;
    }
}
