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

:root {
    --main-bg-clr: hsl(204, 45%, 98%);
    --primary-clr: hsl(193, 82%, 31%);
    --popup-card-bg: hsl(204, 45%, 99%); /* default value */

    --slight-spacing: 0.03em;
}

html,
body {
    font-family: "Open Sans", sans-serif;
}

input,
button {
    font-family: inherit;
}

p {
    font-size: 1rem;
}

button:focus-visible,
input:focus {
    outline-style: solid;
    outline-width: medium;
}

.cap-first {
    text-transform: capitalize;
}

.home {
    margin-top: 3rem;
    display: flex;
    align-items: center;
    flex-direction: column;
    min-height: 100vh;

    background-color: var(--main-bg-clr);
}

.home-title {
    margin-bottom: 2.5rem;
    color: var(--primary-clr);
}

.home-form {
    width: 20rem;
    max-width: 80%;
    margin-bottom: 2rem;
    display: flex;
}

.home-form-search {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 1.125rem;
    border-radius: 500px;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.125);
}

.home-form-search:focus {
    outline-offset: 0.25rem;
    outline-color: var(--primary-clr);
}

.home-form-search::placeholder {
    color: #999;
}

.home-error {
    margin-bottom: 2rem;
    padding: 0.5rem 1rem;
    max-width: 55ch;
    min-height: 4.25rem;
    line-height: 1.6;
    background-color: #fecdd3;
    color: #881337;
    border-radius: 5px;
    font-weight: 700;
    opacity: 0;
    transition: opacity 150ms ease-in-out;
}

.home-error--show {
    opacity: 1;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
}

.pagination-controls__btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;

    margin: 0 0.25rem;
    padding: 0.5rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: var(--slight-spacing);
    font-size: 0.875rem;
    font-weight: 700;
    background: none;
    border: 1px solid var(--primary-clr);
    border-radius: 4px;
    cursor: pointer;
    color: var(--primary-clr);
}

.pagination-controls__btn:focus {
    outline-color: var(--primary-clr);
}

.chevron {
    width: 1rem;
    height: 1rem;
}

.btn--hide {
    visibility: hidden;
}

.card--hide {
    display: none;
}

.main {
    margin: 1rem 0 4rem 0;
    width: 80rem;
    max-width: 90%;
    min-height: 277rem;

    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
    align-content: start;
    grid-gap: 1.5rem;
}

.main-card-btn-container {
    background: none;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}

.main-card-btn-container:focus-visible {
    outline-style: solid;
    outline-width: medium;
    outline-color: var(--primary-clr);
}

.main-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: #c3dafe; /* fallback */
    background: linear-gradient(to bottom, hsl(221, 90%, 86%), hsl(217, 97%, 88%));
    border-radius: 20px;
    box-shadow: 0 6px 9px rgba(0, 0, 0, 0.165);
    overflow-x: hidden;
}

/* Only apply to devices that can hover properly */
@media (hover: hover) and (pointer: fine) {
    /* holographic effect */
    .main-card:hover::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 1;
        background-image: linear-gradient(115deg, rgb(0, 231, 255) 0%, rgb(255, 0, 231) 100%);
        opacity: 0.35;
        transform: scaleX(4);
        transform-origin: left;
        animation: holo 4s ease-in-out infinite alternate-reverse;
    }
    /* sparkle effect */
    .main-card:hover::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 5;
        background-image: url("./images/sparkles.webp");
        background-position: center;
        background-size: 100%;
        mix-blend-mode: color-dodge;
        opacity: 0.6;
    }

    @keyframes holo {
        0% {
            opacity: 0.35;
            transform: translateX(-10%) scaleX(4);
        }

        100% {
            opacity: 0.225;
            transform: translateX(-300%) scaleX(4);
        }
    }
}

.main-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2.5rem;
}

.main-card-fig {
    width: 10rem;
    height: 10rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: hsl(0, 0%, 98%);
}

.main-card-fig-img {
    width: 70%;
    height: 70%;
    transform: translateY(15%);
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.31));
    image-rendering: pixelated;
}

.main-card-content-num,
.main-card-content-name,
.main-card-content-type {
    margin: 0.2rem 0;
}

.main-card-content-num {
    padding: 0.25rem 0.75rem;
    line-height: 1;
    font-size: 0.875rem;
    background-color: hsl(0, 0%, 98%);
    border-radius: 500px;
    color: hsl(0, 0%, 36%);
}

.main-card-content-name {
    text-transform: uppercase;
    letter-spacing: var(--slight-spacing);
    font-weight: 400;
    font-size: 1.0625rem;
    color: hsl(247, 35%, 24%);
}

.main-card-content-type {
    font-size: 0.85rem;
}

