/* ============================================================
   ESCENAS — layout de la aplicación
   Construido sobre halogen.css (tokens y componentes del kit).
   ============================================================ */

html, body { height: 100%; overflow: hidden; }

body {
    display: flex;
    flex-direction: column;
}

body > * { position: relative; z-index: 1; }
body > .hk-backdrop { z-index: 0; }

/* ------------------------------------------------------------
   BARRA SUPERIOR
   ------------------------------------------------------------ */
.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    box-shadow: inset 0 -1px 0 var(--hairline);
    background: rgba(10, 13, 10, .7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.wordmark__text {
    font-size: 19px;
    font-weight: 900;
    letter-spacing: -.04em;
    line-height: 1;
}

.wordmark__text b { color: var(--halogen); font-weight: 900; }

.topbar__right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar__hint { text-align: right; }

/* ------------------------------------------------------------
   ESTRUCTURA
   ------------------------------------------------------------ */
.layout {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

/* ------------------------------------------------------------
   LIENZO
   ------------------------------------------------------------ */
.stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

#escena-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

#escena-canvas.is-grabbing { cursor: grabbing; }
#escena-canvas.is-over { cursor: pointer; }
.stage[data-vista="plano"] #escena-canvas { cursor: default; }

/* Corchetes de encuadre */
.frame-marks {
    position: absolute;
    inset: 24px;
    pointer-events: none;
}

.frame-marks i {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(163, 230, 53, .3);
}

.frame-marks i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.frame-marks i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.frame-marks i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.frame-marks i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* Etiquetas flotantes de los marcadores */
.labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.labels.is-hidden { display: none; }

.puck-label {
    position: absolute;
    transform: translate(-50%, -50%);
    padding: 3px 10px;
    border-radius: var(--r-pill);
    background: rgba(10, 13, 10, .85);
    box-shadow: inset 0 0 0 1px var(--hairline);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.puck-label--camera {
    color: var(--halogen);
    box-shadow: inset 0 0 0 1px rgba(163, 230, 53, .5);
}

.puck-label--focus { box-shadow: inset 0 0 0 1px rgba(163, 230, 53, .32); }

/* Controles flotantes sobre el lienzo */
.stage-top {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    pointer-events: none;
}

.stage-top > * { pointer-events: auto; }
.stage-top .spacer { flex: 1 1 0; pointer-events: none; }

.icon-row { display: flex; gap: 8px; }

/* Píldora descriptiva del encuadre */
.shot-readout {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: stretch;
    max-width: calc(100% - 48px);
    border-radius: var(--r-pill);
    background: rgba(10, 13, 10, .9);
    box-shadow: inset 0 0 0 1px var(--hairline);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
}

.shot-readout output {
    padding: 9px 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shot-readout .copy-btn {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    box-shadow: inset 1px 0 0 var(--hairline);
    color: var(--ink-dim);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    padding: 0 15px;
    cursor: pointer;
    transition: background var(--morph), color var(--morph);
}

.shot-readout .copy-btn:hover { background: var(--halogen-soft); color: var(--halogen); }
.shot-readout .copy-btn.is-done { color: var(--halogen); }

/* ------------------------------------------------------------
   BARRA LATERAL
   ------------------------------------------------------------ */
.sidebar {
    flex: 0 0 340px;
    width: 340px;
    box-shadow: inset 1px 0 0 var(--hairline);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--hairline) transparent;
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 8px; }

/* ------------------------------------------------------------
   TIPO DE PLANO
   ------------------------------------------------------------ */
.shot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.shot-btn {
    padding: 11px 8px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--raised);
    box-shadow: inset 0 0 0 1px var(--hairline);
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--morph), box-shadow var(--morph), border-radius var(--morph);
}

.shot-btn:hover { box-shadow: inset 0 0 0 1px rgba(163, 230, 53, .45); }

.shot-btn[aria-pressed="true"] {
    background: var(--halogen);
    color: var(--canvas);
    border-radius: var(--r-morph);
    box-shadow: 0 4px 18px rgba(163, 230, 53, .26);
}

/* ------------------------------------------------------------
   CAMPOS CON SLIDER
   ------------------------------------------------------------ */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.field__head label { font-size: 12.5px; color: var(--ink-dim); }

.field__value {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--halogen);
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
   SUJETOS
   ------------------------------------------------------------ */
.subject-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.subject-card {
    background: var(--raised);
    border-radius: var(--r-morph);
    box-shadow: inset 0 0 0 1px var(--hairline);
    padding: 11px;
    min-width: 0;
    transition: box-shadow var(--morph);
}

.subject-card.is-focus { box-shadow: inset 0 0 0 1px rgba(163, 230, 53, .5); }

.subject-card__head {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.subject-name {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    font-size: 12.5px;
    font-weight: 700;
    padding: 2px 0;
    outline: none;
    box-shadow: inset 0 -1px 0 transparent;
    text-overflow: ellipsis;
    transition: box-shadow var(--morph);
}

.subject-name:focus { box-shadow: inset 0 -1px 0 var(--halogen); }

.mini-btn {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-dim);
    cursor: pointer;
    transition: background var(--morph), color var(--morph);
}

.mini-btn:hover { background: rgba(255, 255, 255, .06); color: var(--ink); }
.mini-btn svg { width: 13px; height: 13px; display: block; }

.mini-btn[aria-pressed="true"] {
    background: var(--halogen);
    color: var(--canvas);
}

.subject-card .field { margin-bottom: 9px; }
.subject-card .field__head label { font-size: 11px; }
.subject-card .field__value { font-size: 10.5px; }

/* ------------------------------------------------------------
   PROMPT
   ------------------------------------------------------------ */
.prompt-row { margin-bottom: 12px; }
.prompt-row:last-child { margin-bottom: 0; }

.prompt-row > label {
    display: block;
    font-size: 12.5px;
    color: var(--ink-dim);
    margin-bottom: 6px;
}

.prompt-out {
    border-radius: var(--r-morph);
    background: var(--canvas);
    box-shadow: inset 0 0 0 1px var(--hairline);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.65;
    color: var(--ink);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.prompt-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.prompt-actions .hk-btn { flex: 1 1 0; }

/* ------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 900px) {
    html, body { overflow: auto; }
    body { height: auto; min-height: 100%; }
    .layout { flex-direction: column; }
    .stage { flex: 0 0 auto; height: 60vh; min-height: 340px; }
    .sidebar {
        flex: 1 1 auto;
        width: 100%;
        box-shadow: inset 0 1px 0 var(--hairline);
        overflow-y: visible;
    }
    .subject-grid { grid-template-columns: 1fr; }
    .element-list { grid-template-columns: 1fr; }
    .topbar__hint { display: none; }
}

@media (max-width: 520px) {
    .topbar { padding: 10px 14px; }
    .stage-top { top: 12px; left: 12px; right: 12px; flex-wrap: wrap; }
    .stage-top .spacer { display: none; }
    .shot-readout { bottom: 14px; }
    .shot-readout output { font-size: 10px; padding: 8px 12px; }
}

/* ------------------------------------------------------------
   ELEMENTOS DE ESCENA
   ------------------------------------------------------------ */
.panel-note {
    font-size: 11px;
    line-height: 1.45;
    color: var(--ink-dim);
    margin: 0 0 8px;
}
.panel-note + .add-grid { margin-bottom: 14px; }

.add-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 7px;
}
.add-grid--tpl { grid-template-columns: 1fr 1fr; }

.add-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    padding: 9px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--raised);
    box-shadow: inset 0 0 0 1px var(--hairline);
    color: var(--ink);
    cursor: pointer;
    transition: border-radius var(--morph), box-shadow var(--morph), background var(--morph);
}
.add-grid--tpl .add-btn { border-radius: var(--r-morph); }
.add-btn b { font-size: 11.5px; font-weight: 700; }
.add-btn span {
    font-size: 9.5px;
    letter-spacing: .06em;
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
}
.add-btn:hover:not(:disabled) {
    border-radius: var(--r-morph);
    background: var(--halogen-soft);
    box-shadow: inset 0 0 0 1px rgba(163, 230, 53, .5);
}
.add-btn:disabled { opacity: .38; cursor: not-allowed; }

