/* =========================================================
   TERRE DES DRAGONS — SIDEBAR DU CODEX
   ========================================================= */

:root {
    --tdd-sidebar-width: 292px;
    --tdd-sidebar-gold: #d3a657;
    --tdd-sidebar-gold-light: #f2d993;
    --tdd-sidebar-gold-dark: #6a3e12;
    --tdd-sidebar-red: #7f2118;
    --tdd-sidebar-panel: #110d09;
    --tdd-sidebar-text: #d9caad;
    --tdd-sidebar-muted: #87765d;
}

.tdd-sidebar,
.tdd-sidebar * {
    box-sizing: border-box;
}

.tdd-sidebar {
    position: relative;
    z-index: 800;
    width: var(--tdd-sidebar-width);
    min-width: var(--tdd-sidebar-width);
    align-self: stretch;
}

.tdd-sidebar__backdrop {
    display: none;
}

.tdd-sidebar__panel {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 14px 12px 24px;
    overflow: hidden;

    background:
        radial-gradient(circle at 50% 0, rgba(128, 55, 18, .2), transparent 22%),
        repeating-linear-gradient(
            112deg,
            transparent 0 28px,
            rgba(255, 255, 255, .012) 29px,
            transparent 31px
        ),
        linear-gradient(90deg, #090705, #1b130d 52%, #090705);

    border-right: 1px solid rgba(199, 144, 56, .48);

    box-shadow:
        14px 0 28px rgba(0, 0, 0, .52),
        inset -1px 0 rgba(255, 228, 166, .04);
}

.tdd-sidebar__panel::before,
.tdd-sidebar__panel::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    pointer-events: none;
}

.tdd-sidebar__panel::before {
    left: 0;
    background:
        linear-gradient(
            90deg,
            #241306,
            #9b6927 25%,
            #35200b 54%,
            #c18c3c 76%,
            #160c04
        );
    box-shadow: inset -2px 0 3px rgba(0, 0, 0, .7);
}

.tdd-sidebar__panel::after {
    right: 0;
    background:
        linear-gradient(
            90deg,
            #160c04,
            #c18c3c 24%,
            #35200b 46%,
            #9b6927 75%,
            #241306
        );
    box-shadow: inset 2px 0 3px rgba(0, 0, 0, .7);
}

.tdd-sidebar__cap {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 72px 1fr;
    align-items: center;
    gap: 10px;
    min-height: 84px;
    margin: 0 6px 8px;
}

.tdd-sidebar__cap::before,
.tdd-sidebar__cap::after {
    content: "";
    height: 2px;
    background:
        linear-gradient(
            90deg,
            transparent,
            var(--tdd-sidebar-gold-dark),
            var(--tdd-sidebar-gold-light)
        );
    box-shadow: 0 0 8px rgba(201, 143, 54, .24);
}

.tdd-sidebar__cap::after {
    transform: scaleX(-1);
}

.tdd-sidebar__rivet {
    position: absolute;
    top: 9px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, #e8c47c, #7b4c19 45%, #281507 80%);
    border: 1px solid #aa742b;
    box-shadow:
        0 2px 3px rgba(0, 0, 0, .8),
        inset 0 0 2px rgba(255, 241, 196, .55);
}

.tdd-sidebar__rivet:first-child {
    left: 2px;
}

.tdd-sidebar__rivet:last-child {
    right: 2px;
}

