/* Tower Director 2026 - the tower page. The kit draws the cards, claim form and leaderboards (kit.css,
   "verified leaderboards"); this file is the stage: the heads-up display with the clock's speeds, the
   view of the tower (a canvas, with the goal, a tip, zoom buttons and the card of what is selected
   over it), the build tools under it and the side column. Sizes only from the kit scale. */

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.td { max-width: 1280px; margin: 0 auto; padding: 16px var(--gutter) 24px; display: grid; gap: 16px; }
.td__stage {
    position: relative;
    /* what floats over the view stays inside the stage: the sticky header, its drawer and the toast stay on top */
    isolation: isolate;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
    height: clamp(520px, calc(100svh - var(--header-h) - 48px), 920px);
    padding: 10px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.td__stage[aria-busy="true"] { background: linear-gradient(110deg, var(--surface-2) 35%, var(--surface) 50%, var(--surface-2) 65%) 0 0 / 300% 100%; animation: skeleton 1.4s ease-in-out infinite; }

/* the heads-up display */
.td__hud { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; }
.hud-chip { display: inline-flex; flex-direction: column; min-width: 64px; padding: 4px 10px; border-radius: 10px; background: var(--surface-2); color: var(--ink); line-height: 1.25; }
.hud-chip__label { font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }
.hud-chip strong { font-size: var(--fs-m); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-chip strong.is-low { color: var(--accent); }
.hud-chip--stars strong { color: var(--gold-ink); letter-spacing: .04em; }
.hud-chip--stars strong.is-landmark { text-shadow: 0 0 6px rgb(201 165 90 / .7); }
.speed { display: inline-flex; margin-left: auto; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.speed__btn { display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0 6px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink); font-size: var(--fs-xs); letter-spacing: -.12em; cursor: pointer; }
.speed__btn:last-child { border-right: 0; }
.speed__btn:hover { background: var(--surface-2); }
.speed__btn[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-ink); }
.speed__btn .icon { width: 18px; height: 18px; }
.td__menu { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer; }
.td__menu:hover { background: var(--surface-2); }

/* the view of the tower */
.td__view { position: relative; min-height: 0; border-radius: 12px; overflow: hidden; background: #1b2440; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25); }
.td__canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.td__canvas:active { cursor: grabbing; }
.td:not([data-tool="inspect"]) .td__canvas { cursor: crosshair; }
.td[data-tool="demolish"] .td__canvas { cursor: not-allowed; }

.goal { position: absolute; left: 8px; top: 8px; display: grid; gap: 3px; max-width: min(360px, calc(100% - 72px)); padding: 6px 10px 8px; border-radius: 10px; background: rgb(14 18 32 / .74); color: #f4efe4; font-size: var(--fs-xs); line-height: 1.4; pointer-events: none; }
.goal__days { color: #f0d693; font-weight: 600; }
.goal__bar { position: relative; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .2); overflow: hidden; }
.goal__bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--k, 0) * 100%); background: #e2c27a; }
.goal__report { padding-top: 3px; border-top: 1px solid rgb(255 255 255 / .18); color: #d8f0dc; }
.has-info .tip { display: none; }
/* the kit's toast: above the tools, not on them (on a phone the kit puts it under the header) */
@media (min-width: 640px) { .td ~ .toast { bottom: max(96px, env(safe-area-inset-bottom)); } }

.tip { position: absolute; left: 50%; bottom: 10px; z-index: 2; display: flex; align-items: center; gap: 4px; width: min(calc(100% - 16px), 480px); padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); transform: translateX(-50%); }
.tip__text { margin: 0; flex: 1; font-size: var(--fs-s); line-height: 1.45; }
.tip__close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; }
.tip__close:hover { background: var(--surface-2); color: var(--ink); }
.tool-hint { position: absolute; left: 50%; bottom: 10px; z-index: 1; width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 4px 12px; border-radius: 12px; background: rgb(14 18 32 / .74); color: #f4efe4; font-size: var(--fs-xs); line-height: 1.45; text-align: center; transform: translateX(-50%); pointer-events: none; }
/* a build tool in hand: its hint takes the tip's place */
.td:not([data-tool="inspect"]) .tip, .has-info .tool-hint { display: none; }

.viewbar { position: absolute; right: 8px; top: 8px; display: grid; gap: 6px; }
.viewbar__btn { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgb(255 255 255 / .25); border-radius: 12px; background: rgb(14 18 32 / .62); color: #f4efe4; cursor: pointer; }
.viewbar__btn:hover { background: rgb(14 18 32 / .85); }
.viewbar__btn .icon { width: 20px; height: 20px; }

/* the card of what is selected */
.info { position: absolute; left: 8px; bottom: 8px; z-index: 3; width: min(310px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 12px 14px; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
.info__head { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.info__title { margin: 6px 0 0; font-size: var(--fs-m); }
.info__floor { margin: 0; font-size: var(--fs-xs); color: var(--ink-2); }
.info__close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: -4px -6px 0 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; }
.info__close:hover { background: var(--surface-2); color: var(--ink); }
.info__list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 8px; }
.info__list div { padding: 4px 8px; border-radius: 8px; background: var(--surface-2); }
.info__list dt { font-size: var(--fs-xs); color: var(--ink-2); }
.info__list dd { margin: 0; font-size: var(--fs-s); font-weight: 600; font-variant-numeric: tabular-nums; }
.mood--0 { color: #2f7d4b; }
.mood--1 { color: var(--gold-ink); }
.mood--2 { color: var(--accent); }
.info__about { margin: 0 0 10px; font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-2); }
.info__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.info__actions .btn { min-height: 44px; }
.info__demolish.is-armed { border-color: var(--accent); background: var(--accent); color: #fff; }

/* the build tools */
.tools { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding: 0 0 2px; }
.tools__group { display: flex; gap: 4px; padding-right: 8px; border-right: 1px solid var(--line); }
.tools__group:last-child { padding-right: 0; border-right: 0; }
.tool { position: relative; display: grid; justify-items: center; align-content: center; gap: 1px; flex: none; min-width: 64px; min-height: 58px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.tool:hover { border-color: var(--gold); }
.tool[aria-pressed="true"] { border-color: var(--gold); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--gold); }
.tool__icon { width: 22px; height: 22px; fill: currentColor; }
.tool__name { font-size: var(--fs-xs); line-height: 1.25; white-space: nowrap; }
.tool__cost { font-size: var(--fs-xs); line-height: 1.2; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tool.is-locked { color: var(--ink-3); background: var(--surface-2); }
.tool.is-locked .tool__icon { opacity: .5; }
.tool__lock { position: absolute; top: 1px; right: 4px; font-size: var(--fs-xs); color: var(--gold-ink); }
.tool[data-tool="demolish"][aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }

/* cards over the stage */
.td__panel { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; overflow-y: auto; overscroll-behavior: contain; border-radius: 18px; background: rgb(12 14 22 / .5); touch-action: pan-y; }
.saved { margin: 0 0 14px; padding: 12px; border: 1px solid var(--gold); border-radius: 12px; background: var(--surface-2); }
.saved__text { margin: 0 0 8px; font-size: var(--fs-s); }
.modes { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; border: 0; }
.end-badge[data-reason="done"] { background: rgb(201 165 90 / .22); color: var(--gold-ink); }
.end-badge[data-reason="quit"] { background: rgb(155 50 38 / .12); color: var(--accent); }

/* beside the stage */
.td__side { display: grid; gap: 16px; align-content: start; }

@media (min-width: 1024px) {
    .td { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; padding-top: 24px; }
    .td__side { position: sticky; top: calc(var(--header-h) + 24px); }
}

/* phones: the stage fills the screen under the header */
@media (max-width: 639px) {
    .td { padding: 0 0 16px; gap: 6px; }
    .td__stage { height: calc(100svh - var(--header-h)); min-height: 460px; padding: 6px; gap: 6px; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--line); }
    .td__hud { gap: 4px; }
    .hud-chip { min-width: 0; padding: 2px 8px; }
    .hud-chip strong { font-size: var(--fs-s); }
    .td__view { border-radius: 8px; }
    .goal { max-width: calc(100% - 66px); }
    .info { left: 6px; right: 6px; bottom: 6px; width: auto; max-height: 62%; }
    .tool { min-width: 60px; min-height: 54px; padding: 3px 4px; }
    .td__panel { padding: 12px; place-items: start center; border-radius: 0; }
    .panel-card { padding: 18px 16px; }
    .end-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 10px 0; }
    .end-stats div { padding: 4px 6px; }
    .end-stats dt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .end-stats dd { font-size: var(--fs-s); }
    .td__side { padding: 10px var(--gutter) 0; }
}

/* phones on their side: one row of numbers, the tools as a column beside the view */
@media (orientation: landscape) and (max-height: 500px) {
    .td { padding-top: 0; }
    .td__stage, .td[data-phase] .td__stage { height: calc(100svh - var(--header-h)); min-height: 300px; padding: 4px max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left)); gap: 4px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); }
    .td__hud { grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; }
    .hud-chip { flex-direction: row; align-items: baseline; gap: 6px; padding: 2px 8px; }
    .td__view { grid-column: 1; grid-row: 2; }
    .goal__text, .goal__report { display: none; }
    .tools { grid-column: 2; grid-row: 2; flex-direction: column; gap: 6px; overflow-x: hidden; overflow-y: auto; padding: 0; }
    .tools__group { flex-direction: column; padding: 0 0 6px; border-right: 0; border-bottom: 1px solid var(--line); }
    .tools__group:last-child { padding-bottom: 0; border-bottom: 0; }
    .tool { min-height: 50px; }
    .info { max-height: calc(100% - 12px); }
}
