/* ================= PURCHASE MODAL ================= */

#purchaseModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 5000;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px;
    box-sizing: border-box;
    backdrop-filter: blur(4px);
}

#purchaseModal .modal-box {
    width: 100%;
    background: #0b0b0b;
    border-radius: 16px;
    color: white;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.8);
    box-sizing: border-box;
    margin: auto;
    overflow: hidden;
    /* Desktop: 2-column grid via template areas */
    max-width: 980px;
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-areas:
        "m-title   m-cert"
        "m-info    m-cert"
        "m-name    m-cert"
        "m-message m-cert"
        "m-plan    m-cert"
        "m-color   m-cert"
        "m-lang    m-cert"
        "m-buttons m-cert"
        "m-footer  m-cert";
}

/* ── GRID AREA ASSIGNMENTS ── */
.m-title, .m-info, .m-name, .m-message,
.m-plan, .m-color, .m-lang, .m-buttons, .m-footer, .m-cert {
    min-width: 0; /* prevent grid blowout */
    overflow: hidden;
}
.m-title   { grid-area: m-title;   padding: 22px 20px 0; overflow: visible; }
.m-info    { grid-area: m-info;    padding: 2px 20px 0; }
.m-name    { grid-area: m-name;    padding: 0 20px; overflow: visible; }
.m-message { grid-area: m-message; padding: 0 20px; overflow: visible; }
.m-plan    { grid-area: m-plan;    padding: 0 20px; overflow: visible; }
.m-color   { grid-area: m-color;   padding: 0 20px; overflow: visible; }
.m-lang    { grid-area: m-lang;    padding: 14px 20px 0; overflow: visible; }
.m-buttons { grid-area: m-buttons; padding: 0 20px; display: flex; gap: 10px; overflow: visible; }
.m-footer  { grid-area: m-footer;  padding: 8px 20px 20px; overflow: visible; }

/* ── CERTIFICATE PREVIEW COLUMN ── */
.m-cert {
    grid-area: m-cert;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.018);
    border-radius: 0 16px 16px 0;
    overflow: hidden;
    min-width: 0;
}

.modal-right-label {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 600;
}

/* ── LIVE CERTIFICATE PREVIEW ── */
.cert-live-wrap {
    width: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #030510;
    border: 1px solid rgba(255,255,255,0.06);
    /* Fallback aspect-ratio when flex height not yet resolved */
    aspect-ratio: 1123 / 794;
}

#certLivePreview {
    position: absolute;
    top: 0;
    left: 0;
    width: 1123px;
    height: 794px;
    border: none;
    transform-origin: top left;
    pointer-events: none;
    display: block;
}

/* ── DESIGN NAV HEADER ── */
.cert-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cert-nav-name {
    display: none;
}

.cert-nav-btn {
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.08) !important;
    border: 1px solid rgba(255,255,255,0.18) !important;
    color: rgba(255,255,255,0.7) !important;
    font-size: 18px !important;
    line-height: 1 !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-top: 0 !important;
    padding: 0 !important;
    font-weight: normal !important;
    flex-shrink: 0;
    transition: all 0.15s;
}

.cert-nav-btn:hover {
    background: rgba(255,215,0,0.15) !important;
    border-color: rgba(255,215,0,0.5) !important;
    color: #ffd700 !important;
}

/* ── MINI VISUAL THUMBNAILS ── */
.cert-thumbs {
    display: flex;
    gap: 5px;
}

.cert-thumb {
    flex: 1;
    aspect-ratio: 4 / 3;
    border-radius: 7px !important;
    border: 2px solid rgba(255,255,255,0.12) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0 !important;
    padding: 0 !important;
    font-weight: normal !important;
    background: #111;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.cert-thumb:hover:not(.active) {
    border-color: rgba(255,255,255,0.35) !important;
    transform: translateY(-1px);
}

.cert-thumb.active {
    border-color: #ffd700 !important;
    box-shadow: 0 0 0 1px #ffd700, 0 0 12px rgba(255,215,0,0.45) !important;
}

