/* Retro TV Wrapper */
.tv-wrapper {
    background: #333 !important;
    border: 15px solid #fff !important;
    border-radius: 30px;
    padding: 20px;
    width: 90%; /* Reduced from 100% for better control */
    max-width: 1000px; /* Slightly reduced for better proportions */
    margin: 50px auto 0; /* Center horizontally with auto margins */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: visible;
    transform: none; /* Remove the transform that was causing issues */
    box-sizing: border-box; /* Ensure padding doesn't affect width calculations */
}

/* Antenna Base */
.antenna-base {
    content: '';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 49px;
    height: 15px;
    background: #fff;
    border-radius: 3px;
    z-index: 2;
}

/* TV Aerial - V-shaped antenna - SHORTENED */
.tv-wrapper::before,
.tv-wrapper::after {
    content: '';
    position: absolute;
    top: -75px;        /* Changed from -95px - brings them closer */
    width: 4px;
    height: 55px;      /* Changed from 90px - makes them shorter */
    background: #fff;
    z-index: 1;
}

.tv-wrapper::before {
    left: calc(50% - 15px);
    transform: rotate(-25deg);
    transform-origin: bottom;
}

.tv-wrapper::after {
    left: calc(50% + 15px);
    transform: rotate(25deg);
    transform-origin: bottom;
}

/* TV Controls */
.tv-controls {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 30px;
    background: #fff;
    border-radius: 0 0 15px 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 5px;
    z-index: 1;
}

/* Control Panel Knobs */
.tv-controls::before,
.tv-controls::after {
    content: '';
    width: 20px;
    height: 20px;
    background: #333;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    background: black;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 auto;
}

/* Video iframe positioning */
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Navigation Container */
.nav-container {
    display: flex; /* Changed from grid to flex for better control */
    justify-content: space-between; /* Space buttons evenly */
    align-items: center;
    width: 90%;
    max-width: 1000px; /* Match TV width */
    margin: 30px auto;
    position: relative;
    z-index: 2;
}

/* Button Container */
.button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 0 auto; /* Center in available space */
}

/* Navigation Buttons */
.nav-btn {
    background-color: #fff;
    color: #333;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    min-width: 150px;
    text-align: center;
    display: inline-block; /* More consistent display */
    margin: 5px 0; /* Add space between stacked buttons */
}

.nav-btn:hover {
    background-color: #333;
    color: #fff;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .tv-wrapper {
        padding: 10px;
        border-width: 10px !important;
        width: 95%; /* Wider on mobile */
        margin: 60px auto 0;
    }

    .tv-wrapper::before,
    .tv-wrapper::after {
        height: 60px;
        top: -60px;
    }
    
    .tv-wrapper::before {
        left: calc(50% - 15px); /* Keep original positioning */
    }
    
    .tv-wrapper::after {
        left: calc(50% + 15px); /* Keep original positioning */
    }

    .antenna-base {
        width: 30px;
        height: 12px;
    }

    /* Better mobile navigation */
    .nav-container {
        flex-direction: column; /* Stack navigation elements */
        width: 95%;
        gap: 10px;
    }

    .nav-btn {
        width: 100%;
        min-height: 44px;
        min-width: 200px; /* Ensure buttons are wide enough to tap */
        margin: 5px 0;
    }
    
    .tv-controls {
        width: 160px;
        height: 25px;
        bottom: -25px;
    }

    .tv-controls::before,
    .tv-controls::after {
        width: 15px;
        height: 15px;
    }
}

/* Further refinements for very small screens */
@media (max-width: 480px) {
    .tv-wrapper {
        border-width: 8px !important;
        padding: 8px;
        width: 96%;
    }
    
    /* Simpler antenna for very small screens */
    .tv-wrapper::before,
    .tv-wrapper::after {
        height: 40px;
        top: -40px;
        width: 3px;
    }
    
    .antenna-base {
        width: 25px;
        height: 10px;
    }
}


