/* Cards Grid Layout */
.maps-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 1220px;
    margin: 0 auto;
    padding: 6px 0;
}

@media (max-width: 1100px) {
    .maps-grid {
        grid-template-columns: repeat(3, minmax(210px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 760px) {
    .maps-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (max-width: 640px) {
    .maps-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* ==========================================
   Map Card Design
   ========================================== */
.map-card {
    background: rgba(12, 12, 12, 0.94);
    border: 1px solid rgba(255, 244, 225, 0.14);
    border-radius: 2px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: none;
    transition:
        transform 220ms ease,
        border-color 220ms ease,
        background-color 220ms ease,
        box-shadow 220ms ease;
}

.map-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border: 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(11, 11, 11, 0.1) 48%, rgba(11, 11, 11, 0.78) 100%);
    pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 5;
}

.map-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 244, 225, 0.34);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.map-card.selected {
    transform: translateY(-2px);
    background: rgba(14, 14, 14, 0.98);
    border-color: rgba(255, 244, 225, 0.66);
    box-shadow:
        0 0 0 1px rgba(255, 244, 225, 0.32),
        0 14px 36px rgba(0, 0, 0, 0.28);
}

.map-card.selected::before {
    opacity: 0.82;
}

.banner {
    width: 100%;
    aspect-ratio: 15 / 10;
    overflow: hidden;
    position: relative;
    background: #0b0b0b;
}

.banner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 52%;
    background: linear-gradient(to top, rgba(10, 10, 10, 0.96) 0%, rgba(10, 10, 10, 0.28) 48%, transparent 100%);
    z-index: 2;
    transition: opacity 0.3s;
}

.banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 320ms ease, filter 220ms ease;
    z-index: 1;
    filter: saturate(0.82) contrast(1.02) brightness(0.88);
}

.map-card:hover .banner img {
    transform: scale(1.03);
    filter: saturate(0.92) contrast(1.04) brightness(0.92);
}

.card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 14px 14px;
    position: absolute;
    inset: auto 0 0 0;
    z-index: 6;
    background: transparent;
    flex-grow: 1;
}

.card-text {
    display: flex;
    flex-direction: column;
    align-self: flex-end;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.map-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.96rem;
    font-weight: 700;
    color: #f5f0e5;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: none;
}

.map-desc {
    display: none !important;
}

.map-mode-control {
    position: relative;
    z-index: 8;
    display: block;
    width: max-content;
    max-width: 100%;
}

.map-mode-trigger {
    position: relative;
    display: grid;
    grid-template-columns: 6px minmax(0, 1fr) 7px;
    align-items: center;
    gap: 7px;
    width: max-content;
    max-width: 100%;
    min-height: 24px;
    margin: 0;
    padding: 3px 7px 4px 1px;
    border: 0;
    border-bottom: 1px solid rgba(255, 244, 225, 0.24);
    border-radius: 1px;
    outline: 0;
    background: transparent;
    color: rgba(245, 240, 229, 0.72);
    font-family: 'Inter', sans-serif;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
    transition:
        color 160ms ease,
        border-color 160ms ease,
        background-color 160ms ease;
}

.map-mode-current {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-mode-mark,
.map-mode-option-mark {
    width: 5px;
    height: 5px;
    border: 1px solid currentColor;
    border-radius: 50%;
    opacity: 0.72;
}

.map-mode-control[data-mode="training"] .map-mode-mark,
.map-mode-control[data-mode="pogo"] .map-mode-mark,
.map-mode-control[data-mode="only3rows"] .map-mode-mark,
.map-mode-control[data-mode="only1rowObs"] .map-mode-mark,
.map-mode-option[data-mode="training"] .map-mode-option-mark,
.map-mode-option[data-mode="pogo"] .map-mode-option-mark,
.map-mode-option[data-mode="only3rows"] .map-mode-option-mark,
.map-mode-option[data-mode="only1rowObs"] .map-mode-option-mark {
    background: currentColor;
}

.map-mode-control[data-mode] .map-mode-trigger {
    color: color-mix(in srgb, var(--accent-primary) 72%, #ffffff);
    border-bottom-color: color-mix(in srgb, var(--accent-primary) 42%, transparent);
}

.map-mode-chevron {
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    pointer-events: none;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 180ms ease;
}

.map-mode-trigger:hover,
.map-mode-trigger:focus-visible,
.map-mode-control.is-open .map-mode-trigger {
    color: color-mix(in srgb, var(--accent-primary) 82%, #ffffff);
    border-bottom-color: color-mix(in srgb, var(--accent-primary) 70%, transparent);
    background: color-mix(in srgb, var(--accent-primary) 9%, transparent);
}

.map-mode-control.is-open .map-mode-chevron {
    transform: translateY(2px) rotate(225deg);
}

.map-mode-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 7px);
    z-index: 40;
    width: 228px;
    max-width: calc(100vw - 48px);
    padding: 4px;
    border: 1px solid rgba(255, 244, 225, 0.2);
    border-radius: 2px;
    background: rgba(12, 12, 12, 0.96);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px) scale(0.98);
    transform-origin: left top;
    transition:
        opacity 150ms ease,
        visibility 150ms ease,
        transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.map-mode-control.is-open .map-mode-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.map-mode-menu.is-floating.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transform-origin: left top;
}

