/* ═══════════════════════════════════════════
   Kepler's Laws — Layout & Styling
   ═══════════════════════════════════════════ */

.kepler-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    color: #e2e8f0;
}

/* ── Header ─────────────────────────────── */
.kepler-header {
    margin-bottom: 0.75rem;
}
.kepler-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.kepler-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}
.kepler-subtitle {
    font-size: 0.85rem;
    color: #94a3b8;
    margin: 0 0 0 2.25rem;
}

/* ── Tabs ────────────────────────────────── */
.kepler-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #334155;
    padding-bottom: 0.5rem;
}
.kepler-tab {
    background: transparent;
    border: 1px solid #475569;
    border-radius: 6px 6px 0 0;
    color: #94a3b8;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.kepler-tab:hover {
    color: #e2e8f0;
    background: #1e293b;
}
.kepler-tab.active {
    color: #fbbf24;
    border-color: #fbbf24;
    background: #1e293b;
}
.kepler-tab-num {
    font-weight: 700;
    margin-right: 0.25rem;
}

/* ── Main Layout ─────────────────────────── */
.kepler-main {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* ── Controls Panel ──────────────────────── */
.kepler-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.kepler-control-group {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem;
}
.kepler-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.kepler-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.75rem;
    color: #cbd5e1;
    margin-bottom: 0.15rem;
}
.kepler-value {
    color: #fbbf24;
    font-family: monospace;
    font-size: 0.7rem;
}
.kepler-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #475569;
    border-radius: 2px;
    outline: none;
    margin-bottom: 0.4rem;
    cursor: pointer;
}
.kepler-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fbbf24;
    cursor: pointer;
}
.kepler-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fbbf24;
    border: none;
    cursor: pointer;
}

/* ── Buttons ─────────────────────────────── */
.kepler-btn {
    background: #334155;
    border: 1px solid #475569;
    border-radius: 6px;
    color: #e2e8f0;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.kepler-btn:hover {
    background: #475569;
    color: #fff;
}
.kepler-btn.active {
    background: #fbbf24;
    color: #1e293b;
    border-color: #fbbf24;
}
.kepler-btn-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
}
.kepler-btn-row {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.4rem;
}

/* ── Presets ──────────────────────────────── */
.kepler-preset-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.kepler-preset {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #94a3b8;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.7rem;
    text-align: left;
    transition: all 0.15s;
}
.kepler-preset:hover {
    background: #1e293b;
    color: #fbbf24;
    border-color: #fbbf24;
}

/* ── Checkboxes ──────────────────────────── */
.kepler-check {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: #cbd5e1;
    cursor: pointer;
    margin-bottom: 0.15rem;
}
.kepler-check input[type="checkbox"] {
    accent-color: #fbbf24;
    cursor: pointer;
}

/* ── Canvas Wrapper & Zoom ────────────────── */
.kepler-canvas-wrap {
    position: relative;
    flex-shrink: 0;
}
.kepler-zoom-btns {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 2;
}

/* ── Canvas Area ─────────────────────────── */
.kepler-canvas-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.kepler-canvas-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

/* ── Quick-Reference Tips ────────────────── */
.kepler-tips {
    flex: 1;
    min-width: 150px;
    max-width: 220px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    font-size: 0.7rem;
    line-height: 1.5;
    color: #94a3b8;
    align-self: stretch;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
}
.kepler-tips-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 0.35rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.kepler-tips-title:not(:first-child) {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid #334155;
}
.kepler-tip {
    margin-bottom: 0.25rem;
    color: #cbd5e1;
    font-size: 0.68rem;
    line-height: 1.45;
}
.kepler-tip kbd {
    display: inline-block;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 3px;
    padding: 0 0.3rem;
    font-size: 0.62rem;
    font-family: monospace;
    color: #fbbf24;
    min-width: 1.4em;
    text-align: center;
    margin-right: 0.2rem;
}
.kepler-tip i {
    color: #64748b;
    width: 1em;
    text-align: center;
    margin-right: 0.15rem;
}
.kepler-tip b {
    color: #fbbf24;
    font-weight: 600;
}
#keplerCanvas {
    height: calc(100vh - 260px);
    aspect-ratio: 1;
    max-width: 100%;
    background: #0a0e1a;
    border-radius: 8px;
    border: 1px solid #334155;
    cursor: crosshair;
    touch-action: none;
}

