@use 'base.scss';
@use 'panels.scss';
@use 'mixins';
@use 'sass:math';

%active {
    box-shadow: 0 0 6px var(--color-text-inverse) inset;
}

#boardContainer, #map {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#initiativePanel {
    width: max-content;

    span {
        display: flex;
        justify-content: center;
        font-size: 20px;
    }

    .hidden { display: none; }
}

#initiativeBar {
    width: max-content;
    top: 16px;

    &.hidden { display: none; }

    button { color: white; }

    .char {
        &:not(:hover) {
            .step-input { pointer-events: none; }
            i { opacity: 0; }
        }

        &:hover {
            z-index: 1;
            > .step-input { background-color: var(--color-background); }
        }

        &.private {
            color: var(--color-primary);
            > div {
                width: 36px;
                height: 36px;
                margin: 6px 0;
            }
        }

        > .step-input { margin-bottom: 4px; }

        > div {
            position: relative;
            cursor: pointer;
            overflow: hidden;
            transition-duration: 0.1s;
            color: white;

            &:hover, &.hovered { border: 1px solid white; }

            > span {
                width: 100%;
                height: 100%;
                font-size: 20px;
                display: flex;
                align-items: center;
                justify-content: center;
                background-color: #0006;
            }
        }
    }

    .roster:empty::after {
        content: "Waiting for players to roll...";
        color: var(--color-note);
    }

    #initiativeReroll:enabled:only-child {
        display: block !important;
        visibility: hidden;
        margin-right: 16px;
        top: auto;
    }
}

#initiativeReroll {
    /* hardcoded (but calculated) mess:
       (step-input height) + (step-input margin) + (half of char image height) - (half of button height)

       Sass will simplify this to 34px at compile time.
    */
    top: 24px + 4px + math.div(48px, 2) - math.div(36px, 2);

    &:disabled { display: none; }
    &:only-child::after {
        visibility: visible;
        content: "Waiting for players to roll...";
        color: var(--color-note);
    }
}

