/*
 * Les symboles du ludus (D63) : l'atelier des symboles (la grille et les plaques de l'atelier des emblèmes, emblem.css,
 * avec son aperçu carré et ses réglages propres), la collection, l'administration. Les dessins viennent du serveur ;
 * l'atelier n'ajoute à l'aperçu que des repères (le bord du fond, le cadre de la pièce choisie).
 */

/* ---------- Le lien vers l'atelier des symboles, dans l'atelier des emblèmes ---------- */

.emblem-head-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.75rem 0.3rem 0.5rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    text-decoration: none;
    background: rgb(201 151 63 / 10%);
    border: 1px solid rgb(201 151 63 / 45%);
    border-radius: 999px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.emblem-head-link:hover,
.emblem-head-link:focus-visible {
    background: rgb(201 151 63 / 20%);
    border-color: var(--gold);
}

.emblem-head-link-glyph,
.symbol-name-glyph {
    width: 1rem;
    height: 1rem;
    background: currentColor;
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linejoin='round'><circle cx='12' cy='12' r='9.5'/><path d='M12 5.5 13.9 10l4.6.4-3.5 3 1.1 4.6L12 15.6 7.9 18l1.1-4.6-3.5-3 4.6-.4z'/></svg>") center / contain no-repeat;
}

.symbol-name-glyph {
    width: 1.3rem;
    height: 1.3rem;
    color: var(--bronze-light);
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><path d='M4 7h16M7 12h10M9 17h6'/></svg>");
}

/* ---------- L'atelier : l'aperçu ---------- */

.symbol-niche {
    display: grid;
    place-items: center;
    border-radius: 14px;
}

.symbol-stand {
    position: absolute;
    inset: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    touch-action: none;
}

.symbol-stand:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: -2px;
    border-radius: 12px;
}

.symbol-preview {
    width: 100%;
    height: 100%;
    user-select: none;
    filter: drop-shadow(0 18px 18px rgb(0 0 0 / 55%)) drop-shadow(0 0 30px rgb(255 205 120 / 14%));
}

.symbol-preview [data-symbol-piece] {
    cursor: grab;
}

.symbol-stand.is-dragging,
.symbol-stand.is-dragging [data-symbol-piece] {
    cursor: grabbing;
}

/* Les repères de l'atelier (dessinés par lui, au-dessus du dessin du serveur) */
.symbol-guides {
    pointer-events: none;
}

/* La zone de prise d'une petite pièce : invisible, mais au doigt comme à la souris elle se saisit */
.symbol-hit {
    fill: transparent;
    pointer-events: all;
    cursor: grab;
}

.symbol-guide-frame {
    fill: none;
    stroke: rgb(243 211 138 / 32%);
    stroke-width: 0.45;
    stroke-dasharray: 1.6 1.6;
}

.symbol-guide-piece {
    fill: rgb(243 211 138 / 5%);
    stroke: var(--gold);
    stroke-width: 0.55;
    stroke-dasharray: 2.2 1.4;
    animation: symbol-march 1.6s linear infinite;
}

@keyframes symbol-march {
    to {
        stroke-dashoffset: -7.2;
    }
}

@media (prefers-reduced-motion: reduce) {
    .symbol-guide-piece {
        animation: none;
    }
}

/* Le symbole en petit, sur un disque de métal (comme sur une phalère) */
.symbol-small-figure {
    position: absolute;
    right: 0.9rem;
    bottom: 0.8rem;
    z-index: 2;
    display: grid;
    justify-items: center;
    gap: 0.25rem;
    margin: 0;
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sand-mute);
}

