/* ── Mod Detail: Card Flip + Detail Popup ── */

:root {
    --flip-duration: 0.3s;
    --popup-bg-alpha: 0.85;
    --popup-width: 360px;
    --popup-max-height: 480px;
}

/* ── Card Flip Infrastructure ── */

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.card-front,
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-front {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-card);
    transform: translateZ(0);
}

.card-back {
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1e3250 0%, var(--bg-card, #0d1220) 100%);
}

.card-back-logo {
    width: 60%;
    height: auto;
    opacity: 0.4;
    pointer-events: none;
}

/* ── Flipped Card: Elevated Stacking ── */

.mod-card.flipped {
    transform: perspective(600px) rotateY(180deg);
    z-index: 100;
}

.mod-card.flipped .card-front {
    visibility: hidden;
}

/* ── Detail Popup ── */

.mod-detail-popup {
    display: none;
    position: fixed;
    width: var(--popup-width);
    max-height: var(--popup-max-height);
    overflow-y: auto;
    background: rgba(0, 0, 0, var(--popup-bg-alpha));
    color: #e0e0e0;
    border: 2px solid;
    border-color: #2a3550 #0d1220 #0d1220 #2a3550;
    border-radius: var(--surface-radius, 6px);
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.6);
    padding: 12px;
    z-index: 1000;
    font-family: 'BN6Thin', sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.mod-detail-popup.visible {
    display: block;
}

/* ── Popup Scrollbar ── */

.mod-detail-popup::-webkit-scrollbar {
    width: 6px;
}

.mod-detail-popup::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
}

.mod-detail-popup::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.mod-detail-popup::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mod-detail-popup {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) rgba(255, 255, 255, 0.04);
}

/* ── Close Button ── */

.mod-detail-popup .close-btn {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    z-index: 1;
}

.mod-detail-popup .close-btn:hover {
    color: #fff;
}

.mod-detail-popup .copy-link-btn {
    position: absolute;
    top: 4px;
    right: 36px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    z-index: 1;
}

.mod-detail-popup .copy-link-btn:hover {
    color: #fff;
}

/* ── Sections ── */

.detail-section {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.detail-section-title {
    font-family: 'BN6Bold', sans-serif;
    font-size: 13px;
    color: #8899bb;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-section .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.detail-section .detail-row--filterable:hover {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
}

.detail-section .detail-row--filterable .detail-value {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.detail-section .detail-label {
    color: #889;
    flex-shrink: 0;
    margin-right: 8px;
}

.detail-section .detail-value {
    color: #dde;
    word-break: break-all;
    text-align: right;
}

/* ── Tag Chips ── */

.detail-section .tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-chip {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    color: #bcc;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* ── Download Rows ── */

.download-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    gap: 8px;
}

.download-row .download-hash {
    font-family: 'BN6Small', monospace;
    font-size: 11px;
    color: #889;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.download-row .download-version {
    font-family: 'BN6Small', monospace;
    font-size: 12px;
    color: #bcd;
    min-width: 48px;
    flex-shrink: 0;
}

.download-row .download-version.has-patchnote {
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: help;
}

.download-row .download-version.has-patchnote::after {
    content: ' 📋';
    font-size: 10px;
}

.download-row .download-date {
    font-size: 12px;
    color: #99a;
    white-space: nowrap;
}

.download-row .btn-download-zip {
    background: rgba(68, 170, 255, 0.2);
    color: #6bf;
    border: 1px solid rgba(68, 170, 255, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
}

.download-row .btn-download-zip:hover {
    background: rgba(68, 170, 255, 0.35);
}

/* ── Source Discord Link ── */

.source-discord-link {
    color: #6bf;
    text-decoration: none;
}

.source-discord-link:hover {
    text-decoration: underline;
    color: #8cf;
}

/* ── Stat Rows ── */

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

.stat-row .stat-label {
    color: #889;
}

.stat-row .stat-value {
    color: #dde;
    font-family: 'BN6Small', monospace;
}

/* ── Dependency Links ── */

.dep-link {
    color: #6bf;
    text-decoration: none;
    cursor: pointer;
}

.dep-link:hover {
    text-decoration: underline;
}

/* ── Color Swatch ── */

.color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 6px;
}

/* ── Loading Placeholder ── */

.detail-loading {
    color: #667;
    font-style: italic;
    font-size: 12px;
}

/* ── Discord Link ── */

.discord-link {
    color: #7289da;
    text-decoration: none;
}

.discord-link:hover {
    text-decoration: underline;
}

/* ── Mobile: 80% popup with margin, centered, rounded ── */
body.mobile .mod-detail-popup {
    width: 86vw;
    height: 80dvh;
    max-height: 80dvh;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    font-size: 1.25rem;
}

/* Backdrop behind popup — tap it to close */
body.mobile.detail-popup-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    pointer-events: all;
}