#boardContainer {
    position: relative;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;

    > .controls {
        position: absolute;
        z-index: 5;
        padding: 8px 10px;
        box-sizing: border-box;
        gap: 8px;

        h3 {
            margin-top: 2px;
            font-weight: normal;
        }

        button.active {
            color: var(--color-text-primary);
            background-color: var(--color-button-big);
        }

        #gridControls {
            display: flex;
            flex-direction: column;

            > span {
                display: flex;
                justify-content: space-between;
                gap: 8px;
                white-space: nowrap;

                input {
                    width: 160px;
                }
            }
        }
    }

    #sceneEditor {
        top: 16px;
        left: 16px;
        width: min-content;
    }

    #rightControls {
        position: absolute;
        top: 16px;
        right: 16px;
        gap: 16px;
        display: flex;
        flex-direction: column;
        z-index: 6;
        pointer-events: none;
        width: 280px;

        > .panel {
            padding: 8px;
            transition: opacity 0.2s;
        }
    }

    #prefabPalette {
        gap: 0;
        height: auto;
        max-height: 800px;
        transition-property: opacity, max-height !important;
        transition-timing-function: ease-in-out !important;

        > .close {
            background-color: transparent !important;
        }

        &.collapsed {
            max-height: 42px;
            overflow: hidden;

            > .prefab-selection {
                opacity: 0;
            }
        }

        #prefabImage {
            width: 80px;
            height: 80px;
            align-self: center;
        }
        #emptyIcon {
            font-size: 80px;
            opacity: 0.5;
            align-self: center;
        }

        #prefabProperties {
            transition-duration: 0.3s;
            overflow: hidden;
            max-height: 600px;
            margin-top: 8px;

            &.disabled {
                max-height: 0;
                margin-top: 0;
            }

            span {
                display: flex;
                gap: 8px;
                white-space: nowrap;

                > input {
                    width: 100%;
                }
            }
        }

        #prefabAccess {
            display: flex;
            flex-direction: column;
            margin: 0;
            padding: 0;
            gap: 1px;
            border: 1px solid var(--color-input-underline);
            background-color: var(--color-input-underline);
            z-index: 10;
            opacity: 1;
            overflow-y: auto;
            max-height: 180px;
            transition-duration: 0.2s;

            > li {
                border: none;
                border-radius: 0;
                color: var(--color-note);
                align-items: baseline;
                display: flex;
                justify-content: space-between;
                cursor: pointer;
                background-color: var(--color-background);

                &.active::after {
                    content: '\f00c';
                    font-family: 'Font Awesome 5 Free';
                    font-weight: 900;
                    text-rendering: auto;
                    -webkit-font-smoothing: antialiased;
                }
                &.active {
                    color: var(--color-text-primary);
                }

                &:hover {
                    background-color: var(--color-not-intense);
                }
            }

            &.disabled {
                max-height: 0;
                border: 0 solid transparent;
            }
        }
    }

    #selectionProperties {
        position: relative;
        gap: 8px;
        white-space: nowrap;

        > span {
            justify-content: flex-start;
            width: 260px;

            > :first-child {
                margin-left: 8px;
            }

            > input {
                min-width: 48px;
                width: 100%;
            }
        }

        &.hidden {
            @extend .invisible;
        }
    }

    #sizeInherit {
        position: absolute;
        left: 64px;
        color: var(--color-note);
        pointer-events: none;
    }

    #playerControls {
        top: 16px;
        left: 16px;
        display: flex;
        flex-direction: column;
        padding: 0;

        button {
            height: 40px;
        }

        .tab {
            position: relative;

            .content {
                position: absolute;
                top: -4px;
                left: calc(100% - 4px);
                pointer-events: none;
                opacity: 0;
                transition-duration: 0.1s;
                padding: 4px;
            }

            .toolbox {
                grid-auto-flow: column;
                border-color: var(--color-not-intense);
                background-color: var(--color-not-intense) !important;
                color: var(--color-text-primary);
            }

            &:active { background-color: var(--color-button-hover); }

            &.hovered, &.active {
                .content {
                    pointer-events: all;
                    opacity: 1;
                    left: 100%;
                }
            }
        }
    }

    .no-edit, .edit-only {
        transition-duration: 0.2s;
    }

    &.edit {
        .no-edit {
            @extend .invisible;
        }

        .movable:not(#angleArrow) {
            opacity: 0.5;
            pointer-events: none;
        }

        #gridCanvas {
            &.blink pattern > * {
                opacity: 1 !important;
            }
        }

        #rightControls > div { pointer-events: none; }
    }
    &:not(.edit) {
        .edit-only { @extend .invisible; }
        #gridPadding { display: none; }
        .movable.accessible { cursor: move; }
    }
    &:not([mode="pan"]) {
        .panning-only {
            @extend .invisible;
        }
    }
    &:not([mode="measure"]) {
        #measureCanvas { pointer-events: none; }
    }
    &:not([mode="fow"]) {
        #polymaskWrapper { pointer-events: none; opacity: 0.85; }
    }
}

%selectable-tile {
    cursor: pointer;
    box-sizing: border-box;
    border: 2px solid transparent;

    &.selected {
        opacity: 1;
        border: 2px solid var(--color-note);
    }
}

.prefab {
    @extend %with-tooltip;
    @include base.center-background;
    @extend %selectable-tile;
    opacity: 0.5;
    align-items: center;
    font-size: 20px;

    &:not(.selected) {
        transform: scale(0.95);

        &:hover {
            opacity: 1;
        }
    }
}

.prefab-selection {
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: opacity 0.1s;
}

.prefab-container {
    padding: 1px;
    gap: 1px;

    > *, > .wrapper > * {
        width: 36px;
        height: 36px;
        transition-duration: 0.2s;
        transition-timing-function: cubic-bezier(0.23, 1, 0.320, 1);

        &:active {
            transform: scale(0.9) !important;
        }
    }
}

$scene-preview-width: 140px;

