:root {
    --bg:        #12161b;
    --surface:   #1b2128;
    --surface-2: #232b34;
    --line:      #2f3945;
    --text:      #eef2f6;
    --muted:     #9aa7b4;
    --accent:    #f0b429;   /* ambre de taverne */
    --accent-2:  #58c3a4;
    --danger:    #e2685f;
    --radius:    14px;
    --shadow:    0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Open Sans", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .brand-text, .price {
    font-family: "Space Grotesk", system-ui, sans-serif;
    line-height: 1.2;
    margin: 0 0 .6rem;
}

/* Le titre principal porte la voix de la maison : Kanit, la meme graisse que
   le logotype. Les sous-titres restent en Space Grotesk, sinon toute la page
   crie. */
h1 {
    font-family: "Kanit", "Space Grotesk", sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -.01em;
    font-size: clamp(1.7rem, 4vw, 2.4rem);
}
h2 { font-size: 1.35rem; }

a { color: inherit; }
.muted { color: var(--muted); }

.wrap {
    width: min(1140px, 100% - 2rem);
    margin-inline: auto;
}

/* --- En-tete --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(18, 22, 27, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-height: 68px;
}

.brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    margin-right: auto;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent);
    color: #12161b;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
}

.brand-text { font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; }
.brand-text strong { font-size: 1rem; letter-spacing: .02em; }

.site-nav { display: flex; gap: 1.1rem; }
.site-nav a { text-decoration: none; color: var(--muted); font-weight: 600; }
.site-nav a:hover { color: var(--text); }
.site-nav .nav-accent { color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: .75rem; }

.cart-link {
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.cart-badge {
    background: var(--accent);
    color: #12161b;
    border-radius: 999px;
    padding: 0 .45rem;
    font-size: .78rem;
    font-weight: 700;
}

.ghost {
    text-decoration: none;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .3rem .8rem;
    font-size: .88rem;
}

/* --- Messages --- */
.flashes { margin-top: 1rem; }

.flash {
    margin: 0 0 .5rem;
    padding: .7rem 1rem;
    border-radius: 10px;
    border-left: 3px solid;
}

.flash-success { background: rgba(88, 195, 164, .12); border-color: var(--accent-2); }
.flash-error   { background: rgba(226, 104, 95, .12);  border-color: var(--danger); }

main { padding: 2rem 0 4rem; }

/* --- Blocs --- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.hero {
    background: linear-gradient(140deg, var(--surface) 0%, #1d2733 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1.5rem, 4vw, 3rem);
    margin-bottom: 2.5rem;
}

.hero p { color: var(--muted); max-width: 52ch; }

/* --- Boutons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1.3rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #12161b;
    font-weight: 700;
    font-family: "Space Grotesk", sans-serif;
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-danger    { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-block     { width: 100%; }
.btn-sm        { padding: .4rem .8rem; font-size: .85rem; }

/* --- Grille de cartes --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1.1rem;
}

.listing {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    transition: transform .15s ease, border-color .15s ease;
}

.listing:hover { transform: translateY(-3px); border-color: var(--accent); }

.listing-img {
    aspect-ratio: 5 / 7;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.listing-img img { width: 100%; height: 100%; object-fit: contain; }

.listing-body { padding: .8rem .9rem 1rem; display: flex; flex-direction: column; gap: .25rem; }
.listing-name { font-weight: 600; font-size: .95rem; }
.listing-meta { font-size: .8rem; color: var(--muted); }
.price { color: var(--accent); font-weight: 700; font-size: 1.05rem; }

.badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--muted);
}

/* --- Formulaires --- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="tel"], select, textarea {
    width: 100%;
    padding: .65rem .8rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

textarea { min-height: 90px; resize: vertical; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

.form-narrow { max-width: 440px; margin-inline: auto; }

/* --- Tableaux --- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .5rem; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.table-scroll { overflow-x: auto; }

/* --- Statistiques --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stat-value { font-family: "Space Grotesk", sans-serif; font-size: 1.7rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* --- Scanner --- */
.scan-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }

.dropzone {
    /* Un label est inline par defaut : sans ceci la bordure ne suit pas le contenu */
    display: block;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
}

.dropzone:hover { border-color: var(--accent); }
.dropzone input { display: none; }

.preview { max-width: 100%; border-radius: 10px; margin-top: 1rem; }

/* Suggestions de noms sous le champ de recherche */
.suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 30;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-height: 260px;
    overflow-y: auto;
}

.suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: .55rem .8rem;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover,
.suggestion-item.is-active { background: var(--accent); color: #12161b; }
.suggestion-item small { display: block; opacity: .75; font-size: .8rem; }

.candidates { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .8rem; }

.candidate {
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: .5rem;
    cursor: pointer;
    text-align: center;
    font-size: .8rem;
    color: var(--text);
}

.candidate img { width: 100%; border-radius: 6px; display: block; }
.candidate.is-selected { border-color: var(--accent); }

.suggestion {
    background: var(--surface-2);
    border-radius: 10px;
    padding: .8rem 1rem;
    font-size: .9rem;
    margin-bottom: 1rem;
}

.suggestion strong { color: var(--accent); font-size: 1.2rem; }

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* --- Pied de page --- */
.site-footer {
    border-top: 1px solid var(--line);
    padding: 2rem 0;
    color: var(--muted);
    font-size: .9rem;
}

.site-footer p { margin: .2rem 0; }

/* --- Mobile --- */
@media (max-width: 860px) {
    .scan-shell { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .header-inner { flex-wrap: wrap; min-height: 0; padding: .7rem 0; gap: .7rem; }
    .brand { margin-right: 0; }
    .site-nav { order: 3; width: 100%; justify-content: space-between; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Une note de gradation se distingue d'un simple etat : c'est un argument
   de vente, pas une nuance. */
.badge-grade {
    background: var(--accent);
    border-color: var(--accent);
    color: #12161b;
    font-weight: 700;
}

/* Boutons de partage : ils doivent rester lisibles sur un ecran de telephone,
   ou la fiche est le plus souvent consultee. */
.partage {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Repli quand le navigateur refuse la copie automatique : le lien doit etre
   visible et selectionnable, sinon le message ne sert a rien. */
.partage-repli {
    flex: 1 1 100%;
    font-size: .85rem;
}

/* ==========================================================================
   L'accueil : ce que l'ancien site avait et que la version sobre a perdu.

   L'illustration de la taverne, le logotype et le mot "dresseur" viennent de
   comptoir-nakama.ch. Seul le rouge d'origine est abandonne : le logotype est
   un aplat d'une seule couleur, il est donc recolore par masque CSS plutot
   que par un filtre, ce qui donne exactement l'ambre du reste du site.
   ========================================================================== */

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- Grand bandeau --- */

/* main est centre dans .wrap : on en sort pour aller bord a bord, et on
   remonte sous l'en-tete en annulant le padding de main. */
/* L'accueil n'est pas contraint par .wrap : le bandeau va bord a bord et les
   sections se recentrent elles-memes. */
.page-large { padding: 0 0 4rem; }

.hero-taverne {
    position: relative;
    margin-bottom: 3rem;
    overflow: hidden;
    isolation: isolate;
}

.hero-fond {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to bottom,
            rgba(18, 22, 27, .60) 0%,
            rgba(18, 22, 27, .82) 45%,
            rgba(18, 22, 27, .97) 100%),
        image-set(url("../img/taverne.jpg") 1x);
    background-size: cover;
    background-position: center 42%;
    z-index: -1;
}

@media (max-width: 700px) {
    .hero-fond { background-image:
        linear-gradient(to bottom, rgba(18,22,27,.5) 0%, rgba(18,22,27,.78) 55%, rgba(18,22,27,.96) 100%),
        url("../img/taverne-900.jpg"); }
}

.hero-contenu {
    padding: clamp(3rem, 9vw, 6rem) 0 clamp(2.5rem, 6vw, 4rem);
    text-align: center;
}

/* Le logotype est une image a canal alpha : le masque en reprend la forme et
   la remplit d'ambre. Un filter: hue-rotate() aurait donne une teinte
   approximative qui derive des que l'accent change. */
.hero-logo {
    width: min(520px, 78vw);
    aspect-ratio: 1066 / 248;
    margin: 0 auto 1.4rem;
    background-color: var(--accent);
    -webkit-mask: url("../img/logo-nakama.webp") center / contain no-repeat;
    mask: url("../img/logo-nakama.webp") center / contain no-repeat;
    filter: drop-shadow(0 6px 24px rgba(0, 0, 0, .55));
}

.hero-baseline {
    max-width: 48ch;
    margin: 0 auto;
    color: #d9e2ea;
    font-size: clamp(1rem, 2.2vw, 1.12rem);
}

.hero-actions {
    display: flex;
    gap: .8rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.btn-lg { padding: .95rem 2.2rem; font-size: 1.02rem; letter-spacing: .04em; }

.btn-ghost {
    background: rgba(255, 255, 255, .07);
    color: var(--text);
    border-color: rgba(255, 255, 255, .35);
    backdrop-filter: blur(4px);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .14); }

/* --- Titres de section --- */

.titre-display {
    font-family: "Kanit", "Space Grotesk", sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    font-size: clamp(1.6rem, 4.5vw, 2.6rem);
    letter-spacing: -.01em;
    margin-bottom: 1.2rem;
}

.bloc { margin-bottom: 3.5rem; }
.bloc > .muted { margin-top: -.6rem; margin-bottom: 1.4rem; }

/* --- Rayons --- */

.rayons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .8rem;
}

.rayon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    transition: border-color .15s, transform .15s;
}

a.rayon:hover { border-color: var(--accent); transform: translateY(-2px); }

.rayon-nom { font-weight: 600; }
.rayon-n {
    font-family: "Space Grotesk", sans-serif;
    font-size: .8rem;
    color: var(--accent);
    white-space: nowrap;
}

/* Un rayon vide reste visible mais ne ment pas : il n'est pas cliquable. */
.rayon-vide { opacity: .5; }
.rayon-vide .rayon-n { color: var(--muted); font-style: italic; }

/* --- Dresseurs --- */

.dresseurs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .9rem;
}

.dresseur {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: 1.4rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    text-align: center;
    transition: border-color .15s, transform .15s;
}
.dresseur:hover { border-color: var(--accent); transform: translateY(-2px); }

.dresseur-jeton {
    display: grid;
    place-items: center;
    width: 56px; height: 56px;
    margin-bottom: .4rem;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--accent), #d99512);
    color: #12161b;
    font-family: "Kanit", "Space Grotesk", sans-serif;
    font-weight: 900;
    font-size: 1.5rem;
}

.dresseur-nom { font-weight: 600; }
.dresseur-n { font-size: .82rem; }

/* --- Appel a rejoindre --- */

.appel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(240, 180, 41, .16) 0%, transparent 60%),
        var(--surface);
    padding: clamp(1.5rem, 5vw, 3rem);
}
.appel p { color: var(--muted); max-width: 54ch; }
.appel .titre-display { margin-bottom: .8rem; }

@media (prefers-reduced-motion: reduce) {
    .rayon, .dresseur { transition: none; }
    a.rayon:hover, .dresseur:hover { transform: none; }
}
