@font-face {
    font-family: "Montserrat Alternates";
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url("fonts/montserrat-alternates-300.woff2") format("woff2");
}

@font-face {
    font-family: "Montserrat Alternates";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/montserrat-alternates-400.woff2") format("woff2");
}

:root {
    --primary-color: #f4f4f4;
    --secondary-color: #333;
    --text-shadow: none;
    --gradient-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] {
    --primary: #333;
    --secondary: #f3fff8;
}

[data-theme="light"] {
    --primary: #f4f4f4;
    --secondary: #333;
}

[data-theme="blue"] {
    --primary: #005b96;
    --secondary: #f3fff8;
}

[data-theme="green"] {
    --primary: #36802d;
    --secondary: #f3fff8;
}

[data-theme="red"] {
    --primary: #d32f2f;
    --secondary: #f3fff8;
}

[data-theme="yellow"] {
    --primary: #8c7223;
    --secondary: #f3fff8;
}

[data-theme="purple"] {
    --primary: #9c1fc4;
    --secondary: #f3fff8;
}

[data-theme="gradient-1"] {
    --primary: linear-gradient(to top right, #12c2e9, #c471ed, #f64f59);
    --secondary: #f3fff8;
    --shadow: var(--gradient-shadow);
}

[data-theme="gradient-2"] {
    --primary: linear-gradient(to top right, #007991, #78ffd6);
    --secondary: #f3fff8;
    --shadow: var(--gradient-shadow);
}

[data-theme="gradient-3"] {
    --primary: linear-gradient(to bottom left, #f0f2f0, #000c40);
    --secondary: #f3fff8;
    --shadow: var(--gradient-shadow);
}

[data-theme="gradient-4"] {
    --primary: linear-gradient(to top right, #ff6e7f, #bfe9ff);
    --secondary: #333;
}

[data-theme="gradient-5"] {
    --primary: linear-gradient(to top right, #ffa17f, #00223e, #2c5364);
    --secondary: #f3fff8;
    --shadow: var(--gradient-shadow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat Alternates', sans-serif;
    background: var(--primary-color);
    height: 100vh;
    height: 100dvh;
}

#bg-fade {
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s;
}

header {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: center;
    text-align: center;
    height: 95vh;
    height: 95dvh;
}

footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 5vh;
    height: 5dvh;
}

.footer-text {
    color: var(--secondary-color);
    text-shadow: var(--text-shadow);
    transition: color 1s, text-shadow 1s;
}

.heart {
    vertical-align: -0.125em;
    color: #e25555;
}

.social-links {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
}

.social-link {
    display: inline-flex;
    font-size: 1.3rem;
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 1s, opacity 0.2s, transform 0.2s;
}

.social-link svg {
    filter: var(--icon-filter, none);
    transition: filter 1s;
}

.social-link:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

.social-link:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 3px;
    border-radius: 3px;
}

div {
    text-align: center;
}

.colours {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
}

div h1 {
    font-size: 4rem;
    color: var(--secondary-color);
    text-shadow: var(--text-shadow);
    margin: 3rem auto;
    padding: 1rem;
    transition: color 1s, text-shadow 1s;
}

#custom-color {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

#custom-color:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 6px;
    border-radius: 6px;
}

.btn {
    margin: 2rem 2rem;
    padding: 1.5rem 1.5rem;
    border: 2px solid var(--secondary);
    border-radius: 5px;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
}

.btn:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

.btn:focus {
    outline: none;
}

.btn:active,
.btn.active {
    transform: scale(1.1);
}

.btn:focus-visible,
.btn.active {
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px #111;
}

@media(max-width: 1400px) {
    .btn {
        margin: 2rem 1.5rem;
    }
}

@media(max-width: 768px) {
    .btn {
        margin: 2rem 1rem;
    }
}

@media(max-width: 500px) {
    .btn {
        margin: 1rem 0.5rem;
    }

    .colours {
        grid-template-columns: repeat(4, 1fr);
    }

    header {
        height: 85vh;
        height: 85dvh;
    }

    footer {
        flex-direction: column;
        gap: 0.2rem;
        height: 15vh;
        height: 15dvh;
    }
}

@media(max-height: 400px) {
    .colours {
        grid-template-columns: repeat(4, 1fr);
    }

    header {
        height: 90vh;
        height: 90dvh;
    }

    footer {
        height: 10vh;
        height: 10dvh;
    }
}

#picker-dialog {
    margin: auto;
    padding: 2rem 2.5rem;
    border: none;
    border-radius: 8px;
    min-width: min(22rem, 90vw);
    font-family: 'Montserrat Alternates', sans-serif;
    color: #545454;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#picker-dialog[open] {
    animation: dialog-in 0.25s ease-out;
}

#picker-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#picker-dialog h2 {
    font-size: 1.6rem;
    font-weight: 300;
    margin-bottom: 1.5rem;
}

