/* ========================================
   Cast TV Player - Titan OS Smart TV App
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    color: #fff;
    /* Base font-size is scaled dynamically via Titan SDK Text Magnification.
       All sizes below use rem so they scale with user preference. */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* --- Loading Screen --- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    text-align: center;
}

/* Skjar logo (JPG with white background) — styled so it blends
   into the black loading screen: padded, rounded, subtle shadow.
   Animated: entrance (scale + fade) then a continuous gentle float
   with a soft glowing pulse. */
.loading-logo {
    position: relative;
    display: inline-block;
    margin-bottom: 1.5rem;
    animation: logo-entrance 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.loading-logo-img {
    width: 180px;
    height: auto;
    background-color: #fff;
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    animation: logo-float 3.2s ease-in-out infinite 0.8s;
}

/* Entrance: scale up + fade in */
@keyframes logo-entrance {
    0%   { opacity: 0; transform: scale(0.6); }
    60%  { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}

/* Continuous gentle float (up/down) */
@keyframes logo-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

/* Soft glowing pulse behind the logo */
.loading-logo::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 120%;
    height: 120%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(26, 115, 232, 0.35) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    animation: logo-glow 2.4s ease-in-out infinite;
}

@keyframes logo-glow {
    0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.9); }
    50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.15); }
}

.loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    margin: 1rem auto;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.5px;
}

/* --- Error Screen --- */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.error-screen.active {
    opacity: 1;
    visibility: visible;
}

.error-content {
    text-align: center;
    padding: 2.5rem;
}

.error-icon {
    margin-bottom: 1.25rem;
}

.error-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #fff;
}

.error-message {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2rem;
    line-height: 1.5;
    max-width: 25rem;
}

/* --- TV Buttons (D-pad navigable) --- */
.tv-button {
    display: inline-block;
    padding: 0.75rem 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #fff;
    background-color: #1a73e8;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
    margin: 0 0.5rem;
}

.tv-button:hover,
.tv-button:focus {
    background-color: #1557b0;
}

.tv-button:focus-visible {
    border-color: #fff;
    transform: scale(1.05);
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.5);
}

.tv-button-danger {
    background-color: #d32f2f;
}

.tv-button-danger:hover,
.tv-button-danger:focus {
    background-color: #b71c1c;
}

.tv-button-secondary {
    background-color: #37474f;
}

.tv-button-secondary:hover,
.tv-button-secondary:focus {
    background-color: #263238;
}

/* --- Player Container --- */
.player-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000;
    z-index: 1;
}

.player-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* --- Focus Indicator --- */
.focus-indicator {
    position: absolute;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.focus-indicator.active {
    opacity: 1;
}

/* --- Exit Confirmation Dialog --- */
.exit-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.exit-dialog.active {
    opacity: 1;
    visibility: visible;
}

.exit-dialog-content {
    background-color: #1c1c1e;
    border-radius: 12px;
    padding: 2.5rem 3rem;
    text-align: center;
    max-width: 34rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.exit-dialog-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.exit-dialog-message {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2rem;
}

.exit-dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* --- Inactive / cursor hide --- */
.player-container.inactive {
    cursor: none;
}

.player-container.inactive .focus-indicator {
    opacity: 0 !important;
}

/* --- Responsive (HD → FHD → 4K) --- */
@media (min-width: 1280px) {
    .loading-logo-img {
        width: 220px;
    }
    .loading-text { font-size: 1.125rem; }
    .error-title { font-size: 2rem; }
    .error-message { font-size: 1.125rem; }
    .tv-button { font-size: 1.25rem; padding: 0.875rem 3.5rem; }
    .exit-dialog-title { font-size: 1.75rem; }
}

@media (min-width: 2560px) {
    .loading-logo-img {
        width: 320px;
    }
    .loading-spinner {
        width: 3.75rem;
        height: 3.75rem;
        border-width: 4px;
    }
    .loading-text { font-size: 1.5rem; }
    .error-title { font-size: 3rem; }
    .error-message { font-size: 1.5rem; max-width: 37.5rem; }
    .tv-button { font-size: 1.75rem; padding: 1.25rem 4.5rem; }
    .exit-dialog-title { font-size: 2.25rem; }
    .exit-dialog-content { max-width: 45rem; padding: 3rem 4rem; }
}
