/* City builder (/city-builder): only what is the game's own - the strip of building tools and speed buttons above the
   map, and the canvas with the map and the scoreboard. Buttons, fields, sections and the accent come from the app kit
   (css/app-kit, docs/app-kit.md). Loaded only on this page (StylePaths). The map keeps its own colours in both themes
   (filter-engines/city-builder.js). */

.city-builder-stage {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* The tools and the clock: one row on a wide screen; on a phone the tools scroll sideways above the clock. */
.city-builder-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.city-builder-tools {
    display: flex;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 2px;
}

.city-builder-tool {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 56px;
    min-height: 48px;
    padding: 4px 6px;
    border: 1px solid var(--ak-border, rgba(127, 127, 127, 0.3));
    border-radius: 10px;
    background: var(--ak-surface, transparent);
    color: inherit;
    font: inherit;
    font-size: 11px;
    line-height: 1.15;
    cursor: pointer;
    touch-action: manipulation;
}

.city-builder-tool:hover {
    border-color: var(--ak-accent);
}

.city-builder-tool[aria-pressed="true"] {
    border-color: var(--ak-accent);
    background: color-mix(in srgb, var(--ak-accent) 16%, transparent);
    color: var(--ak-accent);
    font-weight: 600;
}

.city-builder-tool:focus-visible {
    outline: 2px solid var(--ak-accent);
    outline-offset: 1px;
}

/* A building the city has not grown into yet: faded, with a padlock. It can still be picked, to see where it unlocks. */
.city-builder-tool.is-locked {
    position: relative;
    opacity: 0.6;
}

.city-builder-tool.is-locked::after {
    content: "";
    position: absolute;
    top: 3px;
    inset-inline-end: 4px;
    width: 9px;
    height: 11px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 11'%3E%3Cpath d='M2 5V3.5a2.5 2.5 0 0 1 5 0V5h1v6H1V5zm1 0h3V3.5a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 11'%3E%3Cpath d='M2 5V3.5a2.5 2.5 0 0 1 5 0V5h1v6H1V5zm1 0h3V3.5a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.city-builder-tool-label {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.city-builder-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.city-builder-clock {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.city-builder-clock .ak-seg-btn {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.city-builder-clock .ak-seg-btn[aria-pressed="true"] {
    background: color-mix(in srgb, var(--ak-accent) 14%, transparent);
    color: var(--ak-accent);
    font-weight: 700;
}

/* The map: as tall as the screen allows, the canvas placed absolutely so its pixel size never stretches the board. */
.city-builder-panel {
    min-width: 0;
}

.city-builder-board {
    position: relative;
    width: 100%;
    height: clamp(300px, calc(100svh - 230px), 900px);
    min-height: 0;
}

.city-builder-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    background: #0d141e;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    cursor: crosshair;
    -webkit-tap-highlight-color: transparent;
}

.city-builder-landing-app[data-cb-tool="query"] .city-builder-canvas {
    cursor: grab;
}

.city-builder-canvas:focus-visible {
    box-shadow: 0 0 0 3px var(--ak-accent);
}

/* The budget and the advisor in the panel. */
.city-builder-budget {
    margin: 0;
    display: grid;
    gap: 4px;
    font-size: 13px;
}

.city-builder-budget > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.city-builder-budget dt {
    opacity: 0.75;
}

.city-builder-budget dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Borrow, under the budget: the button fills the row. */
.city-builder-loan {
    margin-top: 8px;
}

.city-builder-loan .ak-btn {
    width: 100%;
}

.city-builder-good {
    color: #2e9e57;
}

.city-builder-bad {
    color: #d8473b;
}

.city-builder-log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.35;
}

.city-builder-log li {
    display: grid;
    gap: 1px;
    padding-left: 10px;
    border-left: 3px solid #e3a03a;
}

.city-builder-log li.city-builder-log-good {
    border-left-color: #2e9e57;
}

.city-builder-log li.city-builder-log-empty {
    border-left-color: transparent;
    padding-left: 0;
    opacity: 0.7;
}

.city-builder-log time {
    font-size: 11px;
    opacity: 0.65;
}

/* Phones: the tools scroll in their own row above the clock, and the map takes the rest of the screen. */
@media (max-width: 640px) {
    .city-builder-strip {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .city-builder-clock {
        justify-content: space-between;
    }

    .city-builder-tool {
        min-width: 54px;
        min-height: 46px;
        font-size: 10px;
    }

    .city-builder-board {
        height: clamp(300px, calc(100svh - 270px), 760px);
    }
}

/* Phones and tablets: the shared landing rule caps the stage at the screen width; the map needs the height. */
@media (max-width: 960px) {
    .city-builder-stage {
        max-height: none !important;
    }
}
