/* ===================================================================
   Side Panel — reusable image-detail panel
   Used by gallery, profile, saved, animation, resources views.
   =================================================================== */

/* --- Article-embedded gallery images.
   Anchor wraps the bare <img> emitted by article_md.py post-finalization.
   Always inline-block sized exactly to the <img> child so the selection border
   is square and the absolute-positioned like-button overlay anchors correctly.
   Centering of the anchor is handled by the containing <p> / cell via
   text-align: center. --- */

.article-gallery-link {
    position: relative;
    display: inline-block;
    line-height: 0;
    vertical-align: top;
    max-width: 100%;
}

/* Reset the global .post-content img { display:block; margin: 32px auto } so
   the wrapped img doesn't push the anchor around or double-margin. */
.article-gallery-link > img.article-img {
    display: block;
    margin: 0;
    max-width: 100%;
}

/* Center standalone article images (paragraph that contains only the link). */
.post-content p:has(> .article-gallery-link) {
    text-align: center;
}

.post-content > p > .article-gallery-link {
    margin: 32px 0;
}

/* Layout containers center their anchors and override img sizing rules
   that originally targeted the bare <img>. */
.image-row > .article-gallery-link {
    max-width: 45%;
    margin: 0;
}

.image-gallery > p,
.image-gallery {
    text-align: center;
}

.snake-cell {
    text-align: center;
}

.figure-image,
.figure-image > p {
    text-align: center;
}

/* --- Fix: Use outline instead of border to prevent DOM reflow --- */
.article-gallery-link.selected {
    outline: 4px solid var(--text-color);
    z-index: 50; /* Ensures the scaled image pops over adjacent text/images */
}

@media (hover: hover) and (pointer: fine) {
    /* Lift the wrapper so hovered images safely overlap their neighbors */
    .article-gallery-link:hover {
        z-index: 40;
    }

    .article-gallery-link:hover img {
        transform: scale(1.05);
        /* Removed z-index: 1 here; lifting the parent wrapper is cleaner */
    }

    .article-gallery-link.selected {
        transition: transform 0.2s ease-in;
        transform: scale(0.8);
    }

    .article-gallery-link.selected img {
        transform: scale(1.6);
    }
}


.side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    max-width: 400px;
    width: 100%;
    height: 100dvh;
    transition: right 0.1s ease-out;
    z-index: 900000;
    display: flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    backdrop-filter: blur(20px);
    background-color: var(--text-color2-t);
}

.side-panel.active {
    right: 0;
}

.gallery-margin {
    width: 0px;
    background-color: rgba(0, 0, 0, 0);
    transition: width 0.3s ease-in;
}

/* --- Panel image --- */

.panel-image {
    height: 30vh;
    width: 30vh;
    object-fit: contain;
    max-width: 768px;
    max-height: 768px;
    margin-top: 4vh;
    image-rendering: pixelated;
}

#panelImage[src=""] {
    display: none;
}

/* --- Title --- */

#panelTitle {
    padding: 0 8%;
    font-size: 3.5vh;
    text-align: center;
}

/* --- Creator info --- */

.creator-info {
    font-family: 'Press Start 2P', cursive;
    font-weight: normal;
    font-size: 1.2vh;
    display: flex;
    text-align: left;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-top: 0;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 150px;
    padding: 0 20%;
}

.creator-info:hover {
    color: var(--contrast-color);
    transition: transform 0.3s ease-in-out, color 0.3s ease;
}

.creator-info a {
    text-decoration: none;
    color: inherit;
    cursor: cell;
}

.side-panel .creator-info img {
    width: 5dvh;
    height: 5dvh;
    margin-right: 10px;
}

/* --- Close button --- */

.close-button {
    top: 2%;
    left: 20px;
    position: absolute;
    background-color: var(--text-color);
    color: var(--text-color2);
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    border: none;
    cursor: cell;
    max-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-button:hover {
    scale: 1.2;
}

/* --- Options menu --- */

.options-wrapper {
    position: absolute;
    top: 2%;
    right: 20px;
    z-index: 1002;
}

.options-button {
    background-color: var(--text-color);
    color: var(--text-color2);
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    font-weight: bold;
    border: none;
    cursor: cell;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 8px;
    padding-left: 10px;
    padding-bottom: 10px;
    margin-top: 4px;
}

.options-button:hover {
    transform: scale(1.2);
}

.options-dropdown {
    display: none;
    position: absolute;
    top: 48px;
    right: 0;
    background-color: var(--text-color2);
    border: 2px solid var(--text-color);
    border-radius: 8px;
    padding: 5px;
    min-width: 150px;
    flex-direction: column;
    gap: 5px;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2);
}

.options-dropdown.show {
    display: flex;
}

.options-item {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    text-align: left;
    padding: 8px 12px;
    cursor: cell;
    width: 100%;
    transition: background 0.2s;
    white-space: nowrap;
}

.options-item:hover {
    background-color: var(--text-color);
    color: var(--text-color2);
}

.options-item.delete-option:hover {
    background-color: var(--contrast-color);
    color: var(--text-color2);
}

/* --- Color palette --- */

.color-palette {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 380px;
    margin-bottom: 16px;
    padding: 0px 48px;
    margin-top: 16px;
}

.color-palette div {
    width: 16px;
    height: 16px;
}

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

