/* Storyboards: the page around a board (Pages/Storyboards), its five views, the card panel, and the canvas that
   js/storyboard-canvas.js moves. The header and panels borrow the whiteboard page's (.wbp, whiteboard.css). */

/* ---- the page ---- */
.stb { position: relative; min-height: 0; height: 100%; }
.stb__bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; padding: .45rem 1.25rem;
    border-bottom: 1px solid var(--rl-border); background: var(--rl-surface);
}
.stb__add { display: inline-flex; align-items: center; gap: .35rem; }
.stb__add select { max-width: 12rem; }
.stb__count { margin-left: auto; font-size: .8rem; color: var(--rl-text-muted); }
.stb__message { margin: .5rem 1.25rem 0; display: flex; align-items: center; gap: .5rem; }
.stb__main { position: relative; flex: 1; min-height: 0; display: flex; }
.stb__view { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.stb__view--canvas, .stb__view--dialogue { overflow: hidden; }
.stb__typesPanel { max-height: 60%; }

.stb-peers { display: inline-flex; align-items: center; }
.stb-peers__dot, .sbc__peer {
    display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-left: -.3rem; border-radius: 50%;
    background: var(--peer-color, var(--rl-accent)); color: #fff; font: 700 .66rem/1 system-ui, sans-serif;
    border: 2px solid var(--rl-surface);
}
.stb-panel__x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 .2rem; opacity: .7; }
.stb-panel__x:hover { opacity: 1; }
.stb-hidden { display: none; }
.stb-empty { margin: auto; max-width: 32rem; padding: 2rem; text-align: center; color: var(--rl-text-muted); display: flex; flex-direction: column; gap: .75rem; align-items: center; }

/* The card's sketch: the whiteboard page, embedded, over everything. */
.stb-sketch {
    position: fixed; inset: 0; z-index: 1050; display: flex; flex-direction: column; background: var(--rl-surface);
}

