/* =============================================
   Eyestage Client — Styles
   Based on designer UI, integrated with backend
============================================= */

:root {
    --bg: #000;
    --fg: #fff;
    --muted: rgba(255, 255, 255, .72);
    --hair: rgba(255, 255, 255, .10);
    --accent: #ff6a1a;
    --char-color: #d4af37;
    --header-h: 54px;
    --dock-h: 64px;
    --mini-h: 22vh;
    --mini-h-min: 100px;
    --mini-h-max: 100px;
    --pad-x: 18px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    overflow: hidden;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 22px;
    line-height: 1;
}

/* ===== Header ===== */
.app-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: 74px;
    padding: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    z-index: 20;
    pointer-events: auto;
}

.brand {
    pointer-events: auto;
}

.brand-mark {
    width: 7em;
    max-width: 15em;
}

/* ===== Viewport ===== */
.viewport {
    height: 100dvh;
    padding-top: 0;
    padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: 1fr;
}

/* ===== Render Layer ===== */
.render-layer {
    position: relative;
    background: #000;
    display: grid;
    place-items: center;
    padding: 0 var(--pad-x);
    will-change: transform, filter, opacity;
    cursor: pointer;
    overflow: hidden;
}

body.mode-programa .render-layer {
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
        padding-top: 28vh;
    
}
body.mode-libreto .render-layer {
        padding-top: 28vh;
}

.subtitle-wrap {
    width: 80%;
    max-width: 820px;
}

.subtitle-character {
    text-align: center;
    font-size: clamp(11px, 2.5vw, 14px);
    color: var(--char-color);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 300;
    margin-bottom: 6px;
    opacity: 0.85;
    font-family: 'Roboto Condensed', sans-serif;
}

.subtitle {
    text-align: center;
    font-size: clamp(24px, 5vw, 28px);
    line-height: 1.08;
    letter-spacing: .2px;
    text-rendering: geometricPrecision;
    font-family: 'Roboto Condensed', ui-sans-serif, system-ui, sans-serif;
    font-weight: 700;
}

/* Multi-line subtitles — unified style (matches single-line) */
.subtitle-multi-block {
    text-align: center;
    margin-bottom: 18px;
}

.subtitle-multi-block:last-child {
    margin-bottom: 0;
}

.subtitle-multi-char {
    font-size: clamp(11px, 2.5vw, 14px);
    color: var(--char-color);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 300;
    margin-bottom: 6px;
    opacity: 0.85;
    font-family: 'Roboto Condensed', sans-serif;
}

.subtitle-multi-text {
    font-size: clamp(24px, 5vw, 28px);
    line-height: 1.08;
    letter-spacing: .2px;
    font-family: 'Roboto Condensed', ui-sans-serif, system-ui, sans-serif;
    font-weight: 700;
    color: var(--fg);
}

/* Multi-line subtitles */
.subtitle-line {
    margin-bottom: 4px;
}

.subtitle-line-char {
    color: var(--char-color);
    font-size: 0.7em;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-programa div#liveSubtitle,
.mode-libreto div#liveSubtitle {
    font-size: clamp(17px, 5vw, 23px);
}

/* ===== Panels ===== */
.panel {
    display: none;
    background: #000;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.panel-header {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 16px var(--pad-x) 12px;
    background: rgba(0, 0, 0, .38);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.panel-header h2 {
    margin: 0 0 6px 0;
    font-size: 16px;
    letter-spacing: .4px;
}

.panel-header p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.25;
}

.panel-body {
    padding: 18px var(--pad-x) 26px;
    display: grid;
    gap: 14px;
}

.block {
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 14px;
    padding: 14px;
    background: rgba(255, 255, 255, .03);
}

.block h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.block p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.credits {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

/* ===== Libreto ===== */
.libreto-body {
    padding-top: 22px;
}

.line {
    margin: 0 0 16px 0;
    font-size: clamp(18px, 4.6vw, 24px);
    line-height: 1.22;
    letter-spacing: .2px;
    opacity: .26;
    transition: opacity 140ms linear, transform 140ms linear;
    cursor: pointer;
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 300;
    text-align: center;
}

.line.is-past {
    opacity: .70;
}

.line.is-current {
    opacity: 1;
    text-shadow: 0 0 18px rgba(255, 255, 255, .14);
    font-weight: 500;
}

.line-character {
    font-size: 0.65em;
    color: var(--char-color);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.line-entry {
    margin: 0;
}

.ghost-btn {
    border: 1px solid var(--hair);
    border-radius: 12px;
    background: rgba(255, 255, 255, .04);
    color: var(--fg);
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
}

/* ==== Camera Module ==== */




.cameraPill {
    height: 44px;
    width: 44px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .04);
    backdrop-filter: blur(10px);
    overflow: hidden;
    display: flex;
    align-items: center;
    transition: width 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease);
    display:none;
    margin-left:8px;
}

