/* =============================================================
   LEAVE IT TO THE WORLD

   VAZNO: dimenzije kartica moraju se poklapati sa layout.php
     .size-popular  290 x 130
     .size-legend   560 x 170
   Ako menjas ovde, promeni i tamo pa pokreni reindeksiranje.
   ============================================================= */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    font-family: 'Poppins', system-ui, sans-serif;
    color: #f8fafc;
    -webkit-tap-highlight-color: transparent;
}

/* Nebo iza zida */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 15%, rgba(56, 189, 248, 0.09), transparent 55%),
        radial-gradient(ellipse at 85% 80%, rgba(168, 85, 247, 0.08), transparent 55%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Platno ---------- */

#viewport {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    cursor: grab;
    touch-action: none;          /* samo ovde, ne globalno */
    user-select: none;
}
#viewport:active { cursor: grabbing; }

#world {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    transform-origin: 0 0;
    will-change: transform;
}

/* ---------- Naslov ---------- */

.hero-center {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    width: 940px;
    text-align: center;
    pointer-events: none;
    z-index: 2;
}
.hero-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: #93c5fd;
    text-shadow: 0 0 24px rgba(96, 165, 250, 0.55);
    white-space: nowrap;
}
.hero-subtitle {
    margin-top: 10px;
    font-size: 1rem;
    color: #94a3b8;
    letter-spacing: 1px;
}

/* ---------- Kartica ---------- */

.card {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    overflow: hidden;
    contain: layout paint;
}

.size-basic,
.size-popular { width: 290px; height: 130px; padding: 14px 16px; }
.size-legend  { width: 560px; height: 170px; padding: 20px 24px; }

.card-text {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    line-height: 1.3;
    white-space: pre-wrap;
    overflow-wrap: anywhere;      /* duge reci se prelamaju */
    word-break: normal;
    color: #e2e8f0;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.7rem;
    color: #94a3b8;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.size-legend .card-meta { font-size: 0.8rem; }

.card-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55%;
}
.card-flag { font-size: 0.95em; line-height: 1; }
.card-date { margin-left: auto; white-space: nowrap; opacity: 0.75; }

/* Kartica otvorena preko direktnog linka */
.card.is-highlight {
    animation: highlight 2.4s ease-out 2;
}
@keyframes highlight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
    50%      { box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.35); }
}

/* ---------- Ramovi ---------- */

.frame-plain {
    border-color: rgba(148, 163, 184, 0.35);
}

.frame-neon {
    border: 2px solid #22d3ee;
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.55),
                inset 0 0 12px rgba(34, 211, 238, 0.12);
    animation: neonPulse 3.2s ease-in-out infinite;
}
@keyframes neonPulse {
    50% { box-shadow: 0 0 22px rgba(34, 211, 238, 0.85),
                      inset 0 0 16px rgba(34, 211, 238, 0.2); }
}

.frame-fire {
    border: 2px solid transparent;
    background:
        linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.88)) padding-box,
        linear-gradient(120deg, #fbbf24, #f97316, #dc2626, #f97316, #fbbf24) border-box;
    background-size: auto, 300% 100%;
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.4);
    animation: fireShift 4s linear infinite;
}
@keyframes fireShift {
    to { background-position: 0 0, 300% 0; }
}

.frame-glitter {
    border: 2px solid transparent;
    background:
        linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.88)) padding-box,
        linear-gradient(115deg, #f0abfc, #e0e7ff, #a5f3fc, #e0e7ff, #f0abfc) border-box;
    background-size: auto, 300% 100%;
    box-shadow: 0 0 14px rgba(232, 121, 249, 0.35);
    animation: fireShift 5.5s linear infinite;
}

.frame-gold {
    border: 2px solid transparent;
    background:
        linear-gradient(rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.9)) padding-box,
        linear-gradient(100deg, #78350f, #fcd34d, #fffbeb, #fcd34d, #78350f) border-box;
    background-size: auto, 300% 100%;
    box-shadow: 0 0 14px rgba(252, 211, 77, 0.35);
    animation: fireShift 6s linear infinite;
}

.frame-aurora {
    border: 2px solid transparent;
    background:
        linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.88)) padding-box,
        linear-gradient(120deg, #22d3ee, #4ade80, #a78bfa, #4ade80, #22d3ee) border-box;
    background-size: auto, 300% 100%;
    box-shadow: 0 0 16px rgba(74, 222, 128, 0.32);
    animation: fireShift 6.5s linear infinite;
}

.frame-rainbow {
    border: 2px solid transparent;
    background:
        linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.88)) padding-box,
        linear-gradient(90deg, #f87171, #fbbf24, #4ade80, #38bdf8, #a78bfa, #f87171) border-box;
    background-size: auto, 300% 100%;
    animation: fireShift 7s linear infinite;
}

/* Kad je zumirano daleko, animacije se gase — mobilni disu */
#world.is-far .card { animation: none !important; }
#world.is-far .card-meta { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
    .card, .pulse-dot { animation: none !important; }
}

/* ---------- Traka sa brojacem ---------- */

.global-stats-bar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 32px);
    padding: 6px 16px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.8rem;
    color: #94a3b8;
    letter-spacing: 0.4px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.global-stats-bar strong { color: #f8fafc; font-weight: 600; }

.pulse-dot {
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.9); }
    50%      { opacity: 1;   transform: scale(1.2); }
}

/* ---------- Donja traka ---------- */

.ui-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 30px;
    padding: 12px 18px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(148, 163, 184, 0.8); }

/* Ko-fi — kruzno ikonicno dugme, uparuje se sa dugmetom za centriranje.
   Namerno bez Ko-fi boja i natpisa: stoji uz "Leave a Message", pa bi
   sarena reklama tu ostavljala utisak da se poruka placa. */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1;
    text-decoration: none;
    box-sizing: border-box;
}
.btn:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }

.btn-primary {
    padding: 12px 26px;
    color: #0f172a;
    background: #38bdf8;
    border-color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.45);
}
.btn-primary:hover { background: #7dd3fc; border-color: #7dd3fc; }

#recenterBtn { font-size: 1.15rem; padding: 12px 16px; }

/* ---------- Poruka pri dnu ---------- */

.toast {
    position: fixed;
    bottom: 92px;
    left: 50%;
    transform: translate(-50%, 10px);
    z-index: 95;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 18px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    font-size: 0.85rem;
    color: #e2e8f0;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobilni ---------- */

@media (max-width: 640px) {
    .hero-center { width: 90vw; }
    .hero-title  { font-size: 1.8rem; letter-spacing: 3px; white-space: normal; }
    .hero-subtitle { font-size: 0.85rem; }
    .global-stats-bar { font-size: 0.7rem; padding: 5px 12px; white-space: normal; text-align: center; }
    .ui-bar { bottom: 18px; gap: 8px; }
    .btn { font-size: 0.9rem; padding: 11px 16px; }
    .btn-icon { width: 40px; height: 40px; padding: 0; }
}