/*
 * Identidade visual noir do Mafia Mayor, compartilhada por todas as telas
 * (jogador, Painel do mayor, Display e login): uma rua à noite com chuva e um
 * único feixe de luz quente de poste (o canvas .atmo-gl, desenhado por
 * mafia-atmo.js), grão de filme e vinheta por cima de tudo. A interface usa
 * vermelho; a luz é quente.
 *
 * Fontes (carregadas por cada página): Instrument Serif (títulos e números
 * grandes, em itálico), DM Mono (rótulos, legendas, números pequenos) e
 * Outfit (texto e botões).
 *
 * Cada página coloca, no <body>:
 *   <canvas class="atmo-gl" id="atmo-gl"></canvas>  (atrás de tudo)
 *   <div class="atmo-light"></div> <div class="atmo-beam"></div>  (luz em CSS, sem WebGL)
 *   <div class="atmo-vignette"></div> <div class="atmo-grain"></div>  (por cima de tudo)
 */
:root {
  --ink: #060709;
  --ink-2: #0b0c10;
  --ink-3: #111218;
  --bone: #efe9dd;
  --bone-2: #b3ac9f;
  --bone-3: #706a60;
  /* Vermelho da interface (botões, abas, destaques). */
  --lamp: #ff4b45;
  --lamp-soft: rgba(255, 75, 69, 0.16);
  /* A luz do poste: quente. */
  --warm: #ffb066;
  --amber: #e8b064;
  --blood: #e5484d;
  --blood-deep: #7d1a1e;
  --moon: #8fb0d6;
  --alive: #7fd6a4;
  --gold: #e9c87d;
  --violet: #b98cf0;
  --halo: #f4ead0;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.14);
  --glass: rgba(255, 255, 255, 0.035);
  --glass-2: rgba(255, 255, 255, 0.06);
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Instrument Serif', 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Atmosfera ------------------------------------------------ */
.atmo-gl,
.atmo-light,
.atmo-beam,
.atmo-vignette,
.atmo-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.atmo-gl {
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.has-gl .atmo-gl { opacity: 1; }
.has-gl .atmo-light,
.has-gl .atmo-beam { display: none; }

/* Versão CSS (sem WebGL): brilho quente do poste no alto à esquerda, lua fria embaixo. */
.atmo-light { z-index: 0; overflow: hidden; }
.atmo-light::before,
.atmo-light::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
}
.atmo-light::before {
  width: 120vw;
  height: 90vw;
  left: -45vw;
  top: -38vw;
  background: radial-gradient(closest-side, rgba(255, 176, 102, 0.26), rgba(255, 176, 102, 0.07) 50%, transparent 72%);
  animation: lamp-drift 42s var(--ease-in-out) infinite alternate;
}
.atmo-light::after {
  width: 90vw;
  height: 90vw;
  right: -40vw;
  bottom: -30vw;
  background: radial-gradient(closest-side, rgba(143, 176, 214, 0.16), transparent 70%);
}
@keyframes lamp-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(14vw, 10vw) scale(1.12); }
}
/* O feixe do poste: um cone só, de bordas macias, descendo em diagonal. */
.atmo-beam {
  z-index: 0;
  background: conic-gradient(from 132deg at 14% -6%, transparent 0deg, rgba(255, 176, 102, 0.1) 10deg, rgba(255, 205, 150, 0.14) 23deg, rgba(255, 176, 102, 0.1) 36deg, transparent 46deg);
  -webkit-mask-image: linear-gradient(to bottom, #000 20%, transparent 95%);
  mask-image: linear-gradient(to bottom, #000 20%, transparent 95%);
  filter: blur(6px);
}

.atmo-vignette {
  z-index: 400;
  background:
    radial-gradient(130% 95% at 50% 38%, transparent 50%, rgba(0, 0, 0, 0.6) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent 14%, transparent 82%, rgba(0, 0, 0, 0.4));
}
/* Grão de filme: tile de ruído 3x maior que a tela, pulando de posição em
   passos secos - o tremido é o que faz parecer película. */
.atmo-grain {
  z-index: 401;
  opacity: 0.1;
  overflow: hidden;
  mix-blend-mode: overlay;
  transition: opacity 0.6s ease;
}
.atmo-grain::before {
  content: '';
  position: absolute;
  inset: -100%;
  width: 300%;
  height: 300%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  animation: grain 0.8s steps(1, end) infinite;
  will-change: transform;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  10% { transform: translate(-4%, -6%); }
  20% { transform: translate(-9%, 3%); }
  30% { transform: translate(5%, -10%); }
  40% { transform: translate(-3%, 12%); }
  50% { transform: translate(-10%, 7%); }
  60% { transform: translate(9%, 0); }
  70% { transform: translate(0, 9%); }
  80% { transform: translate(3%, 14%); }
  90% { transform: translate(-7%, 5%); }
  100% { transform: translate(0, 0); }
}

/* Dígitos que rolam (mafia-clock.js): largura fixa por dígito (a serifa não
   tem algarismos tabulares - sem isso o relógio tremeria); o novo cai de
   cima e o antigo (data-prev) sai por baixo. */
.digit {
  position: relative;
  display: inline-block;
  width: 0.5em;
  text-align: center;
}
.digit.is-colon { width: 0.24em; }
.digit > span { display: inline-block; }
.digit.roll > span { animation: digit-in 0.5s var(--ease-expo) backwards; }
.digit.roll::before {
  content: attr(data-prev);
  position: absolute;
  inset: 0;
  animation: digit-out 0.5s var(--ease-expo) forwards;
}
@keyframes digit-in { from { opacity: 0; transform: translateY(-42%); filter: blur(5px); } }
@keyframes digit-out { to { opacity: 0; transform: translateY(42%); filter: blur(5px); } }

@media (prefers-reduced-motion: reduce) {
  .atmo-grain::before,
  .atmo-light::before { animation: none !important; }
}
