/* ==============================================================================
   Mobile WebAR Fullscreen & Responsive Layout Styles
   ============================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.d-none {
    display: none !important;
}

.text-danger { color: #ef4444 !important; }
.text-success { color: #10b981 !important; }
.text-warning { color: #f59e0b !important; }
.text-info { color: #0ea5e9 !important; }
.me-1 { margin-right: 4px !important; }
.me-2 { margin-right: 8px !important; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: #000000;
    font-family: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

#arContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    touch-action: none !important;
}

#arContainer canvas,
#arContainer video {
    touch-action: none !important;
}

/* ------------------------------------------------------------------------------
   Splash / Permission Prompt Screen (#startScreen, #emptyScreen)
   ------------------------------------------------------------------------------ */
#startScreen, #emptyScreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    background: radial-gradient(circle at center, #1e293b 0%, #0a0f1d 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    text-align: center;
    color: #f8fafc;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Glassmorphism Start Box (Always centered, never overflows) */
.start-box {
    width: 100%;
    max-width: 440px;
    min-width: 0;
    margin: auto;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 28px 22px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 420px) {
    #startScreen, #emptyScreen {
        padding: 12px;
    }
    .start-box {
        padding: 22px 16px;
        border-radius: 20px;
    }
}

/* Typography inside Start Box */
.start-box-title {
    font-weight: 700;
    font-size: clamp(18px, 4.8vw, 22px);
    line-height: 1.35;
    margin: 0 0 8px 0;
    color: #ffffff;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.start-box-desc {
    color: #94a3b8;
    font-size: clamp(12px, 3.4vw, 13.5px);
    line-height: 1.55;
    margin: 0 0 14px 0;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
}

.start-box-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 14px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    word-break: break-all;
}

/* Marker Preview in Single View */
.marker-preview-thumb {
    width: min(140px, 42vw);
    height: min(140px, 42vw);
    object-fit: cover;
    border-radius: 14px;
    border: 2px solid #0ea5e9;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
    margin: 14px auto;
    display: block;
    background: #0b1120;
}

/* Marker Preview Gallery in Hub View */
.hub-marker-gallery {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 2px 14px 2px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(14, 165, 233, 0.5) rgba(15, 23, 42, 0.5);
}

.hub-marker-gallery::-webkit-scrollbar {
    height: 5px;
}
.hub-marker-gallery::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 10px;
}
.hub-marker-gallery::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.6);
    border-radius: 10px;
}

.hub-gallery-card {
    flex: 0 0 94px;
    max-width: 94px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 6px;
    text-align: center;
    box-sizing: border-box;
    transition: transform 0.2s, border-color 0.2s;
}

.hub-gallery-card img {
    width: 100%;
    max-width: 82px;
    height: 62px;
    max-height: 62px;
    object-fit: cover;
    border-radius: 8px;
    background: #000;
    margin: 0 auto 5px auto;
    display: block;
}

.hub-gallery-card-title {
    font-size: 11px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Call to Action Start AR Button */
.btn-start-ar {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-size: clamp(14px, 4vw, 16px);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
    box-sizing: border-box;
    text-decoration: none;
}

.btn-start-ar:hover {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff;
}

.btn-start-ar:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

/* ------------------------------------------------------------------------------
   Scanning Target Overlay
   ------------------------------------------------------------------------------ */
#scanningGuide {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    overflow: hidden;
    padding: 16px;
    box-sizing: border-box;
}

.scanner-frame {
    width: min(260px, 72vw);
    height: min(260px, 72vw);
    border: 2px dashed rgba(14, 165, 233, 0.65);
    border-radius: 20px;
    position: relative;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.scanner-frame::before, .scanner-frame::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: #0ea5e9;
    border-style: solid;
    pointer-events: none;
}
.scanner-frame::before {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
    border-top-left-radius: 16px;
}
.scanner-frame::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
    border-bottom-right-radius: 16px;
}

.scanner-laser {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, rgba(14, 165, 233, 0) 0%, #38bdf8 50%, rgba(14, 165, 233, 0) 100%);
    box-shadow: 0 0 10px #38bdf8;
    top: 0;
    animation: laserScan 2s ease-in-out infinite alternate;
}

