/* The viewer's page, after the mock in experimental/ux. Colours are from
   colors.css, which index.html loads first. */
@font-face {
    font-family: "Unica77";
    src: url("/fonts/unica77-regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Unica77 Mono";
    src: url("/fonts/unica77-mono-regular.woff2") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "National";
    src: url("/fonts/national-extrabold-italic.woff2") format("woff");
    font-weight: 800;
    font-style: italic;
    font-display: swap;
}

:root {
    --tools-border-color: var(--color-brown-50);
    --tools-text-color: var(--color-brown-70);
    --tools-hover-color: var(--color-brown-20);
    --tools-active-color: var(--color-brown-30);
    --background-color: var(--color-brown-10);
    --problem-color: var(--color-red-70);
    --sync-color: var(--color-yellow-70);
    --drop-color: var(--color-blue-50);
    --focus-color: var(--color-blue-60);

    --tools-size: 24px;
    --name-max-size: 64px;
    --progress-width: 64px;
    --editor-width: min(560px, 45vw);
    --slide: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    margin: 0px;
    overflow: hidden;
}
/* The page is never zoomed, as on a phone that leaves the bottom tools off
   screen: no pinching or double tapping it (the map handles its own), and
   no zooming in to a field focused (index.html's maximum-scale). */
html {
    touch-action: pan-x pan-y;
}
body {
    background-color: var(--background-color);
    font: 13px "Unica77", system-ui, sans-serif;
    color: var(--color-brown-100);
}

/* The editor and the map, above the bottom tools. */
#c6-panes {
    position: absolute;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: calc(var(--tools-size) + 1px);
    display: flex;
    /* Clipped, not hidden, so it can't be scrolled: focusing or scrolling
       to something in a pane off screen, or still sliding, would otherwise
       scroll it, and leave every pane shown offset by that much. */
    overflow: hidden;
    overflow: clip;
}
#c6-prep {
    position: relative;
    top: 0;
    left: 0;
    margin-top: 2px;
    margin-left: 4px;
    font-family: "National";
    font-weight: 800;
    font-style: italic;
    font-size: 18px;
    z-index: 1;
}
#c6-map {
    flex: 1;
    position: relative;
    min-width: 0;
}
#c6-map canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}
#c6-map canvas.dragging {
    cursor: grabbing;
}
/* Over the GeoJSON feature being edited: a vertex or the feature to drag,
   or, with shift, an edge to add a vertex to. */
#c6-map canvas.edit-move {
    cursor: move;
}
#c6-map canvas.edit-add {
    cursor: copy;
}
body.over #c6-map {
    outline: 4px dashed var(--drop-color);
    outline-offset: -4px;
}

/* The editor keeps its width while it slides, so its lines don't reflow;
   the map grows into the space it leaves. Collapsed, only the side tools
   are left showing. */
#c6-editor {
    flex: none;
    position: relative;
    width: var(--editor-width);
    border-right: 1px solid var(--tools-border-color);
    background-color: var(--background-color);
}
/* Only once the page has started, so a narrow window doesn't start with
   the editor sliding away. */
body.ready #c6-editor {
    transition: margin-left var(--slide);
}
body.collapsed #c6-editor {
    margin-left: calc(var(--tools-size) + 1px - var(--editor-width));
}
#c6-editor > section {
    position: absolute;
    top: 0px;
    left: 0px;
    bottom: 0px;
    right: calc(var(--tools-size) + 1px);
}

/* The pane shows the GeoJSON editor, or, with body.markdown, the Markdown
   editor, or with body.agent, the agent prompt. The others keep their text
   and selection, hidden. */
body.markdown #editor-pane, body.agent #editor-pane,
body:not(.markdown) #markdown-pane, body:not(.agent) #agent-pane {
    display: none;
}

/* Markdown's markup, decorated a line at a time (c6::markdown). The text
   is what's edited, so the syntax stays, muted, and only the look of what
   it marks up changes. Bold and italic monospace are as wide as regular,
   so columns still line up. */