/* Mobile: single column — cert preview between color and language */
@media (max-width: 900px) {
    #purchaseModal .modal-box {
        grid-template-columns: 1fr;
        grid-template-areas:
            "m-title"
            "m-info"
            "m-name"
            "m-message"
            "m-cert"
            "m-lang"
            "m-plan"
            "m-color"
            "m-buttons"
            "m-footer";
        border-radius: 14px;
    }
    .m-title, .m-info, .m-name, .m-message,
    .m-plan, .m-color, .m-lang, .m-footer { padding-left: 16px; padding-right: 16px; }
    .m-buttons { padding-left: 16px; padding-right: 16px; }
    .m-cert {
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.07);
        border-bottom: 1px solid rgba(255,255,255,0.07);
        border-radius: 0;
        padding: 14px;
        margin-top: 14px;
        max-height: none;
        overflow-y: visible;
    }
    .cert-live-wrap {
        flex: none;
        aspect-ratio: 1123 / 794;
        min-height: auto;
        width: 100%;
    }
}

/* ================= INPUTS ================= */

#purchaseModal input,
#purchaseModal textarea,
#purchaseModal select {
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    border-radius: 8px;
    border: none;
    box-sizing: border-box;
    font-size: 16px; /* iOS auto-zoom prevention: must be ≥16px */
}

#purchaseModal textarea {
    height: 90px;
    resize: vertical;
}

/* ================= PLAN SELECT ================= */

.plan-select {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.plan-select input[type="radio"] {
    display: none;
}

.plan-label {
    flex: 1;
}

.plan-price {
    white-space: nowrap;
    font-weight: 600;
    color: #ffd700;
    flex-shrink: 0;
}

[data-open-buy-modal] {
    cursor: pointer;
}

.plan-select label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    background: #141414;
    border: 1px solid #2a2a2a;
    cursor: pointer;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.plan-select label:hover {
    border-color: gold;
}

.plan-select label:has(input[type="radio"]:checked) {
    border-color: gold;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
}

/* ================= COLOR PICKER ================= */

#colorPickerWrapper {
    margin-top: 10px;
}

.color-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
}


#starColorPicker {
    margin-top: 4px;
}

#starColorPicker .pickr .pcr-button {
    width: 100%;
    height: 38px;
    border-radius: 8px;
    will-change: transform;
}

/* Override Pickr box-shadow (non-composited) with GPU-friendly outline */
#starColorPicker .pickr .pcr-button.pcr-active,
.pcr-button.pcr-active {
    box-shadow: none !important;
    outline: 3px solid rgba(255, 215, 0, 0.7) !important;
    outline-offset: 2px;
}

/* ================= MODAL BUTTONS ================= */

#purchaseModal button:not(.cert-nav-btn):not(.cert-thumb) {
    margin-top: 12px;
    padding: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: #eee;
    color: #000;
    font-weight: 600;
}

#purchaseModal button:not(.cert-nav-btn):not(.cert-thumb):active {
    background: gold;
    transform: scale(0.98);
}

/* ================= MENU BUTTON ================= */

/* visibility controlled by JS after init */

#starSearch {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 240px;
}

#starSearchInput {
    width: 100%;
    padding: 7px 14px;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 20px;
    color: white;
    font-size: 16px; /* iOS auto-zoom prevention */
    outline: none;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s;
}

@media (max-width: 600px) {
    #starSearch {
        right: 12px;
        width: 160px;
    }

    #starSearchInput {
        padding: 6px 12px;
    }

}

#starSearchInput::placeholder { color: rgba(255,255,255,0.35); }
#starSearchInput:focus { border-color: rgba(255,215,0,0.55); }

#starSearchResults {
    margin-top: 6px;
    background: rgba(10, 10, 20, 0.95);
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 12px;
    overflow: hidden;
    display: none;
    backdrop-filter: blur(8px);
    width: 100%;
}

.search-result {
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: rgba(255,215,0,0.08); }

.search-result .sr-name { color: white; font-weight: 500; }
.search-result .sr-id   { color: rgba(255,215,0,0.5); font-size: 11px; margin-left: 6px; }

#menuToggleBtn {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    border: 1px solid #555;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* ================= GLOBE BUTTON ================= */