#sceneSelector {
    @include panels.hooked(130px);
    min-width: 100%;
    width: 100%;
    border-radius: 0%;
    padding: 0 !important;

    &:hover, &.hovered { z-index: 7; }
}
#scenes {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
    padding: 8px;
}
#addScene {
    min-width: $scene-preview-width;
}

.scene-preview {
    display: flex;
    flex-direction: column;

    > div {
        @include base.center-background;
        min-width: $scene-preview-width;
        max-width: $scene-preview-width;
        height: 100vh;
        overflow: hidden;
        border-radius: base.$radius;
        box-sizing: border-box;
        cursor: pointer;
        position: relative;

        &.editing {
            @extend %active;
            border: 2px dashed var(--color-text-primary) !important;
        }
        &.playing {
            @extend %active;
            border: 2px solid var(--color-good) !important;
        }

        button {
            border-radius: 0%;
            width: 100%;
            height: 100%;
            opacity: 0;
            background-color: var(--color-not-intense);
            align-items: center;

            &:hover {
                opacity: 0.8 !important;
            }
        }
    }

    > span {
        padding: 0;
        display: flex;
        justify-content: space-between;
        opacity: 0.5;
        transition-duration: 0.1s;
        height: 0;
        min-height: 0;
        overflow: hidden;

        button.play:hover {
            color: var(--color-good);
        }
    }

    &:hover {
        > div {
            @extend %active;
            border: 2px solid var(--color-text-primary);
            button {
                opacity: 0.75;
            }
        }

        > span {
            opacity: 1;
            padding: 2px 0;
            min-height: 36px;
        }
    }
}

#movableLabel {
    input {
        color: var(--color-primary);
    }

    b:not(:empty) {
        margin-right: 3px;
    }
}

#selectionArea {
    stroke: white;
    stroke-width: 2px;
    fill: #fff5;
}

#gridCanvas {
    pointer-events: none;

    pattern {
        stroke-width: 0.05;
        fill: none;
    }
}

#session {
    display: flex;
    flex-direction: row;

    &:not(.is-dm) {
        .dm {
            display: none !important;
        }

        #initiativeReroll {
            pointer-events: none;
        }

        .movable.accessible {
            border-color: white;
            z-index: calc(200 - var(--size));

            > img { box-shadow: 0 0 8px #0008 inset; }
        }

        .step-input {
            background-color: transparent !important;

            i { visibility: hidden; }
        }

        #player > :not(button) { max-width: 100%; }
    }

    &.demo .no-demo {
        @extend .invisible;
    }

    @include mixins.on-desktop {
        > *:not(:last-child) {
            border-right: 2px solid var(--color-separator);
        }
    }
}

.roll {
    font-family: 'Courier New', Courier, monospace;
    padding: 0 2px;
    color: white !important;
    background-color: #1a1a1a;
    border-radius: 4px;
    padding: 2px 4px 2px 3px;
    margin: 0 2px;

    &.ignored {
        opacity: 0.5;
    }
}
.dice {
    color: var(--color-primary) !important;
}

#log {
    min-width: calc(150px + 8vw);
    width: 25vw;
    max-width: 300px;
    z-index: 2;

    &, > * {
        display: flex;
        flex-direction: column;
    }
}
#messages {
    overflow-x: hidden;
    overflow-y: auto;
    height: 100%;
    padding: 4px;
    gap: 6px;

    > * {
        position: relative;
        padding: 8px;
        text-shadow: var(--shadow-text);
        font-size: 1.1em;
        overflow-wrap: break-word;
        background-color: var(--color-not-intense);
        border-radius: 8px;
        max-width: 80%;
        width: max-content;

        > span {
            color: #999;
            display: inline-flex;
            flex-wrap: wrap;
        }

        &.hidden { opacity: 0.6; }

        &.big {
            max-width: calc(100% - 16px);
        }

        &.system {
            align-self: center;
            text-align: center;
            background: none;
            color: var(--color-note);
        }

        &.mine {
            align-self: flex-end;
        }
    }

    i {
        display: flex;
        position: absolute;
        right: 100%;
        padding: 6px;
        top: calc(50% - 14px);
        font-size: 14px;
        color: var(--color-note);

        span {
            color: white;
        }
    }

    > .clickable {
        @extend %responsive;
        @extend %with-tooltip;
        cursor: pointer;
        display: block;

        &:hover { background-color: var(--color-button-hover); }

        &.no-select { user-select: none; }

        > span {
            bottom: calc(50% - 16px);
            left: 25%;
            width: 50%;
            max-width: 50%;
            text-align: center;
            color: white;
        }
    }
}
#chat {
    position: relative;

    > textarea {
        max-height: 8vh;
        min-height: 40px;
        resize: none;
    }

    > div {
        @extend %vertical;
        position: absolute;
        top: 0;
        right: 0;

        span {
            color: white;
            top: 0;
            bottom: auto;
            right: 100%;
        }
    }

    button {
        transition-duration: 0.2s;
    }
}