.symbol-small-disc {
    display: grid;
    place-items: center;
    width: 3.4rem;
    height: 3.4rem;
    padding: 0.35rem;
    background: radial-gradient(circle at 35% 30%, #c9c5bd, #7c7873 55%, #2e2c2a);
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgb(74 42 12 / 60%), 0 4px 12px rgb(0 0 0 / 50%);
}

.symbol-small {
    width: 100%;
    height: 100%;
}

.symbol-usage {
    margin: 0;
    font-size: 0.82rem;
    font-style: italic;
    text-align: center;
    color: var(--sand-mute);
}

/* ---------- L'atelier : la pile ---------- */

.symbol-shape-glyph {
    position: relative;
    display: grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border: 2px solid var(--bronze-light);
}

.symbol-shape-glyph.is-round {
    border-radius: 50%;
}

.symbol-shape-glyph.is-square {
    border-radius: 4px;
}

.symbol-shape-glyph .emblem-dot {
    width: 72%;
    height: 72%;
}

.symbol-stack-add .emblem-stack-row {
    border-style: dashed;
    border-color: rgb(111 82 50 / 70%);
}

/* ---------- L'atelier : le panneau ---------- */

.symbol-range {
    width: 100%;
    accent-color: var(--gold);
}

.symbol-segments {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
}

.symbol-segments.is-shapes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.symbol-segment {
    display: grid;
    justify-items: center;
    gap: 0.2rem;
    padding: 0.4rem 0.1rem 0.3rem;
    font: inherit;
    font-size: 0.7rem;
    color: var(--sand-mute);
    background: rgb(14 10 8 / 40%);
    border: 1px solid rgb(74 55 38 / 80%);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.symbol-segment:hover {
    color: var(--sand);
    border-color: var(--bronze);
}

.symbol-segment:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

.symbol-segment[aria-pressed='true'] {
    color: var(--ink);
    background: linear-gradient(180deg, var(--gold), var(--bronze));
    border-color: var(--gold);
}

.symbol-segments.is-shapes .symbol-segment {
    grid-auto-flow: column;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    padding: 0.55rem;
    font-size: 0.8rem;
}

.symbol-segment[aria-pressed='true'] .symbol-shape-glyph {
    border-color: var(--ink);
}

/* L'inclinaison : une réglette, ses pas marqués dessous */
.symbol-range-marks {
    display: flex;
    justify-content: space-between;
    margin: 0.15rem 0.1rem 0;
    font-size: 0.66rem;
    color: var(--sand-mute);
}

/* La peinture : le métal de l'emblème (ou rien, pour le fond), les métaux, puis la palette */
.symbol-paints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.45rem;
}

.symbol-paint {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem 0.25rem 0.3rem;
    font: inherit;
    font-size: 0.76rem;
    color: var(--sand);
    background: rgb(14 10 8 / 40%);
    border: 1px solid rgb(74 55 38 / 80%);
    border-radius: 999px;
    cursor: pointer;
}

.symbol-paint:hover {
    border-color: var(--bronze);
}

.symbol-paint:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

.symbol-paint[aria-pressed='true'] {
    border-color: var(--gold);
    box-shadow: inset 0 0 0 1px var(--gold);
}

.symbol-paint .emblem-dot {
    width: 1.15rem;
    height: 1.15rem;
}

.symbol-paint-none {
    width: 1.15rem;
    height: 1.15rem;
    border: 1.5px dashed var(--sand-mute);
    border-radius: 50%;
}

.symbol-paint-none.is-host {
    background: conic-gradient(from 210deg, #7c7873, #b87a35, #e6dfcf, #d4a437, #7c7873);
    border: 1px solid rgb(0 0 0 / 50%);
}

/* ---------- Téléphone ---------- */

@media (max-width: 56rem) {
    .symbol-stand {
        inset: 0.6rem;
    }

    .symbol-small-figure {
        right: 0.5rem;
        bottom: 0.4rem;
    }

    .symbol-small-figure figcaption {
        display: none;
    }

    .symbol-small-disc {
        width: 2.6rem;
        height: 2.6rem;
    }

    .emblem-head-link {
        margin-left: auto;
        padding: 0.25rem 0.55rem;
        font-size: 0.6rem;
    }

    .symbol-usage {
        font-size: 0.74rem;
    }
}

/* ---------- La collection ---------- */

.symbol-collection .plaque-lead {
    max-width: 46rem;
    margin: 0 0 1rem;
}

.symbol-capacity {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    margin: 0 0 1.4rem;
    color: var(--sand-mute);
}

.symbol-capacity-count {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--gold);
}

.symbol-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14.5rem), 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.symbol-card {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 0.4rem;
    padding: 1rem 1rem 0.9rem;
    text-align: center;
    background:
        url("../images/noise-5lpaXVc.svg"),
        linear-gradient(180deg, rgb(38 27 21 / 97%), rgb(22 16 12 / 97%));
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgb(243 211 138 / 7%), 0 14px 34px rgb(0 0 0 / 38%);
}

