/* ======================= COMPOSANTS COMMUNS =======================
   Boutons, barre de jeu, fenêtres, options. Quatre degrés de bouton, et un
   seul qui s'allume vraiment : l'action principale de l'écran (btn-cta). */

/* --- Boutons --- */
.btn {
    padding: 11px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--stone-500);
    background: linear-gradient(180deg, rgba(40, 45, 62, 0.9), rgba(25, 25, 22, 0.95));
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--bevel);
    transition: border-color var(--speed), transform var(--speed), box-shadow var(--speed), color var(--speed);
}

.btn:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold-lit);
    transform: translateY(-1px);
    box-shadow: var(--bevel), 0 0 18px rgba(201, 171, 69, 0.18);
}

.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

/* Valider, enregistrer : l'action attendue, sans voler la vedette au départ. */
.btn-primary {
    background: linear-gradient(180deg, rgba(78, 92, 14, 0.95), rgba(43, 43, 40, 0.98));
    border-color: rgba(194, 232, 0, 0.55);
    color: #f6ffd6;
}

.btn-primary:hover:not(:disabled) {
    border-color: var(--rune);
    color: #fff;
    box-shadow: var(--bevel), 0 0 22px rgba(194, 232, 0, 0.28);
}

.btn-danger {
    background: linear-gradient(180deg, #7a2230, #43111a);
    border-color: #b8394a;
    color: #ffe8ea;
}

.btn-danger:hover:not(:disabled) { border-color: var(--blood-lit); color: #fff; box-shadow: var(--bevel), 0 0 20px rgba(214, 64, 78, 0.3); }
.btn-ghost { background: transparent; }

.btn.wide {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    font-size: 0.86rem;
}

/*
 * ACTION PRINCIPALE : partir, descendre, repartir.
 *
 * Le seul aplat doré du jeu. Tout le reste de l'interface est sombre : ce
 * bouton est donc ce que l'œil trouve en premier, sur chaque écran où il y en
 * a un. Le reflet qui le traverse au survol ne joue que sa transformation.
 */
.btn-cta {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 54px;
    padding: 0 34px;
    overflow: hidden;
    border: 1px solid var(--lime-lit);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--lime-lit) 0%, var(--lime) 55%, #a3c400 100%);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.7),
        0 12px 30px rgba(194, 232, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(40, 50, 0, 0.35);
    color: #1b2000;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: transform var(--speed), box-shadow var(--speed), filter var(--speed);
}

.btn-cta::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
    transform: translateX(-120%);
    transition: transform 0.7s var(--ease-out);
    pointer-events: none;
}

.btn-cta:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.05);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.7),
        0 16px 38px rgba(194, 232, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(40, 50, 0, 0.35);
}

.btn-cta:hover:not(:disabled)::after { transform: translateX(120%); }
.btn-cta:active:not(:disabled) { transform: translateY(0); }
.btn-cta:disabled { filter: grayscale(0.8) brightness(0.6); cursor: not-allowed; }

