/* Host shell styling. Deliberately minimal: a scrolling transcript over a single
   input line. Prose and the input field use a proportional system font (modern
   style); fixed-width is a per-span style (.style-fixed), not the default — that is
   the only place columns align. The shell renders game output as text nodes into
   #transcript (white-space preserved so intentional spacing survives); it never
   sets innerHTML from game text. */

:root {
    --bg: #1a1a1a;
    --fg: #e6e6e6;
    --dim: #8a8a8a;
    --accent: #cda434;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 80ch;
    margin: 0 auto;
    padding: 1rem;
}
/* With a visible side pane (shell.js toggles the class), widen the play area so
   the pane extends the layout instead of eating the transcript's 80ch. */
#screen.has-side-panes {
    max-width: 118ch;
}

/* Text-window layout (devdocs/text-windows.md): top panes / a middle row of
   left panes + transcript + right panes / bottom panes. Empty containers (and
   hidden panes) collapse to nothing, so a game without windows renders exactly
   as before. The right/bottom containers reverse their flex direction so a
   lower `order` (= the game's priority) is always nearer its screen edge. */
#main-row {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}
#win-top {
    display: flex;
    flex-direction: column;
}
#win-bottom {
    display: flex;
    flex-direction: column-reverse;
}
/* Side-dock containers are fixed-size flanks: flex 0 0 auto so the transcript
   (min-width: 0) absorbs any squeeze, clamped to 45% of the row so a huge
   declared pane never crushes the transcript below half. The clamp must live
   HERE, not on .pane — a percentage max-width on the pane would resolve
   against this auto-sized container (circular) and crush the pane itself. */
#win-left {
    display: flex;
    flex-direction: row;
    flex: 0 0 auto;
    max-width: 45%;
    overflow: hidden;
}
#win-right {
    display: flex;
    flex-direction: row-reverse;
    flex: 0 0 auto;
    max-width: 45%;
    overflow: hidden;
}

/* The transcript column: transcript + its [more] pager, so the pager sits at
   the transcript's immediate bottom edge rather than the screen bottom (bottom
   panes and custom-shell strips stack below the column). */
#transcript-col {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#transcript {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    scrollbar-width: none;
}
#transcript::-webkit-scrollbar {
    display: none;
}

/* A text-window pane: monospace (the game composes lines expecting columns to
   hold), fixed size in its own text metrics (shell.js sets width for side panes,
   height for top/bottom, from the game's declared rows/cols), overflow clipped —
   the declared size is a reservation, not a scroll area. Margins sit on the pane
   (not the container) so hidden panes contribute no gap. */
.pane {
    flex: 0 0 auto;
    background: #222;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-family: "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    overflow: hidden;
}
.pane[hidden] {
    display: none;
}
#win-top .pane {
    margin-bottom: 0.5rem;
}
#win-bottom .pane {
    margin-top: 0.5rem;
}
#win-left .pane {
    margin-right: 0.75rem;
}
#win-right .pane {
    margin-left: 0.75rem;
}
/* .pane-side is a JS hook (title header, has-side-panes tracking); the width
   clamp lives on the dock containers above, where percentages resolve against
   the definite #main-row width. */

/* A canvas (freestyle) pane (devdocs/freestyle-windows.md): the <canvas> fills
   the pane box minus padding; shell.js scales the declared virtual space into
   it (aspect preserved, centered) and repaints from its cached draw list on
   resize. The pane box itself keeps the ordinary pane chrome. */
.pane-canvas {
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
}
.pane-canvas-surface {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}
.pane-canvas-surface[hidden] {
    display: none;
}
/* A side canvas pane must not stretch taller than its dock row by content —
   the canvas has no intrinsic height; let the flex row set it. */
#win-left .pane-canvas, #win-right .pane-canvas {
    align-self: stretch;
}

/* `look "bar"` — the traditional status-line identity: reverse-video colors
   (foreground/background swapped), full width, no border/rounding/title. The
   traditional-white bar overrides the pane box look; sizing/margins stay the
   pane's. Future direction (devdocs/text-windows.md): general styling fields
   (reverse, background color) instead of enumerated looks. */
.pane-bar {
    background: var(--fg);
    color: var(--bg);
    border: none;
    border-radius: 0;
    padding: 0.1rem 0.5rem;
}

.pane-title {
    color: var(--dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
}

/* One content line: runs laid out on a flex row so fill runs consume the slack.
   min-height keeps a deliberately blank line one row tall. */
.pane-line {
    display: flex;
    min-height: 1.4em;
}
.pane-run {
    white-space: pre;
    flex: 0 0 auto;
}
/* A fill run: its (repeated) char fills whatever slack the line has; clipped at
   the line's edge. This is how rules and the left/right split render. */
.pane-fill {
    flex: 1 1 auto;
    overflow: hidden;
    white-space: pre;
    min-width: 0;
}
.pane-align-right {
    margin-left: auto;
}
.pane-align-center {
    margin-left: auto;
    margin-right: auto;
}

/* (The former #status-bar is retired: the traditional status line is now a
   `look "bar"` text window — see .pane-bar below and lib/advent/status.lamp.) */

/* "[more]" pager bar: a reverse-video, full-width row below the transcript, shown
   only while paused. Being a flex row (not an overlay) it shrinks the scroll area, so
   it never covers transcript text. Any key or a click advances a page. */
#more-bar {
    flex: 0 0 auto;
    margin-top: 0.5rem;
    padding: 0.1rem 0.5rem;
    background: var(--fg);
    color: var(--bg);
    font-family: "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, monospace;
    text-align: center;
    cursor: pointer;
    user-select: none;
}
#more-bar[hidden] {
    display: none;
}

