@font-face {
    font-family: "HeyComic";
    src: url("../assets/font/HeyComic.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

html,
body {
    /* font-family: Arial, sans-serif; */
    font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    margin: 0;
    padding: 0;
    background-color: #8FB7EE;
    /* color: #ffffff; */
    overflow-x: hidden;
}

body {
    opacity: 0;
    transition: opacity 0.2s ease;
}

body.page-ready {
    opacity: 1;
}

#navbar-placeholder {
    min-height: 82px;
}

@media (prefers-reduced-motion: reduce) {
    body {
        transition: none;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.form-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 12px;
    font-weight: 600;
}

.form-selector label {
    color: #ffffff;
}

.form-selector-select {
    border: 1px solid #3a3843;
    border-radius: 8px;
    padding: 6px 12px;
    background-color: #ffffff;
    color: #1f2d3d;
    font-size: 14px;
}

.shiny-toggle {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 8px;
    border-radius: 999px;
    border: 1px solid #3a3843;
    background-color: #f4efd6;
    color: #3a3843;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    z-index: 2;
}

.shiny-toggle .shiny-toggle-sparkle {
    font-size: 14px;
    line-height: 1;
    background: none;
    border-radius: 0;
    transform: none;
    box-shadow: none;
}

.shiny-toggle.is-active {
    background-color: #f6c84f;
    color: #3a3843;
}

.shiny-toggle.is-active .shiny-toggle-sparkle {
    filter: brightness(1.1);
}

.shiny-toggle:focus-visible {
    outline: 2px solid #3a6cc6;
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .container {
        width: 100%;
        padding: 12px;
    }

    .form-selector {
        padding: 0 12px;
    }

    .form-selector-select {
        width: 100%;
        max-width: 260px;
    }
}

/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/*                                                                   header                                                                             */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */

#searchHeader {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background-color: #8FB7EE;
    position: relative;
    text-align: center;
}

@media (max-width: 600px) {
    #searchHeader {
        padding: 12px;
    }
}

#searchContainer {
    display: flex;
    align-items: center;
    margin-top: 6px;
    width: 100%;
    justify-content: center;
}

#searchBar {
    width: 320px;
    padding: 10px 14px;
    border-radius: 20px;
    border: 2px solid #5F98E7;
    background-color: #ffffff;
    color: #1f2d3d;
    font-size: 16px;
    outline: none;
    text-align: center;
}

#searchBar::placeholder {
    color: #6F87A8;
}

#searchBar:focus {
    border-color: #3A6CC6;
}

#searchHeader button {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 10px;
}

#searchHeader button img {
    width: 30px;
    height: 20px;
}

/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/*                                                                   body                                                                               */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
h1 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #ffffff;
}

.grid-container-layer1,
.grid-container-layer2,
.grid-container-layer3,
.grid-container-layer4 {
    display: flex;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    max-width: 1200px;
    margin: 20px auto 10px; /* Consolidé margin-top/bottom et centrage */
    gap: 20px;
}

.grid-container-layer3 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-container-layer3 .grid-item {
    height: auto;
    overflow: visible;
}

.grid-item-large {
    flex: 1;
    border: 1px solid #3a3843;
    border-radius: 8px;
    padding: 30px;
    background-color: #ffffff;
    text-align: center;
    min-width: 300px;
    min-height: 300px;
    color: #6F87A8;
    height: auto;
    overflow: visible;
}

.grid-container-layer3 .grid-item {
    flex: 1;
    max-width: 1200px;
}

.grid-container-layer4 img {
    width: 100px;
    height: auto;
}

.grid-container-affinities {
    display: flex;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    max-width: 1200px;
    margin: 20px auto 10px;
    gap: 20px;
}

.affinity-panel {
    width: 100%;
    min-height: auto;
    height: auto;
    padding: 20px;
}

.affinity-header {
    margin-bottom: 10px;
}

.affinity-subtitle {
    margin: 4px 0 0;
    font-weight: 600;
    color: #3a3843;
}

.affinity-list-label {
    margin: 12px 0;
    background-color: #3fa34d;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
}

.affinity-list {
    display: grid;
    grid-template-columns: repeat(9, max-content);
    justify-content: center;
    gap: 8px;
}

.affinity-item {
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    background-color: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: max-content;
    min-width: 0;
}

.affinity-type-icon-wrap {
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    background-color: transparent;
    height: 25px;
    line-height: 0;
}

.affinity-type-icon {
    width: auto;
    height: 25px;
    object-fit: contain;
    border-radius: 0;
    display: block;
}

.affinity-multiplier {
    padding: 6px 4px;
    font-weight: 700;
    text-align: center;
    font-size: 0.85rem;
    color: #3a3843;
    width: 100%;
}

.multiplier-0 {
    background-color: #e1e1e1;
    color: #444444;
}

.multiplier-25 {
    background-color: #c6f1c1;
    color: #1d6a24;
}

.multiplier-50 {
    background-color: #dff6d7;
    color: #1d6a24;
}

.multiplier-100 {
    background-color: #f7f7f7;
    color: #666666;
}

