/* =============================================================================
   Resilient styles for unknown classroom hardware.
   Strategy:
   - No CSS variables in critical paths (Edge legacy / Safari 9 fallback)
   - Flexbox first; grid only as enhancement
   - Use vh/vw with -webkit-fill-available fallbacks for iOS Safari
   - High-contrast colors that survive bad projectors (often washed out)
   ========================================================================== */

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

html, body {
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

/* =====================================================================
   SPLASH SCREEN
   Required to unlock fullscreen API + audio autoplay through user gesture.
   ===================================================================== */
.splash {
    position: fixed;
    inset: 0;                       /* modern shorthand */
    top: 0; right: 0; bottom: 0; left: 0;   /* fallback */
    background: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.splash-inner {
    text-align: center;
    max-width: 600px;
}

.splash-inner h1 {
    font-size: 36px;
    font-weight: 300;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.splash-inner .dim { color: #888; font-weight: 200; }

.splash-inner .subtitle {
    font-size: 18px;
    color: #aaa;
    margin-bottom: 40px;
}

.big-btn {
    background: #fff;
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 18px 48px;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
}

.big-btn:hover,
.big-btn:focus { background: #e0e0e0; transform: scale(1.03); outline: none; }
.big-btn:active { transform: scale(0.98); }

.splash-inner .hint {
    margin-top: 30px;
    font-size: 13px;
    color: #666;
}

.splash-inner kbd {
    background: #222;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
}

/* =====================================================================
   MAIN APP — player + toolbar
   ===================================================================== */
.app {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    background: #000;
}

.player-wrap {
    flex: 1 1 auto;
    min-height: 0;                   /* fix flexbox overflow in Chrome */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.player {
    /* object-fit:contain prevents distortion on any aspect ratio */
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
    outline: none;
}

.toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #111;
    border-top: 1px solid #222;
    flex-wrap: wrap;                 /* survives narrow screens */
}

.tool-btn {
    background: #222;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.tool-btn:hover,
.tool-btn:focus { background: #333; outline: none; }
.tool-btn:active { background: #444; }

.tool-btn.primary {
    background: #fff;
    color: #000;
    border-color: #fff;
    font-weight: 500;
}

.tool-btn.primary:hover,
.tool-btn.primary:focus { background: #e0e0e0; }

.sep {
    flex: 1 1 auto;
    min-width: 10px;
}

/* =====================================================================
   GALLERY (fullscreen frame viewer)
   ===================================================================== */
.gallery {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    -webkit-user-select: none;
    user-select: none;
}

.gallery-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    -webkit-touch-callout: none;
}

.gallery-ui {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    pointer-events: none;            /* clicks pass through to image area */
}

.gallery-ui > * { pointer-events: auto; }

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 100px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    font-size: 40px;
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1;
    font-family: inherit;
}

.nav-btn:hover,
.nav-btn:focus { background: rgba(0, 0, 0, 0.8); outline: none; }

.nav-prev { left: 0;  border-radius: 0 4px 4px 0; }
.nav-next { right: 0; border-radius: 4px 0 0 4px; }

.gallery-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0));
}

.gallery-bar .counter {
    color: #fff;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 4px;
}

.bar-spacer { flex: 1 1 auto; }

/* =====================================================================
   TOAST (error / status messages)
   ===================================================================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.95);
    color: #fff;
    padding: 14px 24px;
    border-radius: 6px;
    border: 1px solid #444;
    font-size: 14px;
    z-index: 200;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* =====================================================================
   FULLSCREEN COMPAT
   Different prefixes for different browsers. Ensures black background
   in fullscreen mode (default is often white in some browsers).
   ===================================================================== */
:fullscreen,
:-webkit-full-screen,
:-moz-full-screen,
:-ms-fullscreen { background: #000 !important; }

video::-webkit-media-controls-panel { background: rgba(0, 0, 0, 0.7); }

/* =====================================================================
   RESPONSIVE — narrow screens (rare in classroom but safe)
   ===================================================================== */
@media (max-width: 600px) {
    .splash-inner h1 { font-size: 26px; }
    .splash-inner .subtitle { font-size: 15px; }
    .big-btn { padding: 14px 36px; font-size: 17px; }
    .tool-btn { padding: 8px 12px; font-size: 13px; }
    .toolbar { padding: 10px; gap: 6px; }
    .nav-btn { width: 44px; height: 80px; font-size: 30px; }
}

/* Touch-friendly on tablets. */
@media (hover: none) and (pointer: coarse) {
    .tool-btn { padding: 14px 22px; font-size: 16px; }
    .nav-btn  { width: 70px; height: 120px; }
}

/* Print: hide everything (just in case someone hits Ctrl+P). */
@media print { body * { visibility: hidden !important; } }