.tdd-sidebar__emblem {
    position: relative;
    display: grid;
    place-items: center;
    width: 66px;
    height: 66px;
    transform: rotate(45deg);
    background:
        linear-gradient(135deg, #2b1808, #80501b 46%, #2a1607);
    border: 2px solid var(--tdd-sidebar-gold);
    box-shadow:
        0 0 0 4px #0c0805,
        0 0 17px rgba(202, 115, 31, .32),
        inset 0 0 14px rgba(0, 0, 0, .65);
}

.tdd-sidebar__emblem::after {
    content: "";
    position: absolute;
    inset: 9px;
    border: 1px solid rgba(242, 211, 139, .45);
}

.tdd-sidebar__emblem svg {
    width: 43px;
    height: 43px;
    transform: rotate(-45deg);
    fill: none;
    stroke: var(--tdd-sidebar-gold-light);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter:
        drop-shadow(0 2px 0 #3a1c07)
        drop-shadow(0 0 4px rgba(227, 170, 73, .25));
}

.tdd-sidebar__heading {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin: 0 12px 18px;
    text-align: center;
}

.tdd-sidebar__heading-line {
    height: 1px;
    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(211, 166, 87, .68)
        );
}

.tdd-sidebar__heading-line:last-child {
    transform: scaleX(-1);
}

.tdd-sidebar__heading strong,
.tdd-sidebar__heading small {
    display: block;
}

.tdd-sidebar__heading strong {
    color: var(--tdd-sidebar-gold-light);
    font-family: "Cinzel", Georgia, serif;
    font-size: .86rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    text-shadow: 0 3px 7px #000;
}

.tdd-sidebar__heading small {
    margin-top: 3px;
    color: var(--tdd-sidebar-muted);
    font-family: Georgia, serif;
    font-size: .66rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.tdd-sidebar__nav {
    position: relative;
    padding: 0 7px;
}

.tdd-sidebar__link,
.tdd-sidebar__group-toggle {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 18px;
    align-items: center;
    width: 100%;
    min-height: 49px;
    margin: 0 0 7px;
    padding: 5px 10px 5px 7px;

    color: var(--tdd-sidebar-text);
    background:
        linear-gradient(
            180deg,
            rgba(55, 38, 24, .68),
            rgba(18, 13, 9, .82)
        );

    border: 1px solid rgba(132, 87, 30, .45);
    border-radius: 3px;

    box-shadow:
        inset 0 0 0 1px rgba(255, 225, 166, .025),
        0 4px 8px rgba(0, 0, 0, .35);

    font-family: "Cinzel", Georgia, serif;
    text-align: left;
    text-decoration: none;
    cursor: pointer;

    transition:
        border-color .16s ease,
        color .16s ease,
        background .16s ease,
        transform .16s ease,
        box-shadow .16s ease;
}

.tdd-sidebar__link::before,
.tdd-sidebar__group-toggle::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: -1px;
    width: 2px;
    opacity: 0;
    background: var(--tdd-sidebar-gold-light);
    box-shadow:
        0 0 8px rgba(230, 178, 83, .8),
        0 0 14px rgba(178, 63, 27, .42);
    transition: opacity .16s ease;
}

.tdd-sidebar__link:hover,
.tdd-sidebar__link:focus-visible,
.tdd-sidebar__group-toggle:hover,
.tdd-sidebar__group-toggle:focus-visible {
    color: #f2dda7;
    border-color: rgba(212, 163, 76, .7);
    background:
        linear-gradient(
            180deg,
            rgba(100, 39, 22, .55),
            rgba(28, 15, 10, .9)
        );
    box-shadow:
        inset 0 0 16px rgba(153, 58, 23, .14),
        0 5px 11px rgba(0, 0, 0, .43);
    transform: translateX(2px);
    outline: none;
}

.tdd-sidebar__link:hover::before,
.tdd-sidebar__link:focus-visible::before,
.tdd-sidebar__group-toggle:hover::before,
.tdd-sidebar__group-toggle:focus-visible::before {
    opacity: 1;
}

.tdd-sidebar__link.is-active {
    color: #ffe6aa;
    border-color: rgba(236, 188, 91, .86);
    background:
        radial-gradient(circle at 12% 50%, rgba(164, 44, 24, .4), transparent 34%),
        linear-gradient(
            180deg,
            rgba(104, 35, 22, .78),
            rgba(31, 13, 9, .92)
        );
    box-shadow:
        inset 0 0 20px rgba(163, 57, 25, .18),
        0 0 12px rgba(188, 119, 38, .16);
}

.tdd-sidebar__link.is-active::before {
    opacity: 1;
}

.tdd-sidebar__icon {
    display: grid;
    place-items: center;
    width: 31px;
    height: 31px;
    color: var(--tdd-sidebar-gold);
    background:
        radial-gradient(circle, rgba(87, 50, 18, .63), rgba(20, 12, 7, .88));
    border: 1px solid rgba(176, 117, 39, .52);
    transform: rotate(45deg);
    box-shadow:
        inset 0 0 5px rgba(0, 0, 0, .72),
        0 2px 5px rgba(0, 0, 0, .54);
}

.tdd-sidebar__icon svg {
    width: 20px;
    height: 20px;
    transform: rotate(-45deg);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 1px #000);
}

.tdd-sidebar__label {
    min-width: 0;
    padding-left: 4px;
    overflow: hidden;
    font-size: .81rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.tdd-sidebar__chevron {
    position: relative;
    width: 15px;
    height: 15px;
}

.tdd-sidebar__chevron::before,
.tdd-sidebar__chevron::after {
    content: "";
    position: absolute;
    top: 7px;
    width: 8px;
    height: 1px;
    background: var(--tdd-sidebar-gold);
    transition: transform .18s ease;
}

.tdd-sidebar__chevron::before {
    left: 1px;
    transform: rotate(45deg);
}

.tdd-sidebar__chevron::after {
    right: 1px;
    transform: rotate(-45deg);
}

.tdd-sidebar__group-toggle[aria-expanded="true"] .tdd-sidebar__chevron::before {
    transform: rotate(-45deg);
}

.tdd-sidebar__group-toggle[aria-expanded="true"] .tdd-sidebar__chevron::after {
    transform: rotate(45deg);
}

.tdd-sidebar__submenu {
    display: grid;
    grid-template-rows: 0fr;
    margin: -2px 0 7px;
    transition:
        grid-template-rows .22s ease,
        opacity .18s ease;
    opacity: 0;
}

.tdd-sidebar__group-toggle[aria-expanded="true"] + .tdd-sidebar__submenu {
    grid-template-rows: 1fr;
    opacity: 1;
}

.tdd-sidebar__submenu-inner {
    position: relative;
    min-height: 0;
    overflow: hidden;
    margin-left: 26px;
    padding-left: 21px;
}

.tdd-sidebar__submenu-inner::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 4px;
    left: 5px;
    width: 1px;
    background:
        linear-gradient(
            180deg,
            rgba(208, 156, 70, .06),
            rgba(208, 156, 70, .58),
            rgba(208, 156, 70, .08)
        );
}

.tdd-sidebar__submenu a {
    position: relative;
    display: block;
    padding: 8px 10px 8px 13px;
    color: #a9997c;
    border-left: 1px solid transparent;
    font-family: Georgia, serif;
    font-size: .88rem;
    text-decoration: none;
    transition:
        color .15s ease,
        background .15s ease,
        border-color .15s ease,
        padding-left .15s ease;
}

.tdd-sidebar__submenu a::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -17px;
    width: 11px;
    height: 1px;
    background: rgba(199, 145, 57, .48);
}