.multiplier-200 {
    background-color: #ffb8b8;
    color: #8a1212;
}

.multiplier-400 {
    background-color: #ff8b8b;
    color: #7b0000;
}

.affinity-legend {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    color: #6F87A8;
}

.affinity-legend-title {
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6F87A8;
}

.affinity-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #3a3843;
}

.affinity-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: inline-block;
}

.img-pokemon-types-layer1 {
    width: 100px !important;
    height: 25px !important;
    border-radius: 8px;
}

.grid-container-layer1 img {
    width: 250px;
    height: 250px;
}

.grid-container-layer1 img.pokemon-main-sprite {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    object-fit: none;
    object-position: center;
    image-rendering: pixelated;
}

.type-images {
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-images img {
    width: 100px;
    height: auto;
    margin-right: 10px;
}

.type-images-layer1 {
    width: 100%;
    margin-top: auto;
    margin-bottom: 0;
    gap: 8px;
    padding-top: 20px;
}

.type-images-layer1 .img-pokemon-types-layer1 {
    margin-right: 0;
}

.grid-container-layer1 .grid-item-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 40px;
}

.grid-container-layer2 img {
    width: 100px;
    height: 100px;
}

.grid-container-layer1 h2,
.grid-container-layer2 h2 {
    margin-bottom: 0; /* Consolidé margin-bottom */
}

.grid-container-layer1 h2 {
    margin-bottom: 20px;
}

.grid-container-layer2 h2 {
    margin-bottom: 0;
}

.evolution-item {
    display: inline-block;
    text-align: center;
    margin: 0 10px;
}

.evolution-item p {
    margin: 5px 0 0;
    font-size: 14px;
}

.evolution-name {
    color: #6F87A8;
    font-weight: 700;
}

.evolution-condition-label,
.evolution-condition-separator {
    color: #6F87A8;
}

.evolution-condition-value {
    color: #000000;
}

.evolution-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.evolution-carousel-window {
    min-width: 140px;
}

.evolution-carousel .evolution-item {
    display: none;
    margin: 0;
}

.evolution-carousel .evolution-item.is-active {
    display: inline-block;
}

.evolution-nav {
    /* background-color: #2a2733; */
    border: 1px solid #3a3843;
    /* color: #e0e0e0; */
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.evolution-nav:disabled {
    opacity: 0.4;
    cursor: default;
}

.grid-item {
    border: 1px solid #24222a;
    border-radius: 8px;
    padding: 20px;
    background-color: #ffffff;
    text-align: center;
    min-width: 200px;
    height: 150px;
    position: relative;
    overflow: hidden;
}

/* Prevent base card styles from clipping large detail panels. */
.grid-item.grid-item-large {
    border: 1px solid #3a3843;
    padding: 30px;
    min-width: 300px;
    min-height: 300px;
    height: auto;
    position: relative;
    overflow: visible;
}

.grid-item.grid-item-large.affinity-panel {
    padding: 20px;
    min-height: auto;
}

.stats-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.grid-container-layer2 .grid-item {
    flex: 1 1 0;
    height: auto;
    min-width: 0;
}

.grid-item.evolution-panel {
    height: auto;
    min-height: 200px;
    overflow: visible;
}

.grid-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid transparent;
    border-radius: inherit;
    pointer-events: none;
    transition: border-color 0.5s ease-in-out;
}

.grid-item.is-clickable:hover::before {
    border-color: #3a3843;
}

.grid-item h2 {
    margin-top: 0; /* Consolidé margin-top */
    color: #6F87A8;
}

span {
    color: #6F87A8;
    /* font-weight: bold; */
}

.gender-label,
.gender-separator {
    color: #6F87A8;
}

.gender-icon {
    margin-right: 6px;
    font-size: 0.9em;
}

.gender-icon-male {
    color: #3a6cc6;
}

.gender-icon-female {
    color: #e05a8f;
}

.main_title {
/*   font-size: 32px;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 20px; */
  font-size: 3rem;
  line-height: 2.5rem;
  font-family: "HeyComic", sans-serif;
  color: #FFFFFF;
  margin-top: 24px;
  margin-bottom: 16px;
}

.page-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
  padding-bottom: 32px;
  gap: 28px;
}

.page-title .main_title,
.page-title .pokedex-logo {
  margin: 0;
}

.pokedex-logo {
  display: block;
  width: 50px;
  height: 50px;
  margin: 12px auto 32px;
}

.grid-container-layer3 .grid-item p {
    margin-bottom: 10px;
}

.held-item-name,
.held-item-label {
    color: #6F87A8;
}

.held-item-value {
    color: #000000;
}

.grid-container-layer4 .grid-item-large .grid-item {
    margin: 20px;
    height: auto;
    width: auto;
}

.grid-container-layer4 table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.grid-container-layer4 th,
.grid-container-layer4 td {
    border: 1px solid #3a3843;
    padding: 8px;
    background-color: #ffffff;
    color: #000000;
    text-align: center;
}

.moves-table {
    width: 100%;
}

