/* ========================================
   Karreeb® Cup to Farm - AR Experience
   Brand: Dark Green #1B5E20 + Gold #C9A84C
   ======================================== */

:root {
    --green-dark: #1B5E20;
    --green-mid: #2E7D32;
    --green-light: #4CAF50;
    --green-pale: #E8F5E9;
    --gold: #C9A84C;
    --gold-dark: #B8860B;
    --cream: #FFF8F0;
    --white: #FFFFFF;
    --text-dark: #1a1a1a;
    --text-mid: #555;
    --rose: #E57373;
    --blue: #1565C0;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #000;
    color: var(--text-dark);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* Camera Feed */
#cameraFeed {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.5s;
}
#cameraFeed.active { opacity: 1; }

/* Screen Container */
.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.screen.active { display: flex; }

/* ========================================
   Top Bar
   ======================================== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    padding-top: calc(8px + var(--safe-top));
    background: var(--green-dark);
    color: var(--white);
    z-index: 20;
    min-height: 48px;
    flex-shrink: 0;
}
.top-bar-left { display: flex; align-items: center; gap: 8px; }
.karreeb-logo-small {
    width: 28px; height: 28px;
    background: var(--gold);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 14px; color: var(--green-dark);
    font-style: italic;
}
.top-right-logo { position: absolute; right: 16px; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: 0.3px; }
.brand-name.center { position: absolute; left: 50%; transform: translateX(-50%); }
.top-bar-right { font-size: 14px; opacity: 0.9; cursor: pointer; }
.close-btn { font-size: 20px; padding: 4px 8px; }
.back-arrow { font-size: 24px; cursor: pointer; padding-right: 8px; }

/* ========================================
   SCREEN 1: QR Scanner
   ======================================== */
#screen-scanner {
    background: #000;
}
.scanner-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
}
.scanner-frame {
    width: min(280px, 70vw); height: min(280px, 50vh);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.corner {
    position: absolute;
    width: 40px; height: 40px;
    border-color: #fff;
    border-style: solid;
    border-width: 0;
}
.corner.top-left { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; }
.corner.top-right { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; }
.corner.bottom-left { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; }
.corner.bottom-right { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; }

.scan-line {
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--green-light), transparent);
    animation: scanMove 2s ease-in-out infinite;
    box-shadow: 0 0 12px var(--green-light);
}
@keyframes scanMove {
    0%, 100% { top: 10%; }
    50% { top: 90%; }
}
.qr-placeholder {
    opacity: 0.6;
    animation: qrPulse 3s ease-in-out infinite;
}
@keyframes qrPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.03); }
}

.scanner-bottom {
    padding: 20px 24px;
    text-align: center;
    flex-shrink: 0;
    padding-bottom: calc(20px + var(--safe-bottom));
}
.scanner-instruction { color: #fff; font-size: 16px; font-weight: 600; }
.scanner-sub { color: rgba(255,255,255,0.6); font-size: 13px; margin-top: 4px; }
.mini-qr { margin: 12px auto; opacity: 0.5; }
.btn-scan {
    background: var(--green-mid);
    color: #fff;
    border: none;
    padding: 14px 36px;
    border-radius: 28px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: transform 0.2s, background 0.2s;
}
.btn-scan:active { transform: scale(0.96); background: var(--green-dark); }

/* ========================================
   SCREEN 2: Loading
   ======================================== */
#screen-loading {
    background: var(--green-mid);
    justify-content: center;
    align-items: center;
    position: relative;
}
.loading-bg {
    position: absolute; inset: 0;
    overflow: hidden;
}
.tea-leaf {
    position: absolute;
    width: 30px; height: 18px;
    background: rgba(0,0,0,0.12);
    border-radius: 50% 0 50% 0;
    animation: floatLeaf 8s ease-in-out infinite;
}
.leaf-1 { top: 8%; right: 10%; animation-delay: 0s; }
.leaf-2 { top: 15%; left: 25%; animation-delay: 1s; transform: rotate(45deg); }
.leaf-3 { top: 25%; right: 30%; animation-delay: 2s; transform: rotate(-30deg); }
.leaf-4 { top: 35%; left: 10%; animation-delay: 0.5s; }
.leaf-5 { top: 65%; right: 20%; animation-delay: 1.5s; transform: rotate(60deg); }
.leaf-6 { top: 75%; left: 30%; animation-delay: 3s; }
.leaf-7 { top: 85%; right: 40%; animation-delay: 2.5s; transform: rotate(-45deg); }
.leaf-8 { top: 55%; left: 15%; animation-delay: 4s; transform: rotate(20deg); }

