/* CSS Variables for theming */
:root {
    --bg-color: #0b0f19;
    --text-color: #f1f5f9;
    --tile-bg: rgba(255, 255, 255, 0.05);
    --tile-hover: rgba(255, 255, 255, 0.1);
    --tile-border: rgba(255, 255, 255, 0.1);
    --accent-color: #3b82f6;
    --focus-ring: #60a5fa;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* WebOS apps usually hide overflow */
    width: 100vw;
    height: 100vh;
}

/* App Hub Container */
.app-hub {
    display: none;
    flex-direction: column;
    padding: 60px 80px;
    height: 100vh;
    background: radial-gradient(circle at top left, #1e293b, var(--bg-color));
}

.app-hub.active {
    display: flex;
}

header {
    margin-bottom: 50px;
    animation: fadeInDown 0.6s ease-out;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 10px;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    font-size: 1.2rem;
    color: #94a3b8;
    font-weight: 400;
}

/* App Grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    animation: fadeInUp 0.8s ease-out;
}

/* App Tile */
.app-tile {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    outline: none;
    backdrop-filter: blur(10px);
}

.app-tile:hover, .app-tile:focus {
    background: var(--tile-hover);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

/* TV Focus State */
.app-tile:focus {
    box-shadow: 0 0 0 4px var(--focus-ring), 0 15px 30px rgba(0, 0, 0, 0.4);
}

.app-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.app-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #f8fafc;
}

.app-info p {
    font-size: 1rem;
    color: #94a3b8;
}

/* Iframe Container */
.iframe-container {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    background: #000;
}

.iframe-container.active {
    display: block;
}

#app-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Overlay that appears briefly to show instructions */
.back-overlay {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.back-overlay.show {
    opacity: 1;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