#markdown-pane .md-heading {
    font-weight: 700;
    color: var(--color-brown-100);
}
#markdown-pane .md-strong {
    font-weight: 700;
}
#markdown-pane .md-em {
    font-style: italic;
}
#markdown-pane .md-strike {
    text-decoration: line-through;
}
#markdown-pane .md-code, #markdown-pane .md-fence {
    background-color: var(--color-stone-20);
}
#markdown-pane .md-link {
    color: var(--color-ultramarine-70);
    text-decoration: underline;
    text-decoration-color: var(--color-ultramarine-40);
}
#markdown-pane .md-url {
    color: var(--color-ultramarine-50);
}
#markdown-pane .md-quote {
    color: var(--color-stone-70);
}
#markdown-pane .md-marker, #markdown-pane .md-list, #markdown-pane .md-rule {
    color: var(--color-stone-50);
}
#markdown-pane .md-list {
    font-weight: 700;
}

.c6-tools {
    display: flex;
    align-items: center;
    position: absolute;
    font-family: "Unica77", sans-serif;
    font-size: 12px;
    color: var(--tools-text-color);
    background-color: var(--background-color);
}
#c6-tools-bottom {
    flex-direction: row;
    left: 0px;
    right: 0px;
    height: var(--tools-size);
    bottom: 0px;
    padding-left: 8px;
    padding-right: 8px;
    border-top: 1px solid var(--tools-border-color);
}
#c6-tools-bottom > div {
    border-right: 1px solid  var(--tools-border-color);
    padding-left: 4px;
    padding-top: 6px;
    padding-bottom: 4px;
    padding-right: 4px;
    vertical-align: baseline;
    white-space: nowrap;
    flex-shrink: 0;
}
/* An icon is as tall as the bar, so its hover background doesn't cover the
   bar's border. */
#c6-tools-bottom > .icon {
    padding-top: 4px;
    padding-bottom: 4px;
}
/* Stops loading a dropped file, beside the progress bar while it's shown. */
#c6-cancel {
    padding: 4px;
    border-right: 1px solid var(--tools-border-color);
}
#c6-cancel::before {
    top: 4px;
}
/* Credits OpenStreetMap for the map's data, linking to its copyright page,
   and, after the selected feature, mails feedback. */
#c6-copyright, #c6-feedback {
    box-sizing: content-box;
    padding: 4px;
    border-right: 1px solid var(--tools-border-color);
}
#c6-copyright::before, #c6-feedback::before {
    top: 4px;
    left: 4px;
}
#c6-copyright:focus-visible, #c6-feedback:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: -2px;
}
/* The status text takes the space left, and is cut short when it's too
   long for it. */
#c6-tools-bottom > :last-child {
    flex-grow: 1;
    flex-shrink: 1;
    border-right: 0px;
}
#c6-tools-side {
    flex-direction: column;
    top: 0px;
    width: var(--tools-size);
    right: 0px;
    bottom: 0px;
    padding-top: 4px;
    padding-bottom: 8px;
    border-left: 1px solid var(--tools-border-color);
}
#c6-tools-side > * {
    border-bottom: 1px solid  var(--tools-border-color);
    padding-left: 4px;
    padding-top: 6px;
    padding-bottom: 4px;
    padding-right: 4px;
}

#c6-status-text {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
#c6-status-text > * {
    overflow: hidden;
    text-overflow: ellipsis;
}
#c6-status-text .grow {
    flex: 1;
}
#editor-status {
    font-variant-numeric: tabular-nums;
}
/* Only the status of the pane last used is shown. */
body:not(.editor-active) #editor-status, body:not(.map-active) #map-status {
    display: none;
}
/* And of the editor shown. */
body.markdown #geojson-status, body.agent #geojson-status,
body:not(.markdown) #markdown-status, body:not(.agent) #agent-status {
    display: none;
}
#problem {
    color: var(--problem-color);
    text-decoration: none;
    flex-shrink: 1;
}
#problem:hover {
    text-decoration: underline;
}
#problem:empty, #sync:empty {
    display: none;
}
#sync {
    color: var(--sync-color);
}

/* The actors bar: a dot for everyone here, in the colour of their cursor
   (--actor-color, set by actors.rs), bordered in a darker shade of it
   (--actor-border-color), this page's first, with its name
   beside it, which is edited by clicking it. Everyone else's name shows
   while they're hovered over, or followed. */