@keyframes floatLeaf {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-12px) rotate(5deg); }
    75% { transform: translateY(12px) rotate(-5deg); }
}

.loading-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 40px;
}
.karreeb-logo-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark), var(--gold));
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.karreeb-logo-circle.small { width: 56px; height: 56px; margin-bottom: 12px; }
.logo-pattern {
    font-size: 32px; font-weight: 900; font-style: italic;
    color: var(--green-dark);
}
.karreeb-logo-circle.small .logo-pattern { font-size: 24px; }

.loading-title {
    font-size: 28px; color: #fff; font-weight: 700;
    letter-spacing: 0.5px;
}
.loading-by { color: var(--gold); font-size: 14px; margin-top: 4px; }
.loading-tagline { color: rgba(255,255,255,0.85); font-size: 15px; margin-top: 8px; }

.loading-progress {
    margin-top: 32px;
    text-align: left;
}
.loading-status { color: rgba(255,255,255,0.7); font-size: 13px; text-align: center; margin-bottom: 8px; }
.progress-bar {
    height: 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}
.loading-steps { margin-top: 16px; }
.step {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 0;
    font-size: 13px; color: rgba(255,255,255,0.6);
}
.step-status {
    font-size: 12px; font-weight: 700;
    min-width: 24px;
}
.step-status.ok { color: var(--gold); }
.step-status.pending { color: rgba(255,255,255,0.4); }

.loading-footer {
    position: absolute;
    bottom: calc(20px + var(--safe-bottom));
    left: 0; right: 0;
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 12px;
}

/* ========================================
   SCREEN 3: Welcome
   ======================================== */