#chatRoller {
    display: flex;
    transition: 0.2s ease-out;
    margin-top: 0;

    &.disabled {
        pointer-events: none;
        margin-top: -50%;
        opacity: 0;
    }

    button {
        color: var(--color-primary);
    }
}
#chatSend {
    align-self: flex-end;
}

#miniChat {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;

    > span {
        position: relative;
        opacity: 0.9;
        background-color: var(--color-not-intense);
        text-align: start;
    }
}

.animate-transform {
    transition-property: transform, scale !important;
    transition-duration: calc(var(--anim-duration) * 1ms) !important;
    transition-timing-function: ease !important;
}

#board {
    position: absolute;
    display: flex;
    transition: scale 0.05s;
    border: 2px solid var(--color-separator);
    box-sizing: border-box;
    box-shadow: 0 0 20px #0003;
    outline: 1px solid transparent;

    canvas {
        position: absolute;
        transition-duration: 0.2s;
    }

    > .hidden { display: none; }
}

#movableGhost {
    @include base.center-background;
    opacity: 0.75;
    z-index: 1000;
    border-radius: 50%;
    box-shadow: 0 0 10px #000a;
    pointer-events: none;

    &.translucent {
        opacity: 0.5;
        z-index: 0;
        box-shadow: none;
    }
}

#gridPadding {
    outline: 2px solid white;
    pointer-events: none;

    > * { pointer-events: all; }

    &:not(:active) > .corner {
        border: 5px solid white;
        background-color: white;
    }
}

$svg-outline-width: 0.15em;
$svg-circle-radius: 0.4em;

$blink-on:  #fffd;
$blink-off: #888d;

@keyframes blink {
    0%   { stroke: $blink-off; fill: $blink-off; }
    50%  { stroke: $blink-on;  fill: $blink-on;  }
    100% { stroke: $blink-off; fill: $blink-off; }
}

#measureCanvas {
    animation: blink 2s infinite linear;
    z-index: 1001;
}
#distanceCanvas {
    stroke: #eee7;
    fill: #eee7;
}
.grid-canvas {
    stroke-width: $svg-outline-width;
    stroke-linecap: round;
    stroke-linejoin: round;

    > * { pointer-events: none; }

    path, .no-fill {
        fill: none !important;
        vector-effect: non-scaling-stroke;
    }
    circle.origin {
        stroke: none !important;
        r: $svg-circle-radius;
    }
    g > rect {
        fill: unset;
        stroke: #fff !important;
    }
}

.toast {
    position: absolute;
    z-index: 1002;
    padding: 8px 12px;
    border-radius: base.$radius;
    background-color: var(--color-not-intense);
    box-shadow: 0 0 8px 2px #0005;
    transition: transform 0s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s 0.1s;
    pointer-events: none;
    white-space: nowrap;
}

.distance-text {
    @extend .toast;
    transform-origin: top left;

    &.slow {
        opacity: 0;
        animation: reveal-opacity 0.4s 0.3s forwards;
    }
}

@keyframes reveal-opacity {
      0% { opacity: 0; }
    100% { opacity: 0.95; }
}