/* ── Info Bar ────────────────────────────── */
.kepler-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-top: none;
    border-radius: 0 0 8px 8px;
    font-size: 0.75rem;
}
.kepler-info-item {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.kepler-info-label {
    color: #64748b;
    font-style: italic;
}
.kepler-info-val {
    color: #e2e8f0;
    font-family: monospace;
    font-size: 0.75rem;
}
.kepler-info-escape {
    color: #f87171;
    font-weight: 600;
}

/* ── Law I Panel ─────────────────────────── */
.kepler-law1-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}
.kepler-law1-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.3rem;
}
.kepler-law1-formula {
    font-size: 0.75rem;
    color: #64748b;
    font-style: italic;
    margin: 0;
}

/* ── Law II Panel ────────────────────────── */
.kepler-law2-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}
.kepler-area-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 60px;
    margin-bottom: 0.3rem;
}
.kepler-area-bar {
    flex: 1;
    border-radius: 2px 2px 0 0;
    min-width: 8px;
    position: relative;
    transition: height 0.3s;
}
.kepler-area-bar .kepler-area-val {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    color: #94a3b8;
    white-space: nowrap;
}
.kepler-area-summary {
    font-size: 0.7rem;
    color: #94a3b8;
    margin: 0;
}

/* ── Law III Panel ───────────────────────── */
.kepler-law3-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}
.kepler-law3-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    align-items: start;
}
#law3Chart {
    background: #0f172a;
    border-radius: 4px;
    border: 1px solid #334155;
    width: 100%;
    height: auto;
}
.kepler-law3-table-wrap {
    overflow-x: auto;
}
.kepler-table-scroll {
    max-height: 200px;
    overflow-y: auto;
}
.kepler-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}
.kepler-table th {
    text-align: left;
    color: #64748b;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #334155;
    font-weight: 600;
    position: sticky;
    top: 0;
    background: #1e293b;
}
.kepler-table td {
    padding: 0.25rem 0.5rem;
    color: #cbd5e1;
    font-family: monospace;
    border-bottom: 1px solid #1e293b;
}
.kepler-table .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ── How to Use ──────────────────────────── */
.kepler-howto {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-top: 0.5rem;
}
.kepler-howto summary {
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}
.kepler-howto-content {
    margin-top: 0.5rem;
}
.kepler-howto-content p {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

/* ── Hidden utility ──────────────────────── */
.hidden {
    display: none !important;
}

/* ══════════════════════════════════════════
   Responsive: tablet/mobile
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
    .kepler-tips {
        display: none;
    }
}

@media (max-width: 768px) {
    .kepler-main {
        grid-template-columns: 1fr;
    }
    .kepler-canvas-area {
        order: -1;
    }
    .kepler-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .kepler-playback-group {
        order: -1;
        grid-column: 1 / -1;
    }
    .kepler-law3-grid {
        grid-template-columns: 1fr;
    }
    .kepler-tabs {
        flex-wrap: wrap;
    }
    #keplerCanvas {
        height: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .kepler-container {
        padding: 0.5rem;
    }
    .kepler-title {
        font-size: 1.15rem;
    }
    .kepler-subtitle {
        font-size: 0.75rem;
        margin-left: 0;
    }
    .kepler-controls {
        grid-template-columns: 1fr;
    }
    .kepler-tab {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }
    /* Larger touch targets for sliders */
    .kepler-slider {
        height: 8px;
        margin-bottom: 0.5rem;
    }
    .kepler-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    .kepler-slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
    /* Larger touch targets for buttons */
    .kepler-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    .kepler-btn-sm {
        padding: 0.35rem 0.5rem;
        min-height: 36px;
    }
    .kepler-preset {
        padding: 0.45rem 0.6rem;
        font-size: 0.75rem;
    }
    .kepler-check {
        padding: 0.2rem 0;
        font-size: 0.8rem;
    }
    .kepler-info-bar {
        gap: 0.4rem 0.6rem;
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }
    .kepler-info-item {
        min-width: 0;
    }
    .kepler-law1-info {
        gap: 0.5rem;
    }
    .kepler-howto summary {
        font-size: 0.8rem;
    }
    .kepler-howto-content p {
        font-size: 0.75rem;
    }
}

