/* ============================================================
   AHGsm — Persistent 3D World Shell (global layer)
   - boots a shared deep-space canvas behind every page
   - glassmorphic panel system that floats over the canvas
   - camera "dive" transition overlay on in-site navigation
   All rules are scoped to ah-* namespaces so they never
   collide with the panel framework or existing styles.
   ============================================================ */

/* ---------- dark root backdrop (guarantees the canvas region is always dark) ----------
   Loaded by every world page (index/panel/wallet/apps/reseller/privacy),
   so the dark base does NOT depend on 3d-style.css being present.
   Painting order: html bg -> #ah-world (z:-1) -> transparent body -> content. */
html,
html.ah-3d-booted {
    background: #040a16;
}

/* ---------- persistent world canvas ---------- */
#ah-world {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1 !important;
    pointer-events: none;
    display: block;
}

/* soft vignette over the world so overlay text always stays readable */
body.ah-3d-on::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background: radial-gradient(
        ellipse 92% 72% at 50% 42%,
        transparent 28%,
        rgba(4, 10, 22, 0.55) 76%,
        rgba(4, 10, 22, 0.92) 100%
    );
}

/* ---------- navigation dive transition overlay ---------- */
#ah-transition {
    position: fixed;
    inset: -12%;
    z-index: 999997;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.38s ease, visibility 0.38s;
    background: radial-gradient(
        circle at 50% 50%,
        transparent 0%,
        rgba(4, 10, 22, 0) 28%,
        rgba(4, 10, 22, 0.6) 72%,
        rgba(4, 10, 22, 0.95) 100%
    );
}
#ah-transition.is-diving,
#ah-transition.is-arriving {
    opacity: 1;
    visibility: visible;
}

#ah-transition .ah-tr-warp {
    position: absolute;
    inset: 0;
    background: repeating-conic-gradient(
        from 0deg at 50% 50%,
        rgba(103, 232, 249, 0.11) 0deg 1.6deg,
        transparent 1.6deg 12deg
    );
    opacity: 0;
    transform: scale(1.05);
}

#ah-transition .ah-tr-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12vmax;
    height: 12vmax;
    margin: -6vmax 0 0 -6vmax;
    border-radius: 50%;
    border: 2px solid rgba(103, 232, 249, 0.55);
    box-shadow:
        0 0 30px rgba(34, 211, 238, 0.45),
        inset 0 0 24px rgba(34, 211, 238, 0.35);
    opacity: 0;
}

#ah-transition .ah-tr-flash {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(103, 232, 249, 0.28), transparent 46%);
    opacity: 0;
}

/* dive out (leaving a page) */
#ah-transition.is-diving .ah-tr-warp {
    animation: ahWarpIn 0.45s cubic-bezier(0.22, 0.72, 0.2, 1) forwards;
}
#ah-transition.is-diving .ah-tr-ring {
    animation: ahRingIn 0.45s cubic-bezier(0.22, 0.72, 0.2, 1) forwards;
}
#ah-transition.is-diving .ah-tr-flash {
    animation: ahFlashIn 0.45s ease forwards;
}
@keyframes ahWarpIn {
    from { transform: scale(1.02); opacity: 0.15; }
    to   { transform: scale(2.7);  opacity: 0.95; }
}
@keyframes ahRingIn {
    from { transform: scale(0.18); opacity: 0; }
    to   { transform: scale(2.3);  opacity: 1; }
}
@keyframes ahFlashIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* arrive (landing on the next page) */
#ah-transition.is-arriving .ah-tr-warp {
    animation: ahWarpOut 0.85s cubic-bezier(0.16, 0.84, 0.24, 1) forwards;
}
#ah-transition.is-arriving .ah-tr-ring {
    animation: ahRingOut 0.85s cubic-bezier(0.16, 0.84, 0.24, 1) forwards;
}
#ah-transition.is-arriving .ah-tr-flash {
    animation: ahFlashOut 0.6s ease forwards;
}
@keyframes ahWarpOut {
    from { transform: scale(2.7);  opacity: 0.95; }
    to   { transform: scale(1.02); opacity: 0; }
}
@keyframes ahRingOut {
    from { transform: scale(2.3);  opacity: 1; }
    to   { transform: scale(0.18); opacity: 0; }
}
@keyframes ahFlashOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ============================================================
   Glassmorphic panel system
   Floats semi-transparent over the persistent 3D canvas.
   ============================================================ */