.tdd-sidebar__submenu a:hover,
.tdd-sidebar__submenu a:focus-visible,
.tdd-sidebar__submenu a.is-active {
    color: #f0d497;
    background:
        linear-gradient(
            90deg,
            rgba(117, 35, 20, .3),
            transparent
        );
    border-left-color: rgba(225, 172, 77, .72);
    padding-left: 17px;
    outline: none;
}

.tdd-sidebar__submenu a.is-active {
    text-shadow: 0 0 7px rgba(230, 168, 72, .22);
}

.tdd-sidebar__group--admin {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(194, 140, 53, .28);
}

.tdd-sidebar__footer {
    display: grid;
    grid-template-columns: 1fr 17px 1fr;
    align-items: center;
    gap: 8px;
    margin: 23px 17px 0;
}

.tdd-sidebar__footer-line {
    height: 1px;
    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(207, 156, 68, .66)
        );
}

.tdd-sidebar__footer-line:last-child {
    transform: scaleX(-1);
}

.tdd-sidebar__footer-gem {
    width: 12px;
    height: 12px;
    transform: rotate(45deg);
    background:
        radial-gradient(
            circle at 30% 25%,
            #ffc894 0 7%,
            #b93324 30%,
            #4b0c09 100%
        );
    border: 1px solid #d69c48;
    box-shadow:
        0 0 7px rgba(214, 65, 35, .55),
        inset 0 0 3px rgba(255, 220, 170, .5);
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 900px) {
    .tdd-sidebar {
        position: fixed;
        inset: 0;
        z-index: 1200;
        width: 100%;
        min-width: 0;
        pointer-events: none;
    }

    .tdd-sidebar__backdrop {
        position: absolute;
        inset: 0;
        display: block;
        opacity: 0;
        background: rgba(0, 0, 0, .68);
        backdrop-filter: blur(2px);
        transition: opacity .2s ease;
    }

    .tdd-sidebar__panel {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(var(--tdd-sidebar-width), 88vw);
        min-height: 0;
        overflow-y: auto;
        transform: translateX(-108%);
        transition: transform .23s ease;
    }

    .tdd-sidebar.is-open {
        pointer-events: auto;
    }

    .tdd-sidebar.is-open .tdd-sidebar__backdrop {
        opacity: 1;
    }

    .tdd-sidebar.is-open .tdd-sidebar__panel {
        transform: translateX(0);
    }

    body.tdd-sidebar-open {
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tdd-sidebar__link,
    .tdd-sidebar__group-toggle,
    .tdd-sidebar__chevron::before,
    .tdd-sidebar__chevron::after,
    .tdd-sidebar__submenu,
    .tdd-sidebar__submenu a,
    .tdd-sidebar__backdrop,
    .tdd-sidebar__panel {
        transition-duration: .001ms !important;
    }
}
