/* The Dungeon Generator's drawing tools (dungeon_draw_tools.js) and layers (dungeon_layers.js). Colours are the editor's
   (dungeon_generator.css). */

.dungeon-page .dungeon-draw-block {
    margin-bottom: 12px;
}

.dungeon-page .dungeon-draw-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dungeon-page[data-layout="phone"] .dungeon-draw-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dungeon-page .dungeon-draw-grid .dungeon-tool {
    min-height: 54px;
}

.dungeon-page[data-layout="phone"] .dungeon-draw-grid .dungeon-tool {
    padding-inline: 2px;
    font-size: 0.72rem;
}

.dungeon-page .dungeon-draw-hint {
    margin-top: 8px;
}

/* A polygon under way: its actions, for a screen with no Enter or Backspace key. */
.dungeon-page .dungeon-draw-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dungeon-page[data-layout="phone"] .dungeon-statusbar .dungeon-draw-actions {
    position: absolute;
    left: 8px;
    bottom: 60px;
    z-index: 5;
}

.dungeon-page .dungeon-draw-actions[hidden] {
    display: none;
}

.dungeon-page .dungeon-draw-inspector {
    margin-top: 8px;
}

/* The layers panel: opened by the map toolbar's Layers button. */
.dungeon-page .dungeon-layers-panel {
    position: absolute;
    top: 52px;
    right: 8px;
    z-index: 30;
    width: min(300px, calc(100% - 16px));
    max-height: calc(100% - 64px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 12px 12px;
    border: 1px solid var(--dungeon-border);
    border-radius: 8px;
    background: var(--dungeon-surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    color: var(--dungeon-text);
}

.dungeon-page .dungeon-layers-panel[hidden] {
    display: none;
}

.dungeon-page .dungeon-layers-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dungeon-page .dungeon-layers-heading h2 {
    margin: 0;
    font-size: 1rem;
}

.dungeon-page .dungeon-layer-list {
    margin: 8px 0;
    padding: 0;
    list-style: none;
}

.dungeon-page .dungeon-layer-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    border-bottom: 1px solid rgba(242, 192, 128, 0.16);
}

.dungeon-page .dungeon-layer-name {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 0.9rem;
}

.dungeon-page .dungeon-layer-name i {
    width: 1.1em;
    text-align: center;
    color: var(--dungeon-muted);
}

.dungeon-page .dungeon-layer-eye,
.dungeon-page .dungeon-layer-lock {
    flex: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--dungeon-text);
}

.dungeon-page .dungeon-layer-eye:hover,
.dungeon-page .dungeon-layer-lock:hover {
    background: var(--dungeon-bg);
}

.dungeon-page .dungeon-layer-row.is-hidden .dungeon-layer-name {
    opacity: 0.45;
    text-decoration: line-through;
}

.dungeon-page .dungeon-layer-row.is-locked .dungeon-layer-lock {
    color: var(--dungeon-accent);
}

.dungeon-page .dungeon-layers-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.dungeon-page .dungeon-layers-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 8px;
}

.dungeon-page [data-layers-toggle].is-active {
    border-color: var(--dungeon-accent);
}

.dungeon-page .dungeon-preview-banner {
    position: absolute;
    left: 50%;
    bottom: 56px;
    z-index: 20;
    max-width: calc(100% - 16px);
    transform: translateX(-50%);
    padding: 6px 12px;
    border: 1px solid var(--dungeon-accent);
    border-radius: 16px;
    background: var(--dungeon-surface);
    color: var(--dungeon-text);
    font-size: 0.82rem;
    text-align: center;
    pointer-events: none;
}

.dungeon-page .dungeon-preview-banner[hidden] {
    display: none;
}

/* A finger needs more room than a pointer. */
@media (any-pointer: coarse) {
    .dungeon-page .dungeon-layer-row {
        min-height: 40px;
    }

    .dungeon-page .dungeon-layer-eye,
    .dungeon-page .dungeon-layer-lock {
        width: 40px;
        height: 40px;
    }
}

/* On a tablet the flyout floats over the map: its width is the rail's flyout width, not what its longest line asks for
   (a hint of the drawing tools is long). */