#screen-welcome {
    background: var(--green-mid);
}
.welcome-scene {
    height: min(200px, 25vh);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.sky-gradient {
    position: absolute; top: 0; left: 0; right: 0;
    height: 120px;
    background: linear-gradient(180deg, #5D7B6F 0%, #A8C5B8 50%, #D4E5DD 100%);
}
.hills {
    position: absolute; bottom: 0; left: 0; right: 0; height: 120px;
    background:
        radial-gradient(ellipse 120% 80% at 20% 100%, #4CAF50 0%, transparent 70%),
        radial-gradient(ellipse 100% 90% at 80% 100%, #388E3C 0%, transparent 70%),
        radial-gradient(ellipse 140% 70% at 50% 100%, #43A047 0%, transparent 60%);
}

.welcome-card {
    flex: 1;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    margin-top: -20px;
    position: relative;
    z-index: 5;
    padding: 28px 24px;
    overflow-y: auto;
    padding-bottom: calc(24px + var(--safe-bottom));
}
.welcome-title {
    color: var(--green-dark);
    font-size: 22px; font-weight: 700;
    text-align: center;
}
.title-divider {
    width: 40px; height: 3px;
    background: var(--gold);
    margin: 10px auto 16px;
    border-radius: 2px;
}
.welcome-desc {
    text-align: center;
    color: var(--text-mid);
    font-size: 14px; line-height: 1.5;
    margin-bottom: 20px;
}
.welcome-stages-label {
    color: var(--text-mid);
    font-size: 13px;
    text-align: center;
    margin-bottom: 12px;
}
.stages-list { margin-bottom: 20px; }
.stage-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 0;
    font-size: 15px; font-weight: 500;
}
.stage-num {
    width: 26px; height: 26px;
    border-radius: 50%;
    color: #fff; font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.how-it-works { margin-bottom: 24px; }
.how-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.how-item { font-size: 13px; color: var(--text-mid); padding: 2px 0; }
.how-item::first-letter { color: var(--gold); }

.btn-begin {
    width: 100%;
    padding: 16px;
    background: var(--green-dark);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 17px; font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}
.btn-begin:active { transform: scale(0.97); background: #14451b; }

/* ========================================
   SCREEN 4: Main AR Interface
   ======================================== */
#screen-ar { background: transparent; }

.ar-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.ar-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(
        180deg,
        rgba(27,94,32,0.3) 0%,
        rgba(46,125,50,0.15) 30%,
        rgba(76,175,80,0.1) 60%,
        rgba(46,125,50,0.2) 100%
    );
    z-index: 1;
}
.ar-overlay.dim {
    background: linear-gradient(
        180deg,
        rgba(27,94,32,0.4) 0%,
        rgba(46,125,50,0.2) 40%,
        rgba(76,175,80,0.15) 100%
    );
}

/* AR Hotspots */
.ar-hotspot {
    position: absolute;
    z-index: 5;
    cursor: pointer;
    width: 36px; height: 36px;
}
.hotspot-dot {
    width: 12px; height: 12px;
    background: var(--gold);
    border: 2px solid #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}
.hotspot-ring {
    position: absolute;
    top: 50%; left: 50%;
    width: 36px; height: 36px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(201,168,76,0.5);
    border-radius: 50%;
    animation: ringPulse 2s ease-out infinite;
}
@keyframes ringPulse {
    0% { width: 16px; height: 16px; opacity: 1; }
    100% { width: 44px; height: 44px; opacity: 0; }
}

.hotspot-tooltip {
    position: absolute;
    z-index: 10;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    max-width: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    line-height: 1.4;
}
.hotspot-tooltip.visible { opacity: 1; }

/* Stage Navigation Bar */
.stage-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255,255,255,0.95);
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.stage-nav-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}
.stage-nav-item.active { opacity: 1; }
.stage-nav-item.completed { opacity: 0.8; }
.stage-nav-num {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--green-dark);
    color: #fff;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.stage-nav-item.active .stage-nav-num {
    background: var(--gold);
    color: var(--green-dark);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.3);
}
.stage-nav-item.completed .stage-nav-num {
    background: var(--green-mid);
}
.stage-nav-label { font-size: 10px; color: var(--text-mid); font-weight: 500; }
.stage-nav-connector {
    flex: 1; height: 2px;
    background: var(--gold);
    margin: 0 -2px;
    margin-bottom: 14px;
}

/* AR Info Panel */
.ar-info-panel {
    background: var(--white);
    padding: 14px 20px;
    flex-shrink: 0;
    border-top: 3px solid var(--gold);
    max-height: 40vh;
    overflow-y: auto;
}
.ar-stage-title { color: var(--green-dark); font-size: 20px; font-weight: 700; }
.ar-stage-desc { color: var(--text-mid); font-size: 13px; margin-top: 4px; line-height: 1.4; }
.ar-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 11px; font-weight: 600;
}
.tag.green { background: var(--green-pale); color: var(--green-dark); }
.tag.gold { background: #FFF3E0; color: var(--gold-dark); }
.tag.rose { background: #FCE4EC; color: #C62828; }
.tag.green-outline { background: transparent; border: 1px solid var(--green-mid); color: var(--green-mid); }
.tag.blue { background: #E3F2FD; color: var(--blue); }
.tag.purple { background: #F3E5F5; color: #7B1FA2; }

.ar-panel-actions {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 12px;
}
.btn-explore {
    background: var(--green-dark);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
.btn-explore:active { transform: scale(0.96); }
.stage-counter { font-size: 12px; color: var(--text-mid); }

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    background: var(--white);
    border-top: 1px solid #eee;
    padding: 6px 0;
    padding-bottom: calc(6px + var(--safe-bottom));
    flex-shrink: 0;
}
.nav-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 2px;
    padding: 6px 0;
    color: var(--text-mid);
    font-size: 10px;
    cursor: pointer;
    transition: color 0.2s;
}
.nav-item.active { color: var(--green-dark); }
.nav-item svg { stroke: currentColor; }

/* ========================================
   SCREEN 5: Stage Detail
   ======================================== */
#screen-detail { background: var(--green-mid); }

.detail-ar-view {
    height: 40%;
    min-height: 200px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #5D7B6F 0%, #7CB342 40%, #4CAF50 70%, #388E3C 100%);
    flex-shrink: 0;
}

.detail-panel {
    flex: 1;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    margin-top: -16px;
    position: relative;
    z-index: 5;
    padding: 20px;
    overflow-y: auto;
    padding-bottom: calc(20px + var(--safe-bottom));
}
.detail-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.detail-title { font-size: 22px; font-weight: 700; color: var(--green-dark); }
.detail-stage-badge {
    background: var(--green-pale);
    color: var(--green-dark);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px; font-weight: 600;
}
.detail-desc {
    color: var(--text-mid);
    font-size: 14px; line-height: 1.5;
    margin-bottom: 12px;
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.did-you-know {
    background: #FFF8E1;
    border-left: 3px solid var(--gold);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 16px;
}
.dyk-label { color: var(--gold-dark); font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.dyk-text { color: var(--text-mid); font-size: 13px; line-height: 1.4; }

.gallery-section { margin-bottom: 16px; }
.gallery-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.gallery-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.gallery-item {
    min-width: 120px; height: 80px;
    border-radius: 10px;
    flex-shrink: 0;
}

.detail-nav {
    display: flex; justify-content: space-between;
    margin-top: 8px;
}
.btn-prev, .btn-next {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
.btn-prev {
    background: #f5f5f5; color: var(--text-mid);
    border: 1px solid #ddd;
}
.btn-next {
    background: var(--green-dark); color: #fff;
    border: none;
}
.btn-prev:active, .btn-next:active { transform: scale(0.96); }
.btn-prev:disabled { opacity: 0.4; cursor: default; }

/* ========================================
   SCREEN 6: Journey Map
   ======================================== */
#screen-journey {
    background: #f5f5f5;
}
.journey-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    padding-bottom: calc(24px + var(--safe-bottom));
}
.journey-origin {
    display: flex; gap: 12px;
    align-items: center;
    padding: 12px;
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 8px;
}
.origin-label { font-size: 12px; color: var(--text-mid); }
.origin-product { font-size: 14px; font-weight: 700; color: var(--text-dark); }
.origin-sub { font-size: 11px; color: var(--text-mid); }

.journey-arrow {
    text-align: center;
    color: var(--green-mid);
    font-size: 18px;
    padding: 4px 0;
}

.journey-stages {
    display: flex; flex-direction: column;
    gap: 12px;
}
.journey-card {
    background: var(--white);
    border: 2px solid var(--card-color);
    border-radius: 14px;
    padding: 16px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}
.journey-card:active { transform: scale(0.98); }
.journey-card h4 { color: var(--card-color); font-size: 16px; margin-bottom: 4px; }
.journey-card p { font-size: 13px; color: var(--text-mid); line-height: 1.3; }
.card-bottom {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 12px;
}
.card-num {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--card-color);
    color: #fff;
    font-size: 14px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.card-status { font-size: 20px; color: var(--card-color); }
.current-dot { color: var(--blue); }
.card-progress {
    position: absolute;
    bottom: 0; left: 0;
    height: 4px;
    border-radius: 0 2px 0 0;
    transition: width 0.5s;
}
.journey-card.locked { opacity: 0.6; }

.overall-progress {
    display: flex; flex-wrap: wrap;
    justify-content: space-between; align-items: center;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 10px;
    font-size: 14px; font-weight: 600;
}
.overall-bar {
    width: 100%; height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}
.overall-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--green-mid) 0%, var(--gold) 50%, #e0e0e0 50%);
    transition: width 0.5s;
}

/* ========================================
   Modals
   ======================================== */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    padding: 28px 24px;
    padding-bottom: calc(28px + var(--safe-bottom));
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease-out;
    text-align: center;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-close {
    position: absolute; top: 16px; right: 20px;
    font-size: 22px; cursor: pointer; color: var(--text-mid);
}
.modal-content h3 {
    font-size: 20px; color: var(--green-dark); margin: 12px 0 16px;
}
.modal-content p {
    font-size: 14px; color: var(--text-mid); line-height: 1.5;
    margin-bottom: 12px;
}
.about-stats {
    display: flex; justify-content: center; gap: 24px;
    margin: 20px 0;
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat strong { font-size: 22px; color: var(--green-dark); }
.stat span { font-size: 11px; color: var(--text-mid); }
.about-footer { font-size: 12px; color: #999; margin-top: 16px; }

.product-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px; margin: 16px 0;
    text-align: left;
}
.product-card {
    background: #f9f9f9;
    border-radius: 12px;
    overflow: hidden;
}
.product-img { height: 80px; }
.product-name { font-size: 13px; font-weight: 600; padding: 8px 10px 2px; color: var(--text-dark); }
.product-price { font-size: 12px; color: var(--gold-dark); padding: 0 10px 10px; }

.btn-shop {
    display: block;
    background: var(--green-dark);
    color: #fff;
    text-decoration: none;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    margin-top: 8px;
}

/* ========================================
   Screen Transitions
   ======================================== */
.screen.fade-in {
    animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.screen.slide-in {
    animation: slideInRight 0.35s ease-out;
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* ========================================
   Camera Fallback (animated AR background)
   ======================================== */
.ar-viewport .ar-fallback,
.detail-ar-view .ar-fallback {
    position: absolute; inset: 0;
    z-index: 0;
    overflow: hidden;
}
.ar-fallback .layer {
    position: absolute; inset: 0;
    animation: arPan 20s ease-in-out infinite alternate;
}
.ar-fallback .layer-sky {
    background: linear-gradient(180deg, #4A6741 0%, #6B8F5E 30%, #8FB87A 50%, #A8D4A0 70%);
    height: 50%;
}
.ar-fallback .layer-field {
    position: absolute; bottom: 0; left: -20%; right: -20%;
    height: 65%;
    background:
        radial-gradient(ellipse 80% 60% at 30% 40%, #4CAF50 0%, transparent 70%),
        radial-gradient(ellipse 90% 50% at 70% 50%, #388E3C 0%, transparent 70%),
        radial-gradient(ellipse 100% 80% at 50% 60%, #43A047 0%, transparent 60%),
        linear-gradient(180deg, #66BB6A 0%, #2E7D32 100%);
    animation: fieldSway 12s ease-in-out infinite alternate;
}
.ar-fallback .layer-rows {
    position: absolute; bottom: 10%; left: -10%; right: -10%;
    height: 50%;
    background: repeating-linear-gradient(
        180deg,
        transparent 0px,
        transparent 30px,
        rgba(27,94,32,0.15) 30px,
        rgba(27,94,32,0.15) 32px
    );
    transform: perspective(300px) rotateX(15deg);
    animation: rowsDrift 15s ease-in-out infinite alternate;
}
.ar-fallback .particle {
    position: absolute;
    width: 6px; height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    animation: particleFloat 6s ease-in-out infinite;
}
.ar-fallback .particle:nth-child(1) { top: 20%; left: 15%; animation-delay: 0s; }
.ar-fallback .particle:nth-child(2) { top: 35%; left: 55%; animation-delay: 1.5s; }
.ar-fallback .particle:nth-child(3) { top: 15%; left: 80%; animation-delay: 3s; }
.ar-fallback .particle:nth-child(4) { top: 45%; left: 30%; animation-delay: 0.7s; }
.ar-fallback .particle:nth-child(5) { top: 25%; left: 65%; animation-delay: 2.2s; }

@keyframes arPan { 0% { transform: scale(1.05) translateX(-1%); } 100% { transform: scale(1.05) translateX(1%); } }
@keyframes fieldSway { 0% { transform: translateX(-1%); } 100% { transform: translateX(1%); } }
@keyframes rowsDrift { 0% { transform: perspective(300px) rotateX(15deg) translateY(-2%); } 100% { transform: perspective(300px) rotateX(15deg) translateY(2%); } }
@keyframes particleFloat { 0%,100% { opacity: 0.2; transform: translateY(0); } 50% { opacity: 0.7; transform: translateY(-15px); } }

/* AR Badge */
.ar-badge {
    position: absolute;
    top: 12px; left: 12px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: flex; align-items: center; gap: 5px;
    backdrop-filter: blur(8px);
}
.ar-badge .live-dot {
    width: 6px; height: 6px;
    background: #f44336;
    border-radius: 50%;
    animation: livePulse 1.5s ease-in-out infinite;
}
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ========================================
   Responsive tweaks
   ======================================== */
@media (min-width: 500px) {
    .scanner-frame { width: 320px; height: 320px; }
    .welcome-card { padding: 32px 40px; }
    .ar-info-panel { padding: 20px 28px; }
}