#globeBtn {
    position: fixed;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    left: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0,0,0,0.85);
    color: white;
    border: 1px solid #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: background 0.2s;
}
#globeBtn:hover { background: rgba(40,40,40,0.95); }

/* ================= LANG/CURRENCY MODAL ================= */

#lcModal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
@media (min-width: 640px) {
    #lcModal { align-items: center; }
}
.lc-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
}
.lc-box {
    position: relative;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 760px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@media (min-width: 640px) {
    .lc-box { border-radius: 16px; max-height: 70vh; }
}
.lc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.lc-tabs {
    display: flex;
    gap: 0;
}
.lc-tab {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 15px;
    font-weight: 500;
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.lc-tab.active {
    color: white;
    border-bottom-color: white;
}
.lc-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.lc-close:hover { opacity: 1; }
.lc-body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}
.lc-panel ul.lc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.lc-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}
.lc-item:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.3);
}
.lc-item.lc-active {
    border-color: white;
    background: rgba(255,255,255,0.08);
}
.lc-flag { font-size: 20px; margin-bottom: 4px; }
.lc-name { color: white; font-size: 13px; font-weight: 500; }
.lc-sub  { color: rgba(255,255,255,0.5); font-size: 12px; }

/* ================= SIDE MENU ================= */

#sideMenu {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 300px;
    max-width: 85vw;
    background: rgba(5, 5, 5, 0.96);
    -webkit-backdrop-filter: blur(8px);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 5500;
    display: flex;
    flex-direction: column;
}

#sideMenu.open {
    transform: translateX(0);
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.side-menu-header button {
    background: none;
    border: none;
    font-size: 18px;
    color: white;
    cursor: pointer;
}

.lang-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.lang-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.lang-btn:hover,
.lang-btn.active {
    opacity: 1;
    border-color: rgba(255,255,255,0.3);
}

.side-menu-content {
    padding: 14px;
    overflow-y: auto;
    color: white;
    font-size: 14px;
}

/* ================= STORY NAV ================= */

#storyNav {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 2000;
}

#storyNav button {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    border: 1px solid #555;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================= COUNTERS ================= */

.input-wrap {
    position: relative;
    margin-top: 10px;
}

.input-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    min-height: 16px;
}

.char-counter {
    font-size: 11px;
    opacity: 0.5;
    color: #ccc;
    flex-shrink: 0;
}

#messageCounter {
    position: absolute;
    right: 6px;
    bottom: -18px;
}

.name-avail {
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s;
}

.name-avail.checking { color: rgba(255,255,255,0.4); }
.name-avail.avail    { color: #6ee86e; }
.name-avail.taken    { color: #ff6b6b; }

.disclaimer {
    margin-top: 10px;
    font-size: 11px;
    opacity: 0.6;
    text-align: left;
    line-height: 1.4;
}

.trust-badges {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-wrap: wrap;
}

.trust-badges span {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
}

.adaptive-price-note {
    margin-top: 4px;
    margin-bottom: 0;
    font-size: 11px;
    opacity: 0.55;
    text-align: left;
    line-height: 1.4;
    cursor: help;
    border-bottom: 1px dashed rgba(255,255,255,0.3);
    display: inline-block;
}

/* ================= TERMS ACCORDION ================= */

.terms-toggle {
    cursor: pointer;
    user-select: none;
    margin-top: 16px;
}

.terms-content {
    font-size: 12px;
    line-height: 1.6;
    opacity: 0.85;
    margin-top: 8px;
}

/* ================= PRIVACY ACCORDION ================= */

.privacy-toggle {
    cursor: pointer;
    user-select: none;
    margin-top: 16px;
}

.privacy-content {
    font-size: 12px;
    line-height: 1.6;
    opacity: 0.85;
    margin-top: 8px;
}

.side-menu-content p strong {
    color: gold;
}

/* ================= BEAUTIFUL UI ALERT ================= */

.ui-alert {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.ui-alert-box {
    background: #0b0b0b;
    color: white;
    padding: 22px;
    border-radius: 14px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 215, 0, 0.4);
    animation: alertPop 0.2s ease;
}

.ui-alert-box button {
    margin-top: 16px;
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: gold;
    color: black;
    font-weight: 700;
    cursor: pointer;
}

@keyframes alertPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

