/* ═══════════════════════════════════════════════════════════════════
   WORLD MAP CSS — Mathico (Mobile-First)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Screens ──────────────────────────────────────────────────────── */
.screen {
    min-height: calc(100vh - 60px);
    width: 100%;
}

/* Transition animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-40px);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

.wm-exit {
    animation: slideOutLeft 0.3s ease-in forwards;
}

.wm-enter {
    animation: slideInLeft 0.35s ease-out forwards;
}

.gs-exit {
    animation: slideOutRight 0.3s ease-in forwards;
}

.gs-enter {
    animation: slideInRight 0.35s ease-out forwards;
}

/* ── Back to Map Button ───────────────────────────────────────────── */
.back-to-map-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: inherit;
    font-size: 16px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s;
    white-space: nowrap;
}

.back-to-map-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── World Map Inner ──────────────────────────────────────────────── */
.wm-inner {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 0 100px 0;
}

.wm-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60vh;
}

/* ── Grade Tabs ───────────────────────────────────────────────────── */
.wm-grade-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 12px 12px;
    /* Не ползваме overflow-x + center — реже първия таб наполовина */
    overflow: visible;
    position: sticky;
    top: 60px;
    z-index: 10;
    background: var(--bg-primary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.wm-grade-tab {
    position: relative;
    flex: 1 1 calc(50% - 8px);
    max-width: calc(50% - 4px);
    justify-content: center;
    padding: 10px 12px;
    border-radius: 50px;
    border: 2px solid transparent;
    background: var(--bg-card, #fff);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    color: var(--text-primary, #1e293b);
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

@media (min-width: 420px) {
    .wm-grade-tab {
        flex: 0 1 auto;
        max-width: none;
        padding: 12px 18px;
        font-size: 16px;
    }
}

.wm-grade-tab.active {
    background: #3b82f6;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.wm-grade-tab.locked {
    opacity: 0.6;
    cursor: default;
}

.wm-lock-badge {
    font-size: 12px;
}

/* Shake animation за locked */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.wm-grade-tab.shake {
    animation: shake 0.4s ease-out;
}

/* ── Grade Header ─────────────────────────────────────────────────── */
.wm-grade-header {
    margin: 0 16px 16px;
    border-radius: 20px;
    padding: 20px;
    margin-top: 16px;
}

.wm-grade-title {
    font-size: 24px;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
}

.wm-grade-subtitle {
    font-size: 16px;
    color: #475569;
    margin-bottom: 12px;
}

.wm-overall-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wm-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.wm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.wm-progress-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

/* ── Worlds ───────────────────────────────────────────────────────── */
.wm-worlds {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wm-world {
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    background: var(--bg-card, #fff);
}

.wm-world.completed {
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.2);
}

/* ── World Header ─────────────────────────────────────────────────── */
.wm-world-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.wm-world-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.wm-world-info {
    flex: 1;
}

.wm-world-name {
    font-size: 18px;
    font-weight: 800;
    color: #1e293b;
}

.wm-world-count {
    font-size: 14px;
    color: #64748b;
    margin-top: 2px;
}

.wm-world-done {
    font-size: 22px;
}

/* ── Level Path ───────────────────────────────────────────────────── */
.wm-level-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px 16px;
    gap: 0;
}

.wm-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Connector line между нивата */
.wm-connector {
    width: 3px;
    height: 20px;
    background: linear-gradient(to bottom, #cbd5e1, #e2e8f0);
    border-radius: 2px;
    margin: 2px 0;
}

/* ── Level Node ───────────────────────────────────────────────────── */
.wm-node {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    cursor: default;
    transition: all 0.2s;
    min-height: 64px;
}

.wm-node.unlocked,
.wm-node.completed {
    cursor: pointer;
    background: var(--bg-card, #fff);
    border-color: var(--node-color, #3b82f6);
    box-shadow: 0 2px 12px color-mix(in srgb, var(--node-color, #3b82f6) 20%, transparent);
}

.wm-node.unlocked:active,
.wm-node.completed:active {
    transform: scale(0.97);
}

.wm-node.locked {
    opacity: 0.5;
}

.wm-node.completed {
    background: color-mix(in srgb, var(--node-color, #22c55e) 8%, white);
}

.wm-node-icon {
    font-size: 26px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--node-color, #3b82f6) 12%, transparent);
    flex-shrink: 0;
}

.wm-node.locked .wm-node-icon {
    background: #f1f5f9;
}

.wm-node-num {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wm-node-name {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-top: 1px;
}

.wm-node.locked .wm-node-name {
    color: #94a3b8;
}

/* Pulse ефект за текущото отключено ниво */
.wm-node-pulse {
    position: absolute;
    right: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--node-color, #3b82f6);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 0 0 currentColor;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
        box-shadow: 0 0 0 6px transparent;
    }
}

.wm-node-pulse {
    animation: pulse 1.8s ease-in-out infinite;
    box-shadow: 0 0 0 0 var(--node-color, #3b82f6);
}

/* ── Locked Grade ─────────────────────────────────────────────────── */
.wm-locked-grade {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.wm-locked-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.wm-locked-title {
    font-size: 22px;
    font-weight: 800;
    color: #64748b;
    margin-bottom: 8px;
}

.wm-locked-text {
    font-size: 14px;
    line-height: 1.5;
}

/* ── Dark mode support ────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .wm-grade-tabs,
    [data-theme="dark"] .wm-grade-tabs {
        background: var(--bg-primary, #071A19);
        border-color: var(--border-color);
    }

    :root:not([data-theme="light"]) .wm-grade-tab,
    [data-theme="dark"] .wm-grade-tab {
        background: var(--bg-card, #0F2A28);
        color: var(--text-primary, #F3F7F6);
    }

    /* Grade header sits on colored gradient — keep dark readable text */
    :root:not([data-theme="light"]) .wm-grade-title,
    [data-theme="dark"] .wm-grade-title {
        color: #0f172a;
    }

    :root:not([data-theme="light"]) .wm-grade-subtitle,
    [data-theme="dark"] .wm-grade-subtitle {
        color: #1e293b;
    }

    :root:not([data-theme="light"]) .wm-progress-label,
    [data-theme="dark"] .wm-progress-label {
        color: #1e293b;
    }

    :root:not([data-theme="light"]) .wm-world,
    [data-theme="dark"] .wm-world {
        background: var(--bg-card, #0F2A28);
    }

    :root:not([data-theme="light"]) .wm-world-name,
    [data-theme="dark"] .wm-world-name {
        color: var(--text-primary, #F3F7F6);
    }

    :root:not([data-theme="light"]) .wm-world-count,
    [data-theme="dark"] .wm-world-count {
        color: var(--text-secondary, #9BB5B1);
    }

    :root:not([data-theme="light"]) .wm-node,
    [data-theme="dark"] .wm-node {
        background: var(--bg-secondary, #163634);
        border-color: var(--border-color);
    }

    :root:not([data-theme="light"]) .wm-node.unlocked,
    :root:not([data-theme="light"]) .wm-node.completed,
    [data-theme="dark"] .wm-node.unlocked,
    [data-theme="dark"] .wm-node.completed {
        background: var(--bg-card, #0F2A28);
    }

    :root:not([data-theme="light"]) .wm-node-name,
    [data-theme="dark"] .wm-node-name {
        color: var(--text-primary, #F3F7F6);
    }

    :root:not([data-theme="light"]) .wm-node.locked .wm-node-name,
    [data-theme="dark"] .wm-node.locked .wm-node-name {
        color: var(--text-secondary, #9BB5B1);
    }

    :root:not([data-theme="light"]) .ach-card,
    [data-theme="dark"] .ach-card {
        background: var(--bg-card, #0F2A28);
        color: var(--text-primary, #F3F7F6);
    }

    :root:not([data-theme="light"]) .ach-card-name,
    [data-theme="dark"] .ach-card-name {
        color: var(--text-primary, #F3F7F6);
    }

    :root:not([data-theme="light"]) .ach-card-desc,
    [data-theme="dark"] .ach-card-desc {
        color: var(--text-secondary, #9BB5B1);
    }
}

[data-theme="dark"] .wm-grade-tabs {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .wm-grade-tab {
    background: var(--bg-card);
    color: var(--text-primary);
}

[data-theme="dark"] .wm-world {
    background: var(--bg-card);
}

[data-theme="dark"] .wm-world-name {
    color: var(--text-primary);
}

[data-theme="dark"] .wm-world-count {
    color: var(--text-secondary);
}

[data-theme="dark"] .wm-node {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .wm-node-name {
    color: var(--text-primary);
}

/* ── Responsive: Tablet+ ──────────────────────────────────────────── */
@media (min-width: 600px) {
    .wm-inner {
        padding-bottom: 60px;
    }

    .wm-level-path {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        padding: 16px;
    }

    .wm-node-wrapper {
        width: auto;
    }

    .wm-connector {
        display: none;
    }

    .wm-node {
        width: 140px;
        flex-direction: column;
        text-align: center;
        padding: 16px 12px;
        gap: 8px;
    }

    .wm-node-pulse {
        right: 8px;
        top: 8px;
    }
}

/* ── Achievement card grid (за профила) ──────────────────────────── */
.ach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    padding: 16px;
}

.ach-card {
    border-radius: 16px;
    padding: 14px 10px;
    text-align: center;
    background: var(--bg-card, #fff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s;
}

.ach-card:active {
    transform: scale(0.95);
}

.ach-card.locked {
    opacity: 0.45;
    filter: grayscale(1);
}

.ach-card-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.ach-card-name {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
}

.ach-card-desc {
    font-size: 12px;
    color: #64748b;
    margin-top: 3px;
    line-height: 1.3;
}
/* Quest map atmosphere */
.wm-map-wrap, .wm-canvas-wrap, #worldMapCanvas, .map-canvas-host {
    background: linear-gradient(180deg, #d8efe9 0%, #b7ddd6 45%, #9ecfc6 100%);
}
[data-theme="dark"] .wm-map-wrap,
[data-theme="dark"] .wm-canvas-wrap,
[data-theme="dark"] #worldMapCanvas,
[data-theme="dark"] .map-canvas-host {
    background: linear-gradient(180deg, #0a2422 0%, #0f2e2b 50%, #13403c 100%);
}
