/* -------------------------------------------
   login + Pinterest-style background (refined)
   Cleaned & fixed so loaded images are visible
   ------------------------------------------- */

:root{
  --bg:#0f172a;
  --card-bg:#1e293b;
  --muted:#94a3b8;
  --accent:#3b82f6;
  --glass-border: rgba(255,255,255,0.12);
}

/* base */
html,body{
  height:100%;
  margin:0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: var(--bg);
  color: #e6eef8;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* ---------------------------
   Pinterest background wrapper
   --------------------------- */
/* The wrapper (behind the login box) */
#pinterest-bg {
  position: fixed;
  inset: 0;
  z-index: 1;                 /* behind login-box (login-box uses z-index:10) */
  pointer-events: none;       /* background must not block inputs */
  overflow: hidden;
}

/* the inner track that scrolls horizontally (flex row) */
.pinterest-track {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 40px 30px;
    box-sizing: border-box;
    will-change: transform;
    opacity: 0.55;
    animation: scrollLeft 48s linear infinite;

    width: max-content;        /* <-- FIX ABSOLUTO */
}

/* slow down animation on small screens for performance */
@media (max-width: 768px) {
  .pinterest-track { animation-duration: 70s; opacity: 0.45; padding: 24px; }
}

/* ---------------------------
   Card (single tile)
   --------------------------- */
.p-card {
  display: inline-block;
  position: relative;
  width: 240px;               /* base width, responsive with media queries */
  border-radius: 16px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: 0 8px 30px rgba(2,6,23,0.6);
  transition: transform .32s cubic-bezier(.2,.9,.3,1), box-shadow .32s;
  pointer-events: auto;       /* allow pointer for hover visuals if needed */
  user-select: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* hover effect */
.p-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 14px 40px rgba(2,6,23,0.7);
}

/* main image in card (height set by JS inline style) */
/* use direct child selector and higher specificity to avoid overrides */
.p-card > img.p-img {
  display: block;
  width: 100%;
  height: 220px;              /* fallback height if JS didn't set */
  object-fit: cover;
  background: linear-gradient(180deg, rgba(15,23,42,0.6), rgba(15,23,42,0.2));
  transition: opacity .45s ease, transform .45s cubic-bezier(.2,.9,.3,1);
  opacity: 0;
  visibility: hidden;         /* ensure not visible until .loaded */
  transform: scale(1.02);
  z-index: 1;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* when observer loads the real src — make visible */
.p-card > img.p-img.loaded {
  opacity: 1 !important;
  visibility: visible !important;
  transform: scale(1);
}

/* If for some reason a global .p-img exists outside card, ensure it's visible when loaded too */
.p-img.loaded { opacity:1 !important; visibility: visible !important; transform: none !important; }

/* overlay info (head + name) placed on top of image */
.p-card .p-card-info {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:12px;
  background: rgba(0,0,0,0.48);
  backdrop-filter: blur(6px);
  color: #fff;
  pointer-events: auto;
  z-index: 3; /* above image */
}

/* avatar head inside overlay */
.p-card .p-card-info img,
.p-card-head {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.95);
  background: #0b1220;
  flex-shrink:0;
  display:block;
  z-index: 4;
}

/* name text */
.p-card .p-card-info span {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* responsive widths */
@media (min-width: 1100px){
  .p-card { width: 260px; }
}
@media (min-width: 1400px){
  .p-card { width: 300px; }
}
@media (max-width: 520px){
  .p-card { width: 180px; border-radius: 12px; }
  .p-card .p-card-info span { max-width: 90px; font-size:13px; }
}

/* ---------------------------
   Login box (foreground)
   --------------------------- */
.login-box {
  position: relative;
  z-index: 10;                 /* above the pinterest background */
  max-width: 420px;
  width: calc(100% - 32px);
  margin: 8vh auto 0 auto;
  padding: 34px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px) saturate(1.05);
  box-shadow: 0 8px 30px rgba(2,6,23,0.6);
}

/* header */
.login-box h2 {
  margin:0 0 6px 0;
  font-size: 26px;
  color: #f8fafc;
  letter-spacing: -0.3px;
  text-align:center;
}
.login-box .subtitle {
  margin:0 0 20px 0;
  text-align:center;
  color: var(--muted);
  font-size: 14px;
}

/* fields */
.field { margin-bottom: 14px; }
.field label {
  display:block;
  font-size:13px;
  color:#e6eef8;
  margin-bottom:6px;
  font-weight:600;
}
.field input {
  width:100%;
  padding:12px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color:#ecf2ff;
  font-size:15px;
  outline: none;
  box-sizing: border-box;
}
.field input::placeholder { color: rgba(230,240,255,0.35); }

/* button */
.login-btn {
  width:100%;
  padding:13px;
  border-radius:10px;
  border:none;
  background: linear-gradient(180deg,var(--accent), #2563eb);
  color:#fff;
  font-size:15px;
  font-weight:800;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(37,99,235,0.16); }

/* small helpers */
.centered { text-align:center; }

/* ---------------------------
   Accessibility / performance
   --------------------------- */
@media (prefers-reduced-motion: reduce) {
  .pinterest-track { animation: none !important; }
  .p-card { transition: none !important; transform: none !important; }
}

/* ---------------------------
   Scroll animation keyframes
   --------------------------- */
@keyframes scrollLeft {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); } /* using duplicated content */
}