.prompt-text {
    color: var(--accent);
}

.player-echo {
    color: var(--accent);
}

.shell-notice {
    color: var(--dim);
    font-style: italic;
}

.shell-error {
    color: #e06c5a;
}

/* Type styles (text.md I3). Prose is proportional, so .style-fixed is the monospace
   island — the one place column/indent alignment holds (combined with the inherited
   pre-wrap whitespace). A style the shell doesn't define renders plain
   (fail-silently). */
.style-bold {
    font-weight: bold;
}

.style-italic {
    font-style: italic;
}

.style-fixed {
    font-family: "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, monospace;
    white-space: pre-wrap;
}

/* A [fit] block (text.md I3): a column-true composition scaled by shell.js so
   its widest line fits the transcript (inline-block + pre make scrollWidth the
   widest line; one block, one font-size ratio). Below the readability floor the
   shrink stops and the block scrolls horizontally instead. TTY hosts ignore the
   style entirely. */
.style-fit {
    display: inline-block;
    white-space: pre;
    max-width: 100%;
    overflow-x: auto;
    vertical-align: bottom;
}

/* Color styles: the ANSI/Z-machine 16 (foreground). Shades are theme variables
   chosen for legibility on the dark default background — a reskinned shell
   overrides the variables, not the classes. "black" renders as a visible dark
   grey (true black would vanish on this background), mirroring how terminal
   themes treat ANSI black. */
:root {
    --c-black: #6b6b6b;
    --c-red: #e06c75;
    --c-green: #98c379;
    --c-yellow: #e5c07b;
    --c-blue: #61afef;
    --c-magenta: #c678dd;
    --c-cyan: #56b6c2;
    --c-white: #dcdfe4;
    --c-bright-black: #8a8a8a;
    --c-bright-red: #ff8b94;
    --c-bright-green: #b5e890;
    --c-bright-yellow: #f4d18c;
    --c-bright-blue: #84c8ff;
    --c-bright-magenta: #de9bee;
    --c-bright-cyan: #6fd6e2;
    --c-bright-white: #ffffff;
}

.style-black { color: var(--c-black); }
.style-red { color: var(--c-red); }
.style-green { color: var(--c-green); }
.style-yellow { color: var(--c-yellow); }
.style-blue { color: var(--c-blue); }
.style-magenta { color: var(--c-magenta); }
.style-cyan { color: var(--c-cyan); }
.style-white { color: var(--c-white); }
.style-bright_black { color: var(--c-bright-black); }
.style-bright_red { color: var(--c-bright-red); }
.style-bright_green { color: var(--c-bright-green); }
.style-bright_yellow { color: var(--c-bright-yellow); }
.style-bright_blue { color: var(--c-bright-blue); }
.style-bright_magenta { color: var(--c-bright-magenta); }
.style-bright_cyan { color: var(--c-bright-cyan); }
.style-bright_white { color: var(--c-bright-white); }

/* Save / restore modals (host-rendered save UX; see devdocs/sandbox.md). The
   dialog is built by shell.js, not present in index.html. */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10;
}

.modal-dialog {
    width: min(30rem, 92vw);
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    padding: 1.25rem;
}

.modal-dialog h2 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-field {
    width: 100%;
    background: #1c1c1c;
    border: 1px solid #3a3a3a;
    border-radius: 5px;
    color: var(--accent);
    caret-color: var(--accent);
    font: inherit;
    padding: 0.5rem 0.65rem;
    outline: none;
}
.modal-field:focus {
    border-color: var(--accent);
}

.modal-list-label {
    color: var(--dim);
    font-size: 0.85rem;
    margin: 1rem 0 0.4rem;
}

.modal-slots {
    border: 1px solid #3a3a3a;
    border-radius: 5px;
    max-height: 11rem;
    overflow-y: auto;
    scrollbar-width: none;
}
.modal-slots::-webkit-scrollbar {
    display: none;
}

.modal-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem 0.45rem 0.5rem;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.modal-slot + .modal-slot {
    border-top: 1px solid #3a3a3a;
}
.modal-slot:hover {
    background: #2a2a2a;
}
.modal-slot.selected {
    background: #2f2a18;
    border-left-color: var(--accent);
}

.slot-name {
    flex: 1 1 auto;
}
.slot-meta {
    color: var(--dim);
    font-size: 0.82rem;
    white-space: nowrap;
}
.slot-del {
    visibility: hidden;
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0 0.2rem;
}
.modal-slot:hover .slot-del,
.modal-slot.selected .slot-del {
    visibility: visible;
}
.slot-del:hover {
    color: var(--shell-error, #e06c5a);
}

.modal-empty {
    color: var(--dim);
    font-style: italic;
    padding: 1.25rem 0.25rem;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.modal-btn {
    font: inherit;
    border-radius: 5px;
    padding: 0.4rem 1rem;
    cursor: pointer;
    border: 1px solid #3a3a3a;
    background: transparent;
    color: var(--fg);
}
.modal-btn:hover {
    border-color: var(--dim);
}
.modal-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: 600;
}
.modal-btn.primary:hover {
    filter: brightness(1.08);
}

/* Inline so it flows directly after the prompt text on the same line; a generous
   fixed width keeps long commands on one line (the field scrolls horizontally
   past it). The max-width reserves room for the "> " prompt span, so on narrow
   (mobile) viewports the field shrinks instead of wrapping below the prompt. */
#input-line {
    display: inline-block;
    width: 40ch;
    max-width: calc(100% - 3ch);
    background: transparent;
    border: none;
    color: var(--accent);
    caret-color: var(--accent);
    font: inherit;
    outline: none;
    padding: 0;
    vertical-align: baseline;
}
