@keyframes rotateOut {
    from {
        opacity: 1;
        transform: perspective(400px) rotateX(0deg);
    }
    to {
        opacity: 0;
        transform: perspective(400px) rotateX(-90deg);
    }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0deg);
  }
}

.rotateOut {
    animation: rotateOut 0.3s ease forwards;
}

.rotateIn {
    animation: rotateIn 0.3s ease forwards;
}

@font-face {
    font-family: "Outfit";
    font-style: normal;
    font-weight: 400;
    src: url("/fonts/outfit-400.woff2") format("woff2");
}

@font-face {
    font-family: "Outfit";
    font-style: normal;
    font-weight: 600;
    src: url("/fonts/outfit-600.woff2") format("woff2");
}

:root {
    --bgcolor1: #2c2c2a;
    --bgcolor2: #252524;
    --bgcolor-main: #1f1f1e;
    --bgcolor3: #1c1c1c;
    --banner-height: 60px;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    height: 100%; /* ios fix */
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bgcolor-main);
    font-family: "Outfit", sans-serif;
    display: flex;
    flex-direction: column;
}

img,
svg {
    display: block;
    max-width: 100%;
}

p {
    text-wrap: pretty;
    overflow-wrap: break-word;
}

button,
a,
[role="button"] {
    -webkit-tap-highlight-color: transparent; /* ios flicker fix */
}

a {
    color: inherit;
}

#banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--banner-height);
    background-color: var(--bgcolor2);
    z-index: 1;
}

#bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.bg-icon {
    position: absolute;
    width: 48px;
    height: 48px;
    opacity: 0.05;
    max-width: none;
    pointer-events: none;
}

.mkwr-logo {
    width: 130px;
    fill: white;
    opacity: 0.87;
}

#menu-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    position: fixed;
    top: calc(var(--banner-height) / 2);
    left: 12px;
    transform: translateY(-50%);
    z-index: 2;
}

#close-btn {
    align-items: center;
}

#track-list-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

#toggle-all-btn {
    margin: 16px 0 8px 0;
    width: fit-content;
}

#reset-settings-btn {
    width: fit-content;
    margin-bottom: 16px;
}

.settings-btn {
    font-family: inherit;
    color: rgba(250, 250, 250, 0.87);
    font-size: 1rem;
    background-color: var(--bgcolor3);
    border: 1px solid rgba(250, 250, 250, 0.87);
    border-radius: 8px;
    padding: 4px 8px;
    cursor: pointer;
}

.settings-btn:hover {
    background-color: var(--bgcolor1);
}

#sidenav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    height: 100%;
    background-color: var(--bgcolor2);
    color: rgba(250, 250, 250, 0.87);
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

#sidenav.open {
    transform: translateX(0);
}

#sidenav-header {
    display: flex;
    align-items: center;
    height: 60px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(250, 250, 250, 0.87);
    padding: 16px;
    cursor: pointer;
}

#sidenav-header span {
    display: flex;
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    margin-left: 5px;
    color: rgba(250, 250, 250, 0.87);
}

.settings-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0px 16px;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.settings-item {
    flex-shrink: 0;
}

.cooldown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.cooldown-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

#cooldown-input {
    /*margin-left: 40px;*/
    padding: 4px 8px;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    text-align: center;
    background-color: var(--bgcolor1);
    border: 1px solid rgba(250, 250, 250, 0.3);
    border-radius: 8px;
    width: 48px;
}

#cooldown-input::-webkit-inner-spin-button,
#cooldown-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.cooldown-item.disabled label,
.cooldown-item.disabled #cooldown-input {
    opacity: 0.4;
}

#max-cooldown-label {
    font-size: 0.8rem;
    opacity: 0.5;
    /*margin-left: 5px;*/
    width: 60px;
    text-align: right;
}

.tracks-dropdown {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

#track-list-container {
    display: none;
    flex-direction: column;
    scrollbar-gutter: stable;
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    padding-right: 4px;
}