/* Une expédition en cours : on la reprend, on n'en lance pas une nouvelle. */
.btn-cta.resume {
    border-color: #e9d27c;
    background: linear-gradient(180deg, #e9d27c 0%, var(--gold) 50%, #8f7a2c 100%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 12px 30px rgba(201, 171, 69, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.55);
    color: #1f1904;
    text-shadow: none;
}

.mini-btn {
    padding: 5px 11px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(27, 27, 24, 0.9);
    border: 1px solid var(--stone-500);
    color: var(--text-soft);
    cursor: pointer;
    border-radius: var(--radius);
    transition: border-color var(--speed), color var(--speed);
}

.mini-btn:hover:not(:disabled) { border-color: var(--gold); color: #fff; }
.mini-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.mini-btn.danger { border-color: #6b2430; color: #e8929c; }
.mini-btn.danger:hover:not(:disabled) { border-color: var(--blood); color: #fff; }

/* =====================================================================
   BARRE DE JEU
   Fixe en haut des écrans de préparation. Trois temps de gauche à droite :
   le blason, les lieux où l'on peut aller, ce que l'on possède.
   ===================================================================== */
.app-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 600;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 18px 0 22px;
    background: linear-gradient(180deg, rgba(11, 11, 8, 0.97), rgba(13, 13, 10, 0.88));
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
}

/* Le filet d'or s'allume au centre, sous l'onglet actif, et s'éteint aux bords. */
.app-bar::after {
    content: '';
    position: absolute;
    left: 20%;
    right: 20%;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.6;
    pointer-events: none;
}

.app-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.app-crest { display: inline-flex; width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(194, 232, 0, 0.35)); }
.app-crest .ui-art { width: 100%; height: 100%; object-fit: contain; }

/* Le nom du jeu, à la manière du logo de Dofus : lettres rondes et épaisses,
   dégradé jaune-vert, cerné de sombre. */
.app-name {
    font-family: var(--font-title);
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    background: linear-gradient(180deg, #f6ffb0 10%, var(--lime-lit) 45%, var(--lime) 70%, #6f8400);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.9)) drop-shadow(0 0 1px rgba(0, 0, 0, 0.9));
}

.app-nav { display: flex; align-self: stretch; gap: 2px; margin: 0 auto; }

.app-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border: 0;
    background: none;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.76rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color var(--speed);
}

.app-tab::before {
    content: '';
    position: absolute;
    inset: 8px 4px;
    border-radius: var(--radius-lg);
    background: radial-gradient(ellipse at 50% 100%, rgba(201, 171, 69, 0.22), transparent 70%);
    opacity: 0;
    transition: opacity var(--speed);
}

.app-tab::after {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--gold-lit);
    box-shadow: 0 0 12px var(--gold);
    transform: scaleX(0);
    transition: transform var(--speed) var(--ease-out);
}

.app-tab:hover { color: var(--text); }
.app-tab:hover::before { opacity: 0.6; }
.app-tab.active { color: var(--gold-lit); }
.app-tab.active::before { opacity: 1; }
.app-tab.active::after { transform: scaleX(1); }

.app-tab-ico {
    position: relative;
    display: inline-flex;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    filter: saturate(0.7) brightness(0.85);
    transition: filter var(--speed), transform var(--speed);
}

.app-tab:hover .app-tab-ico, .app-tab.active .app-tab-ico { filter: none; transform: translateY(-1px); }

.app-tab .tab-badge { position: absolute; top: 10px; right: 6px; margin: 0; }

.app-res { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.app-res .res-item {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 13px 0 6px;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.4);
    color: var(--text);
    font: inherit;
}

.app-res .res-icon { width: 26px; height: 26px; }
.app-res .res-link { cursor: pointer; transition: border-color var(--speed); }
.app-res .res-link:hover { border-color: var(--arcane-lit); }
.app-res .res-link.ready { border-color: var(--arcane-lit); box-shadow: 0 0 14px rgba(166, 139, 255, 0.35); }

.res-value {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.res-label { font-size: 0.78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
#hub-gold { color: var(--gold-lit); }
#hub-shards { color: var(--arcane-lit); }
#hub-bag.full { color: var(--blood-lit); }

.app-sys { display: flex; gap: 4px; flex-shrink: 0; }

.app-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--speed), border-color var(--speed), background var(--speed);
}

.app-icon svg { width: 20px; height: 20px; }
.app-icon:hover { color: var(--gold-lit); border-color: var(--line); background: rgba(201, 171, 69, 0.08); }

@media (max-width: 1240px) {
    .app-name { display: none; }
    .app-tab { padding: 0 12px; }
}

@media (max-width: 1060px) {
    .app-tab-label { display: none; }
    .app-tab { padding: 0 14px; }
}

@media (max-width: 640px) {
    .app-bar { gap: 8px; padding: 0 8px; }
    .app-brand { display: none; }
    .app-tab { padding: 0 8px; }
    .app-res .res-item { padding: 0 9px 0 4px; }
    .res-label { display: none; }
}

/* =====================================================================
   FENÊTRES
   ===================================================================== */
.overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(13, 13, 10, 0.78), rgba(0, 0, 0, 0.92));
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
    padding: 20px;
    animation: fadeIn 0.18s ease;
}

.modal {
    padding: 30px 32px;
    width: min(560px, 100%);
    max-height: 88dvh;
    overflow-y: auto;
    text-align: center;
    background: var(--pane-solid);
    animation: popIn 0.24s var(--ease-out);
}

.modal h1 {
    font-size: 1.35rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-lit);
    margin-bottom: 8px;
}

.modal h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.24em;
    color: var(--gold);
    margin: 26px 0 12px;
}

.modal h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }

.modal-subtitle { color: var(--text-soft); margin: 0 0 18px; font-family: var(--font-lore); font-style: italic; font-size: 1.1rem; }

.dialog-box { width: min(440px, 100%); }
.dialog-msg { color: var(--text-soft); line-height: 1.6; margin: 16px 0 24px; white-space: pre-line; }

.dialog-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }
.dialog-actions .btn { flex: 1; max-width: 200px; }

/* --- Récapitulatif --- */
.summary-box { width: min(600px, 100%); }

.summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.summary-stat {
    background: var(--well);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 13px 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-stat .stat-value {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gold-lit);
}

.summary-stat .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--text-dim);
}

.summary-stat.bad .stat-value { color: var(--blood); }

.summary-loot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}

.summary-item {
    --rar: var(--stone-500);
    background: var(--well);
    border: 1px solid var(--rar);
    border-radius: var(--radius);
    padding: 13px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    box-shadow: inset 0 0 20px color-mix(in srgb, var(--rar) 22%, transparent);
    animation: popIn 0.3s backwards;
}

.summary-item .loot-art-wrap { display: grid; place-items: center; width: 46px; height: 46px; }
.summary-item .loot-icon { font-size: 1.7rem; line-height: 1; }
.summary-item .fam-egg { width: 30px; height: 39px; }
.summary-item .loot-art { width: 46px; height: 46px; object-fit: contain; }
.summary-item .loot-label { font-size: 0.7rem; color: var(--text-soft); text-align: center; line-height: 1.35; }

/* --- Options --- */
.options-box { text-align: left; width: min(640px, 100%); max-height: min(90vh, 900px); overflow-y: auto; }
.options-box h1 { text-align: center; }