.actors {
    display: flex;
    gap: 4px;
    flex-direction: row;
    align-items: center;
}
.actor {
    display: inline-flex;
    align-items: center;
}
button.actor, .actor > button.dot {
    margin: 0px;
    padding: 0px;
    border: 0px;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
button.actor:focus-visible, .actor > button.dot:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: 1px;
}
.dot::before {
    content: "";
    display: inline-block;
    width: 0.8em;
    border-radius: 50%;
    aspect-ratio: 1;
    flex-shrink: 0;
    background: var(--actor-color);
    margin-top: 1px;
    border: 1px solid var(--actor-border-color);
}
.actor:hover > .dot::before, .actor.followed > .dot::before {
    border-color: var(--tools-text-color);
}
.actor-name {
    display: inline-block;
    max-width: 0px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
    transition: max-width 0.5s;
}
.actor:hover > .actor-name, .actor.followed > .actor-name {
    max-width: var(--name-max-size);
    padding-left: 4px;
}
/* This page's name is always shown, as a field that looks like the rest
   of the bar until it's clicked. Being edited, it's shown whole. */
.actor.me > .actor-name {
    max-width: var(--name-max-size);
    padding: 0px 4px;
    border: 0px;
    font: inherit;
    color: inherit;
    background: transparent;
    field-sizing: content;
    min-width: 4ch;
    cursor: text;
    transition: none;
}
.actor.me > .actor-name::placeholder {
    color: var(--tools-text-color);
    opacity: 0.6;
}
.actor.me > .actor-name:focus {
    max-width: none;
    outline: none;
    color: var(--color-brown-100);
}

/* While the map follows another actor, it's bordered in their colour
   (--follow-color, set by actors.rs). The border is drawn over the
   canvas, and lets the pointer through to it. */
#c6-map.following::after {
    content: "";
    position: absolute;
    inset: 0px;
    border: 3px solid var(--follow-color);
    pointer-events: none;
}
.logo {
    display: inline-block;
    width: 18px;
    height: 12px;
    background: url("icons/diagonal.svg");
    background-position: 3px 2px;
    background-size: 20px;
    background-repeat: no-repeat;
}
.icon {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: transparent;
}
/* An icon that's a button looks like a normal div icon. */
button.icon {
    box-sizing: content-box;
    margin: 0px;
    border: 0px;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
button.icon::before {
    top: 6px;
    left: 4px;
}
button.icon:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: -2px;
}
.icon::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    background-color: var(--tools-text-color);
}
.icon:hover {
    background-color: var(--tools-hover-color);
}
.icon[aria-expanded="true"] {
    background-color: var(--tools-active-color);
}
.icon-add::before {
    mask-image: url("icons/add.svg");
}
.icon-cancel::before {
    mask-image: url("icons/cancel.svg");
}
/* An icon's display would otherwise show it while it's hidden. */
.icon[hidden] {
    display: none;
}
.icon-geojson::before {
    mask-image: url("icons/geojson.svg");
}
.icon-markdown::before {
    mask-image: url("icons/markdown.svg");
}
.icon-agent::before {
    mask-image: url("icons/agent.svg");
}
.icon-copyright::before {
    mask-image: url("icons/copyright.svg");
}
.icon-mail::before {
    mask-image: url("icons/mail.svg");
}
.progress {
    display: inline-block;
    flex: none;
    box-sizing: border-box;
    width: var(--progress-width);
    height: 8px;
    border: 1px solid var(--tools-text-color);
    margin-right: 4px;
}
.bar {
    display: block;
    background: linear-gradient(to left, var(--color-violet-60), var(--color-green-60), var(--color-rose-60));
    background-size: var(--progress-width) var(--progress-width);
    width: 100%;
    height: 100%;
}
/* Overlays cover the status text while they're shown, sliding up from the
   bottom of the bar, and back down once they're done: the tooltip of
   whatever the pointer is over, over it the progress bar, of loading a
   dropped file or of holding down the countdown to delete the document
   (see progress.rs), and over that a notice, saying something has been
   done, for a few seconds (see notice.rs). Problems and syncing stay
   showing, over them. */