#tooltip {
    position: absolute;
    bottom: 80px;
    background-color: #111a;
    border-radius: 8px;
    padding: 8px 12px;

    &:empty {
        display: none;
    }

    b {
        color: #ffc69a;
    }
}

#grid {
    position: absolute;
    z-index: 0;
}

.use-cell-size {
    font-size: calc(var(--cell-size) * 0.5px);
}

@keyframes movable-spawn {
    0%   { margin-top: 20px; opacity: 0; }
    100% { margin-top: 0; opacity: 1; }
}
@keyframes movable-remove {
    0%   { margin-top: 0; opacity: 0.5; }
    100% { margin-top: 40px; opacity: 0; }
}

.aura, .ring, .movable > .img {
    border-radius: 50%;
    pointer-events: none;
}

$token-unit-size: 70;
$token-unit-size-px: $token-unit-size + px;
$token-unit-size-half-px: ($token-unit-size * -0.5) + px;

.movable {
    position: absolute;
    display: flex;
    justify-content: center;
    border: 0 solid var(--color-background);
    border-radius: 50%;
    left: calc(var(--size) * $token-unit-size-half-px);
    top: calc(var(--size) * $token-unit-size-half-px);
    width: calc(var(--size) * $token-unit-size-px);
    height: calc(var(--size) * $token-unit-size-px);
    box-sizing: border-box;
    transform: translate(var(--x), var(--y)) scale(calc(var(--cell-size) / $token-unit-size));
    transition: transform 0.3s, left 0.1s, top 0.1s, width 0.1s, height 0.1s, opacity 0.1s;
    z-index: calc(100 - var(--size));

    --size: 1;
    --x: 0;
    --y: 0;
    --angle: 0;

    &.invisible {
        &:not(.accessible) { display: none; }
        &.accessible {
            opacity: 0.65;
            pointer-events: all;
        }
    }

    &:not(#movableGhost) {
        animation: movable-spawn 0.5s cubic-bezier(0.23, 1, 0.320, 1);

        > .img { background-color: #1118; }
    }
    &.no-animate-move {
        transition-property: border-color, width, height, opacity;
    }
    &.animate-remove {
        animation: movable-remove 0.4s forwards cubic-bezier(0.6, -0.28, 0.735, 0.045) !important;
    }

    > * {
        position: absolute;
        box-sizing: border-box;
    }

    > .img {
        @include base.center-background;
        border: 3px solid;
        border-color: inherit;
        border-radius: 50%;
    }

    > .rotating {
        @extend %center;
        rotate: calc(var(--angle) * 1deg);
    }

    > .conds {
        top: 0;
        left: 0;
        display: flex;
        cursor: default;

        > i {
            @extend %with-tooltip;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 100%;
            width: 26px;
            height: 26px;
            font-size: 14px;
            background-color: var(--color-background);

            > span { font-size: inherit; }
        }
    }

    > .aura {
        left: calc(var(--aura) * -70px);
        top: calc(var(--aura) * -70px);
        width: calc(70px * (var(--aura) * 2 + var(--size)));
        height: calc(70px * (var(--aura) * 2 + var(--size)));
        background-color: #8884;
        transition: 0.1s;
    }

    > .ring {
        width: 100%;
        height: 100%;
        animation: scale-pulse 1s infinite alternate ease-in-out;
        opacity: 0.7;
    }

    > .toast {
        top: 60%;
        font-size: 14px;
        background-color: #1119;
        padding: 6px 8px;
        opacity: 0;
    }

    > .bars {
        bottom: 100%;
        width: 100%;
        pointer-events: none;
        padding-inline-start: 0;
        margin: 0;
        transition: 0.1s;
    }

    &.empty {
        border-color: var(--color-bad);
        display: flex;
        align-items: center;
        justify-content: center;

        .img { background: #222 !important; }

        > span {
            pointer-events: none;
            display: flex;
            font-family: 'Fira Mono';
            color: var(--color-bad);
            text-align: center;
            font-size: calc(var(--size) * 110px / var(--length));
            z-index: 3;
            --length: 1;
        }
    }
    &.accessible:hover {
        border-color: var(--color-primary) !important;
    }

    &.pinged {
      .ring {

        animation: pulse-ping 1.5s infinite;
      }
    }

    &.selected {
        border-color: var(--color-primary);
        z-index: calc(300 - var(--size));

        > img {
            box-shadow: 0 0 16px 4px #000a,
                        0 0 8px #0008 inset;
        }

        > .ring {
            border: 3px solid var(--color-primary);
        }
    }
    &.active, &.hovered {
        border-color: white !important;

        > .ring {
            border: 3px solid white;
        }
    }
    &:not(:active):hover {
        > .toast {
            opacity: 1;
            transition-delay: 0s;
        }
    }

    &:not(:active):hover, &:not(:active).active {
        .token-bar {
            @extend %active-token-bar;
        }
    }
}

%active-token-bar {
    height: 1em;
    opacity: 1;

    span {
        opacity: 1;
    }
}

.token-bar {
    position: relative;
    width: 90%;
    font-size: calc(1em + 0.5em * (var(--size) - 1));
    height: 0.5em;
    padding: 0;
    margin: 2px auto;
    background-color: #333c;
    transition: 0.2s;
    justify-content: center;
    opacity: 0.7;
    --progress: 0;
    --color: #000;

    > .bar-fill {
        height: 100%;
        width: calc(var(--progress) * 100%);
        margin-right: auto;
        background-color: var(--color);
    }

    span {
        position: absolute;
        font-size: 0.5em;
        opacity: 0;
        transition: inherit;
        text-shadow: var(--shadow-text);
    }

    &.active {
        @extend %active-token-bar;
    }
}

.token-bar-label {
    width: max-content;
    right: 100%;
    margin-right: 4px;
}

.token-bar-value {
    padding: 0 2px;
}

@keyframes scale-pulse {
    0%   { transform: scale(calc(1 + 0.3 / var(--size))); }
    100% { transform: scale(calc(1 + 0.5 / var(--size))); }
}

#selectionConditions {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    width: fit-content;
}

#conds {
    top: 0;
    right: 0;
    gap: 8px;

    .toolbox {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
    }
}