.loading {
    opacity: 0;
    /* Hidden by default, shown on API request */
    display: none;
    position: fixed;
    bottom: 5%;

    transition:
        opacity 500ms,
        display 500ms;
    transition-behavior: allow-discrete;
}

.loading-ball {
    width: 0.8rem;
    height: 0.8rem;
    margin-left: 0.375rem;
    margin-right: 0.375rem;
    border-radius: 50%;
    background-color: #4299e1;
    animation: bounce 600ms ease-in-out infinite;
}

.loading-ball:nth-of-type(2) {
    animation-delay: 100ms;
    background-color: #3182ce;
}
.loading-ball:nth-of-type(3) {
    animation-delay: 200ms;
    background-color: #2b6cb0;
}

@keyframes bounce {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-14px);
    }

    100% {
        transform: translateY(0);
    }
}

.loader--show {
    opacity: 1;
    display: flex;
}

#pokemon-popup,
#popup-content {
    border-radius: 30px;
    border: none;
}

/* OPEN state */
#pokemon-popup:popover-open {
    opacity: 1;
    transform: scale(1);
}

#pokemon-popup {
    margin: auto;
    width: min(94%, 60rem);
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior-block: contain;

    /* FINAL exit animation state */
    opacity: 0;
    transform: scale(0.925);
    transition:
        opacity 300ms ease-in-out,
        transform 300ms ease-in-out,
        overlay 300ms ease-in-out allow-discrete,
        display 300ms ease-in-out allow-discrete;
}

/* popover animation */
/* BEFORE state */
@starting-style {
    #pokemon-popup:popover-open {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* popover backdrop animation */
/* BEFORE state */
[popover]::backdrop {
    background-color: transparent;
    transition:
        background-color 300ms ease-in-out,
        overlay 300ms ease-in-out allow-discrete,
        display 300ms ease-in-out allow-discrete;
}

/* OPEN state */
[popover]:popover-open::backdrop {
    background-color: rgb(0 0 0 / 35%);
}

@starting-style {
    [popover]:popover-open::backdrop {
        background-color: transparent;
    }
}

.poke-main-section {
    position: relative;
    flex: 1;
    display: grid;
    grid-template-columns: 0.75fr 1fr;
    gap: 2rem;
    max-width: 100%;
    padding: 3.5rem 2.5rem;
    border-radius: 30px;
    background-color: var(--popup-card-bg);
    box-shadow: 0 9px 22px -4px rgba(0, 0, 0, 0.185);
}

.popup__close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    padding: 0.25rem;

    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: none;
    background-color: #fff;
    cursor: pointer;
}

.popup__close-btn__x {
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.5;
    transition: opacity 110ms ease-in-out;
}

.popup__close-btn:hover .popup__close-btn__x {
    opacity: 1;
}

.poke-main-section-data-title {
    font-size: 2.1rem;
    text-transform: uppercase;
    letter-spacing: var(--slight-spacing);
}

.poke-main-section-data-img {
    margin-top: 1.5rem;
    width: 75%;
    height: auto;
}

.poke-main-section-data-body:first-of-type {
    margin-top: 2rem;
}

.poke-main-section-data-body {
    margin-top: 1rem;
}

.poke-main-section-data-body span {
    font-weight: 700;
}

.poke-main-section-stats-title {
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: 400;
    font-size: 1.125rem;
    letter-spacing: var(--slight-spacing);
}

.poke-main-section-stats-prog {
    width: 15rem;
    height: 2rem;
    margin-bottom: 2rem;
    background-color: #fff;
    border-radius: 500px;
}

.poke-main-section-stats-prog-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #4c51bf;
    height: 100%;
    border-radius: 500px;

    color: #fff;
}

/* Easter Egg Gif */
.easter-egg-gif {
    position: fixed;
    z-index: 20;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Scroll Timeline Animation */
@keyframes color-fade {
    from {
        background-color: var(--main-bg-clr);
    }

    to {
        background-color: #e0e7ff;
    }
}

body {
    animation: color-fade linear;
    animation-timeline: scroll(root block);
}

@media screen and (max-width: 46em) {
    .poke-main-section-stats-prog {
        width: 100%;
    }

    .poke-main-section {
        margin: 0;
        grid-template-columns: 1fr;
    }

    .poke-main-section-data {
        display: flex;
        flex-direction: column;
    }

    .poke-main-section-data-img,
    .poke-main-section-data-title {
        align-self: center;
    }
}

@media screen and (max-width: 34.25em) {
    .home {
        margin-top: 1.5rem;
    }

    .home-title {
        margin-bottom: 1.25rem;
    }

    .home-form {
        margin-bottom: 2rem;
    }
}

@media screen and (max-width: 26.5em) {
    .poke-main-section {
        padding: 2.5rem 2rem;
    }

    .poke-main-section-stats-title {
        margin-bottom: 0.25rem;
    }
}