#c6-status-text > .overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding: inherit;
    background-color: var(--background-color);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform var(--slide), visibility 0s var(--slide);
}
#c6-status-text > .overlay.shown {
    transform: translateY(0);
    visibility: visible;
    transition: transform var(--slide);
}
#progress-text, .tooltip, #notice {
    overflow: hidden;
    text-overflow: ellipsis;
}
#c6-status-text > #notice {
    display: block;
}
#c6-status-text > .tooltip, #c6-status-text > .tooltip.shown {
    display: block;
    transition: none;
}
#problem, #sync {
    position: relative;
    background-color: var(--background-color);
}

/* How much memory the map takes, with what's drawn in its tooltip. It's
   left out until anything's held. */
#c6-tools-bottom > #c6-memory {
    font-variant-numeric: tabular-nums;
    cursor: default;
}
#c6-tools-bottom > #c6-memory:empty {
    display: none;
}
#c6-memory:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: -2px;
}

/* Which data the map is drawn from, which switches between the map's and
   a dropped file's once one has been dropped. */
#c6-tools-bottom > #c6-map-type {
    user-select: none;
    -webkit-user-select: none;
}
#c6-tools-bottom > #c6-map-type.switchable {
    cursor: pointer;
}
#c6-tools-bottom > #c6-map-type.switchable:hover {
    background-color: var(--tools-hover-color);
}
#c6-map-type:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: -2px;
}

/* The place field: the name of the part of the map in view, which is
   edited to search for a place (see search.rs). The input is laid over a
   copy of its text (.ghost), in the same grid cell, which sizes the field,
   and shows the completion of the place found after the text, which it
   draws transparent beneath the input's own. */
#c6-tools-bottom > #c6-place {
    display: inline-grid;
    padding-top: 0px;
    padding-bottom: 0px;
    align-self: stretch;
    align-items: center;
}
#c6-place > .ghost, #c6-place > input {
    grid-area: 1 / 1;
    font: inherit;
    padding: 0px 4px;
    margin: 0px;
    white-space: pre;
    min-width: 4ch;
}
#c6-place > .ghost > .typed {
    color: transparent;
}
#c6-place > .ghost > .rest {
    color: var(--color-brown-100);
    opacity: 0.4;
}
#c6-place > input {
    /* Fills the ghost's column, without its own width, which by default
       is about 20 characters, widening it: a percentage minimum doesn't
       count towards the column's width, but is then resolved against it. */
    width: 0px;
    min-width: 100%;
    box-sizing: border-box;
    border: 0px;
    color: inherit;
    background: transparent;
    cursor: text;
}
#c6-place > input::placeholder {
    color: var(--tools-text-color);
    opacity: 0.6;
}
#c6-place > input:focus {
    outline: none;
    color: var(--color-brown-100);
}
/* Arrows at the end of the field, while it's edited, saying whether Up
   and Down have other places to step to: up for the field's more-above
   class, and down for more-below, as search.rs sets them, each in a column
   of its own, which is empty without its arrow. */
#c6-place::before, #c6-place::after {
    content: "";
    display: none;
    grid-row: 1;
    width: 8px;
    height: 12px;
    /* Coloured as icons are, through the mask. */
    background-color: var(--tools-text-color);
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}
#c6-place::before {
    grid-column: 2;
    mask-image: url("icons/arrow-up.svg");
}
#c6-place::after {
    grid-column: 3;
    mask-image: url("icons/arrow-down.svg");
}
#c6-place.more-above::before, #c6-place.more-below::after {
    display: block;
}
#c6-tools-bottom > #c6-place:hover {
    background-color: var(--tools-hover-color);
}
/* Without a search index on the server, there's no field. */
#c6-tools-bottom > #c6-place[hidden] {
    display: none;
}

/* The name of the feature of the map selected, linked to its page on
   openstreetmap.org, shown only while one is selected (see page.rs). */
#c6-tools-bottom > #c6-feature[hidden] {
    display: none;
}
#c6-tools-bottom > #c6-feature {
    max-width: 24ch;
    overflow: hidden;
    text-overflow: ellipsis;
}
#c6-feature > a {
    color: inherit;
    text-decoration: none;
}
#c6-tools-bottom > #c6-feature:hover {
    background-color: var(--tools-hover-color);
}
#c6-feature > a:hover {
    text-decoration: underline;
}
#c6-feature > a:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: 1px;
}

