@use 'mixins';
@import url('https://fonts.googleapis.com/css2?family=Recursive&family=Lato&family=Fira+Mono&display=swap');

$radius: 4px;

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
}

body {
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-paragraph);
    display: flex;
    flex-direction: column;
    color: var(--color-text-primary);
    background-color: var(--color-background);
    overflow: hidden;

    --color-background: #1a1717;
    --color-primary: #ffb77c;
    --color-text-primary: white;
    --color-text-inverse: black;
    --color-not-intense: #352f2a;
    --color-button-hover: #493c39;
    --color-button-active: #584742;
    --color-button-big: #524038;
    --color-button-text: #ddd;
    --color-input-underline: #6b534e;
    --color-input-active: var(--color-primary);
    --color-selected: #ccc;
    --color-good: #62ffa9;
    --color-bad: #ff7676;
    --color-note: #aaa;
    --color-panel-border: #72534aaa;
    --color-header: #2e2926;
    --color-separator: #614f4a;
    --color-icon-wall: #251f1d;

    --weight-thick: 500;
    --shadow-panel: 0 0 12px 6px #0006;
    --shadow-text: 0 0 10px #000a;

    --font-paragraph: 'Lato', sans-serif;
    --font-title: 'Recursive', serif;

    &:not(.logged-in) {
        .acc { display: none; }
    }
}

::selection {
    background-color: var(--color-separator);
}

a {
    color: var(--color-button-text);
    text-decoration: underline;
    cursor: pointer;

    &:hover {
        color: var(--color-text-primary);
    }
    &:active {
        color: var(--color-note);
    }

    &.disabled { pointer-events: none; opacity: 0.4; }

    &.title {
        text-decoration: none;
        display: flex;
        gap: 8px;

        > div {
            height: 32px;
            max-height: 0;
            width: 32px;
            position: relative;
            transition: max-height 0.7s cubic-bezier(0.23, 1, 0.320, 1), filter 0.5s;
            transform: translateY(2.5px);
        }

        img {
            position: absolute;
            height: 32px;
            animation: icon 1s infinite cubic-bezier(0.645, 0.045, 0.355, 1);
        }

        > h1 {
            transition: 0.5s cubic-bezier(0.215, 0.610, 0.355, 1);
        }

        &:hover > h1 {
            color: var(--color-text-primary);
            transform: translateX(4px);
        }
        &:hover > div {
            max-height: 4px;
            filter: grayscale(1) contrast(1.2) brightness(1.5);
        }
    }

    &.icon {
        text-decoration: none;
    }
}

@keyframes icon {
    0%   { top: -100%; }
    50% { top: 100%; }
    100% { top: -100%; }
}

b {
    font-weight: var(--weight-thick);
    color: var(--color-primary);
}

p {
    margin: 0;
    color: var(--color-note);
    word-wrap: break-word;
    white-space: normal;
    max-width: fit-content;
}