body.mode-live .cameraPill {
    display: flex;
}

.cameraIconBtn {
    height: 44px;
    width: 44px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .92);
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 44px;
    transition: opacity 140ms var(--ease), transform 180ms var(--ease);
}

.camera-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms var(--ease);
    background: #000;
}

.camera-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.camera-gradient {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;

    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.75) 0%,     /* fuerte arriba (header) */
        rgba(0, 0, 0, 0.35) 20%,    /* transición */
        rgba(0, 0, 0, 0.0) 45%,     /* zona limpia */
        rgba(0, 0, 0, 0.4) 70%,     
        rgba(0, 0, 0, 1) 100%     /* opcional: refuerzo abajo para subtítulos */
    );
}

.subtitle-wrap {
    position: absolute;
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: 80%;
    max-width: 820px;
    transition:
        top 320ms var(--ease),
        transform 320ms var(--ease),
        opacity 220ms var(--ease);
}

body.mode-live.camera-active .render-layer {
    background: #000;
}

body.mode-live.camera-active .camera-layer {
    opacity: 1;
}

.cameraPill.is-active {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .22);
}

body.mode-live.camera-active .subtitle-wrap {
    top: calc(100% - var(--dock-h) - env(safe-area-inset-bottom));
    transform: translate(-50%, -100%);
}

/* ===== Dock ===== */
.dock {
    position: fixed;
    inset: auto 0 0 0;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom));
    padding: 10px var(--pad-x) calc(10px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
    gap: 0;
    background: rgba(0, 0, 0, .92);
    backdrop-filter: blur(10px);
    z-index: 30;
}

.dock-item {
    appearance: none;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .70);
    font-size: 12px;
    letter-spacing: .9px;
    text-transform: uppercase;
    padding: 12px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.dock-item[aria-selected="true"] {
    color: rgba(255, 255, 255, .98);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #ff3b30;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, .12);
    opacity: 0;
}

body.mode-live .live-dot {
    opacity: 1;
}

.dock-underline {
    bottom: calc(10px + env(safe-area-inset-bottom) + 6px);
    height: 2px;
    width: 100%;
    background: rgba(255, 255, 255, .92);
    transition: transform 240ms var(--ease);
    border-radius: 999px;
    margin: auto;
}

/* ===== Modes ===== */
body.mode-live .viewport {
    grid-template-rows: 1fr;
}

body.mode-live .panel {
    display: none;
}

body.mode-programa .viewport,
body.mode-libreto .viewport {
    grid-template-rows: clamp(var(--mini-h-min), var(--mini-h), var(--mini-h-max)) 1fr;
}

body.mode-programa #panelPrograma {
    display: block;
    margin-top: 10vh;
}

body.mode-libreto #panelLibreto {
    display: block;
    margin-top: 10vh;
}

.panel.is-enter {
    animation: panelIn 200ms var(--ease) both;
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Language Pill ===== */
.langPillWrap {
    pointer-events: auto;
    position: relative;
    top: 8px;
    display: flex;
    align-items: center;
}

.langPill {
    height: 44px;
    width: 44px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .04);
    backdrop-filter: blur(10px);
    overflow: hidden;
    display: flex;
    align-items: center;
    transition: width 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease);
}

.langPill.is-open {
    width: max-content;
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .16);
    justify-content: flex-end;
}

.langIconBtn {
    height: 44px;
    width: 44px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .92);
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 44px;
    transition: opacity 140ms var(--ease), transform 180ms var(--ease);
}

.langPill.is-open .langIconBtn {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
}

.langFlags {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    margin: 0;
    flex-wrap: nowrap;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: opacity 160ms var(--ease), transform 180ms var(--ease);
}