.stats-row {
    display: flex;
    justify-content: space-evenly;
    vertical-align: middle;
    align-items: flex-start;
    background-color: black;
    color: white;
    padding: 3%;
    gap: 2vw;
    width: 35%;
    border-radius: 8px;
}

.stat-item {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item img {
    margin-top: 5px;
    margin-bottom: 5px;
    width: 50%;
    height: 50%;
}

.stat-item span {
    font-size: 16px;
}

.stat-item.coins-count span {
    font-size: 16px;
}

.stat-item:hover {
    transform: scale(1.1);
}

.stat-coin img {
    min-width: 32px !important;
}

.stat-like img {
    min-width: 32px !important;
}

/* --- Button row --- */

.button-row {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    width: 100%;
    position: absolute;
    bottom: 7%;
    left: 0;
    z-index: 10;
    padding: 0 10px;
    box-sizing: border-box;
}

.button-row .icon-btn {
    width: 36px !important;
    height: 36px !important;
    cursor: cell;
    transition: transform 0.3s ease;
    margin: 0 !important;
}

.button-row .icon-btn:hover {
    transform: scale(1.2);
}

.button-row .icon-btn[data-tooltip]:hover::after {
    font-size: 9px !important;
    padding: 4px 0px;
    bottom: 100%;
}

.collect-btn {
    width: auto;
    cursor: cell;
    transition: transform 0.3s ease;
    margin: 5px;
    background-color: var(--text-color2) !important;
    color: var(--text-color) !important;
    border: 2px solid var(--text-color);
    display: inline-flex;
    align-items: center;
    font-size: 1.5vh;
    border-radius: 8px;
    font-family: 'Press Start 2P', cursive;
}

.collect-number {
    margin-left: 10px;
    font-size: 1.2vh;
}

.collect-btn:hover {
    color: var(--contrast-color) !important;
    outline: 2px solid var(--contrast-color);
    border: 2px solid var(--contrast-color);
}

/* --- Tooltip --- */

.has-tooltip {
    position: relative;
    cursor: cell;
}

.custom-tooltip {
    position: fixed;
    top: 55%;
    right: 420px;
    background-color: var(--text-color2);
    color: var(--text-color);
    padding: 20px;
    border-radius: 6px;
    white-space: normal;
    max-width: 50vw;
    width: max-content;
    border: 2px solid var(--text-color);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.5;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
    display: none;
}

.has-tooltip:hover .custom-tooltip {
    display: block;
    opacity: 1;
}

.tooltip-seed {
    color: var(--contrast-color);
    font-weight: bold;
}

/* --- Info squares --- */

.info-container {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.info-square {
    display: none;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    background-color: var(--text-color2);
    padding: 5px 10px;
    text-align: center;
    font-size: 8px;
    font-weight: bold;
    white-space: nowrap;
    font-family: 'Press Start 2P', cursive;
}

/* --- Moderation button --- */

.btn-moderate {
    width: fit-content;
    padding: 10px;
    display: none;
    position: absolute;
    top: 15px;
    right: 420px;
}


/* ===================================================================
   Mobile (max-width: 768px)
   =================================================================== */

@media (max-width: 768px) {

    #panelTitle {
        font-size: 18px;
    }

    .panel-image {
        margin-top: 1vh;
    }

    .custom-tooltip {
        position: fixed;
        top: 10%;
        left: 50%;
        transform: translateX(-50%);
        background-color: var(--text-color2);
        color: var(--text-color);
        padding: 20px;
        border-radius: 6px;
        white-space: normal;
        max-width: 70vw;
        width: max-content;
        border: 2px solid var(--text-color);
        font-family: 'Space Grotesk', sans-serif;
        font-size: 14px;
        font-weight: normal;
        line-height: 1.5;
        z-index: 100;
        opacity: 0;
        transition: opacity 0.3s;
        display: none;
    }

    .side-panel {
        -webkit-backdrop-filter: blur(50px);
        backdrop-filter: blur(50px);
    }

    .side-panel {
        right: -100%;
        width: 100%;
    }

    .side-panel.active {
        right: 0;
    }

    .side-panel {
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        position: fixed;
        top: 0 !important;
        right: -100%;
        max-width: 100%;
        width: 100%;
        height: 100dvh;
        transition: right 0.2s ease-out;
        z-index: 900000;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
    }

    .side-panel.closing {
        transition: right 0.3s ease-out !important;
    }

    .side-panel.closing *:not(.side-panel) {
        opacity: 0;
        transition: opacity 0.1s ease-out;
    }

    @keyframes image-swipe-down {
        0% {
            transform: translateY(100%) scale(0);
            opacity: 0;
        }
        100% {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
    }

    @keyframes image-swipe-up {
        0% {
            transform: translateY(-100%) scale(0);
            opacity: 0;
        }
        100% {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
    }

    .side-panel img.swipe-up {
        animation: image-swipe-up 0.5s ease-in-out forwards;
    }

    .side-panel img.swipe-down {
        animation: image-swipe-down 0.5s ease-in-out forwards;
    }
}


/* ===================================================================
   Large screens (min-width: 1800px)
   =================================================================== */

@media (min-width: 1800px) {

    .side-panel {
        right: -25%;
        width: 25%;
        max-width: 25%;
    }

    .side-panel.active {
        right: 0;
    }
}