span.compact {
    display: -webkit-box;
    width: 100%;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

%heading {
    font-family: inherit;
    margin: 0;
    font-weight: var(--weight-thick);
}

h1 {
    @extend %heading;
    font-family: var(--font-title);
    font-weight: normal;
    color: var(--color-primary);
    transition: color 0.2s;
}
h2 {
    @extend %heading;
}
h3 {
    @extend %heading;
}

%clickable {
    outline: none;
    border: none;
    border-radius: $radius;
    background-color: transparent;
    color: var(--color-button-text);
    fill: var(--color-button-text);
    padding: 8px 12px;
    transition-duration: 0.05s;
    transition-timing-function: ease-out;
    font-family: inherit;
    font-size: 16px;

    &:disabled {
        opacity: 0.5;
    }
}
.elevate {
    padding-bottom: 12px;
    box-shadow: 0 -4px 0 #0007 inset;
    background-color: var(--color-not-intense);
}
@include mixins.on-desktop {
    %clickable:not(:disabled) {
        cursor: pointer;
    }
    %clickable:not(:disabled):hover, .tab %clickable:not(:disabled):focus {
        background-color: var(--color-button-hover);
        color: var(--color-text-primary);
        fill: var(--color-text-primary);
    }
}
%clickable:not(:disabled).hovered {
    background-color: var(--color-button-hover);
    color: var(--color-text-primary);
    fill: var(--color-text-primary);
}
%clickable:not(:disabled):active {
    background-color: var(--color-button-active);
    transition-duration: 0s;
}

button {
    @extend %clickable;
}
button.icon {
    padding: 8px;
    box-sizing: border-box;
    min-width: 36px;
    height: 36px;
    font-size: 16px;
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 4px;
    align-items: baseline;
    justify-content: center;

    > i {
        align-self: center;
    }
}
button.big {
    @extend %responsive;
    background-color: var(--color-button-big);
    color: var(--color-text-primary);
    padding: 8px 16px;
    padding-bottom: 12px;
    box-shadow: 0 -4px 0 #0007 inset;
    min-width: 100px;

    &.icon { height: 40px; }
}
button.compact {
    padding: 4px 8px;
}
button.compact.big {
    box-shadow: none;
}
button.toggle.active {
    background-color: var(--color-primary) !important;
    color: var(--color-text-inverse) !important;
}
button.toggle.with-tooltip {
    > span:last-of-type {
        color: white;
    }
}

.good:not(:disabled) {
    color: var(--color-good) !important;
}
.bad:not(:disabled) {
    color: var(--color-bad) !important;
}

textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: 1px solid var(--color-input-underline);
    transition-property: border-color;
    transition-duration: 0.1s;
    margin: 1px;
    background-color: transparent;
    color: inherit;
    padding: 2px 3px;
    resize: none;

    &:enabled:hover {
        border: 2px solid var(--color-input-underline);
        margin: 0;
    }
    &:enabled:focus {
        border: 2px solid var(--color-input-active);
        margin: 0;
    }
    &:disabled {
        opacity: 0.5;
    }
}

input {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
    border-bottom: 1px solid var(--color-input-underline);
    transition-property: border-bottom-color;
    transition-duration: 0.1s;
    margin-bottom: 1px;
    background-color: transparent;
    color: inherit;
    padding: 0 1px 3px 1px;

    &:enabled:hover {
        border-bottom: 2px solid var(--color-input-underline);
        margin-bottom: 0;
    }
    &:enabled:focus {
        border-bottom: 2px solid var(--color-input-active);
        margin-bottom: 0;
    }
    &:disabled {
        opacity: 0.5;
    }

    &[type=number] {
        width: 70px;
    }
    &[type=color], &[type=range] {
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        cursor: pointer;
    }
    &[type=color] {
        border: 1px solid #aaa !important;
        box-sizing: border-box;
        outline-offset: 0px;

        &:hover { border: 1px solid white !important; }

        &::-webkit-color-swatch-wrapper { padding: 0; }
        &::-webkit-color-swatch { border: 1px solid black; }
    }
    &[type=range] {
        border: none !important;
        -webkit-appearance: none;  /* Override default CSS styles */
        width: 100%; /* Full-width */
        height: 4px; /* Specified height */
        margin: 8px 0 !important;
        background: var(--color-input-underline);
        outline: none; /* Remove outline */

        &.smooth-bg {
            --v: 50%;
            background: linear-gradient(to right,
                                        var(--color-primary) var(--v),
                                        var(--color-input-underline) var(--v));
        }

        &:hover {
            &::-webkit-slider-thumb { background: var(--color-primary); }
            &::-moz-range-thumb     { background: var(--color-primary); }
        }

        &::-webkit-slider-thumb {
            -webkit-appearance: none; /* Override default look */
            appearance: none;
            width: 16px; /* Set a specific slider handle width */
            height: 16px; /* Slider handle height */
            border-radius: 50%;
            background: var(--color-button-text);
            transition-duration: 0.1s;
        }
        
        &::-moz-range-thumb {
            width: 16px; /* Set a specific slider handle width */
            height: 16px; /* Slider handle height */
            border-radius: 50%;
            background: white;
        }

        &.progressbar {
            cursor: inherit;
        }

        &.progressbar::-webkit-slider-thumb {
            background: none;
        }
        &.progressbar::-webkit-slider-thumb {
            background: none;
        }
    }

    &[type=checkbox] {
        margin-right: 6px;

        /* Change checkbox color to primary color */
        --brightness: 1.65;
        &:checked {
            filter: invert(90%) hue-rotate(-30deg) brightness(var(--brightness));
        }
    }
}
@supports (-moz-appearance:none) {
    input[type=checkbox] { --brightness: 1.4; }
}