.options-list { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }

.option-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    background: var(--well);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--speed);
}

.option-row:hover { border-color: var(--line-strong); }
.option-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.option-label {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text);
}

.option-text small { color: var(--text-dim); font-size: 0.78rem; }
.option-row input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
    width: 44px;
    height: 23px;
    border-radius: 12px;
    background: #0a0a07;
    border: 1px solid var(--stone-500);
    position: relative;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
    transition: border-color var(--speed);
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--stone-400);
    transition: transform var(--speed), background var(--speed), box-shadow var(--speed);
}

.option-row input:checked ~ .switch { border-color: var(--rune); }
.option-row input:checked ~ .switch::after {
    transform: translateX(21px);
    background: var(--rune);
    box-shadow: 0 0 10px rgba(194, 232, 0, 0.7);
}

.options-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* Seuils de survie : un curseur à la place de l'interrupteur. */
.options-list.thresholds { margin-top: 8px; }
.threshold-row { cursor: default; }
.threshold-row .option-label b { color: var(--gold-lit); }
.threshold-row input[type="range"] { position: static; opacity: 1; pointer-events: auto; width: 150px; flex-shrink: 0; }

@media (max-width: 780px) {
    .threshold-row { flex-wrap: wrap; }
    .threshold-row input[type="range"] { width: 100%; }
}

/* --- Curseur : le même partout (départ, seuils, volumes) --- */
input[type="range"] {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, var(--gold-deep), var(--gold));
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff6dc, var(--gold-lit) 45%, var(--gold));
    border: 2px solid var(--ink);
    box-shadow: 0 0 0 1px var(--gold), 0 0 12px rgba(201, 171, 69, 0.6);
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--gold-lit);
    border: 2px solid var(--ink);
}

/* --- Pastille de compte : points à placer, défis prêts, Ascension possible --- */
.tab-badge {
    display: inline-grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    margin-left: 6px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--blood);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0;
    box-shadow: 0 0 10px rgba(214, 64, 78, 0.7);
    animation: blink 1.4s ease-in-out infinite;
}

.tab-badge.ascend { background: var(--arcane); box-shadow: 0 0 10px rgba(166, 139, 255, 0.8); }

/* Le bouton de surbrillance n'a de sens que sur une carte (js/ui/surbrillance.js). */
.surbrillance-btn { display: none; }
body:is([data-screen="familiars-screen"], [data-screen="forge-screen"], [data-screen="ascend-screen"], [data-screen="shop-screen"]) .surbrillance-btn { display: grid; }
.surbrillance-btn[aria-pressed="true"] { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 55%, transparent); background: color-mix(in srgb, var(--lime) 10%, transparent); }

/* ---------- La bourse : toutes les ressources, à la Maison et à la Forge ----------
   (js/ui/bourse.js) Pliée, une ligne de puces ; dépliée, chaque ressource. */
.bourse {
    display: flex;
    flex-direction: column;
    background: rgba(14, 13, 11, 0.86);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}
.bourse-tete {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    background: none;
    color: var(--text-soft);
    font: inherit;
    cursor: pointer;
}
.bourse-tete:hover .bourse-titre { color: var(--gold-lit); }
.bourse-titre { font-family: var(--font-display); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.bourse-puces { flex: 1; display: flex; justify-content: flex-end; gap: 10px; }
.bourse-puce { display: inline-flex; align-items: center; gap: 4px; font-size: 0.86rem; }
.bourse-puce b { font-variant-numeric: tabular-nums; color: var(--text); }
.bourse-puce.vide { opacity: 0.5; }
.bourse-chevron { width: 12px; height: 12px; color: var(--text-dim); transition: transform 0.2s; }
.bourse.ouverte .bourse-chevron { transform: rotate(180deg); }
.bourse-liste { display: flex; flex-direction: column; gap: 2px; max-height: min(60vh, 460px); overflow-y: auto; padding: 0 6px 8px; border-top: 1px solid var(--line-soft); }
.bourse-ligne {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
}
button.bourse-ligne { cursor: pointer; }
button.bourse-ligne:hover { background: rgba(255, 255, 255, 0.04); }
.bourse-ligne.vide { opacity: 0.45; }
.bourse-art { display: inline-grid; place-items: center; width: 22px; height: 22px; }
.bourse-img { max-width: 100%; max-height: 100%; }
.bourse-nom { display: flex; flex-direction: column; font-size: 0.78rem; line-height: 1.2; min-width: 0; }
.bourse-nom small { font-size: 0.64rem; color: var(--text-dim); }
.bourse-n { font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.bourse .purse-egg {
    display: inline-block;
    justify-self: center;
    width: 14px;
    height: 18px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: radial-gradient(circle at 35% 28%, #fff, #e8dcc0 40%, #9c8d70);
}

/* Un panneau déplaçable (js/ui/deplacable.js) : on l'attrape, il suit la souris. */
.deplacable { touch-action: none; }
.deplacable.en-deplacement { cursor: grabbing; user-select: none; }
.deplacable.en-deplacement * { cursor: grabbing !important; }