/* =================================== */
/* ===== VCR CONTROL PANEL STYLES ==== */
/* =================================== */

:root {
    --vcr-bg: linear-gradient(180deg, #282828 0%, #1a1a1a 100%);
    --button-inset-bg: #111;
    --button-inset-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
    --transport-bg: linear-gradient(180deg, #b0b0b0 0%, #888888 100%);
    --transport-shadow: 0 5px 8px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.2);
--cta-color: linear-gradient(45deg, #ff5722, #ff7043);
    --cta-hover-color: #00ffff;
    --cta-hover-glow: rgba(0, 255, 255, 0.5);
}

/* --- Main VCR Panel --- */
.vcr-panel {
    background: var(--vcr-bg);
    border: 2px solid #444;
    border-top-color: #666;
    border-bottom-color: #111;
    border-radius: 12px;
    padding: 0.6rem 1.2rem;
    width: 95%; /* Use percentage for flexibility */
    max-width: 850px; /* Keep the max-width for desktop */
    margin: 35px auto 20px auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255,255,255,0.1);
    /* The transform properties have been removed */
}

/* --- Inactive Lesson Button Styling & Hover Effect --- */
.vhs-slot-btn.inactive {
    position: relative; /* Required for hover text */
    cursor: default; /* This keeps it from looking clickable */
    /* The button will now correctly inherit the default orange background */
}

/* This rule re-applies the blue hover effect to the inactive button */
.vhs-slot-btn.inactive:hover {
    background: #222;
    border-color: var(--cta-hover-color);
    box-shadow: var(--button-inset-shadow), 0 0 15px var(--cta-hover-glow);
}

/* This hides the original button text on hover */
.vhs-slot-btn.inactive:hover .vhs-slot-text {
    visibility: hidden;
}

/* This creates and displays the "Coming Soon" text on hover */
.vhs-slot-btn.inactive:hover::after {
    content: attr(data-hover-text);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cta-hover-color); /* Makes the hover text match the blue glow */
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0 0.5rem; /* Adjusted padding slightly to give icons more room */
    text-align: center;
    white-space: nowrap; /* Prevents text from wrapping too early */
}

/* Hides the original button text on hover */
.vhs-slot-btn.inactive:hover .vhs-slot-text {
    visibility: hidden;
}

/* Creates and displays the new hover text */
.vhs-slot-btn.inactive:hover::after {
    content: attr(data-hover-text);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0 1rem;
    text-align: center;
}
/* --- Grid Layout --- */
.vcr-grid {
    display: grid;
    grid-template-columns: auto 1fr auto; /* Rewind | Center Group | FF */
    gap: 1rem;
    align-items: stretch;
}

.center-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* MODIFIED: Reduced gap */
    min-width: 0; /* Prevents grid blowout */
}

.function-grid-top, .function-grid-bottom {
    display: grid;
    gap: 0.5rem; /* MODIFIED: Reduced gap */
}

.function-grid-top {
     grid-template-columns: 1fr 1fr 1fr;
}

.function-grid-bottom {
    grid-template-columns: 1fr 1fr 1fr;
}


/* --- Big Transport Buttons --- */
.transport-btn {
    background: var(--transport-bg);
    border: 2px solid #555;
    border-top-color: #ccc;
    border-bottom-color: #444;
    border-radius: 8px;
    width: 90px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--transport-shadow);
    transition: all 0.2s ease-out;
    text-decoration: none;
}
.transport-btn svg {
    width: 40px;
    height: 40px;
    fill: #333;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5));
    transition: fill 0.2s ease;
}
.transport-btn:hover {
    background: #222; /* Change background to match inset buttons */
    border-color: var(--cta-hover-color);
    box-shadow: var(--button-inset-shadow), 0 0 15px var(--cta-hover-glow);
}
.transport-btn:hover svg {
    fill: var(--cta-hover-color); /* Make the icon glow */
}
.transport-btn:active, .transport-btn.active {
    background: var(--cta-hover-color);
    border-color: var(--cta-hover-color);
    box-shadow: none;
    transform: translateY(2px);
}
.transport-btn:active svg, .transport-btn.active svg {
    fill: #000;
}