/* ---- the canvas ---- */
.sbc {
    position: relative; flex: 1; min-height: 0; overflow: hidden; outline: none; touch-action: none; user-select: none;
    background-color: var(--rl-surface-sunken);
    background-image: radial-gradient(circle, color-mix(in srgb, var(--rl-text) 14%, transparent) 1px, transparent 1.2px);
    background-size: 24px 24px;
}
.sbc__world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.sbc__links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.sbc__link { fill: none; stroke: color-mix(in srgb, var(--rl-text) 45%, transparent); stroke-width: 2; }
.sbc__link--leadsto { stroke: var(--rl-accent); }
.sbc__link--choice { stroke: #d97706; stroke-width: 2.4; }
.sbc__link--requires { stroke: #dc2626; stroke-dasharray: 7 4; }
.sbc__link--appearsin { stroke: #db2777; stroke-dasharray: 2 4; }
.sbc__link--belongsto { stroke: #16a34a; stroke-dasharray: 10 3 2 3; }
.sbc__link.is-on { stroke-width: 4; filter: drop-shadow(0 0 3px var(--rl-accent)); }
.sbc__hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.sbc__arrowhead { fill: color-mix(in srgb, var(--rl-text) 55%, transparent); }
.sbc__label {
    font: 600 12px/1 system-ui, sans-serif; fill: var(--rl-text); paint-order: stroke; stroke: var(--rl-surface-sunken);
    stroke-width: 4px; pointer-events: all; cursor: pointer;
}
.sbc__label.is-on { fill: var(--rl-accent); }
.sbc__temp { fill: none; stroke: var(--rl-accent); stroke-width: 2; stroke-dasharray: 6 4; }

.sbc__card {
    position: absolute; box-sizing: border-box; display: flex; flex-direction: column; gap: .3rem; padding: 0 0 .55rem;
    background: var(--rl-surface); color: var(--rl-text); border: 1px solid var(--rl-border);
    border-top: 4px solid var(--card-color, var(--rl-accent)); border-radius: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .12); cursor: grab; overflow: visible;
}
.sbc__card > :not(.sbc__port):not(.sbc__cover):not(.sbc__band) { padding: 0 .7rem; }
.sbc__card.is-selected { outline: 3px solid var(--rl-accent); outline-offset: 2px; }
.sbc__card.is-peer { box-shadow: 0 0 0 3px var(--peer-color), 0 2px 8px rgba(15, 23, 42, .12); }
.sbc__card.is-dragging { cursor: grabbing; box-shadow: 0 12px 30px rgba(15, 23, 42, .25); z-index: 2; }
.sbc--readonly .sbc__card { cursor: pointer; }
.sbc__band {
    display: flex; align-items: center; gap: .35rem; padding: .3rem .6rem .1rem; font-size: .72rem; font-weight: 600;
    color: var(--card-color, var(--rl-text-muted)); text-transform: uppercase; letter-spacing: .03em;
}
.sbc__icon { font-size: .95rem; text-transform: none; }
.sbc__busy { margin-left: auto; text-transform: none; }
.sbc__peer { margin-left: auto; width: 1.3rem; height: 1.3rem; }
.sbc__cover { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; pointer-events: none; }
.sbc__title { font-weight: 650; font-size: .95rem; line-height: 1.25; overflow-wrap: anywhere; }
.sbc__summary {
    font-size: .8rem; line-height: 1.4; color: var(--rl-text-muted);
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.sbc__speaker { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rl-text-muted); }
.sbc__line { font-size: .9rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.sbc__meta { font-size: .76rem; color: var(--rl-text-muted); font-style: italic; }
.sbc__badges { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .72rem; color: var(--rl-text-muted); }
.sbc__port {
    position: absolute; right: -8px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%;
    background: var(--card-color, var(--rl-accent)); border: 2px solid var(--rl-surface); cursor: crosshair;
    opacity: 0; transition: opacity .12s;
}
.sbc__card:hover .sbc__port, .sbc__card.is-selected .sbc__port { opacity: 1; }
@media (pointer: coarse) { .sbc__port { opacity: 1; width: 20px; height: 20px; margin-top: -10px; right: -11px; } }

.sbc__hud {
    position: absolute; left: .75rem; bottom: .75rem; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
    padding: .35rem .5rem; border-radius: 12px; background: var(--rl-surface); border: 1px solid var(--rl-border);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .14); font-size: .78rem; max-width: calc(100% - 1.5rem);
}
.sbc__kind { display: inline-flex; align-items: center; gap: .3rem; color: var(--rl-text-muted); }
.sbc__hint { color: var(--rl-text-muted); }
.sbc__empty {
    position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--rl-text-muted);
    text-align: center; padding: 2rem;
}
.sbc--dialogue .sbc__card { border-radius: 14px; }

/* ---- the outline ---- */
.stb-outline { padding: 1rem 1.25rem 3rem; }
.stb-outline__list { list-style: none; margin: 0; padding: 0; }
.stb-outline__list .stb-outline__list { padding-left: 1.4rem; border-left: 1px dashed var(--rl-border); margin-left: .6rem; }
.stb-outline__row { display: flex; align-items: center; gap: .35rem; padding: .15rem 0; }
.stb-outline__item.is-selected > .stb-outline__row { background: color-mix(in srgb, var(--rl-accent) 10%, transparent); border-radius: 8px; }
.stb-outline__fold { width: 1.4rem; flex: none; border: 0; background: none; color: var(--rl-text-muted); cursor: pointer; }
.stb-outline__name {
    flex: 1; min-width: 0; display: flex; align-items: baseline; gap: .45rem; text-align: left; border: 0; background: none;
    color: var(--rl-text); cursor: pointer; padding: .3rem .4rem; border-left: 3px solid var(--card-color); border-radius: 0 6px 6px 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stb-outline__name:hover { background: var(--rl-surface-sunken); }
.stb-outline__type { font-size: .75rem; color: var(--rl-text-muted); }
.stb-outline__summary { font-size: .82rem; color: var(--rl-text-muted); overflow: hidden; text-overflow: ellipsis; }
.stb-outline__tools { display: inline-flex; gap: .2rem; opacity: 0; transition: opacity .12s; }
.stb-outline__row:hover .stb-outline__tools, .stb-outline__row:focus-within .stb-outline__tools { opacity: 1; }
@media (pointer: coarse) { .stb-outline__tools { opacity: 1; } }

/* ---- the timeline ---- */
.stb-timeline { padding: 1rem 1.25rem 3rem; display: flex; flex-direction: column; gap: 1.1rem; }
.stb-timeline__add { flex-wrap: wrap; gap: .4rem; }
.stb-timeline__track { font-size: .85rem; margin: 0 0 .4rem; color: var(--rl-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stb-timeline__strip { list-style: none; margin: 0; padding: .5rem; display: flex; gap: .7rem; overflow-x: auto; background: #111827; border-radius: 10px; }
.stb-frame { flex: none; width: 11rem; display: flex; flex-direction: column; gap: .3rem; }
.stb-frame__face {
    position: relative; display: flex; flex-direction: column; gap: .2rem; text-align: left; padding: 0 0 .5rem; border: 0; cursor: pointer;
    border-radius: 6px; overflow: hidden; background: var(--rl-surface); color: var(--rl-text); border-top: 4px solid var(--card-color);
}
.stb-frame.is-selected .stb-frame__face { outline: 3px solid var(--rl-accent); }
.stb-frame__face img, .stb-frame__blank { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.stb-frame__blank { display: grid; place-items: center; font-size: 2rem; background: var(--rl-surface-sunken); }
.stb-frame__face strong, .stb-frame__summary { padding: 0 .5rem; }
.stb-frame__summary { font-size: .74rem; color: var(--rl-text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stb-frame__num {
    position: absolute; left: .35rem; top: .35rem; min-width: 1.4rem; height: 1.4rem; display: grid; place-items: center;
    border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .72rem; font-weight: 700;
}
.stb-frame__tools { display: flex; gap: .25rem; justify-content: center; }

/* ---- the dialogue view ---- */
.stb-dialogue { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stb-dialogue__bar { padding: .5rem 1rem; flex-wrap: wrap; gap: .4rem; border-bottom: 1px solid var(--rl-border); }
.stb-dialogue__status { padding: .3rem 1rem; }
.stb-script { list-style: none; margin: 0; padding: 1rem 1.25rem 3rem; overflow: auto; display: flex; flex-direction: column; gap: .6rem; max-width: 52rem; }
.stb-script__line { display: grid; grid-template-columns: 9rem 1fr auto; gap: .75rem; align-items: start; padding: .3rem .4rem; border-radius: 8px; }
.stb-script__line.is-selected { background: color-mix(in srgb, var(--rl-accent) 10%, transparent); }
.stb-script__who { text-align: right; font-weight: 700; text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; border: 0; background: none; color: var(--rl-text); cursor: pointer; }
.stb-script__what { white-space: pre-wrap; line-height: 1.5; }
.stb-script__direction { color: var(--rl-text-muted); font-style: italic; margin-left: .3rem; }
.stb-script__choice { color: #b45309; font-size: .85rem; margin-top: .2rem; }
.stb-play { margin: auto; width: min(40rem, 100%); padding: 2rem 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }
.stb-play__line { display: flex; gap: 1rem; align-items: flex-start; padding: 1.25rem; border-radius: 14px; background: var(--rl-surface); border: 1px solid var(--rl-border); }
.stb-play__face { width: 5.5rem; height: 5.5rem; border-radius: 12px; object-fit: cover; flex: none; }
.stb-play__who { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .8rem; color: var(--rl-text-muted); }
.stb-play__text { font-size: 1.15rem; line-height: 1.5; margin: .3rem 0 .6rem; white-space: pre-wrap; }
.stb-play__choices { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.stb-play__choices .btn { justify-content: flex-start; text-align: left; }

/* ---- the codex ---- */
.stb-codex { flex: 1; min-height: 0; display: grid; grid-template-columns: 16rem 1fr; }
.stb-codex__index { overflow: auto; padding: .9rem; border-right: 1px solid var(--rl-border); background: var(--rl-surface); display: flex; flex-direction: column; gap: .4rem; }
.stb-codex__index ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.stb-codex__group { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rl-text-muted); margin: .6rem 0 .1rem; }
.stb-codex__entry {
    width: 100%; display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; border: 0; border-radius: 8px;
    background: none; color: var(--rl-text); text-align: left; cursor: pointer;
}
.stb-codex__entry img { width: 1.8rem; height: 1.8rem; border-radius: 6px; object-fit: cover; }
.stb-codex__entry:hover { background: var(--rl-surface-sunken); }
.stb-codex__entry.is-on { background: color-mix(in srgb, var(--rl-accent) 14%, transparent); }
.stb-codex__new { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .8rem; }
.stb-codex__page { overflow: auto; padding: 1.5rem 2rem 3rem; max-width: 60rem; }
.stb-codex__head { display: flex; gap: 1.25rem; align-items: flex-start; padding-bottom: 1rem; border-bottom: 3px solid var(--card-color); margin-bottom: 1rem; }
.stb-codex__head h2 { margin: .1rem 0 .4rem; font-size: 1.6rem; }
.stb-codex__portrait { width: 11rem; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; flex: none; }
.stb-codex__kicker { font-size: .8rem; color: var(--card-color); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stb-codex__summary { color: var(--rl-text-muted); margin: 0 0 .6rem; }
.stb-codex__fields { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0 0 1.25rem; }
.stb-codex__fields dt { font-weight: 600; color: var(--rl-text-muted); }
.stb-codex__fields dd { margin: 0; white-space: pre-wrap; }
.stb-codex__box, .stb-codex__gallery, .stb-codex__backlinks { margin-bottom: 1.25rem; }
.stb-codex__box h3, .stb-codex__gallery h3, .stb-codex__backlinks h3 { font-size: 1rem; margin: 0 0 .4rem; }
.stb-codex__box p { white-space: pre-wrap; margin: 0; }
.stb-codex__backlinks ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }

/* ---- shared bits ---- */
.stb-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.stb-chip {
    display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; font-size: .82rem;
    border: 1px solid var(--rl-border); background: var(--rl-surface-sunken); color: var(--rl-text); cursor: pointer;
}
.stb-chip__go, .stb-chip__x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font: inherit; }
.stb-chip__x { opacity: .6; }
.stb-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .5rem; }
.stb-gallery figure { margin: 0; display: flex; flex-direction: column; gap: .25rem; padding: .3rem; border-radius: 8px; border: 1px solid var(--rl-border); }
.stb-gallery figure.is-cover { border-color: var(--rl-accent); box-shadow: 0 0 0 1px var(--rl-accent); }
.stb-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.stb-gallery audio { width: 100%; }
.stb-gallery input { font-size: .76rem; padding: .15rem .3rem; }
.stb-gallery figcaption { font-size: .76rem; color: var(--rl-text-muted); }
.stb-gallery__tools { display: flex; gap: .25rem; flex-wrap: wrap; }
/* A document on a card: its kind and size in a square the size of a picture, a download when pressed. */
.stb-file { aspect-ratio: 1; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; text-decoration: none; color: var(--rl-text-muted); background: color-mix(in srgb, var(--rl-text) 5%, transparent); }
.stb-file:hover { background: color-mix(in srgb, var(--rl-accent) 10%, transparent); }
.stb-file__badge { min-width: 2.6rem; padding: .45rem .4rem; border-radius: 6px; background: #7c3aed; color: #fff; font: 700 .75rem/1 system-ui, sans-serif; text-align: center; }
.stb-file__size { font-size: .72rem; }
/* Files or text being dragged over the canvas or a card's panel. */
.sbc--drop, .stb-panel.is-drop { outline: 3px dashed var(--rl-accent); outline-offset: -6px; }

/* ---- the card types editor ---- */
.stb-types { display: grid; grid-template-columns: 14rem 1fr; gap: 1rem; }
.stb-types__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.stb-types__item {
    width: 100%; display: flex; align-items: center; gap: .45rem; padding: .3rem .45rem; border: 0; border-left: 3px solid var(--card-color);
    border-radius: 0 6px 6px 0; background: none; color: var(--rl-text); text-align: left; cursor: pointer;
}
.stb-types__item .ui-sub { margin-left: auto; }
.stb-types__item.is-on, .stb-types__item:hover { background: var(--rl-surface-sunken); }
.stb-types__row { display: flex; gap: .75rem; flex-wrap: wrap; }
.stb-types__row .field:first-child { flex: 1; min-width: 10rem; }
.stb-types__icon { width: 6rem; }
.stb-types__head { margin: .8rem 0 .3rem; font-size: .95rem; }
.stb-types__field { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--rl-border); }
.stb-types__field input, .stb-types__field select { flex: 1 1 8rem; min-width: 0; }
.stb-types__tools { display: inline-flex; gap: .2rem; }

/* ---- the card panel ---- */
.stb-panel {
    width: min(26rem, 100%); flex: none; display: flex; flex-direction: column; min-height: 0;
    border-left: 1px solid var(--rl-border); background: var(--rl-surface); box-shadow: -6px 0 18px rgba(15, 23, 42, .08);
}
.stb-panel__head { display: flex; align-items: center; gap: .5rem; padding: .6rem .9rem; border-bottom: 3px solid var(--card-color); }
.stb-panel__icon { font-size: 1.3rem; }
.stb-panel__type { flex: 1; min-width: 0; font-weight: 600; }
.stb-panel__body { flex: 1; min-height: 0; overflow-y: auto; padding: .8rem .9rem 2rem; display: flex; flex-direction: column; gap: .75rem; }
.stb-panel__title { font-size: 1.15rem; font-weight: 650; padding: .3rem .45rem; }
.stb-panel__summary { resize: vertical; }
.stb-panel__message {
    margin: 0; padding: .45rem .6rem; border-radius: 8px; font-size: .85rem; display: flex; gap: .4rem; align-items: flex-start;
    background: color-mix(in srgb, var(--rl-accent) 10%, transparent);
}
.stb-panel__section { display: flex; flex-direction: column; gap: .45rem; padding-top: .65rem; border-top: 1px solid var(--rl-border); }
.stb-panel__section h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rl-text-muted); margin: 0; }
.stb-panel__section .field { display: flex; flex-direction: column; gap: .2rem; }
.stb-panel__section .field label { font-size: .8rem; font-weight: 600; }
.stb-panel input:not([type=checkbox]):not([type=color]), .stb-panel select, .stb-panel textarea { width: 100%; box-sizing: border-box; }
.stb-panel__row { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.stb-panel__row input:not([type=checkbox]):not([type=color]), .stb-panel__row select { width: auto; flex: 1 1 8rem; min-width: 0; }
.stb-panel__check { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }
.stb-panel__count { max-width: 4.5rem; flex: 0 0 4.5rem !important; }
.stb-panel__danger { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: .85rem; }
.stb-box { display: flex; flex-direction: column; gap: .25rem; }
.stb-box__head { display: flex; gap: .3rem; align-items: center; }
.stb-box__head input { font-weight: 600; }
.stb-written { padding: .6rem; border-radius: 8px; background: var(--rl-surface-sunken); border: 1px solid var(--rl-border); }
.stb-written p { white-space: pre-wrap; margin: 0 0 .5rem; font-size: .88rem; line-height: 1.5; }
.stb-link { display: flex; flex-direction: column; gap: .25rem; padding: .35rem; border-radius: 8px; }
.stb-link.is-on { background: color-mix(in srgb, var(--rl-accent) 12%, transparent); }

/* A phone has no room beside the view, so the panel covers it. */
@media (max-width: 860px) {
    .stb-panel { position: absolute; inset: 0 0 0 auto; z-index: 6; width: min(26rem, 100%); }
    .stb-codex { grid-template-columns: 1fr; }
    .stb-codex__index { max-height: 12rem; border-right: 0; border-bottom: 1px solid var(--rl-border); }
    .stb-types { grid-template-columns: 1fr; }
    .stb-script__line { grid-template-columns: 1fr; }
    .stb-script__who { text-align: left; }
}

/* Printing gives the outline, the timeline, the script or the codex as a clean document; the browser saves it as a PDF. */
@media print {
    .stb__bar, .stb__head .wbp__actions, .wbp__panel, .stb-panel, .sbc__hud, .stb-outline__tools, .stb-frame__tools,
    .stb-codex__index, .stb-dialogue__bar, .stb-timeline__add, .stb__message, .wbp__viewonly { display: none !important; }
    .stb, .stb__main, .stb__view, .stb-codex, .stb-codex__page, .stb-dialogue { display: block !important; overflow: visible !important; height: auto !important; }
    .stb-timeline__strip { background: none; flex-wrap: wrap; }
    .stb-codex__head, .stb-codex__box, .stb-frame, .stb-script__line { break-inside: avoid; }
}