/* ---------------------------
   Utility: ensure lazy images fade in after loaded
   --------------------------- */
/* keep this rule so other contexts still work */
.p-img { opacity: 0; visibility: hidden; transition: opacity .45s ease, transform .45s; transform: scale(1.02); }
.p-img.loaded { opacity: 1 !important; visibility: visible !important; transform: none !important; }

/* ---------------------------
   Fallback / empty state
   --------------------------- */
#pinterest-bg.empty::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.25));
  pointer-events: none;
}

/* ---------------------------
   Minor layout polish for gallery/login coexistence
   --------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  box-sizing: border-box;
}

/* ensure forms are visible on top in small screens */
@media (max-width: 640px) {
  .login-box { margin-top: 6vh; padding: 20px; }
  .pinterest-track { padding: 18px; gap: 12px; }
}
/* Wallpaper fixo da cidade */
#city-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('../images/city.png') center/cover no-repeat fixed;
  z-index: 0;               /* abaixo de tudo */
  pointer-events: none;
  opacity: 0.22;
}
.pinterest-track {
    width: max-content; /* garante que o flex não colapse */
}

/* -------------------------------------------
   Registration Modal
------------------------------------------- */

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}

.modal-window {
  position: relative;
  z-index: 30;
  width: 420px;
  max-width: 90%;
  padding: 32px;
  border-radius: 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(16px) saturate(1.2);
  animation: modalIn .35s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-window h2 {
  margin-top: 0;
  text-align: center;
  color: #fff;
}

.modal-close {
  margin-top: 16px;
  width: 100%;
  border: none;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255,255,255,0.2);
}

/* create-account link */
.create-account-link {
  text-align: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.create-account-link .open-register {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  margin-left: 4px;
}

.create-account-link .open-register:hover {
  text-decoration: underline;
}

/* -------------------------------------------
   Better Popup (Glass + animations)
------------------------------------------- */

.popup.hidden {
  display: none;
}

.popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: popupFadeIn .3s ease;
}

@keyframes popupFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}

.popup-window {
  position: relative;
  z-index: 50;
  padding: 28px;
  width: 380px;
  max-width: 90%;
  border-radius: 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  text-align: center;
  animation: popupSlideIn .35s cubic-bezier(.2,.9,.3,1);
}

@keyframes popupSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.popup-window h3 {
  margin-top: 0;
  color: #fff;
  font-size: 20px;
  margin-bottom: 10px;
}

.popup-window.success h3 {
  color: #4ade80;
}

.popup-window.error h3 {
  color: #f87171;
}

.popup-window p {
  color: #e2e8f0;
  font-size: 15px;
  line-height: 1.5;
}

.popup-close {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}

.popup-close:hover {
  background: rgba(255,255,255,0.30);
}

/* Loading Spinner */
.loading-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px auto;
  animation: spinner 0.7s linear infinite;
}

@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* ---------------------------
   Download Button
   --------------------------- */
.download-game-link {
    text-align: center;
    margin-top: 14px;
}

.download-btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.18);
    cursor: pointer;
    font-weight: 600;
    backdrop-filter: blur(10px);
    transition: 0.22s ease;
}

.download-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
}

/* ---------------------------
   Discord CTA
   --------------------------- */
.discord-link {
    text-align: center;
    margin-top: 10px;
}

.discord-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.16);
    background: linear-gradient(180deg, #5865f2, #4752c4);
    font-weight: 700;
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.discord-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.04);
    box-shadow: 0 10px 24px rgba(88, 101, 242, 0.35);
}

.discord-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: inline-block;
}

/* ---------------------------
   Tooltip ABOVE the button
   --------------------------- */
#downloadTooltip {
    position: fixed;
    z-index: 9999;

    width: 260px;
    padding: 20px;

    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 16px;
    backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);

    text-align: center;
    animation: fadeInUp 0.25s ease forwards;

    display: none;
}

#downloadTooltip:not(.hidden) {
    display: block;
}

/* Tooltip arrow — BALÃO DE FALA */
/* Tooltip container */
#downloadTooltip {
    position: fixed;
    z-index: 99999;

    width: 260px;
    padding: 20px;

    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 16px;
    backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);

    text-align: center;
    display: none;

    transform: translateX(-50%); /* sempre centraliza */
}

/* Seta (balão) */
#downloadTooltip .tooltip-arrow {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);

    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid rgba(255,255,255,0.10);
}

/* Download options */
.download-option {
    display: block;
    margin: 8px 0;
    padding: 11px;
    border-radius: 12px;

    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.16);
    backdrop-filter: blur(6px);

    color: #fff;
    font-weight: 700;
    text-decoration: none;

    transition: 0.2s ease;
}

.download-option:hover {
    background: rgba(255,255,255,0.22);
    transform: translateY(-2px);
}

/* Close */
.tooltip-close {
    margin-top: 12px;
    padding: 8px 16px;

    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;

    transition: 0.2s ease;
}

.tooltip-close:hover {
    background: rgba(255,255,255,0.22);
}

/* Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