/* ══════════════════════════════════════════
   Night Mode (red-tinted)
   ══════════════════════════════════════════ */
body[data-theme="night"] .kepler-container {
    color: #fca5a5;
}
body[data-theme="night"] .kepler-title {
    color: #fca5a5;
}
body[data-theme="night"] .kepler-subtitle {
    color: #b47070;
}
body[data-theme="night"] .kepler-tab {
    color: #b47070;
    border-color: #7f1d1d;
}
body[data-theme="night"] .kepler-tab:hover {
    color: #fca5a5;
    background: #7f1d1d;
}
body[data-theme="night"] .kepler-tab.active {
    color: #ef4444;
    border-color: #ef4444;
    background: #7f1d1d;
}
body[data-theme="night"] .kepler-control-group,
body[data-theme="night"] .kepler-law1-panel,
body[data-theme="night"] .kepler-law2-panel,
body[data-theme="night"] .kepler-law3-panel,
body[data-theme="night"] .kepler-howto,
body[data-theme="night"] .kepler-info-bar,
body[data-theme="night"] .kepler-tips {
    background: #7f1d1d;
    border-color: #991b1b;
}
body[data-theme="night"] .kepler-tips-title {
    color: #b47070;
    border-top-color: #991b1b;
}
body[data-theme="night"] .kepler-tip {
    color: #fca5a5;
}
body[data-theme="night"] .kepler-tip kbd {
    background: #991b1b;
    border-color: #b91c1c;
    color: #ef4444;
}
body[data-theme="night"] .kepler-tip i {
    color: #b47070;
}
body[data-theme="night"] .kepler-tip b {
    color: #ef4444;
}
body[data-theme="night"] .kepler-btn {
    background: #991b1b;
    border-color: #b91c1c;
    color: #fca5a5;
}
body[data-theme="night"] .kepler-btn:hover {
    background: #b91c1c;
    color: #fef2f2;
}
body[data-theme="night"] .kepler-btn.active {
    background: #ef4444;
    color: #450a0a;
    border-color: #ef4444;
}
body[data-theme="night"] .kepler-slider {
    background: #991b1b;
}
body[data-theme="night"] .kepler-slider::-webkit-slider-thumb {
    background: #ef4444;
}
body[data-theme="night"] .kepler-slider::-moz-range-thumb {
    background: #ef4444;
}
body[data-theme="night"] .kepler-preset {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #b47070;
}
body[data-theme="night"] .kepler-preset:hover {
    background: #7f1d1d;
    color: #ef4444;
    border-color: #ef4444;
}
body[data-theme="night"] .kepler-value {
    color: #ef4444;
}
body[data-theme="night"] .kepler-label,
body[data-theme="night"] .kepler-check,
body[data-theme="night"] .kepler-info-val,
body[data-theme="night"] .kepler-table td {
    color: #fca5a5;
}
body[data-theme="night"] .kepler-info-label,
body[data-theme="night"] .kepler-group-title,
body[data-theme="night"] .kepler-table th {
    color: #b47070;
}
body[data-theme="night"] #keplerCanvas {
    background: #1a0505;
    border-color: #7f1d1d;
}
body[data-theme="night"] #law3Chart {
    background: #450a0a;
    border-color: #7f1d1d;
}
body[data-theme="night"] .kepler-check input[type="checkbox"] {
    accent-color: #ef4444;
}
body[data-theme="night"] .kepler-howto summary {
    color: #b47070;
}
body[data-theme="night"] .kepler-howto-content p {
    color: #fca5a5;
}
body[data-theme="night"] .kepler-table th {
    background: #7f1d1d;
}
