/* =========================================================
   PCHS PHYSICS ANIMATION ENGINE
   CLEAN RECTIFIED CSS
   ========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #dfe5ee;
    color: #1e2a3b;
    line-height: 1.5;
}

a {
    text-decoration: none;
}

.app {
    width: 100%;
}

.page-shell {
    width: 94%;
    max-width: 1600px;
    margin: 20px auto 40px;
}

/* ================= HEADER ================= */

.topbar {
    position: relative;
    background: linear-gradient(180deg, #052270 0%, #042381 100%);
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(41, 73, 169, 0.18);
    margin-bottom: 22px;
    overflow: hidden;
}

.topbar::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 34%;
    height: 100%;
    background:
        radial-gradient(circle at 78% 40%, rgba(66, 211, 255, 0.20), transparent 42%),
        radial-gradient(circle at 62% 78%, rgba(66, 211, 255, 0.10), transparent 38%);
    pointer-events: none;
    z-index: 0;
}

.topbar::after {
    content: "Master Physics";
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: rgb(240, 233, 109);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 3px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
    opacity: 0.95;
}

.topbar-inner {
    position: relative;
    z-index: 2;
    padding: 18px 22px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
}

.logo-box {
    width: 132px;
    height: 92px;
    background: #ffffff;
    border-radius: 12px;
    padding: 8px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 132px;
    overflow: hidden;
}

.site-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    gap: 10px;
}

.brand-text h1 {
    margin: 0;
    line-height: 1.1;
    color: #ffffff;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 2px;
    word-break: break-word;
}

.scene-links {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-left: 0;
}

.home-link,
.back-link {
    display: inline-block;
    background: linear-gradient(180deg, #e87a0c 0%, #d96f08 100%);
    color: #ffffff;
    padding: 9px 18px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 800;
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.24), 0 4px 10px rgba(0,0,0,0.10);
    line-height: 1.1;
    transition: 0.2s ease;
}

.home-link:hover,
.back-link:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.scene-links::after {
    content: "Concepts | Diagrams | Animations";
    margin-left: 12px;
    padding: 7px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #00b4d8, #0096c7);
    color: #ffffff;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 1px;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 150, 199, 0.18);
}

/* ================= HOMEPAGE ================= */

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chapter-card {
    display: block;
    width: 100%;
    background: #f9f6fa;
    border: 2px solid #d4830f;
    border-radius: 18px;
    padding: 22px 18px 18px;
    box-shadow: 0 2px 8px rgba(60, 80, 120, 0.07);
}

.chapter-card h2 {
    font-size: 26px;
    font-weight: 800;
    color: #d4830f;
    margin-bottom: 10px;
    letter-spacing: -0.2px;
}

.chapter-desc {
    color: #64748b;
    font-size: 16px;
    margin-bottom: 16px;
}

.problem-list {
    display: grid;
    gap: 12px;
}

.problem-list.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.problem-list.three-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.problem-card {
    display: block;
    background: #eaf0f7;
    border: 2px solid #c2d1e3;
    border-radius: 14px;
    padding: 16px 14px;
    color: inherit;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.88);
    transition: 0.2s ease;
}

.problem-card:hover {
    background: #e2ebf6;
    border-color: #b8c9df;
    transform: translateY(-1px);
}

.problem-card h3 {
    font-size: 17px;
    font-weight: 800;
    color: #13243a;
    margin-bottom: 6px;
    line-height: 1.3;
}

.problem-card p {
    font-size: 16px;
    color: #40536b;
    line-height: 1.45;
}

/* ================= SCENE HEADER ================= */

.scene-header-card {
    background: #f6f7fa;
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 2px 8px rgba(60, 80, 120, 0.07);
}

.scene-header-card h2 {
    font-size: 28px;
    font-weight: 800;
    color: #d4830f;
    margin-bottom: 8px;
}

.scene-header-card p {
    color: #64748b;
    font-size: 15px;
    margin-bottom: 6px;
}

.scene-header-card p:last-child {
    margin-bottom: 0;
}

/* ================= SCENE LAYOUT ================= */

.scene-layout {
    width: 100%;
}

.scene-top-row {
    display: grid;
    grid-template-columns: 1fr 360px; /* slightly bigger controls */
    gap: 20px;
    align-items: start;
}

.canvas-panel {
    background: #f6f7fa;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(60, 80, 120, 0.08);
    width: 100%;
}

.controls-panel {
    display: flex;
    background: #f6f7fa;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(60, 80, 120, 0.08);
    padding: 14px;
    max-height: 900px;
    overflow-y: auto;
}

.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: #b8c6db;
    border-radius: 10px;
}

.controls-block {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: 8px;
}

#physicsCanvas {
    width: 100%;
    max-width: 1400px;
    height: auto;
    min-height: 700px;
    display: block;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #ccd6e4;
    border-radius: 12px;
}

.scene-bottom-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 14px 0;
}

.panel-block {
    background: #f6f7fa;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(60, 80, 120, 0.08);
}

.panel-block h2,
.controls-block h2 {
    font-size: 20px;
    font-weight: 800;
    color: #1d2b43;
    margin-bottom: 12px;
}

#controls {
    width: 100%;
}

#controls label,
.control-group label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #506077;
    margin-bottom: 10px;
}

