@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --phet-dark: #222;
    --phet-darker: #111;
    --phet-panel: #f5f5f5;
    --phet-border: #ccc;
    --phet-blue: #3b9eff;
    --phet-green: #2ec935;
    --phet-red: #e44444;
    --phet-orange: #ff9800;
    --phet-tab-bg: #3a3a3a;
    --phet-tab-active: #1a1a1a;
    --phet-accent: #0066cc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    margin: 0;
    padding: 0;
    background: #111;
}

#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #111;
    transform-origin: top left;
}

/* ============================
   LAUNCHER SCREEN
   ============================ */
#launcher {
    position: absolute;
    inset: 0;
    background: #1a1a2e;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.launcher-title {
    color: white;
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 60px;
    letter-spacing: 2px;
    text-shadow: 0 0 40px rgba(59, 158, 255, 0.5);
}

.launcher-grid {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 20px;
}

.launcher-card {
    width: 220px;
    height: 200px;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 22px;
    cursor: pointer;
    transition: all 0.25s;
    color: white;
    text-align: center;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.launcher-card:hover {
    background: rgba(255, 255, 255, 0.13);
    border-color: var(--phet-blue);
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(59, 158, 255, 0.3);
}

.launcher-card span {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.card-preview {
    width: 100%;
    flex: 1;
    margin-bottom: 14px;
}

/* Card Previews (simple SVG-style drawings with CSS) */
.waves-preview {
    background: radial-gradient(ellipse at 20% 50%, rgba(59, 158, 255, 0.8) 0%, transparent 60%);
    background-size: 100% 100%;
    background-image: repeating-conic-gradient(from 0deg at 20% 50%, transparent 0deg, rgba(59, 158, 255, 0.3) 3deg, transparent 6deg);
}

.interference-preview {
    background-image:
        radial-gradient(ellipse at 30% 50%, rgba(0, 200, 255, 0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 50%, rgba(0, 200, 255, 0.5) 0%, transparent 50%);
}

.slits-preview {
    background: linear-gradient(90deg, rgba(59, 158, 255, 0.5) 0%, rgba(59, 158, 255, 0.05) 100%);
    position: relative;
}

.diffraction-preview {
    background: radial-gradient(circle at 50% 50%, rgba(255, 200, 50, 0.8) 0%, transparent 60%);
}

/* ============================
   SIM CONTAINER
   ============================ */
#sim-container {
    flex: 1;
    width: 100%;
    display: none;
    flex-direction: column;
    background: #2a2a2a;
    overflow: hidden;
}

/* ============================
   SIM HEADER (Top Bar)
   ============================ */
.sim-header {
    height: 52px;
    background: #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #555;
    position: relative;
    flex-shrink: 0;
}

.screen-title {
    position: absolute;
    left: 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #ddd;
    letter-spacing: 1px;
}

/* Instrument Selector (pill in center) */
.instrument-selector {
    display: flex;
    background: #222;
    border: 2px solid #555;
    border-radius: 40px;
    padding: 4px;
    gap: 4px;
}

.inst-pick {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    padding: 6px 18px;
    border-radius: 30px;
    color: #aaa;
    transition: all 0.2s;
    font-size: 0.88rem;
    font-weight: 600;
}

.inst-pick:hover {
    color: #fff;
}

.inst-pick.active {
    background: var(--phet-blue);
    color: white;
    box-shadow: 0 2px 10px rgba(59, 158, 255, 0.5);
}

/* ============================
   STAGE (Middle area)
   ============================ */
#stage {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ============================
   VIEWPORT / CANVAS AREA
   ============================ */
.viewport-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
}

#wave-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Medium label (top-right of canvas) */
.medium-label {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
    text-transform: uppercase;
    pointer-events: none;
}

/* ============================
   GREEN POWER TOGGLE (PhET style)
   ============================ */
.phet-primary-toggle {
    position: absolute;
    bottom: 18px;
    left: 18px;
    width: 56px;
    height: 56px;
    background: var(--phet-green);
    border: 3px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 0 #166534, 0 6px 20px rgba(46, 201, 53, 0.4);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.phet-primary-toggle.off {
    background: var(--phet-red);
    box-shadow: 0 4px 0 #7f1d1d, 0 6px 20px rgba(228, 68, 68, 0.3);
}

.phet-primary-toggle:active {
    transform: translateY(3px);
    box-shadow: none !important;
}

/* ============================
   SOURCE MOUNTS (Left Overlay)
   ============================ */
.source-mount-left {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100px;
    pointer-events: none;
    z-index: 200;
}

.source-head-unit {
    position: absolute;
    left: 0;
    transform: translateY(-50%);
}

/* ============================
   WATER FAUCET (PhET-Style)
   ============================ */
.faucet-assembly {
    display: flex;
    align-items: flex-end;
    position: relative;
    width: 90px;
    height: 80px;
}

/* Vertical pipe coming from top */
.faucet-pipe {
    position: absolute;
    top: 0;
    left: 28px;
    width: 20px;
    height: 50px;
    background: linear-gradient(90deg, #555 0%, #aaa 40%, #888 70%, #555 100%);
    border-radius: 3px 3px 0 0;
    box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.3);
}

/* Horizontal spout pipe */
.faucet-spout {
    position: absolute;
    top: 38px;
    left: 28px;
    width: 42px;
    height: 18px;
    background: linear-gradient(180deg, #aaa 0%, #777 50%, #555 100%);
    border-radius: 0 0 0 0;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

/* Nozzle tip (the outlet) */
.faucet-nozzle {
    position: absolute;
    top: 44px;
    right: 0px;
    width: 16px;
    height: 28px;
    background: linear-gradient(90deg, #888 0%, #bbb 50%, #888 100%);
    border-radius: 0 0 4px 4px;
    border: 1px solid #555;
}

/* Handle on top */
.faucet-handle {
    position: absolute;
    top: 0;
    left: 18px;
    width: 40px;
    height: 12px;
    background: linear-gradient(180deg, #e44 0%, #c00 100%);
    border: 2px solid #700;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    transform-origin: 18px 6px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.faucet-handle.on {
    transform: rotate(-30deg);
    background: linear-gradient(180deg, #2ec935 0%, #166534 100%);
    border-color: #052e16;
}

/* ============================
   SPEAKER VISUAL
   ============================ */
.speaker-assembly {
    width: 70px;
    height: 60px;
    position: relative;
    display: flex;
    align-items: center;
}

.speaker-body {
    width: 40px;
    height: 52px;
    background: linear-gradient(90deg, #333 0%, #555 50%, #333 100%);
    border: 2px solid #666;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
}

.speaker-cone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle, #aaa 0%, #555 60%, #333 100%);
    border: 2px solid #777;
}

.speaker-cone::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: #222;
    border-radius: 50%;
}

.speaker-pulse {
    position: absolute;
    right: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 30px;
    background: linear-gradient(180deg, #555 0%, #888 50%, #555 100%);
    border-radius: 0 3px 3px 0;
}

/* ============================
   LASER / LIGHT SOURCE
   ============================ */
.laser-assembly {
    width: 80px;
    height: 36px;
    position: relative;
    display: flex;
    align-items: center;
}

.laser-body {
    width: 60px;
    height: 32px;
    background: linear-gradient(180deg, #555 0%, #333 100%);
    border: 2px solid #666;
    border-radius: 4px 16px 16px 4px;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    position: relative;
}

.laser-aperture {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 14px;
    background: #fbbf24;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.8);
}

/* ============================
   DRAGGABLE TOOLS
   ============================ */
.tool-probe {
    position: absolute;
    width: 250px;
    background: #1a1a2e;
    border: 2px solid #3b9eff;
    border-radius: 12px;
    padding: 10px;
    cursor: move;
    z-index: 500;
    box-shadow: 0 8px 32px rgba(59, 158, 255, 0.3);
}

.probe-header {
    font-size: 0.78rem;
    font-weight: 700;
    color: #3b9eff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#probe-graph-canvas {
    width: 100%;
    border-radius: 6px;
    background: #050510;
}

.measuring-tape {
    position: absolute;
    background: #f59e0b;
    border: 2px solid #92400e;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: move;
    z-index: 400;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.8rem;
    color: #451a03;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

/* ============================
   CONTROL PANEL (RIGHT SIDE)
   ============================ */
.control-side {
    width: 280px;
    background: #e8e8e8;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    flex-shrink: 0;
    border-left: 2px solid #bbb;
}

.panel-phet {
    background: white;
    border: 2px solid #ccc;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.panel-header {
    font-weight: 800;
    font-size: 0.82rem;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #eee;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sliders */
.slider-group {
    margin-bottom: 14px;
}

.slider-group:last-child {
    margin-bottom: 0;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #444;
}

.val-badge {
    background: #eee;
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #333;
}

.phet-slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slider-end-label {
    font-size: 0.65rem;
    color: #888;
    font-weight: 600;
    white-space: nowrap;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 32px;
    background: linear-gradient(180deg, #5db8ff 0%, #0066cc 100%);
    border: 3px solid white;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.4);
}

/* Radio Buttons (PhET style) */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.radio-phet {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    color: #333;
}

.radio-phet input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--phet-blue);
    cursor: pointer;
}

/* Checkboxes */
.checkbox-phet {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.checkbox-phet:last-child {
    margin-bottom: 0;
}

.checkbox-phet input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--phet-blue);
    cursor: pointer;
}

/* ============================
   NAV FOOTER (Bottom tabs)
   ============================ */
.nav-footer {
    height: 72px;
    background: var(--phet-tab-bg);
    display: flex;
    align-items: stretch;
    border-top: 2px solid #555;
    flex-shrink: 0;
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
    gap: 4px;
    border-right: 1px solid #555;
    position: relative;
}

.nav-tab:last-child {
    border-right: none;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-tab.active {
    background: var(--phet-tab-active);
    color: white;
    border-top: 3px solid var(--phet-blue);
}

.tab-icon svg {
    transition: stroke 0.2s;
}

.nav-tab.active .tab-icon svg {
    stroke: var(--phet-blue);
}

.nav-tab span {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}