.map-mode-option {
    display: grid;
    grid-template-columns: 7px minmax(0, 1fr) 12px;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    padding: 8px 9px;
    border: 0;
    border-radius: 1px;
    background: transparent;
    color: rgba(245, 240, 229, 0.62);
    font-family: 'Inter', sans-serif;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 140ms ease, background-color 140ms ease;
}

.map-mode-option:hover,
.map-mode-option:focus-visible {
    color: color-mix(in srgb, var(--accent-primary) 78%, #ffffff);
    background: color-mix(in srgb, var(--accent-primary) 10%, transparent);
    outline: 0;
}

.map-mode-option.active {
    color: color-mix(in srgb, var(--accent-primary) 82%, #ffffff);
    background: color-mix(in srgb, var(--accent-primary) 9%, transparent);
}

.map-mode-check {
    width: 8px;
    height: 4px;
    border-left: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    opacity: 0;
    transform: translateY(-1px) rotate(-45deg) scale(0.72);
    transition: opacity 140ms ease, transform 180ms ease;
}

.map-mode-option.active .map-mode-check {
    opacity: 1;
    transform: translateY(-1px) rotate(-45deg) scale(1);
}

.map-card.mode-menu-open {
    z-index: 12 !important;
    overflow: visible;
}

.favorite-btn {
    background: rgba(9, 9, 9, 0.66);
    border: 1px solid rgba(255, 244, 225, 0.18);
    cursor: pointer;
    color: rgba(245, 240, 229, 0.72);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition:
        color 180ms ease,
        background-color 180ms ease,
        border-color 180ms ease,
        transform 180ms ease;
    flex-shrink: 0;
    box-shadow: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.favorite-btn:hover {
    color: #fff4dd;
    background: rgba(255, 244, 225, 0.12);
    border-color: rgba(255, 244, 225, 0.28);
    transform: translateY(-1px);
}

.favorite-btn.active {
    color: #111111;
    background: #f3efe6;
    border-color: #f3efe6;
}

.favorite-btn.active svg path {
    fill: currentColor;
}

.favorite-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 180ms ease;
}

.favorite-btn:active svg {
    transform: scale(0.85);
}

/* Micro-Interaction Animation when Star Clicked (Controlled via JS class re-trigger) */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(15deg); }
    100% { transform: scale(1); }
}

@media (max-width: 600px) {
    .card-content {
        padding: 10px 12px 12px;
    }
    
    .map-name {
        font-size: 0.84rem;
    }
    
    .map-desc {
        font-size: 0.6rem;
    }
    
    .favorite-btn {
        width: 30px;
        height: 30px;
    }
}

/* ==========================================
   7. macOS style Floating Action Dock
   ========================================== */
.bottom-controls {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    display: flex;
    justify-content: center;
    width: auto;
    pointer-events: none; /* Let clicks pass through outside the toggle */
}

.mode-toggle-wrapper {
    pointer-events: auto; /* Enable clicks inside the toggle */
}

.mode-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 40px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-xl), 0 10px 30px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.mode-toggle.play-only {
    padding: 4px;
    border-radius: 50%;
    gap: 0;
}

/* Mode Options */
.mode-toggle-item {
    padding: 10px 20px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 30px;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    letter-spacing: 0.05em;
    user-select: none;
}

.mode-toggle-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mode-toggle-item.active {
    background: var(--active-bg);
    color: var(--active-text);
    box-shadow: var(--shadow-sm);
}

/* Pulse Keyframes for play button */
@keyframes pulsePlay {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* Pulse Play Action Button */
.play-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: var(--active-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    flex-shrink: 0;
    padding: 0;
    box-shadow: 0 4px 10px var(--accent-glow);
    animation: pulsePlay 2s infinite;
}

.play-button svg {
    width: 20px;
    height: 20px;
    transform: translateX(1px); /* center play icon visually */
    display: block;
}

.play-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 14px var(--accent-glow);
    animation: none; /* pause pulse on hover */
}

.play-button:active {
    transform: scale(0.95);
}

/* Disable drag & select rules */
.banner,
.card-content,
.favorite-btn,
.maps-grid,
.mode-toggle,
.mode-toggle-item {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

img {
    -webkit-user-drag: none;
    pointer-events: none;
}

.favorite-btn,
.map-mode-control,
.map-mode-trigger,
.map-mode-option,
.mode-toggle-item,
.play-button {
    pointer-events: auto;
}

.map-name {
    -webkit-user-select: text;
    user-select: text;
}

/* Dark mode readability: remove heavy glow from selected/active states */
html.dark-mode .map-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

html.dark-mode .map-card.selected {
    box-shadow:
        0 0 0 1px rgba(255, 244, 225, 0.32),
        0 14px 36px rgba(0, 0, 0, 0.28);
}

html.dark-mode .mode-toggle-item.active {
    box-shadow: 0 0 0 1px var(--active-ring), 0 6px 14px var(--accent-glow);
    background: var(--active-bg);
    color: var(--active-text);
}

html.dark-mode .play-button {
    animation: none;
    box-shadow: 0 0 0 1px var(--active-ring), 0 8px 18px var(--accent-glow);
    background: var(--accent-gradient);
    color: var(--active-text);
}

html.dark-mode .play-button:hover {
    box-shadow: 0 0 0 1px var(--active-ring), 0 10px 22px var(--accent-glow);
    transform: scale(1.04);
}