.element-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}
.element-list:empty { display: none; }

.element-card {
    background: var(--raised);
    border-radius: var(--r-morph);
    box-shadow: inset 0 0 0 1px var(--hairline);
    padding: 11px;
    min-width: 0;
    transition: box-shadow var(--morph), opacity var(--morph);
}
/* Sigue en la escena, pero no entra en la toma */
.element-card.is-out { opacity: .55; }
.element-card.is-out .element-card__tag::after {
    content: ' · fuera del plano';
    color: var(--halogen);
}

.element-card__tag {
    font-size: 9.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin: -4px 0 10px;
}

.element-card .field { margin-bottom: 9px; }
.element-card .field__head label { font-size: 11px; }
.element-card .field__value { font-size: 10.5px; }

/* ------------------------------------------------------------
   TARJETA BLOQUEADA: lo que llegará más adelante
   ------------------------------------------------------------ */
.hk-card--locked { position: relative; overflow: hidden; }
.hk-card--locked .soon-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Capa translúcida: se lee lo que hay debajo, pero queda claro que
   todavía no se puede tocar */
.soon-veil {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(180deg, rgba(10, 13, 10, .62), rgba(10, 13, 10, .78));
    backdrop-filter: blur(1.5px) saturate(.7);
    -webkit-backdrop-filter: blur(1.5px) saturate(.7);
}

.soon-veil b {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.soon-veil__lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--r-morph);
    background: var(--halogen-soft);
    box-shadow: inset 0 0 0 1px rgba(163, 230, 53, .38);
    color: var(--halogen);
}

.soon-veil__lock svg { width: 17px; height: 17px; display: block; }
.hk-card--locked .soon-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 0;
    box-shadow: inset 0 -1px 0 var(--hairline);
}
.hk-card--locked .soon-list li:last-child { box-shadow: none; }
.hk-card--locked .soon-list b { font-size: 12px; color: var(--ink); }
.hk-card--locked .soon-list span { font-size: 11px; line-height: 1.45; color: var(--ink-dim); }

/* Selector de postura dentro de la tarjeta de sujeto */
.hk-select--mini {
    padding: 7px 9px;
    font-size: 11.5px;
}