.symbol-card-art {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    padding: 0.6rem;
    background:
        radial-gradient(circle at 50% 42%, rgb(255 214 140 / 18%), transparent 65%),
        linear-gradient(180deg, #221812, #0d0907);
    border: 1px solid rgb(111 82 50 / 55%);
    border-radius: 10px;
    transition: border-color 0.15s ease;
}

.symbol-card-art:hover,
.symbol-card-art:focus-visible {
    border-color: var(--bronze);
}

.symbol-card-art .emblem-symbol {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 10px 12px rgb(0 0 0 / 55%));
}

.symbol-card-name {
    margin: 0.2rem 0 0;
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--gold);
}

.symbol-card-usage {
    margin: 0;
    font-size: 0.82rem;
    font-style: italic;
    color: var(--sand-mute);
}

.symbol-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
}

.symbol-card-actions form {
    margin: 0;
}

.symbol-card.is-new,
.symbol-card.is-full {
    display: grid;
    grid-template-rows: 1fr;
    place-items: center;
    min-height: 16rem;
    background: rgb(14 10 8 / 35%);
    border-style: dashed;
}

.symbol-card-new {
    display: grid;
    justify-items: center;
    gap: 0.6rem;
    width: 100%;
    height: 100%;
    align-content: center;
    color: var(--sand);
    text-decoration: none;
}

.symbol-card-new:hover .symbol-card-plus,
.symbol-card-new:focus-visible .symbol-card-plus {
    background: rgb(201 151 63 / 25%);
    border-color: var(--gold);
}

.symbol-card-plus {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    border: 2px solid var(--bronze);
    border-radius: 50%;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.symbol-card-plus::before {
    content: '';
    width: 1.6rem;
    height: 1.6rem;
    background: var(--gold);
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'><path d='M12 5v14M5 12h14'/></svg>") center / contain no-repeat;
}

.symbol-card-new-text {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--gold);
}

.symbol-card-new-hint,
.symbol-card-full {
    margin: 0;
    padding: 0 0.6rem;
    font-size: 0.84rem;
    color: var(--sand-mute);
}

/* La confirmation d'une suppression (fenêtre native) */
.symbol-confirm {
    max-width: min(26rem, calc(100vw - 2rem));
    padding: 1.2rem 1.3rem;
    color: var(--sand);
    background:
        url("../images/noise-5lpaXVc.svg"),
        linear-gradient(180deg, rgb(38 27 21 / 99%), rgb(22 16 12 / 99%));
    border: 1px solid var(--bronze);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgb(0 0 0 / 70%);
}

.symbol-confirm::backdrop {
    background: rgb(0 0 0 / 55%);
}

.symbol-confirm-text {
    margin: 0 0 1rem;
}

.symbol-confirm form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ---------- Administration ---------- */

.admin-symbols-title {
    margin-top: 2.5rem;
}

