/* ================================================================
   PHOTOSYNTHESIS SIMULATOR — PhET-Style Scale-to-Fit Layout
   Desktop view is the "true" design. On mobile the entire
   #phet-stage is scaled down via JS transform: scale() to fit
   the screen — identical to how PhET simulations work.
   ================================================================ */

/* --- Root viewport: always fills the real screen exactly --- */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    /* dark letterbox colour, like PhET black bars */
    color: #0f172a;
    font-family: 'Outfit', sans-serif;
    /* Prevent any browser rubber-band / elastic scroll on mobile */
    overscroll-behavior: none;
    touch-action: none;
}

/* ----------------------------------------------------------------
   #phet-stage  — The fixed-size "design canvas"
   JS sets its width/height and transform: scale() dynamically.
   Think of it like a 1280×720 TV inside whatever-size room.
   ---------------------------------------------------------------- */
#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    /* Width & height are set by JS to DESIGN_WIDTH × DESIGN_HEIGHT */
    transform-origin: top left;
    /* scale from the top-left corner */
    background: #f8fafc;
    /* Centering handled by JS translate — mirrors PhET exactly */
}

/* ----------------------------------------------------------------
   Everything inside #phet-stage uses the SAME px values as desktop.
   Nothing below changes on mobile — JS handles the zoom.
   ---------------------------------------------------------------- */

nav {
    background: rgba(255, 255, 255, 0.95) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 50;
}

.nav-links a {
    color: #475569 !important;
}

.nav-links a:hover {
    color: #10b981 !important;
}

.lab-container {
    display: flex;
    margin-top: 76px;
    height: calc(100% - 76px);
    /* 100% of #phet-stage, not viewport */
    width: 100%;
}

.canvas-area {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #ffffff 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-direction: column;
}

#simCanvas {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    width: 100%;
    height: 100%;
    max-width: 900px;
    max-height: 600px;
    cursor: crosshair;
}

.stats-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    gap: 1rem;
    pointer-events: none;
    max-width: 900px;
    margin: 0 auto;
    z-index: 5;
}

.stat-panel {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    pointer-events: auto;
    min-width: 140px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stat-line {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.75rem;
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    align-items: center;
}

.stat-label {
    color: #64748b;
}

.stat-value {
    font-weight: 700;
    color: #0f172a;
}

/* Controls Panel */
.controls-panel {
    width: 380px;
    background: #ffffff;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    overflow-y: auto;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.03);
}

.control-group {
    background: #f0fdf4;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 1.2rem;
}

.control-group h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: #10b981;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.slider-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.8rem;
}

.slider-label {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 0.4rem;
    display: flex;
    justify-content: space-between;
}

input[type="range"] {
    width: 100%;
    accent-color: #10b981;
    height: 6px;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #10b981;
    cursor: pointer;
}

.btn-lab {
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-lab:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-lab:active {
    transform: translateY(1px);
}

.canvas-tooltip {
    position: absolute;
    bottom: -100px;
    /* Hide initially */
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
    z-index: 20;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.canvas-tooltip.show {
    bottom: 2rem;
}