#c6-tools-bottom > #c6-expiry {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    font-variant-numeric: tabular-nums;
}
#c6-tools-bottom > #c6-expiry:hover {
    background-color: var(--tools-hover-color);
}
#c6-tools-bottom > #c6-expiry.holding {
    background-color: var(--tools-active-color);
}
#c6-expiry:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: -2px;
}

.deletable {
    animation-duration: 2s;
    animation-fill-mode: forwards;
    animation-iteration-count: 1;
}
@keyframes delete-editor {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(5deg); }
  20% { transform: rotate(5deg); }
  30% { transform: rotate(-20deg); }
  70% { transform: rotate(-20deg); }
  100% { transform: translate(20px, 100vh); }
}
html.deleted #c6-editor {
    animation-name: delete-editor;
}
@keyframes destroy-tools-bottom {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(-5deg); }
  20% { transform: rotate(-5deg); }
  30% { transform: rotate(40deg); }
  70% { transform: rotate(40deg); }
  100% { transform: translate(0, 100px); }
}
html.deleted #c6-map {
    animation-name: delete-editor;
}
@keyframes delete-tools-bottom {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(-5deg); }
  20% { transform: rotate(-5deg); }
  30% { transform: rotate(30deg); }
  70% { transform: rotate(30deg); }
  100% { transform: translate(-20px, 100vh); }
}
html.deleted #c6-tools-bottom {
    animation-name: delete-tools-bottom;
}

/* A narrow window, less than 120% of the editor's widest (672px, NARROW in
   page.rs), lays the three editors and the map out in a row, each as wide
   as the window, and shows one at a time, sliding the row along to the one
   chosen. The editor's element drops out of the layout (display: contents),
   so its panes are laid out beside the map, and the side tools are pinned
   into the bottom bar, at its left. Which slide shows follows the body's
   classes, as the wide layout does: the GeoJSON editor, .markdown, .agent,
   or the map, .collapsed. */
@media (width < 672px) {
    :root {
        --tools-side-width: calc(3 * (var(--tools-size) + 1px));
    }
    #c6-panes {
        --slide-index: 0;
    }
    body.markdown #c6-panes { --slide-index: 1; }
    body.agent #c6-panes { --slide-index: 2; }
    body.collapsed #c6-panes { --slide-index: 3; }
    #c6-editor {
        display: contents;
    }
    #c6-editor > section, #c6-map {
        flex: none;
        position: relative;
        width: 100%;
        transform: translateX(calc(-100% * var(--slide-index)));
        background-color: var(--background-color);
    }
    body.ready #c6-editor > section, body.ready #c6-map {
        transition: transform var(--slide);
    }
    /* All the panes are in the row, the ones off screen inert. */
    #c6-panes #c6-editor > section {
        display: block;
        inset: auto;
    }
    #c6-tools-side {
        position: fixed;
        z-index: 1;
        flex-direction: row;
        top: auto;
        right: auto;
        left: 0px;
        bottom: 0px;
        width: auto;
        height: var(--tools-size);
        padding: 0px;
        border-left: 0px;
        border-top: 1px solid var(--tools-border-color);
    }
    #c6-tools-side > .logo {
        display: none;
    }
    #c6-tools-side > * {
        border-bottom: 0px;
        border-right: 1px solid var(--tools-border-color);
        padding-top: 4px;
        padding-bottom: 4px;
    }
    #c6-tools-bottom {
        padding-left: calc(var(--tools-side-width) + 4px);
    }
}
/* On a phone, the bottom bar only has room for the editor buttons and actors,
   and we stop showing line numbers in the editor */
@media (width < 480px) {
    #c6-tools-bottom > #c6-expiry, #c6-tools-bottom > #c6-memory,
    #c6-tools-bottom > #c6-place, #c6-tools-bottom > #c6-feature,
    #c6-tools-bottom > #c6-status-text,
    .c6-gutter {
        display: none;
    }
    #c6-tools-bottom > #c6-actors {
        border-right: 0px;
    }
}
@media (prefers-reduced-motion: reduce) {
    :root { --slide: 0ms; }
}