.admin-symbol-art {
    width: 9rem;
    aspect-ratio: 1;
    padding: 0.5rem;
    background: linear-gradient(180deg, #221812, #0d0907);
    border-radius: 10px;
}

.admin-symbol-art .emblem-symbol {
    width: 100%;
    height: 100%;
}

.admin-symbols-inline {
    display: grid;
    gap: 0.35rem;
    margin: 0 0 0.8rem;
    padding: 0;
    list-style: none;
}

.admin-symbols-inline li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.admin-symbols-inline form {
    margin: 0;
}

@media (max-width: 40rem) {
    .symbol-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    .symbol-card {
        padding: 0.6rem 0.6rem 0.7rem;
    }

    .symbol-card-name {
        font-size: 0.9rem;
    }

    .symbol-card-usage {
        font-size: 0.74rem;
    }

    .symbol-card.is-new,
    .symbol-card.is-full {
        min-height: 12rem;
    }
}

/* ---------- L'atelier des emblèmes : le chemin vers l'atelier des symboles ---------- */

/* Le bouton de la barre du haut, à côté de la bascule enseigne / bannière */
.page-emblem .emblem-stage {
    position: relative;
}

.emblem-workshop-button {
    position: absolute;
    top: 0.25rem;
    right: 0.6rem;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem 0.45rem 0.6rem;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    text-decoration: none;
    background: rgb(14 10 8 / 82%);
    border: 1px solid var(--bronze);
    border-radius: 999px;
    box-shadow: 0 6px 18px rgb(0 0 0 / 50%), inset 0 0 0 1px rgb(243 211 138 / 8%);
    backdrop-filter: blur(4px);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.emblem-workshop-button:hover,
.emblem-workshop-button:focus-visible {
    color: var(--ink);
    background: linear-gradient(180deg, var(--gold), var(--bronze));
    border-color: var(--gold);
    outline: none;
}

.emblem-workshop-button-glyph {
    width: 1.25rem;
    height: 1.25rem;
    background: currentColor;
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'><circle cx='12' cy='12' r='9.5'/><path d='M12 5.5 13.9 10l4.6.4-3.5 3 1.1 4.6L12 15.6 7.9 18l1.1-4.6-3.5-3 4.6-.4z'/></svg>") center / contain no-repeat;
}

/* La première tuile des grilles de symboles : créer le sien */
.emblem-create {
    position: relative;
    grid-column: span 2;
    display: grid;
    grid-template-columns: 4.6rem minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 0.65rem;
    align-items: center;
    padding: 0.45rem 0.6rem 0.45rem 0.45rem;
    color: var(--sand);
    text-decoration: none;
    background: radial-gradient(circle at 20% 50%, rgb(201 151 63 / 16%), rgb(14 10 8 / 40%) 70%);
    border: 1.5px dashed var(--gold);
    border-radius: 9px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.emblem-create:hover,
.emblem-create:focus-visible {
    border-style: solid;
    box-shadow: 0 0 18px rgb(243 211 138 / 22%);
    outline: none;
}

.emblem-create-art {
    position: relative;
    grid-row: span 2;
    width: 4.6rem;
    aspect-ratio: 1;
    background: radial-gradient(circle at 50% 45%, rgb(255 214 140 / 16%), rgb(0 0 0 / 30%) 72%);
    border-radius: 8px;
    overflow: hidden;
}

/* Trois pièces qui viennent s'assembler : le bouclier au fond, le glaive dessus, l'étoile au-dessus ; une pause, et ça recommence */
.emblem-create-piece {
    position: absolute;
    inset: 12%;
    width: 76%;
    height: 76%;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgb(0 0 0 / 55%));
}

.emblem-create-piece.is-1 {
    animation: emblem-create-shield 4.2s ease-in-out infinite;
}

.emblem-create-piece.is-2 {
    inset: 18% 30%;
    width: 40%;
    height: 64%;
    animation: emblem-create-blade 4.2s ease-in-out infinite;
}

.emblem-create-piece.is-3 {
    inset: 4% 38% auto;
    width: 24%;
    height: 24%;
    animation: emblem-create-star 4.2s ease-in-out infinite;
}

@keyframes emblem-create-shield {
    0% { opacity: 0; transform: scale(0.6); }
    15% { opacity: 1; transform: scale(1); }
    85% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

@keyframes emblem-create-blade {
    0%, 15% { opacity: 0; transform: translate(-90%, -60%) rotate(-30deg); }
    35% { opacity: 1; transform: translate(0, 0) rotate(-30deg); }
    85% { opacity: 1; transform: translate(0, 0) rotate(-30deg); }
    100% { opacity: 0; transform: translate(0, 0) rotate(-30deg); }
}

@keyframes emblem-create-star {
    0%, 35% { opacity: 0; transform: translate(160%, -40%) scale(0.6); }
    55% { opacity: 1; transform: translate(0, 0) scale(1); }
    85% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(0, 0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .emblem-create-piece.is-1,
    .emblem-create-piece.is-2,
    .emblem-create-piece.is-3 {
        animation: none;
    }

    .emblem-create-piece.is-2 {
        transform: rotate(-30deg);
    }
}

/* Le « + » posé sur l'assemblage */
.emblem-create-plus {
    position: absolute;
    right: 0.2rem;
    bottom: 0.2rem;
    display: grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    background: linear-gradient(180deg, var(--gold), var(--bronze));
    border-radius: 50%;
    box-shadow: 0 2px 6px rgb(0 0 0 / 55%);
}

.emblem-create-plus::before {
    content: '';
    width: 0.75rem;
    height: 0.75rem;
    background: var(--ink);
    mask: var(--i-plus) center / contain no-repeat;
}

.emblem-create.is-full .emblem-create-plus {
    display: none;
}

.emblem-create-name {
    align-self: end;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--gold);
}

.emblem-create-hint {
    align-self: start;
    font-size: 0.74rem;
    line-height: 1.3;
    color: var(--sand-mute);
}

.emblem-create.is-full {
    border-color: var(--line-strong);
}

.emblem-create.is-full .emblem-create-name {
    color: var(--sand);
}

/* Le sceau « Personnel » sur la vignette d'un symbole composé */
.emblem-option-frame {
    position: relative;
}

.emblem-option-seal {
    position: absolute;
    left: 50%;
    bottom: 0.15rem;
    transform: translateX(-50%);
    padding: 0.05rem 0.4rem;
    font-family: var(--font-display);
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
    background: linear-gradient(180deg, var(--gold), var(--bronze));
    border-radius: 999px;
    box-shadow: 0 1px 4px rgb(0 0 0 / 60%);
}

/* La bulle qui présente l'atelier des symboles, la première fois */
.emblem-bubble {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.6rem;
    padding: 0.55rem 0.5rem 0.55rem 0.7rem;
    background: linear-gradient(90deg, rgb(201 151 63 / 22%), rgb(201 151 63 / 8%));
    border: 1px solid var(--bronze);
    border-radius: 10px;
}

.emblem-bubble::after {
    content: '';
    position: absolute;
    bottom: -0.45rem;
    left: 2rem;
    width: 0.8rem;
    height: 0.8rem;
    background: rgb(70 50 28);
    border-right: 1px solid var(--bronze);
    border-bottom: 1px solid var(--bronze);
    transform: rotate(45deg);
}

.emblem-bubble-glyph {
    flex: none;
    width: 1.3rem;
    height: 1.3rem;
    background: var(--gold);
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'><circle cx='12' cy='12' r='9.5'/><path d='M12 5.5 13.9 10l4.6.4-3.5 3 1.1 4.6L12 15.6 7.9 18l1.1-4.6-3.5-3 4.6-.4z'/></svg>") center / contain no-repeat;
}

.emblem-bubble-text {
    flex: 1;
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--sand);
}

.emblem-bubble-close {
    flex: none;
}

@media (max-width: 56rem) {
    .emblem-workshop-button {
        top: 0.15rem;
        right: 0.4rem;
        padding: 0.4rem;
    }

    .emblem-workshop-button-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .emblem-create {
        grid-template-columns: 3.6rem minmax(0, 1fr);
    }

    .emblem-create-art {
        width: 3.6rem;
    }
}