$ping-radius: 100px;

.ping {
    position: absolute;
    pointer-events: none;
    border-radius: $ping-radius * 2;
    border: 3px solid white;
    animation: ping-grow infinite 3s ease-out;
    z-index: 25;
}

@keyframes ping-grow {
    0% { width: 0; height: 0; opacity: 0; }
    10% { opacity: 1; }
    70% { opacity: 1; }
    100% {
        width: $ping-radius * 2;
        height: $ping-radius * 2;
        transform: translate(-$ping-radius, -$ping-radius);
        opacity: 0;
    }
}

#inactiveSceneWarning {
    @extend %responsive;
    position: absolute;
    z-index: 6;
    top: 16px;
    background-color: var(--color-background);
    box-shadow: 0 0 8px 2px #0006;
    box-sizing: border-box;
    padding: 8px;
    border-radius: base.$radius;
    text-align: center;
    transition-property: transform, opacity;
    cursor: pointer;

    &.hidden { @extend .invisible; }
}

#online {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 20px 16px;
    display: flex;
    flex-wrap: wrap-reverse;
    gap: 4px;
    width: 20vw;
    min-width: 300px;
    min-height: 30px;
    z-index: 5;

    > span {
        display: flex;
        align-items: center;
        background-color: #111b;
        padding: 6px 10px 6px 8px;
        gap: 6px;
        border-radius: 100px;
        box-sizing: border-box;

        &.with-tooltip {
            cursor: pointer;

            &:hover { background-color: #040404cc; }
        }
    }
}

#dice {
    border-collapse: collapse;
    background-color: var(--color-background);
}

