/* RedTulip v2 — Territory Picker Styles
   Glassmorphism, globe, and transition effects for the territory selection screen.
   Lifted from v1 index2.php and adapted for v2 design tokens. */

:root {
    --gradient-color-1: #0a1628;
    --gradient-color-2: #1a3a5c;
    --gradient-color-3: #2d5a87;
    --gradient-color-4: #4a90b8;
    --picker-accent: #5eca44;
    --picker-accent-dk: #459a2f;
}


/* ─── Gradient Canvas ─────────────────────────────────────── */

#gradient-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100vh + env(safe-area-inset-top));
    z-index: 0;
    clip-path: circle(85% at 50% 0%);
}


/* ─── Atmospheric Glow ────────────────────────────────────── */

.atmosphere-glow {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74, 144, 184, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
    animation: atmospherePulse 4s ease-in-out infinite;
}

@keyframes atmospherePulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.6; }
    50% { transform: translateX(-50%) scale(1.15); opacity: 0.9; }
}


/* ─── Globe Container ─────────────────────────────────────── */

#globeViz {
    position: fixed;
    top: calc((32% - 33px) + env(safe-area-inset-top));
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    mix-blend-mode: plus-lighter;
    opacity: 0;
    animation: globeFadeIn 1.5s ease-out 0.3s forwards;
}

@keyframes globeFadeIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}


/* ─── Central Logo ────────────────────────────────────────── */

#picker-logo {
    position: fixed;
    top: calc((32% - 33px) + env(safe-area-inset-top));
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: url('../images/logo.png') center/contain no-repeat;
    background-size: 125%;
    background-color: white;
    border-radius: 50%;
    z-index: 10;
    box-shadow:
        0 0 0 4px rgba(255, 255, 255, 0.25),
        0 0 60px rgba(74, 144, 184, 0.4),
        0 20px 60px rgba(0, 0, 0, 0.4);
    opacity: 0;
    animation: logoReveal 1s ease-out 0.6s forwards;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes logoReveal {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#picker-logo.logo-hide {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
    animation: logoFadeOut 0.3s ease-out forwards;
}

@keyframes logoFadeOut {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
}

#picker-logo.logo-show {
    animation: logoFadeIn 0.4s ease-out forwards !important;
}

@keyframes logoFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}


/* ─── Header Brand ────────────────────────────────────────── */

.picker-header {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 16px);
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100;
    opacity: 0;
    animation: fadeDown 0.8s ease-out 0.2s forwards;
}

@keyframes fadeDown {
    0% { opacity: 0; transform: translateY(-20px); }
    100% { opacity: 1; transform: translateY(0); }
}


/* ─── UI Stack (Main Content) ─────────────────────────────── */

#ui-stack {
    position: relative;
    z-index: 50;
    width: min(420px, calc(100vw - 32px));
    margin: 0 auto;
    padding-top: calc(40vh + env(safe-area-inset-top));
    padding-bottom: max(100px, calc(env(safe-area-inset-bottom) + 80px));
}


/* ─── Glass Card (Hero) ───────────────────────────────────── */

.glass-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.05) 100%);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    outline: 4px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    padding: 20px 24px;
    margin-bottom: 2rem;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card.show {
    opacity: 1;
    transform: translateY(0);
}

.glass-card.glass-card-hide {
    opacity: 0;
    transform: translateY(-50px);
    pointer-events: none;
}


/* ─── Territory Sheet ─────────────────────────────────────── */

.territory-sheet {
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.08) 100%);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    outline: 4px solid rgba(255, 255, 255, 0.25);
    border-radius: 28px 28px 24px 24px;
    overflow: hidden;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    margin-top: 2rem;
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.territory-sheet.show {
    opacity: 1;
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 100px;
    margin: 12px auto 8px;
}

.sheet-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 20px;
}

.sheet-header .divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,0.15), transparent);
}

.sheet-header .divider-line:last-child {
    background: linear-gradient(270deg, rgba(255,255,255,0.15), transparent);
}

.sheet-label {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: white;
}


/* ─── Territory Items ─────────────────────────────────────── */

.territory-list {
    padding: 8px 0;
}

.territory-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.territory-item::before {
    content: '';
    position: absolute;
    inset: 4px 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    transition: all 0.3s ease;
    z-index: -1;
}

.territory-item:active::before {
    background: rgba(255, 255, 255, 0.15);
}

.territory-item.selected::before {
    background: linear-gradient(135deg, rgba(94, 202, 68, 0.25) 0%, rgba(74, 144, 184, 0.15) 100%);
}

.territory-item + .territory-item {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}


/* ─── Territory Flag ──────────────────────────────────────── */

.territory-flag {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.territory-item.selected .territory-flag {
    box-shadow: 0 4px 16px rgba(94, 202, 68, 0.25);
    transform: scale(1.05);
}


/* ─── Territory Info ──────────────────────────────────────── */

.territory-info {
    flex: 1;
    min-width: 0;
}

.territory-name {
    font-size: 1.1rem;
    color: white;
    margin-bottom: 2px;
    transition: color 0.3s ease;
    line-height: 1;
}

.territory-item.selected .territory-name {
    color: var(--picker-accent);
}

.territory-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1;
}

.status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--picker-accent);
    animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


/* ─── Territory Action ────────────────────────────────────── */

.territory-action {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-arrow {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.territory-item.selected .action-arrow {
    background: linear-gradient(135deg, var(--picker-accent) 0%, var(--picker-accent-dk) 100%);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(94, 202, 68, 0.4);
}

.enter-btn {
    display: none;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--picker-accent) 0%, var(--picker-accent-dk) 100%);
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(94, 202, 68, 0.4);
    transition: all 0.3s ease;
    animation: enterBtnPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes enterBtnPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.territory-item.selected .enter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.territory-item.selected .action-arrow {
    display: none;
}

.enter-btn:active {
    transform: scale(0.95);
}


/* ─── Coming Soon Items ───────────────────────────────────── */

.territory-item.coming-soon {
    cursor: default;
    opacity: 0.5;
}

.territory-item.coming-soon .territory-flag {
    filter: grayscale(0.4);
}

.coming-soon-badge {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 100px;
}


/* ─── Zoom Indicator ──────────────────────────────────────── */

.zoom-indicator {
    position: fixed;
    top: calc(32% + env(safe-area-inset-top) + 80px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.75rem;
    color: white;
    opacity: 0;
    z-index: 100;
    transition: all 0.4s ease;
    pointer-events: none;
}

.zoom-indicator.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}


/* ─── Globe Territory Markers ─────────────────────────────── */

.territory-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    outline: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition:
        width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        background 0.4s ease,
        outline 0.4s ease,
        box-shadow 0.4s ease;
}

.territory-marker.inactive {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    outline: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.territory-marker.selected {
    width: 18px;
    height: 18px;
    background: var(--picker-accent);
    outline: 4px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 20px rgba(94, 202, 68, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.territory-marker.selected::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--picker-accent);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
    animation: territoryRipple 2s ease-out infinite;
}

@keyframes territoryRipple {
    0% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.3);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}