.dungeon-page[data-layout="tablet"] .dungeon-flyout {
    width: var(--dungeon-flyout-width);
}

/* The map sheet's edge handles (dungeon_map_sheet.js): a grip along the right edge, along the bottom edge and at the
   corner, lit when pointed at or dragged; the outline of the size the map will have while one is dragged. */
.dungeon-page .dungeon-sheet-handle {
    --grip: 14px;
    position: absolute;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.dungeon-page .dungeon-sheet-handle[hidden] {
    display: none;
}

.dungeon-page .dungeon-sheet-handle::after {
    content: "";
    border-radius: 4px;
    background: var(--dungeon-sheet-edge);
    opacity: 0.75;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.dungeon-page .dungeon-sheet-handle:hover::after,
.dungeon-page .dungeon-sheet-handle:focus-visible::after,
.dungeon-page .dungeon-sheet-handle.is-dragged::after {
    opacity: 1;
    background: var(--dungeon-accent);
}

.dungeon-page .dungeon-sheet-handle:focus-visible {
    outline: none;
}

.dungeon-page .dungeon-sheet-handle--e {
    width: var(--grip);
    margin-left: 2px;
    cursor: ew-resize;
}

.dungeon-page .dungeon-sheet-handle--e::after {
    width: 5px;
    height: min(64px, 40%);
}

.dungeon-page .dungeon-sheet-handle--s {
    height: var(--grip);
    margin-top: 2px;
    cursor: ns-resize;
}

.dungeon-page .dungeon-sheet-handle--s::after {
    width: min(64px, 40%);
    height: 5px;
}

.dungeon-page .dungeon-sheet-handle--se {
    width: var(--grip);
    height: var(--grip);
    margin: 2px 0 0 2px;
    cursor: nwse-resize;
}

.dungeon-page .dungeon-sheet-handle--se::after {
    width: 10px;
    height: 10px;
    border-radius: 2px 2px 10px 2px;
}

.dungeon-page .dungeon-sheet-ghost {
    position: absolute;
    z-index: 3;
    border: 2px dashed var(--dungeon-accent);
    background: rgba(var(--dungeon-accent-rgb), 0.08);
    pointer-events: none;
}

.dungeon-page .dungeon-sheet-ghost[hidden],
.dungeon-page .dungeon-sheet-ghost-label[hidden] {
    display: none;
}

.dungeon-page .dungeon-sheet-ghost-label {
    position: absolute;
    z-index: 5;
    padding: 2px 8px;
    pointer-events: none;
    border-radius: 10px;
    background: var(--dungeon-accent);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 700;
}

@media (any-pointer: coarse) {
    .dungeon-page .dungeon-sheet-handle {
        --grip: 24px;
    }
}

/* The brush size keeps clear of the "Draw with" heading under it. */
.dungeon-page .dungeon-brush-field {
    margin-bottom: 14px;
}

/* The Diagonal tool's icon: a square cut corner to corner, its lower right half rock (distinct from Surface's tiles). */
/* (i.… : as specific as the rail's own rule for its icons, which it follows.) */
.dungeon-page i.dungeon-glyph-diagonal {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-radius: 2px;
    background: linear-gradient(to bottom right, transparent calc(50% - 1px), currentColor calc(50% - 1px));
    vertical-align: -0.125em;
}

/* The Diagonal panel: its picture, one line, and the selected room's two buttons. */
.dungeon-page .dungeon-diagonal-picture {
    margin: 4px 0 10px;
}

.dungeon-page .dungeon-diagonal-picture svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.dungeon-page .dungeon-panel-actions {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.dungeon-page .dungeon-panel-actions .dungeon-btn {
    justify-content: flex-start;
}

/* A layer with nothing on the open floor: dimmed, and saying so. */
.dungeon-page .dungeon-layer-row.is-empty .dungeon-layer-name {
    opacity: 0.55;
}

.dungeon-page .dungeon-layer-row.is-empty .dungeon-layer-name::after {
    content: "none here";
    margin-left: auto;
    color: var(--dungeon-muted);
    font-size: 0.75rem;
}