#diceTab {
    z-index: 1;
    --offset: 0;

    .with-tooltip {
        position: absolute;
        bottom: calc(100% - 4px);
        width: calc(100% - 8px);
        border-bottom: none !important;
        box-sizing: border-box;
        background-color: var(--color-background);
        display: flex;
        gap: 4px;
        align-items: center;
    }

    tr {
        counter-reset: drow;
        counter-increment: drow var(--offset);
    }

    td:not(:first-child)::before {
        counter-increment: drow;
        content: counter(drow);
    }

    td, .with-tooltip {
        @extend %clickable;
        padding: 4px;
        min-width: 20px;
        border: 1px solid var(--color-not-intense);
        border-radius: 0%;
        transition-duration: 0s;
    }
}

.tab-horiz {
    display: flex;
    gap: 4px;

    > * {
        transition: opacity 0.1s;
    }
}

#ambience {
    position: relative;
    z-index: 1;
    user-select: none;

    > button {
        position: relative;
        background: var(--color-header);
        border-radius: 0%;
        gap: 6px;
    }

    .shrink {
        max-height: 300px;
        transition: max-height 0.3s, padding 0.3s;
    }

    &.keep-open {
        #pinPlayer { color: var(--color-primary); }
    }

    &:not(:hover) {
        .shrink {
            max-height: 0 !important;
            padding: 0 !important;
            transition: max-height 0.3s, padding 0.1s 0.2s;
            overflow: hidden;
        }
    }

    &:hover, &.keep-open {
        > .content {
            max-height: 400px;
        }

        #pinPlayer { opacity: 1; }
    }

    > .content {
        max-height: 0;
        transition: max-height 0.2s;
        background: var(--color-background);
        border-bottom: 2px solid var(--color-separator);
        overflow: hidden;

        > div {
            margin: 4px;
            padding: 6px;
            background: var(--color-header);
        }

        span {
            display: flex;
            padding: 4px;
            gap: 6px;

            > i {
                min-width: 20px;
                text-align: center;
            }
        }
    }
}

#player {
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    background: var(--color-button-hover) !important;
    transition-duration: 0.25s;
    height: 38px;

    &.hide {
        padding: 0 !important;
        margin: 0 !important;
        height: 0;
    }

    > :not(button) {
        width: max-content;
        max-width: calc(100% - 44px);
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        text-shadow: var(--shadow-text);
        transition: opacity 0.4s;

        &.transition {
            cursor: default;
            opacity: 0;
            transition: 0.2s;
        }
    }

    a { text-decoration: none; }

    > button {
        position: absolute;
        right: 8px;
        background-color: transparent;
    }
}

#pinPlayer {
    color: var(--color-note);
    position: absolute;
    right: 16px;
    top: 11px;
    opacity: 0;
    transition: opacity 0.2s;
}

#playlists {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px;
    padding: 8px 0;
}

.no-music {
    #playlists, #playerMusicSlider {
        display: none !important;
    }

    #ambience:hover, #ambience.keep-open {
        > .content {
            max-height: 140px;
        }

        #pinPlayer { opacity: 1; }
    }

    #ambience .shrink {
        max-height: 140px;
    }
}

#angleArrow {
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    animation: none !important;
    transition: opacity 0.2s;
    --offset: 20px;

    &.show {
        opacity: 1;
    }

    * { position: absolute; }

    .rotating {
        rotate: calc(var(--angle) * 1deg + 180deg);
    }
}
#angleCurrent {
    --offset: -16px;
}
.arrowEnd {
    transform: translate(0, calc(var(--size) * $token-unit-size-half-px - var(--offset)));
    text-shadow: 0 0 4px #000b;
    font-size: 1.5rem;
}

.color-palette {
    display: flex;
    gap: 2px;
}

.color-tile {
    @extend .interactable;
    @extend %responsive;
    @extend %selectable-tile;
    background-color: var(--color);
    width: 100%;
    height: 24px;

    &.selected {
        border-color: white;
    }
}

@keyframes pulse-ping {
  0% {
    transform: scale(3);
    border: 10px solid rgba(98, 255, 169, 0.7);
  }

  50% {
    transform: scale(1.5);
    border: 10px solid rgba(98, 255, 169, 1);
  }

  100% {
    transform: scale(0);
    border: 1px solid rgba(98, 255, 169, 0);
  }
}