.moves-table-empty td {
    font-style: italic;
    text-align: center;
}

.pokemon-detail-nav {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1100;
}

.pokemon-nav-button {
    pointer-events: auto;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid #3a3843;
    background-color: #ffffff;
    color: #3a3843;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.pokemon-nav-button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/*                                                                    Stats                                                                             */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */

.stat-bar-container {
    display: flex;
    align-items: center;
    margin: 5px 0;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 2px;
    width: 190px;
    /* background-color: #555; */
}

.stat-bar {
    height: 20px;
    border-radius: 5px;
    transition: width 0.5s ease-in-out;
}

.stat-value-number {
    color: #000000;
}

.stat-value {
    margin-left: 5px;
}

.stat-name {
    width: 100px;
    text-align: left;
    margin-right: 18px;
}

.stats-table {
    width: 100%;
    table-layout: fixed;
}

.stats-table .stat-label {
    width: 45%;
    padding-right: 10px;
}

.stats-table .stat-bar-cell {
    width: 55%;
    padding-left: 20px;
}

.grid-item-large .stats-table {
    margin-top: 16px;
}

@media (max-width: 768px) {
    .grid-container-layer1,
    .grid-container-layer3,
    .grid-container-layer4 {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        margin: 16px auto;
        max-width: 100%;
        padding: 0;
        width: 100%;
        max-width: 100vw;
    }

    .grid-container-layer3 {
        display: grid;
        grid-template-columns: 1fr;
    }

    .grid-container-layer2 {
        flex-wrap: wrap;
        gap: 12px;
        margin: 16px auto;
        max-width: 100%;
        padding: 0;
        width: 100%;
        max-width: 100vw;
    }

    .grid-item-large {
        min-width: 0;
        min-height: auto;
        padding: 20px;
        width: 100%;
        box-sizing: border-box;
        max-width: 100%;
    }

    .grid-container-layer1 .grid-item-large {
        padding-bottom: 40px;
    }

    .grid-container-layer1 img {
        width: 180px;
        height: 180px;
    }

    .grid-container-layer2 .grid-item {
        flex: 1 1 calc(50% - 12px);
        min-width: 0;
        min-height: 140px;
        padding: 16px;
        height: auto;
        overflow: visible;
        box-sizing: border-box;
        max-width: 100%;
    }

    .grid-item.evolution-panel {
        min-height: 160px;
    }

    .grid-container-layer3 .grid-item,
    .grid-container-layer4 .grid-item-large {
        width: 100%;
        max-width: 100%;
        overflow: visible;
    }

    .stat-bar-container {
        width: 100%;
        max-width: 150px;
    }

    .stats-table {
        table-layout: auto;
        width: 100%;
    }

    .stats-table .stat-label {
        width: 55%;
        text-align: left;
        overflow-wrap: anywhere;
    }

    .stats-table .stat-bar-cell {
        width: 45%;
        padding-left: 10px;
    }

    .grid-container-layer4 table {
        font-size: 0.9em;
    }

    .grid-container-layer4 th,
    .grid-container-layer4 td {
        padding: 6px;
    }

    .grid-item {
        height: auto;
        min-width: 0;
        overflow: visible;
        box-sizing: border-box;
        max-width: 100%;
        width: 100%;
    }

    .moves-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .moves-table table {
        min-width: 520px;
    }

    .grid-container-layer4 img {
        width: 40px;
        height: auto;
    }

    .grid-container-affinities {
        margin: 16px auto;
        width: 100%;
        max-width: 100vw;
    }

    .grid-item.grid-item-large.affinity-panel {
        padding: 16px;
    }

    .affinity-list {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 6px;
        width: 100%;
    }

    .affinity-item {
        width: 100%;
    }

    .affinity-list-label {
        font-size: 0.75rem;
        letter-spacing: 0.06em;
    }

    .affinity-type-icon {
        width: 100%;
        height: 22px;
    }

    .grid-container-layer4 h2 {
        padding: 0 8px;
        overflow-wrap: anywhere;
        font-size: 1.2em;
        line-height: 1.3;
        white-space: normal;
    }

    .grid-container-layer3 .grid-item {
        overflow-wrap: anywhere;
    }

    .grid-container-layer4 th,
    .grid-container-layer4 td {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

@media (max-width: 520px) {
    .grid-container-layer2 .grid-item {
        flex: 1 1 100%;
    }

    .grid-container-layer1 img {
        width: 160px;
        height: 160px;
    }

    .stat-bar-container {
        max-width: 130px;
    }

    .grid-container-layer4 h2 {
        font-size: 1.1em;
    }

    .moves-table table {
        min-width: 420px;
    }
}


/* Les règles de couleur de stat-bar sont supprimées car elles sont appliquées en ligne via JS */

/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/*                                                                    Footer                                                                            */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
footer {
    background-color: #5F98E7;
    color: #e0e0e0;
    padding: 10px;
    text-align: center;
}

footer a {
    color: #e0e0e0;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

name-underline {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 1px dashed #8e99ab;
}