@keyframes laserScan {
    0% { top: 5%; opacity: 0.3; }
    100% { top: 95%; opacity: 1; }
}

/* ------------------------------------------------------------------------------
   Floating Action Controls & Tracking Status
   ------------------------------------------------------------------------------ */
.viewer-controls-top-right {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 35;
    display: flex;
    align-items: center;
    gap: 8px;
}

.circle-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-size: 15px;
    transition: transform 0.15s ease, background 0.2s ease;
}
.circle-btn:active {
    transform: scale(0.92);
}

.hub-gallery-btn {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fbbf24;
    padding: 8px 14px;
    border-radius: 24px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    white-space: nowrap;
}
.hub-gallery-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}

/* Tracking Status Pill (Adaptive on Mobile so it never clashes with top controls) */
#trackingStatusPill {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    padding: 7px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    max-width: calc(100% - 32px);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

@media (max-width: 600px) {
    #trackingStatusPill {
        top: max(64px, calc(env(safe-area-inset-top) + 54px));
        font-size: 12px;
        padding: 6px 14px;
    }
}

.status-searching {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(14, 165, 233, 0.5);
    color: #38bdf8;
}

.status-found {
    background: rgba(22, 101, 52, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid #4ade80;
    color: #ffffff;
}

/* ------------------------------------------------------------------------------
   Interactive Popup Dialogue Card
   ------------------------------------------------------------------------------ */
#dialogueCard {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    width: calc(100% - 32px);
    max-width: 400px;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(14, 165, 233, 0.4);
    border-radius: 20px;
    padding: 20px;
    color: #f8fafc;
    z-index: 50;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    box-sizing: border-box;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#dialogueCard.active {
    transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------------------------
   Touch Rotate Toolbar
   ------------------------------------------------------------------------------ */
#touchRotateToolbar {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: calc(100% - 32px);
    max-width: 380px;
    pointer-events: auto;
    box-sizing: border-box;
}

.rotate-toggle-pill {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(14, 165, 233, 0.5);
    color: #38bdf8;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.rotate-toggle-pill:active, .rotate-toggle-pill.active {
    background: rgba(14, 165, 233, 0.9);
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.6);
}

.rotate-slider-container {
    width: 100%;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.rotate-range-input {
    width: 100%;
    accent-color: #0ea5e9;
    cursor: pointer;
    height: 6px;
    margin: 8px 0;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-xs:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ------------------------------------------------------------------------------
   Floating YouTube Player & Unmute Overlay
   ------------------------------------------------------------------------------ */
.ar-youtube-modal {
    position: fixed;
    top: max(68px, calc(env(safe-area-inset-top) + 54px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 440px;
    z-index: 55;
    background: #0f172a;
    border-radius: 16px;
    border: 1px solid rgba(239, 68, 68, 0.6);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    box-sizing: border-box;
}

.floating-unmute-pill {
    position: fixed;
    bottom: max(85px, calc(env(safe-area-inset-bottom) + 75px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #10b981;
    color: #10b981;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    max-width: calc(100% - 32px);
    box-sizing: border-box;
}

/* ------------------------------------------------------------------------------
   Slide-up Marker Drawer
   ------------------------------------------------------------------------------ */
#markerDrawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px 24px 0 0;
    padding: 20px 16px max(20px, env(safe-area-inset-bottom)) 16px;
    z-index: 60;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
    transform: translateY(110%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#markerDrawer.active {
    transform: translateY(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.drawer-scroll-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.drawer-marker-card {
    flex: 0 0 120px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
}

.drawer-marker-card:hover, .drawer-marker-card.active {
    border-color: #0ea5e9;
    background: rgba(14, 165, 233, 0.15);
}

.drawer-marker-card img {
    width: 100%;
    height: 85px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 6px;
    background: #000;
}

.drawer-marker-title {
    font-size: 11px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hub project detected notification banner */
.hub-detected-toast {
    position: fixed;
    top: max(70px, calc(env(safe-area-inset-top) + 60px));
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    z-index: 45;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    white-space: nowrap;
    max-width: calc(100% - 32px);
    box-sizing: border-box;
}

.hub-detected-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