/* --- Inset Function Buttons --- */
.function-btn {
    background: var(--button-inset-bg);
    color: #ccc;
    border: 1px solid #000;
    border-radius: 6px;
    padding: 0.35rem 1rem; /* MODIFIED: Reduced vertical padding */
    font-weight: 600;
    box-shadow: var(--button-inset-shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 0.9rem;
    min-height: 36px; /* MODIFIED: Reduced min-height */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Space for icons */
}
.function-btn:hover,
.function-btn.active {
    background: #222;
    color: var(--cta-hover-color);
    border-color: var(--cta-hover-color);
    box-shadow: var(--button-inset-shadow), 0 0 15px var(--cta-hover-glow);
    transform: translateY(-1px); /* Subtle lift effect for both states */
}

.function-btn.active .btn-icon {
    fill: var(--cta-hover-color);
}

.function-btn.active .comment-counter {
    background: var(--cta-hover-color);
    color: var(--text-dark);
    border: none;
}

.function-btn.center-wide {
    grid-column: 2 / 3;
}

.btn-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* --- VHS Slot Button (CTA) --- */
.vhs-slot-btn {
    background: var(--cta-color);
    border-radius: 6px;
    padding: 0.5rem 1rem; /* MODIFIED: Matched to function buttons */
    border: 2px solid #111;
    box-shadow: var(--button-inset-shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    position: relative;
    min-height: 36px; /* Reduced min-height */
}
.vhs-slot-btn::before { /* The tape slot illusion */
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 2px solid rgba(0,0,0,0.5);
    border-radius: 4px;
    background: linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0.4));
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    transition: opacity 0.2s ease;
}
.vhs-slot-btn:hover {
    background: #222; /* Becomes transparent like others */
    border-color: var(--cta-hover-color);
    box-shadow: var(--button-inset-shadow), 0 0 15px var(--cta-hover-glow);
}
.vhs-slot-btn:hover::before {
    opacity: 0; /* Hide the slot illusion on hover */
}
.vhs-slot-text {
    position: relative; /* Ensure text is on top of the slot effect */
    font-size: 1rem; /* MODIFIED: Reduced font size */
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    transition: color 0.2s ease;
}
.vhs-slot-btn:hover .vhs-slot-text {
    color: var(--cta-hover-color); /* Text turns blue */
}

/* Specificity fix for share button wrapper */
.share-btn-wrapper.function-btn {
    padding: 0;
    position: relative;
}
.share-btn-wrapper > .function-btn {
    width: 100%;
    height: 100%;
}

/* REMOVED the conflicting .share-btn-wrapper.active rule */


/* --- NEW RESPONSIVE DESIGN SECTION --- */
@media (max-width: 768px) {
    .vcr-panel {
        width: 95%;
        padding: 1rem;
        margin-top: 25px;
    }

    .vcr-grid {
        display: flex;
        flex-direction: column; /* Stack all sections vertically */
        gap: 1rem;
    }

    .transport-wrapper {
        display: flex;
        justify-content: space-between; /* Puts Prev/Next buttons at either end */
        order: 2; /* Place transport buttons AFTER the center controls */
    }

    .transport-btn {
        width: 48%; /* Make buttons share the space */
        height: 60px;
    }

    .center-controls {
        order: 1; /* Place center controls FIRST */
    }
    
    .function-grid-top, .function-grid-bottom {
        grid-template-columns: 1fr 1fr; /* Two columns for function buttons */
    }

    /* Make the center buttons (Fullscreen, Share) span both columns */
    .function-grid-top .function-btn.center-wide,
    .function-grid-bottom .function-btn.center-wide {
        grid-column: 1 / -1;
    }
}