.langPill.is-open .langFlags {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.flagBtn {
    height: 32px;
    width: 32px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(0, 0, 0, .18);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 18px;
    line-height: 1;
    transition: transform 120ms var(--ease), background 120ms var(--ease);
}

.flagBtn:active {
    transform: translateY(1px) scale(.98);
}

.flagBtn.active {
    border-color: var(--accent);
    background: rgba(255, 106, 26, .15);
}

.flagBtn img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

/* ===== Fullscreen Pill ===== */
.fullPill {
    margin-left: 10px;
    height: 44px;
    width: 44px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .04);
    backdrop-filter: blur(10px);
    overflow: hidden;
    display: flex;
    align-items: center;
    transition: width 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease);
}

.fullIconBtn {
    height: 44px;
    width: 44px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .92);
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 44px;
    transition: opacity 140ms var(--ease), transform 180ms var(--ease);
}

/* ===== Connection Dot ===== */
.conn-dot {
    position: fixed;
    top: 28px;
    left: 20px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff3b30;
    opacity: 0.4;
    z-index: 25;
    transition: background 0.5s, opacity 0.5s;
}

.conn-dot.ok {
    background: #34c759;
    opacity: 0;
}

/* ===== Idle Fade ===== */
.app-header,
.dock,
.panel div {
    transition: opacity 2000ms cubic-bezier(.22, .61, .36, 1), transform 2000ms cubic-bezier(.22, .61, .36, 1);
    will-change: opacity !important;
}

body.ui-idle .app-header,
body.ui-idle .dock,
body.ui-idle .panel div {
    opacity: 0.15 !important;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .dock-underline {
        transition: none;
    }

    .panel.is-enter {
        animation: none;
    }

    .langPill,
    .langIconBtn,
    .langFlags,
    .flagBtn {
        transition: none;
    }
}

/* =========================================================
   Capture UI (shutter button + preview modal) — v22.04
   ========================================================= */

/* Shutter button — flotando sobre el viewport en modo live + cámara */
.capture-ui {
    /* position: fixed; */
    /* left: 50%; */
    /* transform: translateX(-50%); */
    z-index: 20;
    display: none;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.capture-ui[aria-hidden="false"] {
    display: block;
    pointer-events: auto;
}
body.ui-idle .capture-ui {
    opacity: 0.2;
    pointer-events: none;
}

.capture-btn {
    display: block;
    margin: 0 auto;
    position: relative;
    width: 72px;
    height: 72px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.capture-btn__outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.95);
    box-shadow: 0 2px 14px rgba(0,0,0,0.4);
    transition: transform 0.15s ease;
}
.capture-btn__inner {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    transition: transform 0.12s ease, background 0.15s ease;
}
.capture-btn:active .capture-btn__inner,
.capture-btn.is-pressed .capture-btn__inner {
    transform: scale(0.85);
    background: rgba(255,240,200,0.95);
}

/* Preview modal */
.capture-preview {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.capture-preview[hidden] { display: none !important; }

.capture-preview__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.capture-preview__sheet {
    position: relative;
    background: #141416;
    color: #fff;
    width: 100%;
    max-width: 540px;
    max-height: 92vh;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.6);
    animation: capture-sheet-in 0.28s cubic-bezier(.2,.8,.3,1) both;
}

@media (min-width: 540px) {
    .capture-preview { align-items: center; }
    .capture-preview__sheet {
        border-radius: 16px;
        padding: 18px;
    }
}

@keyframes capture-sheet-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.capture-preview__media {
    flex: 1 1 auto;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}
.capture-preview__media img {
    max-width: 100%;
    max-height: 64vh;
    display: block;
    object-fit: contain;
}

.capture-preview__hint {
    margin: 0;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
    text-align: center;
    line-height: 1.4;
}
.capture-preview__hint:empty { display: none; }

.capture-preview__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.capture-preview__actions > .capture-preview__btn--ghost {
    grid-column: 1 / -1;
}

.capture-preview__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: #fff;
    transition: background 0.15s;
    touch-action: manipulation;
}
.capture-preview__btn:hover { background: rgba(255,255,255,0.1); }
.capture-preview__btn:active { transform: scale(0.98); }
.capture-preview__btn--primary {
    background: linear-gradient(135deg, #833AB4 0%, #FD1D1D 50%, #FCB045 100%); /* Instagram-like */
    border-color: transparent;
}
.capture-preview__btn--primary:hover { filter: brightness(1.08); }
.capture-preview__btn--ghost {
    background: transparent;
    color: rgba(255,255,255,0.6);
}
.capture-preview__btn .material-symbols-outlined {
    font-size: 1.1rem;
}

/* Body lock cuando preview abierto */
body.preview-open {
    overflow: hidden;
}
