/*
 * Big screen (10-foot) styles. Plain CSS without custom properties, flex gap
 * or `inset` so older Samsung / LG TV browsers render it correctly.
 * Sizes use vh so the layout scales with the TV resolution.
 */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #0b0f17;
    color: #f9fafb;
    font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 2.6vh;
    overflow: hidden;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 5vh 6vw;
    background: #0b0f17;
}

.brand { display: flex; align-items: center; }
.brand img { height: 7vh; width: auto; }
.brand-tag {
    margin-left: 1.5vw;
    padding: .25em .7em;
    border: 1px solid #374151;
    border-radius: 999px;
    color: #9ca3af;
    font-size: .8rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* Shown only when the browser offers to install the app. */
.btn-install {
    margin-left: auto;
    padding: .45em 1.1em;
    border: 1px solid #374151;
    border-radius: 999px;
    background: transparent;
    color: #d1d5db;
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-install[hidden] { display: none; }
.btn-install:hover,
.btn-install:focus { border-color: #ED2929; background: #ED2929; color: #fff; outline: none; }

/* Installed app already runs full screen: no need for the full screen hint. */
.is-installed .hint { display: none; }

h1 { font-size: 2.6rem; line-height: 1.15; margin: 0 0 .6em; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: #9ca3af; font-size: 1.2rem; }
.eyebrow { color: #F74343; font-size: 1rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }

/* Only the active view is shown. */
.view { display: none; flex: 1; }
#app[data-view="loading"] .view-loading,
#app[data-view="idle"] .view-idle,
#app[data-view="ready"] .view-ready,
#app[data-view="message"] .view-message,
#app[data-view="error"] .view-error { display: flex; }
#app[data-view="pair"] .view-pair { display: flex; }

.center { flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.view-loading { flex-direction: column; align-items: center; justify-content: center; }

/* Pair view: QR on the left, steps and code on the right. */
.view-pair { align-items: center; justify-content: center; }
.pair-qr { flex: 0 0 auto; }
.qr-box {
    width: 46vh;
    height: 46vh;
    padding: 2.4vh;
    background: #ffffff;
    border-radius: 2vh;
}
.qr-box svg { display: block; width: 100%; height: 100%; }
.pair-text { flex: 0 1 auto; max-width: 52vw; margin-left: 6vw; }
.steps { list-style: none; margin: 0 0 1.4em; padding: 0; }
.steps li {
    display: flex;
    align-items: flex-start;
    margin-bottom: .9em;
    font-size: 1.35rem;
    line-height: 1.35;
    color: #e5e7eb;
}
.step-no {
    flex: 0 0 auto;
    width: 1.6em;
    height: 1.6em;
    line-height: 1.6em;
    margin-right: .7em;
    border-radius: 50%;
    background: #ED2929;
    color: #fff;
    text-align: center;
    font-weight: 700;
    font-size: .85em;
}
.code {
    display: inline-block;
    padding: .2em .6em;
    border: 2px solid #374151;
    border-radius: .3em;
    background: #111827;
    font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 4.2rem;
    font-weight: 700;
    letter-spacing: .14em;
}
.hint { margin-top: 1.4em; color: #6b7280; font-size: 1rem; }
.is-fullscreen .hint { display: none; }

/* Buttons are large and get an obvious focus ring for remote control use. */
.btn {
    display: inline-block;
    margin-top: 1em;
    padding: .7em 3em;
    border: 0;
    border-radius: .4em;
    background: #ED2929;
    color: #fff;
    font: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    -webkit-transition: -webkit-transform .15s ease, background .15s ease;
    transition: transform .15s ease, background .15s ease;
}
.btn:hover { background: #F74343; }
.btn:focus {
    outline: .25rem solid #ffffff;
    outline-offset: .3rem;
    background: #F74343;
    -webkit-transform: scale(1.06);
    transform: scale(1.06);
}

.spinner {
    width: 7vh;
    height: 7vh;
    margin-bottom: 2vh;
    border: .8vh solid #374151;
    border-top-color: #ED2929;
    border-radius: 50%;
    -webkit-animation: spin 1s linear infinite;
    animation: spin 1s linear infinite;
}
@-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Player covers the whole screen. */
.player {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10;
}
.is-playing .player { display: block; }
.is-playing #app { display: none; }
.player > * { width: 100%; height: 100%; }
.player iframe,
.player video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border: 0 !important;
    background: #000;
}

.btn-row { display: flex; justify-content: center; }
.btn-row .btn + .btn { margin-left: 1.5vw; }
.btn-secondary { background: #374151; }
.btn-secondary:hover, .btn-secondary:focus { background: #4b5563; }

/*
 * "Back to code" bar shown over the player. The corner area is a hover zone
 * (the iframe swallows mouse moves, so the bar can't react to moves over it).
 */
.player-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 15;
    padding: 3vh 2.5vw 5vh;
    align-items: center;
}
.is-playing .player-bar { display: flex; }
.btn-back,
.player-bar-hint {
    opacity: 0;
    -webkit-transition: opacity .25s ease;
    transition: opacity .25s ease;
}
.player-bar:hover .btn-back,
.player-bar:hover .player-bar-hint,
.player-bar.show .btn-back,
.player-bar.show .player-bar-hint,
.btn-back:focus,
.btn-back:focus + .player-bar-hint { opacity: 1; }
.btn-back {
    padding: .55em 1.2em;
    border: 0;
    border-radius: 999px;
    background: rgba(17, 24, 39, .85);
    color: #fff;
    font: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-back:hover { background: #ED2929; }
.btn-back:focus { outline: .2rem solid #fff; outline-offset: .2rem; background: #ED2929; }
.btn-back-arrow { margin-right: .3em; }
.player-bar-hint {
    margin-left: 1em;
    padding: .3em .7em;
    border-radius: .3em;
    background: rgba(17, 24, 39, .6);
    color: #d1d5db;
    font-size: .9rem;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 6vh;
    z-index: 20;
    padding: .7em 1.4em;
    border-radius: .4em;
    background: rgba(17, 24, 39, .92);
    color: #fff;
    font-size: 1.1rem;
    opacity: 0;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    -webkit-transition: opacity .25s ease;
    transition: opacity .25s ease;
    pointer-events: none;
}
.toast.show { opacity: 1; }

/* Phone help page (shown when a phone camera opens the QR link directly). */
html.help-root, html.help-root body { height: auto; min-height: 100%; overflow: auto; font-size: 16px; }
.help { max-width: 30rem; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.help-logo { height: 3rem; width: auto; margin-bottom: 1.5rem; }
.help h1 { font-size: 1.75rem; }
.help p, .help-steps { color: #d1d5db; line-height: 1.5; }
.help-steps { padding-left: 1.25rem; }
.help-steps li { margin-bottom: .5rem; }
.help-code {
    margin: 1.25rem 0;
    padding: .6rem 1rem;
    border: 1px solid #374151;
    border-radius: .5rem;
    background: #111827;
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-align: center;
}
.help-links .btn { display: block; margin-top: .75rem; padding: .8rem 1rem; font-size: 1rem; text-align: center; }

/* Narrow or portrait screens (e.g. testing on a laptop window): stack the pair view. */
@media (max-aspect-ratio: 1/1) {
    html, body { font-size: 2vh; }
    .view-pair { flex-direction: column; text-align: center; }
    .pair-text { max-width: 90vw; margin: 4vh 0 0; }
    .steps li { text-align: left; }
    .qr-box { width: 34vh; height: 34vh; }
}