.ah-glass {
    position: relative;
    background:
        linear-gradient(160deg, rgba(13, 34, 52, 0.74) 0%, rgba(6, 16, 28, 0.68) 55%, rgba(4, 10, 22, 0.72) 100%);
    border: 1px solid rgba(103, 232, 249, 0.16);
    border-radius: 18px;
    backdrop-filter: blur(16px) saturate(155%);
    -webkit-backdrop-filter: blur(16px) saturate(155%);
    box-shadow:
        0 20px 46px -20px rgba(0, 0, 0, 0.85),
        0 6px 18px -10px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.10),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}

/* fine 3D gradient edge highlight */
.ah-glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(
        145deg,
        rgba(165, 243, 252, 0.42) 0%,
        rgba(103, 232, 249, 0.08) 32%,
        transparent 55%,
        rgba(103, 232, 249, 0.12) 100%
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.ah-glass-strong {
    background:
        linear-gradient(160deg, rgba(15, 40, 62, 0.9) 0%, rgba(7, 19, 33, 0.88) 55%, rgba(4, 10, 22, 0.9) 100%);
    backdrop-filter: blur(20px) saturate(165%);
    -webkit-backdrop-filter: blur(20px) saturate(165%);
}

.ah-glass-subtle {
    background: rgba(8, 22, 36, 0.5);
    border-color: rgba(103, 232, 249, 0.12);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* readable text over glass */
.ah-glass,
.ah-glass-strong,
.ah-glass-subtle {
    color: #e8f1f9;
}
.ah-glass ::selection,
.ah-glass-strong ::selection {
    color: #04121a;
    background: #67e8f9;
}

/* ---------- glass tables ---------- */
.ah-glass-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    color: #dfeaf5;
}
.ah-glass-table thead th {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: #67e8f9;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    text-align: start;
    border-bottom: 1px solid rgba(103, 232, 249, 0.18);
}
.ah-glass-table tbody tr {
    background: rgba(9, 26, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.2s ease;
}
.ah-glass-table tbody tr:hover {
    background: rgba(16, 42, 64, 0.72);
}
.ah-glass-table tbody td {
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ah-glass-table tbody td:first-child {
    border-inline-start: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px 0 0 12px;
}
.ah-glass-table tbody td:last-child {
    border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0 12px 12px 0;
}

/* ---------- glass form controls ---------- */
.ah-glass-input,
input.ah-glass-input,
select.ah-glass-input,
textarea.ah-glass-input {
    width: 100%;
    color: #eef6fd;
    background: rgba(5, 14, 24, 0.62);
    border: 1px solid rgba(103, 232, 249, 0.18);
    border-radius: 12px;
    padding: 11px 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.ah-glass-input::placeholder {
    color: #7d97ad;
}
.ah-glass-input:focus {
    border-color: rgba(103, 232, 249, 0.62);
    background: rgba(7, 20, 34, 0.8);
    box-shadow:
        0 0 0 3px rgba(34, 211, 238, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---------- glass app-shelf cards (services grid) ---------- */
.ah-glass-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    text-align: center;
    text-decoration: none;
    color: #e8f1f9;
    background:
        linear-gradient(165deg, rgba(14, 38, 60, 0.72), rgba(5, 13, 24, 0.66));
    border: 1px solid rgba(103, 232, 249, 0.14);
    border-radius: 16px;
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    box-shadow:
        0 14px 30px -16px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.22s cubic-bezier(0.22, 0.72, 0.2, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}
.ah-glass-card:hover {
    transform: translateY(-3px);
    border-color: rgba(103, 232, 249, 0.34);
    box-shadow:
        0 22px 44px -18px rgba(0, 0, 0, 0.9),
        0 0 22px -10px rgba(34, 211, 238, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* ---------- reduced motion: kill all 3D animation ---------- */
@media (prefers-reduced-motion: reduce) {
    #ah-transition,
    #ah-transition .ah-tr-warp,
    #ah-transition .ah-tr-ring,
    #ah-transition .ah-tr-flash,
    .ah-glass,
    .ah-glass-card {
        animation: none !important;
        transition: none !important;
    }
    #ah-world {
        display: none;
    }
}

/* ---------- low-end handhelds: shed the blur cost ---------- */
@media (max-width: 620px) {
    .ah-glass,
    .ah-glass-strong,
    .ah-glass-card {
        backdrop-filter: blur(10px) saturate(135%);
        -webkit-backdrop-filter: blur(10px) saturate(135%);
    }
}