.picker {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 16rem;
    margin: 0 auto 1.5rem;
}

.picker-sv {
    --hue: 0;
    position: relative;
    height: 10rem;
    border-radius: 6px;
    background:
        linear-gradient(to top, #000, transparent),
        linear-gradient(to right, #fff, hsl(var(--hue), 100%, 50%));
    cursor: crosshair;
    touch-action: none;
}

.picker-sv:focus-visible {
    outline: 2px solid #111;
    outline-offset: 3px;
}

.picker-sv-thumb {
    position: absolute;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.picker-hue {
    --hue: 0;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 0.8rem;
    border-radius: 999px;
    background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
    cursor: pointer;
}

.picker-hue::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid #fff;
    border-radius: 50%;
    background: hsl(var(--hue), 100%, 50%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.picker-hue::-moz-range-thumb {
    width: 1.1rem;
    height: 1.1rem;
    box-sizing: border-box;
    border: 2px solid #fff;
    border-radius: 50%;
    background: hsl(var(--hue), 100%, 50%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.picker-hue:focus-visible {
    outline: 2px solid #111;
    outline-offset: 3px;
}

.picker-fields {
    display: flex;
    gap: 0.5rem;
}

.picker-preview {
    flex: 0 0 2.5rem;
    height: 2.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}

#picker-hex {
    flex: 1;
    min-width: 0;
    padding: 0 0.6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: inherit;
    font-weight: 300;
    font-size: 1rem;
    text-transform: lowercase;
}

#picker-hex[aria-invalid="true"] {
    border-color: #d32f2f;
    outline-color: #d32f2f;
}

.picker-actions {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
}

.dialog-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
    color: #fff;
    cursor: pointer;
}

.dialog-btn:focus-visible {
    outline: 2px solid #111;
    outline-offset: 2px;
}

.alert-confirm {
    background-image: linear-gradient(to right, #f6d365 0%, #fda085 51%, #f6d365 100%);
    color: #333;
}

.alert-confirm:hover {
    background-image: linear-gradient(to top right, #f6d365 0%, #fda085 51%, #f6d365 100%);
}

.alert-cancel {
    background-image: linear-gradient(to right, #8a2387 0%, #e51d38 51%, #c4520b 100%);
}

.alert-cancel:hover {
    background-image: linear-gradient(to top right, #8a2387 0%, #e51d38 51%, #c4520b 100%);
}

@media (prefers-reduced-motion: reduce) {

    #bg-fade,
    div h1,
    .footer-text,
    .social-link,
    .social-link svg,
    .btn {
        transition: none;
    }

    .social-link:hover,
    .btn:hover,
    .btn:active,
    .btn.active {
        transform: none;
    }

    #picker-dialog[open] {
        animation: none;
    }
}

.then-now {
    position: fixed;
    left: 50%;
    top: 1rem;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: linear-gradient(90deg, #ff7ac6, #7b61ff, #3ec7ff);
    color: #fff;
    font-family: "Montserrat Alternates", sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.7), 0 12px 28px -14px rgba(29, 26, 38, 0.55);
    transform: translateX(-50%);
    transition: transform 0.15s ease;
}

.then-now:hover {
    transform: translateX(-50%) translateY(-2px);
}

.then-now:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .then-now {
        transition: none;
    }

    .then-now:hover {
        transform: translateX(-50%);
    }
}