i svg {
    fill: inherit;
    height: 16px;
}

.step-input {
    display: flex;
    justify-content: space-between;
    width: 80px;

    i {
        align-self: center;
        font-size: 14px;
        padding: 4px;
        color: white;
        cursor: pointer;

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

select {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
    background-color: var(--color-background);
    color: inherit;
    padding: 4px 0;
}

.disabled {
    pointer-events: none;
    user-select: none;
    opacity: 0.5;
}

li {
    display: flex;
    gap: 4px;
    background-color: var(--color-background);
    align-items: center;
    padding: 4px;
}

%responsive {
    transition-property: transform;
    transition-duration: 0.5s;
    transition-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1);
}
%responsive:not(:disabled):hover {
    transform: scale(0.98);
    transition-duration: 0.2s;
}
%responsive:not(:disabled):active, %responsive:not(:disabled).hovered {
    transform: scale(0.95);
}

.responsive {
    @extend %responsive;
}

#content {
    display: flex;
    position: relative;
    height: 100%;
}

#notifications {
    @extend %vertical;
    position: fixed;
    top: 0;
    left: 0; 
    margin: 24px;
    gap: 10px;
    z-index: 102;
}

.notification {
    display: flex;
    background-color: var(--color-background);
    box-shadow: 0 0 8px #0008;
    border-radius: $radius;
    padding: 4px;
    align-items: center;
    gap: 2px;
    width: fit-content;
    border: 2px solid var(--color-background);
    outline: 2px solid transparent;
    user-select: none;
    animation: notif-in 0.5s cubic-bezier(0.23, 1, 0.320, 1) forwards,
               notif-glow 1s ease-out infinite;

    span { margin: 4px; }
}