#controls input[type="range"],
#controls input[type="number"],
#controls input[type="text"],
#controls select,
.control-group input[type="range"],
.control-group input[type="number"],
.control-group input[type="text"],
.control-group select {
    width: 100%;
    margin-top: 6px;
    background: #ffffff;
    border: 1px solid #cad6e5;
    border-radius: 10px;
    padding: 10px 12px;
    color: #24354d;
    font-size: 14px;
    outline: none;
}

#controls input[type="range"],
.control-group input[type="range"] {
    padding: 0;
}

.control-group {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #dfe7f2;
}

#speedValue {
    margin-top: 8px;
    font-size: 14px;
    color: #617186;
    font-weight: 600;
}

.btn-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    margin-bottom: 10px;
}

.btn-col button,
#startBtn,
#pauseBtn,
#resetBtn {
    width: 100%;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

#startBtn {
    background: linear-gradient(180deg, #0a8f3d 0%, #06662b 100%);
    box-shadow: 0 4px 10px rgba(6, 102, 43, 0.22);
}

#startBtn:hover {
    filter: brightness(1.05);
}

#pauseBtn {
    background: linear-gradient(180deg, #ff9f43 0%, #e07a1f 100%);
    box-shadow: 0 4px 10px rgba(224, 122, 31, 0.22);
}

#pauseBtn:hover {
    filter: brightness(1.05);
}

#resetBtn {
    background: linear-gradient(180deg, #4f6ed8 0%, #273fa6 100%);
    box-shadow: 0 4px 10px rgba(39, 63, 166, 0.22);
}

#resetBtn:hover {
    filter: brightness(1.05);
}

.live-box,
.formula-box {
    background: #eef3fb;
    border: 1px solid #d4deed;
    border-radius: 12px;
    padding: 14px;
    color: #34485f;
    font-size: 14px;
    min-height: 64px;
}

.back-row {
    margin-top: 2px;
}

/* ================= DATA BLOCKS ================= */

.data-top-title {
    font-size: 22px;
    font-weight: 800;
    color: #34485f;
    margin-bottom: 6px;
}

.data-top-subtitle {
    font-size: 15px;
    color: #64748b;
    margin-bottom: 14px;
}

.data-grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.data-card {
    background: #f7fbff;
    border: 1px solid #d4deed;
    border-radius: 12px;
    padding: 14px;
}

.data-card.red { border-left: 5px solid #dc2626; }
.data-card.green { border-left: 5px solid #16a34a; }
.data-card.blue { border-left: 5px solid #2563eb; }
.data-card.purple { border-left: 5px solid #7c3aed; }

.data-card-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 10px;
}

.data-card.red .data-card-title { color: #dc2626; }
.data-card.green .data-card-title { color: #16a34a; }
.data-card.blue .data-card-title { color: #2563eb; }
.data-card.purple .data-card-title { color: #7c3aed; }

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(120, 140, 170, 0.25);
}

.data-row:last-child {
    border-bottom: none;
}

.data-key {
    font-weight: 700;
    color: #506077;
    white-space: nowrap;
}

.data-value {
    font-weight: 600;
    color: #1d2b43;
    text-align: right;
}

.data-note-line {
    margin-top: 10px;
    font-size: 13px;
    color: #64748b;
}

.control-grid-two {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 1100px) {
    .topbar::after {
        display: none;
    }
}

@media (max-width: 992px) {
    .problem-list.three-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scene-top-row {
        grid-template-columns: 1fr;
    }

    .brand-text h1 {
        font-size: 30px;
    }

    .scene-links::after {
        font-size: 14px;
        letter-spacing: 0.5px;
        padding: 6px 14px;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .page-shell {
        width: 94%;
        margin-top: 16px;
    }

    .topbar-inner {
        padding: 14px 16px;
    }

    .brand-wrap {
        flex-wrap: wrap;
        align-items: center;
    }

    .logo-box {
        width: 110px;
        height: 78px;
        flex: 0 0 110px;
    }

    .brand-text {
        width: 100%;
    }

    .brand-text h1 {
        font-size: 24px;
        letter-spacing: 1px;
    }

    .scene-links {
        gap: 10px;
    }

    .scene-links::after {
        order: 2;
        width: fit-content;
        font-size: 13px;
        padding: 6px 12px;
        white-space: normal;
    }

    .home-link,
    .back-link {
        font-size: 18px;
        padding: 8px 14px;
    }

    .chapter-card h2,
    .scene-header-card h2 {
        font-size: 24px;
    }

    .problem-list.two-col,
    .problem-list.three-col,
    .data-grid-two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .topbar-inner,
    .chapter-card,
    .scene-header-card,
    .canvas-panel,
    .panel-block,
    .controls-panel {
        padding: 14px;
    }

    .logo-box {
        width: 88px;
        height: 62px;
        flex: 0 0 88px;
    }

    .brand-text h1 {
        font-size: 20px;
        letter-spacing: 0.5px;
    }

    .topbar,
    .chapter-card,
    .scene-header-card,
    .canvas-panel,
    .controls-panel,
    .panel-block {
        border-radius: 14px;
    }

    .scene-links::after {
        font-size: 12px;
        letter-spacing: 0;
        padding: 6px 10px;
    }

    .data-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .data-value {
        text-align: left;
    }
}
