/* === Wuli布雷克 Shared Base Styles === */
:root {
    --bg-color: #FFF9F0;
    --primary: #FF8c42;
    --secondary: #FFC75F;
    --accent: #FF5E5B;
    --text-dark: #4A403A;
    --card-bg: #FFFFFF;
    --shadow: 0 6px 30px rgba(255,140,66,0.18);
}

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

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 5px 40px 10px;
}

/* Branding */
.branding { position: fixed; top: 10px; left: 20px; z-index: 1000; display:flex; align-items:center; gap:8px; }
.logo {
    font-weight: 700; font-size: 1.3rem; color: #fff;
    background: var(--primary); padding: 6px 18px; border-radius: 16px;
    box-shadow: 4px 4px 15px rgba(255,140,66,0.3);
    text-decoration: none;
}
.brand-nav { display:flex; gap:3px; flex-wrap:wrap; }
.brand-nav a {
    font-size:0.7rem;font-weight:600;color:#fff;background:rgba(255,140,66,0.7);
    padding:3px 8px;border-radius:10px;text-decoration:none;transition:all 0.2s;
}
.brand-nav a:hover { background: var(--primary); transform: scale(1.05); }
@media (max-width:600px){ .brand-nav { display:none; } }

/* Back link */
.back-link {
    position: fixed; top: 10px; right: 20px; z-index: 1000;
    text-decoration: none; color: var(--primary); font-weight: 700;
    font-size: 0.95rem; background: rgba(255,255,255,0.9);
    padding: 6px 16px; border-radius: 16px;
    box-shadow: 0 2px 10px rgba(255,140,66,0.15);
    transition: all 0.3s;
}
.back-link:hover { background: #fff; box-shadow: 0 4px 18px rgba(255,140,66,0.3); transform: translateX(-3px); }

/* Button base */
.ctrl-btn {
    padding: 10px; border: none; border-radius: 14px;
    font-size: 1.05rem; font-weight: 700; cursor: pointer;
    transition: all 0.2s; color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.ctrl-btn:active { transform: translateY(2px); box-shadow: none; }
.start { background-color: var(--primary); }
.pause { background-color: #2ecc71; }
.reset { background-color: #95a5a6; }

/* Footer */
.site-footer {
    text-align: center; padding: 20px; font-size: 0.8rem;
    color: #a1887f; margin-top: auto;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ================================================================
   === 页面布局 & Grid（所有模拟页共享） ===
   ================================================================ */
.container {
    width: 100%; max-width: 1400px; margin-top: 8px;
    display: grid;
    grid-template-areas: "header header" "formula formula" "diagram controls";
    grid-template-columns: 1fr 400px;
    gap: 12px;
}
header { grid-area: header; text-align: center; }
h1 { font-size: 2rem; margin-bottom: 2px; color: var(--text-dark); }
.subtitle { font-size: 0.85rem; color: #6B6B6B; }

/* ================================================================
   === 公式区 ===
   ================================================================ */
.formula-display {
    grid-area: formula;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 10px 20px;
    display: flex; flex-direction: column; align-items: center;
    border: 2px solid #fff5eb;
}
.formula-container {
    display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; min-height: 40px;
}
.result-row {
    font-size: 0.95rem; font-weight: 600; margin-top: 4px;
    display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
}
.formula-item { font-size: 0.9rem; font-weight: 600; padding: 3px 10px; border-radius: 10px; background: #fafaf7; }

/* ================================================================
   === 图例 ===
   ================================================================ */
.legend {
    display: flex; gap: 16px; justify-content: center;
    border-top: 1px solid #eee; padding-top: 6px; width: 100%; flex-wrap: wrap;
}
.legend-item { font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

/* ================================================================
   === 图表区 ===
   ================================================================ */
.diagram-section { grid-area: diagram; display: flex; flex-direction: column; gap: 6px; }
.main-wrap {
    background: #fff; border-radius: 20px; box-shadow: var(--shadow);
    overflow: hidden; flex: 2; display: flex; border: 2px solid #fff;
    min-height: 260px;
}
.main-canvas-wrap {
    background: #fff; border-radius: 20px; box-shadow: var(--shadow);
    overflow: hidden; flex: 1; border: 2px solid #fff;
    display: flex;
}
#simCanvas { width: 100%; flex: 1; display: block; }
.sub-wrap {
    background: #fff; border-radius: 16px; box-shadow: var(--shadow);
    flex: 1; display: flex; flex-direction: column;
    border: 1px solid #fff5eb; overflow: hidden; min-height: 130px;
}
.sub-label {
    background: #fff; padding: 3px 10px; font-weight: 700; font-size: 0.8rem; text-align: center;
}
.sub-wrap canvas { width: 100%; flex: 1; display: block; }

/* ================================================================
   === 控件区 ===
   ================================================================ */
.controls-section { grid-area: controls; display: flex; flex-direction: column; gap: 10px; }
.control-panel {
    background: #fff; border-radius: 20px; box-shadow: var(--shadow);
    padding: 14px 18px; display: flex; flex-direction: column; gap: 10px;
}
.param-section {
    background: #fff; border-radius: 14px; padding: 10px 14px 8px; border: 2px solid #f5f0eb;
}
.param-section-header { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.control-group { display: flex; flex-direction: column; gap: 3px; }
.label-row { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.9rem; }
.val-badge {
    background: #fff; padding: 1px 7px; border-radius: 7px;
    font-size: 0.85rem; border: 2px solid #f0f0f0;
}

/* ================================================================
   === Range 滑块 ===
   ================================================================ */
input[type=range] {
    width: 100%; -webkit-appearance: none; appearance: none;
    height: 6px; background: #eee; border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
    background: var(--primary);
}

/* ================================================================
   === 按钮 ===
   ================================================================ */
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }

/* ================================================================
   === 信息卡 ===
   ================================================================ */
.info-card {
    background: #fff; border-radius: 20px; padding: 12px 16px;
    box-shadow: var(--shadow); font-size: 0.9rem; line-height: 1.4; color: #5D6D7E;
}

/* ================================================================
   === 通用组件 ===
   ================================================================ */
.toggle-row { display: flex; gap: 8px; align-items: center; }
.tog-btn {
    flex: 1; padding: 7px 10px; border: 2px solid #ddd; border-radius: 10px;
    font-size: 0.8rem; font-weight: 600; cursor: pointer; text-align: center;
    background: #fff; color: #6B6B6B; transition: all .2s;
}
.tog-btn.sel {
    border-color: var(--primary); background: rgba(255,140,66,0.08); color: var(--primary);
}
.type-badge { font-size: 0.9rem; font-weight: 700; padding: 3px 12px; border-radius: 10px; }

/* ================================================================
   === 响应式 ===
   ================================================================ */
@media (max-width: 1100px) {
    .container {
        grid-template-areas: "header" "formula" "diagram" "controls";
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   === 无障碍 Accessibility ===
   ================================================================ */
.skip-link {
    position: absolute; top: -40px; left: 8px; z-index: 2000;
    background: #185FA5; color: #fff; padding: 8px 16px; border-radius: 10px;
    font-size: 0.9rem; font-weight: 600; text-decoration: none; transition: top 0.2s;
}
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid #185FA5; outline-offset: 2px; border-radius: 6px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