@keyframes notif-glow {
    0%   { outline-color: #fb80; outline-offset: 0; outline-width: 4px; }
    20%  { outline-color: #fb84; border-color: #fb8a; }
    100% { outline-color: #fb80; outline-offset: 10px; }
}

@keyframes notif-in {
    0%   { transform: translateX(-20px); opacity: 0; }
    100% { transform: none; opacity: 1; }
}

@mixin center-background {
    background-size: cover;
    background-origin: border-box;
    background-position: center;
    background-clip: content-box;
}

.roster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    flex-direction: row !important;
    gap: 8px !important;
    
    .char {
        display: flex;
        flex-direction: column;
        text-align: center;
        align-items: center;
        transition-duration: 0.1s;
        width: 48px;

        img, div {
            @include center-background;
            width: 100%;
            height: 48px;
            border-radius: 6px;
            box-shadow: 0 0 2px var(--color-text-primary);
            box-sizing: border-box;
        }
    }
}

%center {
    display: flex;
    align-items: center;
    justify-content: center;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.edit-img {
    display: flex;
    position: relative;
    outline: 2px dashed transparent;
    outline-offset: 2px;
    transition-property: all;

    &.drag {
        outline: 2px dashed white;
        outline-offset: 0;
        filter: contrast(0.5) brightness(1.5);
    }

    > div {
        @extend %center;
        position: absolute;
        background-color: #0008;
        color: white;
        font-weight: bold;
        opacity: 0;
        cursor: pointer;
        user-select: none;
        transition-duration: 0.1s;
    }
    > div:hover, div.hovered {
        opacity: 1;
    }

    > img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        align-self: center;
    }
}

.close {
    @extend .icon;
    border-radius: 50%;
    position: absolute;
    right: 4px;
    top: 4px;
}

%vertical {
    display: flex;
    flex-direction: column;
}

.file-upload {
    @extend %responsive;
    @extend %clickable;
    display: inline-flex;
    padding: 6px 12px;
    cursor: pointer;
    align-self: center;

    > input {
        display: none;
    }
}

section {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transition-duration: 0.5s;
    transition-property: opacity;
}
section.show {
    pointer-events: all;
    opacity: 1;
}

.invisible {
    opacity: 0;
    pointer-events: none;
}

header {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px 8px 12px;
    border-bottom: 2px solid var(--color-separator);
    align-items: center;
    background-color: var(--color-header);
    position: sticky;
    z-index: 101;
    user-select: none;

    > span > * {
        opacity: 1;

        &.hidden {
            @extend .invisible;
        }
    }

    &.on-mobile {
        position: relative;
        justify-content: center;
        border-bottom: none;
        padding: 10px;
    }
}

footer {
    position: sticky;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 101;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: #030303c0;
    color: var(--color-button-text);

    > div {
        width: 50%;
        display: flex;
        gap: 24px;
        align-items: center;
    }

    .with-tooltip > span {
        right: -8px;
    }
} 

.space-between {
    display: flex;
    justify-content: space-between !important;
}

.tooltip {
    transition-duration: 0.1s;
    position: absolute;
    bottom: 100%;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    border-radius: $radius;
    padding: 6px 8px;
    pointer-events: none;
    opacity: 0;
    max-width: 180px;
    width: max-content;
    z-index: 2;
    font-family: var(--font-paragraph);
    font-size: 16px;
    font-weight: normal;
}

%with-tooltip {
    position: relative;
    display: flex;
    justify-content: center;

    > span {
        @extend .tooltip;
    }

    @include mixins.on-desktop {
        &:hover {
            > span {
                opacity: 1;
            }
        }
    }
}

.with-tooltip {
    @extend %with-tooltip;
}
.with-tooltip.tooltip-inline {
    display: inline-flex;
}

.attach-icon {
    display: inline-flex;
    align-items: center;
    position: relative;
    
    > :last-child {
        position: absolute;
        left: 100%;
        margin: 0 0 4px 4px;
    }
}

.row {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.no-wrap {
    white-space: nowrap;
}

.hideable {
    opacity: 1;
}
.hideable.hidden {
    opacity: 0;
    pointer-events: none;
}

.toolbox {
    display: grid;
    gap: 1px !important;
    padding: 1px;

    > i, > .wrapper > i {
        @extend %toolbox-item;
    }
}

%toolbox-item {
    @extend %with-tooltip;
    background-color: var(--color-background);
    width: 36px;
    height: 36px;
    font-size: 20px;
    align-items: center;
    outline: 1px solid #aaa;

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

    > span {
        bottom: calc(100% + 4px);
    }
}

button.floating-action {
    background-color: var(--color-button-hover);
    right: 16px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 2px 12px 2px #0007;
    font-size: 20px;

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

.interactable {
    cursor: pointer;
}

ul.no-inset {
    margin-block: 0;
    padding-inline-start: 0;
}

ul.settings-list {
    gap: 1px;
}

li.list-setting {
    height: 2em;
    padding: 4px 8px;

    > .label {
        width: 100%;
        text-overflow: ellipsis;
        overflow: hidden;
        transition: 0.1s;
    }

    > input {
        padding-top: 3px;
    }

    &.highlight > .label, > .label:hover {
        color: var(--color-primary);
    }
}

.label > i {
    margin-right: 6px;
    font-size: 0.85em;
}

.segmented-button {
    display: flex;
    flex-direction: row;
    gap: 2px;

    > button {
        width: 100%;
        background-color: var(--color-background);
    }

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

    > :nth-child(n + 2) {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }

    > :nth-last-child(n + 2) {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }
}

.tile-container {
    display: flex;
    flex-wrap: wrap;
}