/* Space-time view (views/spacetime-view.js): places on a ground plane, years as height.
   Colours follow design.md: --color-data for the marks, --color-primary only for the chosen
   place and the controls that can be pressed. */

.st-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

.st-segment {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--color-bg-light);
    border-radius: var(--radius-sm);
}

.st-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-width: 28px;
    min-height: 28px;
    padding: var(--space-xs) var(--space-sm);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-light);
    font: inherit;
    font-size: var(--font-size-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-fast);
    transition-property: var(--transition-properties);
}

.st-btn:hover {
    color: var(--color-primary-dark);
    background: var(--color-bg);
}

.st-btn[aria-pressed="true"] {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-weight: 600;
}

/* The figure with its key fills the space under the header; the place list follows below it, one
   scroll away, so the first screen holds the figure alone */
#spacetime-view.active {
    min-height: 0;
}

.st-stage {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 var(--space-lg) var(--space-lg);
}

.st-figure-wrap {
    position: relative;
    height: calc(100% - 52px);
    min-height: 320px;
}

#spacetime-figure {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

#spacetime-figure.st-over {
    cursor: pointer;
}

#spacetime-figure:active {
    cursor: grabbing;
}

/* The scene is painted here, under the SVG that carries text, focus and pointer */
.st-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

#spacetime-figure:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: -3px;
}

.st-axis {
    stroke: var(--color-text-light);
    stroke-width: 1;
}

.st-tick--hover,
.st-tick--picked {
    fill: var(--color-text);
    font-weight: 600;
    paint-order: stroke;
    stroke: var(--color-bg);
    stroke-width: 3px;
    stroke-linejoin: round;
}

/* The three views at the upper left corner of the figure, larger than the other controls */
.st-cams {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    z-index: var(--z-raised);
    border: 1px solid var(--color-border-control);
    background: var(--color-bg);
}

.st-cams .st-btn {
    min-height: 36px;
    padding: var(--space-xs) var(--space-md);
    color: var(--color-text);
    font-size: var(--font-size-md);
}

.st-cams .st-btn[aria-pressed="true"] {
    background: var(--color-primary);
    color: var(--color-bg);
}

/* Zoom at the lower right corner of the figure */
.st-zoom {
    position: absolute;
    right: var(--space-sm);
    bottom: var(--space-sm);
    z-index: var(--z-raised);
}

.st-search {
    display: block;
    width: min(100%, 280px);
    min-height: 32px;
    margin-bottom: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--color-border-control);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    font: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.st-axis-title {
    fill: var(--color-text);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

/* Cue in the upper right corner of the figure, away from the chosen place at the left */
.st-hint {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    margin: 0;
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-light);
    font-size: var(--font-size-xs);
    pointer-events: none;
}

.st-tick {
    fill: var(--color-text-light);
    font-size: var(--font-size-xs);
    font-variant-numeric: tabular-nums;
}

.st-foot {
    fill: none;
    stroke: var(--color-text-light);
    stroke-width: 1;
}

/* Sample widths of the size key; the columns themselves carry the language colours */
.st-mark {
    fill: var(--color-text-light);
}

.st-label {
    fill: var(--color-text);
    font-size: var(--font-size-xs);
    paint-order: stroke;
    stroke: var(--color-bg);
    stroke-width: 3px;
    stroke-linejoin: round;
    pointer-events: none;
}

.st-label--sel {
    fill: var(--color-primary-dark);
}

.st-tooltip {
    position: absolute;
    z-index: var(--z-raised);
    max-width: 260px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-text);
    color: var(--color-bg-light);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.st-foot-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-lg);
    padding-top: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-light);
}

.st-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-lg);
}

.st-legend__group,
.st-legend__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.st-legend__group {
    gap: var(--space-sm);
}

.st-note {
    margin: 0;
    min-width: 0;
    flex: 1 1 320px;
    text-align: right;
}

.st-side {
    margin-top: var(--space-md);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border-light);
}

/* The years of the chosen place, under its row of the place list */
.st-place__year {
    width: 100%;
    min-height: 28px;
    margin: var(--space-xs) 0 var(--space-sm);
    border: 1px solid var(--color-border-control);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    font: inherit;
    font-size: var(--font-size-sm);
}

/* The places as a ranked list in columns, the keyboard and screen reader route to every column */
.st-places {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 220px;
    column-gap: var(--space-xl);
}

.st-places li {
    break-inside: avoid;
}

.st-place {
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
    width: 100%;
    min-height: 26px;
    padding: 2px var(--space-sm);
    border: none;
    border-left: 3px solid transparent;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
}

.st-place:hover,
.st-place:focus-visible {
    background: var(--color-bg-light);
}

.st-place--sel {
    background: var(--color-primary-light);
    border-left-color: var(--color-primary);
}

.st-place__name {
    overflow-wrap: anywhere;
}

.st-place__count {
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 767px) {
    #spacetime-view.active {
        overflow-y: auto;
    }

    .st-stage {
        flex: none;
        overflow: visible;
        padding: 0 var(--space-md) var(--space-md);
    }

    /* The top view of a phone is about as tall as the plane is deep */
    .st-figure-wrap {
        height: auto;
        min-height: 0;
    }

    #spacetime-figure {
        position: relative;
        height: auto;
        aspect-ratio: 5 / 4;
    }

    /* A phone shows the map from above and does not turn */
    .st-hint {
        display: none;
    }

    /* The canvas keeps the size of the figure, not of the wrap around it */
    .st-canvas {
        inset: 0 0 auto 0;
        height: auto;
        aspect-ratio: 5 / 4;
    }
}