.track-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#enabled-count {
    font-size: 0.8rem;
    opacity: 0.5;
}

.track-list-item {
    min-height: 44px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.track-list-item:hover {
    background-color: var(--bgcolor1);
}

.track-list-item:last-child {
    border-bottom: none;
}

.track-list-item:has(input:not(:checked)) .track-name {
    opacity: 0.4;
}

#track-list-btn.open {
    border-bottom: 1px solid rgba(250, 250, 250, 0.15);
    padding-bottom: 12px;
}

#track-list-btn svg {
    transition: transform 0.3s ease;
}

#track-list-btn.open svg {
    transform: rotate(180deg);
}

#track-list-container.open {
    display: flex;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 2.2em;
    height: 1.2em;
    vertical-align: middle;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ccc;
    border-radius: 1.2em;
    transition: background-color 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    width: 0.9em;
    height: 0.9em;
    left: 0.15em;
    top: 50%;
    transform: translateY(-50%);
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

input:checked + .slider {
    background-color: #ffd54a;
}

input:checked + .slider:before {
    transform: translate(1em, -50%);
}

main {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding-bottom: var(--banner-height);
}

.track-btn-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 320px;
    height: fit-content;
    padding: 16px;
    gap: 16px;
    border-radius: 32px;
    background-color: var(--bgcolor2);
    z-index: 1;
}

.track-container {
    height: 206px;
}

.track-container img {
    width: 100%;
    height: auto;
}

.mkw-card-bg { /* TODO delete rect if bgcolor2 is kept on track-btn-container */
    fill: var(--bgcolor2);
}

.mkw-q-card {
    opacity: 0.87;
}

.track-container svg {
    width: 100%;
    height: auto;
    fill: white;
}

#randomize-btn {
    padding: 8px 10px;
    border-radius: 32px;
    border: none;
    font-weight: 600;
    font-size: 1.2rem;
    font-family: inherit;
    cursor: pointer;
    background: linear-gradient(to bottom, #ffe17d 0%, #ffd54a 50%, #ffc917 100%);
    color: #222;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    will-change: transform;
    touch-action: manipulation;
}

#randomize-btn:active {
    transform: scale(0.985);
    opacity: 0.95;
}

#randomize-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#no-repeats-container {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 320px;
    padding: 16px;
    margin-top: 16px;
    border-radius: 32px;
    background-color: var(--bgcolor2);
    z-index: 1;
}

#no-repeats-container.open {
    display: flex;
}

#no-repeats-counter {
    color: rgba(250, 250, 250, 0.87);
}

.sidenav-footer {
    display: flex;
    flex-direction: column;
    margin-top: auto;
    padding: 16px 16px 0px 16px;
}

footer {
    min-height: var(--banner-height);
    background-color: var(--bgcolor2);
    display: flex;
    align-items: center;
    border-top: 1px solid rgba(250, 250, 250, 0.15);
}

footer p {
    color: rgba(250, 250, 250, 0.87);
    font-size: 0.7rem;
}

.mkw-logo {
    width: 60px;
    height: auto;
    margin-left: auto;
}

#track-list-landscape-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    align-items: center;
}

@media (orientation: landscape) and (max-width: 900px){
    #banner { display: none; }

    main { 
        padding-bottom: 0px;
        flex-direction: row-reverse;
    }

    #no-repeats-container {
        margin-right: 16px;
    }

    #track-list-container.open {
        width: 100%;
        height: 100%;
        position: fixed;
        inset: 0;
        z-index: 11;
        background-color: var(--bgcolor2);
    }

    #track-list-landscape-btn {
        display: flex;
    }
    
    #track-list-btn svg {
        display: none;
    }
}

@media (max-width: 768px) {
    #sidenav {
        width: 100%;
    }

    .track-list-item:hover {
        background-color: transparent;
    }

    .settings-btn:hover {
        background-color: var(--bgcolor3);
    }
}