/* =========================================================================
   THE MINDGAMER — componentes de painel

   Compartilhado pelas telas de dado (Perfil, Founder, Configurações). Carrega
   depois de styles.css (tokens e moldura) e antes do CSS próprio de cada tela.

   Aqui: fundo desfocado, painel, avatar, os itens do Founder, botão de ícone,
   popover, toast e utilitários. O que é de uma tela só fica no CSS dela.
   ========================================================================= */

/* ====================================================== fundo: desfoque ===== */

/* Tela de dados não é cena: o fundo vira textura.
   O scale(1.08) existe porque borrar um elemento faz a borda dele esmaecer —
   ampliando, o borrão acontece fora da área visível e sobra só o miolo. */
.stage--quiet .stage__bg {
  filter: blur(calc(15 * var(--u))) brightness(0.82) saturate(0.86);
  transform: scale(1.08);
}

/* scrim próprio: aqui precisa ser uniforme, não o gradiente lateral da Home
   (que existia pra o texto do destaque sentar em cima) */
.stage--quiet .stage__scrim {
  background:
    radial-gradient(115% 95% at 50% -10%, rgb(4 6 16 / 0.20), rgb(4 6 16 / 0.62) 62%),
    linear-gradient(0deg, rgb(3 5 14 / 0.72) 0%, rgb(3 5 14 / 0.34) 40%, rgb(3 5 14 / 0.20) 100%);
}

/* ================================================================ grade ===== */

/* A grade das telas de dado: duas colunas, duas linhas, na mesma área da Home. */

.board {
  position: relative;
  z-index: 2;
  height: 100vh;
  display: grid;
  /* minmax(0, …): sem isso um nome largo demais alarga a coluna inteira */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: calc(423 * var(--u)) calc(322 * var(--u));
  gap: calc(23 * var(--u));
  padding: calc(118 * var(--u)) calc(52 * var(--u)) calc(55 * var(--u)) calc(146 * var(--u));
}

/* =============================================================== painel ===== */

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: calc(11 * var(--u));
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgb(22 29 62 / 0.74), rgb(9 12 30 / 0.88));
  backdrop-filter: blur(9px);
  box-shadow: 0 calc(18 * var(--u)) calc(40 * var(--u)) rgb(2 4 12 / 0.45);
}

/* moldura interna fina, igual à dos cards da Home */
.panel::after {
  content: "";
  position: absolute;
  inset: calc(7 * var(--u));
  border: 1px solid rgb(180 200 255 / 0.07);
  border-radius: calc(7 * var(--u));
  pointer-events: none;
}

.panel__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: calc(14 * var(--u));
  height: calc(62 * var(--u));
  padding: 0 calc(32 * var(--u));
}

/* a estrela de 4 pontas: ornamento da casa.
   clip-path em vez de imagem — fica nítida em qualquer tamanho e obedece
   currentColor, então não precisa de asset nenhum. */
.panel__head::before {
  content: "";
  flex: none;
  width: calc(18 * var(--u));
  height: calc(18 * var(--u));
  background: rgb(165 195 255 / 0.9);
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
}

.panel__title {
  margin: 0;
  font-size: calc(20 * var(--u));
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-1);
  white-space: nowrap;
}

.panel__rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgb(170 195 255 / 0.5), rgb(170 195 255 / 0.16) 76%, transparent);
}

.panel__action,
.panel__note {
  flex: none;
  font-size: calc(15 * var(--u));
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}

.panel__action {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
  transition: color .18s var(--ease);
}

.panel__action:hover { color: var(--ink-0); }

.panel__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 calc(32 * var(--u)) calc(26 * var(--u));
}

/* =============================================================== avatar ===== */

.avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: calc(146 * var(--u));
  height: calc(146 * var(--u));
  border-radius: 50%;
  border: calc(1.5 * var(--u)) solid rgb(160 190 255 / 0.42);
  background:
    radial-gradient(72% 72% at 50% 26%, rgb(85 125 235 / 0.34), transparent 72%),
    linear-gradient(180deg, rgb(29 41 90 / 0.82), rgb(10 14 36 / 0.92));
  box-shadow:
    0 0 calc(32 * var(--u)) rgb(75 115 250 / 0.30),
    inset 0 0 calc(26 * var(--u)) rgb(90 130 255 / 0.16);
}

.avatar__sigil {
  width: 74%;
  height: 74%;
  object-fit: contain;
  filter: drop-shadow(0 0 calc(11 * var(--u)) rgb(120 165 255 / 0.65));
}

/* o nível vive no aro: dá pra saber o nível de alguém de relance, sem ler */
.avatar__level {
  position: absolute;
  left: calc(-6 * var(--u));
  bottom: calc(-4 * var(--u));
  display: grid;
  place-items: center;
  width: calc(48 * var(--u));
  height: calc(48 * var(--u));
  border-radius: 50%;
  border: calc(1.5 * var(--u)) solid rgb(175 200 255 / 0.62);
  background: linear-gradient(180deg, rgb(34 46 100 / 0.96), rgb(9 13 34 / 0.98));
  box-shadow: 0 0 calc(16 * var(--u)) rgb(80 120 255 / 0.5);
  font-size: calc(24 * var(--u));
  line-height: 1;
  color: var(--ink-0);
}

.avatar--sm {
  width: calc(48 * var(--u));
  height: calc(48 * var(--u));
  border-width: 1px;
  box-shadow: none;
}

.avatar--sm .avatar__sigil { width: 70%; height: 70%; filter: none; }

/* avatar padrão: a inicial. O sigilo é da marca, não de cada jogador. */
.avatar--initial {
  font-size: calc(22 * var(--u));
  line-height: 1;
  color: var(--ink-1);
}

.dot {
  position: absolute;
  right: calc(-2 * var(--u));
  bottom: calc(2 * var(--u));
  width: calc(13 * var(--u));
  height: calc(13 * var(--u));
  border-radius: 50%;
  border: calc(2 * var(--u)) solid rgb(9 12 30);
  background: var(--ink-3);
}

.dot--online { background: #62c39a; box-shadow: 0 0 calc(10 * var(--u)) rgb(98 195 154 / 0.8); }

/* ============================================================== founder ===== */

/* Os três itens do Founder (ver FOUNDER.md). Todos em dourado: é a única cor
   quente da interface, então o olho acha o Founder sem precisar ler. */

.founder {
  display: inline-flex;
  align-items: center;
  gap: calc(9 * var(--u));
  margin: 0 0 calc(12 * var(--u));
  padding: calc(6 * var(--u)) calc(12 * var(--u)) calc(6 * var(--u)) calc(10 * var(--u));
  border: 1px solid rgb(226 196 141 / 0.45);
  border-radius: calc(6 * var(--u));
  background: linear-gradient(180deg, rgb(226 196 141 / 0.12), rgb(226 196 141 / 0.03));
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: calc(14 * var(--u));
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--founder);
}

.founder__num { font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }

.founder__star {
  flex: none;
  width: calc(12 * var(--u));
  height: calc(12 * var(--u));
  background: currentColor;
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
}

/* o mesmo selo, menor, pras listas */
.founder--sm {
  flex: none;
  gap: calc(6 * var(--u));
  margin: 0;
  padding: calc(5 * var(--u)) calc(9 * var(--u)) calc(5 * var(--u)) calc(8 * var(--u));
  border-radius: calc(5 * var(--u));
  font-size: calc(13 * var(--u));
}

.founder--sm .founder__star { width: calc(10 * var(--u)); height: calc(10 * var(--u)); }

/* moldura dourada do avatar, com a estrela da casa no topo do aro */
.avatar--founder {
  border-color: rgb(226 196 141 / 0.75);
  box-shadow:
    0 0 0 calc(5 * var(--u)) rgb(226 196 141 / 0.10),
    0 0 calc(32 * var(--u)) rgb(75 115 250 / 0.26),
    inset 0 0 calc(26 * var(--u)) rgb(90 130 255 / 0.16);
}

.avatar--founder::before {
  content: "";
  position: absolute;
  top: calc(-11 * var(--u));
  left: 50%;
  width: calc(20 * var(--u));
  height: calc(20 * var(--u));
  translate: -50% 0;
  background: var(--founder);
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
  filter: drop-shadow(0 0 calc(6 * var(--u)) rgb(226 196 141 / 0.6));
}

/* verso de carta equipado */
.deck {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(10 * var(--u));
  margin: 0;
}

.cardback {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(96 * var(--u));
  height: calc(134 * var(--u));
  border-radius: calc(8 * var(--u));
  border: calc(1.5 * var(--u)) solid rgb(160 190 255 / 0.5);
  background:
    radial-gradient(70% 50% at 50% 44%, rgb(80 110 210 / 0.34), transparent 72%),
    linear-gradient(180deg, #131b3c, #070a1a);
  box-shadow: 0 calc(10 * var(--u)) calc(24 * var(--u)) rgb(2 4 12 / 0.6);
}

/* moldura interna */
.cardback::before {
  content: "";
  position: absolute;
  inset: calc(5 * var(--u));
  border: 1px solid rgb(160 190 255 / 0.3);
  border-radius: calc(5 * var(--u));
}

.cardback__seal {
  width: 80%;
  margin-bottom: calc(10 * var(--u));
  filter: drop-shadow(0 0 calc(8 * var(--u)) rgb(120 165 255 / 0.55));
}

.cardback__num {
  position: absolute;
  bottom: calc(12 * var(--u));
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: calc(11 * var(--u));
  line-height: 1;
  letter-spacing: 0.22em;
  color: var(--ink-2);
}

/* a edição Founder: trama em losango e ouro no lugar do azul */
.cardback--founder {
  border-color: rgb(226 196 141 / 0.8);
  background:
    radial-gradient(70% 50% at 50% 44%, rgb(80 110 210 / 0.30), transparent 72%),
    repeating-linear-gradient(45deg, rgb(226 196 141 / 0.07) 0 1px, transparent 1px calc(8 * var(--u))),
    repeating-linear-gradient(-45deg, rgb(226 196 141 / 0.07) 0 1px, transparent 1px calc(8 * var(--u))),
    linear-gradient(180deg, #141b3a, #070a1a);
}

.cardback--founder::before { border-color: rgb(226 196 141 / 0.38); }
.cardback--founder .cardback__num { color: var(--founder); }

.deck__label {
  font-size: calc(13 * var(--u));
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* médio: prévia do Founder */
.avatar--md { width: calc(110 * var(--u)); height: calc(110 * var(--u)); }

/* ======================================================== botão de ícone ===== */

/* botão só de ícone (mensagem, convite, +) */
.iconbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: calc(42 * var(--u));
  height: calc(42 * var(--u));
  padding: 0;
  border: 1px solid rgb(150 180 255 / 0.40);
  border-radius: calc(9 * var(--u));
  background: linear-gradient(180deg, rgb(34 50 112 / 0.45), rgb(14 20 50 / 0.6));
  color: var(--ink-1);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .18s var(--ease), color .18s var(--ease);
}

.iconbtn svg { width: calc(21 * var(--u)); height: calc(21 * var(--u)); }

.iconbtn:hover,
.iconbtn:focus-visible { border-color: rgb(180 205 255 / 0.9); color: var(--ink-0); }

.iconbtn--add {
  width: calc(30 * var(--u));
  height: calc(30 * var(--u));
  border-radius: calc(8 * var(--u));
  font-size: calc(20 * var(--u));
  line-height: 1;
}

/* ========================================================= botão texto ===== */

.btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: calc(38 * var(--u));
  padding: 0 calc(18 * var(--u));
  border: 1px solid rgb(150 180 255 / 0.45);
  border-radius: calc(7 * var(--u));
  background: linear-gradient(180deg, rgb(34 50 112 / 0.45), rgb(14 20 50 / 0.6));
  color: var(--ink-1);
  font-family: inherit;
  font-size: calc(14 * var(--u));
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .18s var(--ease), color .18s var(--ease);
  /* também serve de link ("Ler" nos termos): sem sublinhado */
  text-decoration: none;
}

.btn:hover,
.btn:focus-visible { border-color: rgb(180 205 255 / 0.9); color: var(--ink-0); }

/* ação que não tem volta */
.btn--danger { border-color: rgb(217 122 133 / 0.5); background: rgb(60 20 32 / 0.35); color: #e8a0a8; }
.btn--danger:hover,
.btn--danger:focus-visible { border-color: rgb(232 150 160 / 0.95); color: #f6c4ca; }

/* ============================================================ interruptor ===== */

.switch {
  position: relative;
  flex: none;
  width: calc(52 * var(--u));
  height: calc(30 * var(--u));
  padding: 0;
  border: 1px solid rgb(150 180 255 / 0.4);
  border-radius: 99px;
  background: rgb(8 12 30 / 0.8);
  cursor: pointer;
  transition: background-color .18s var(--ease), border-color .18s var(--ease);
}

.switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(4 * var(--u));
  width: calc(20 * var(--u));
  height: calc(20 * var(--u));
  border-radius: 50%;
  translate: 0 -50%;
  background: var(--ink-3);
  transition: left .18s var(--ease), background-color .18s var(--ease);
}

.switch[aria-checked="true"] { background: rgb(64 98 205 / 0.8); border-color: rgb(160 188 255 / 0.85); }
.switch[aria-checked="true"]::before { left: calc(100% - 24 * var(--u)); background: var(--ink-0); }

/* ====================================================== linha de ajuste ===== */

/* rótulo (+ explicação) à esquerda, controle à direita */
.setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: calc(24 * var(--u));
  min-height: calc(62 * var(--u));
  padding: calc(8 * var(--u)) 0;
  border-top: 1px solid rgb(170 195 255 / 0.10);
}

.setting:first-child { border-top: 0; }

.setting__label {
  display: block;
  font-size: calc(21 * var(--u));
  line-height: 1.2;
  color: var(--ink-0);
}

.setting__hint {
  display: block;
  margin-top: calc(5 * var(--u));
  font-size: calc(15 * var(--u));
  line-height: 1.3;
  color: var(--ink-3);
}

/* texto de rodapé de um painel */
.panel__foot {
  margin: auto 0 0;
  padding-top: calc(16 * var(--u));
  font-size: calc(16 * var(--u));
  line-height: 1.4;
  color: var(--ink-3);
}

/* ============================================================= popovers ===== */

.pop {
  position: fixed;
  inset: auto;
  margin: 0;
  width: calc(290 * var(--u));
  min-width: 220px;
  padding: calc(14 * var(--u));
  border: 1px solid rgb(150 180 255 / 0.42);
  border-radius: calc(10 * var(--u));
  background: linear-gradient(180deg, rgb(24 32 70 / 0.98), rgb(10 13 32 / 0.98));
  box-shadow: 0 calc(18 * var(--u)) calc(40 * var(--u)) rgb(2 4 12 / 0.65);
  color: var(--ink-0);
  font-family: var(--font-serif);
}

.pop__title {
  display: block;
  margin: 0 0 calc(10 * var(--u));
  padding: 0 calc(4 * var(--u));
  font-size: max(12px, calc(14 * var(--u)));
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.pop__title [data-name] { color: var(--ink-1); text-transform: none; letter-spacing: 0.02em; }

.pop__item {
  display: flex;
  align-items: center;
  gap: calc(12 * var(--u));
  width: 100%;
  padding: calc(9 * var(--u)) calc(8 * var(--u));
  border: 0;
  border-radius: calc(7 * var(--u));
  background: none;
  color: var(--ink-0);
  font-family: inherit;
  font-size: max(15px, calc(20 * var(--u)));
  line-height: 1;
  text-align: left;
  cursor: pointer;
}

.pop__item img { width: calc(30 * var(--u)); min-width: 22px; aspect-ratio: 1; object-fit: contain; }

.pop__item:hover,
.pop__item:focus-visible { background: rgb(120 150 255 / 0.12); }

.pop__text {
  display: block;
  width: 100%;
  margin-bottom: calc(10 * var(--u));
  padding: calc(10 * var(--u));
  border: 1px solid rgb(150 180 255 / 0.3);
  border-radius: calc(7 * var(--u));
  background: rgb(6 9 22 / 0.7);
  color: var(--ink-0);
  font-family: inherit;
  font-size: max(15px, calc(18 * var(--u)));
  line-height: 1.35;
  resize: none;
}

.pop__text:focus { outline: none; border-color: rgb(170 195 255 / 0.8); }

.pop__send {
  display: block;
  margin-left: auto;
  height: calc(40 * var(--u));
  min-height: 32px;
  padding: 0 calc(22 * var(--u));
  border: 1px solid rgb(140 170 255 / 0.6);
  border-radius: calc(7 * var(--u));
  background: linear-gradient(180deg, rgb(40 58 128 / 0.75), rgb(16 24 60 / 0.85));
  color: var(--ink-0);
  font-family: inherit;
  font-size: max(12px, calc(15 * var(--u)));
  line-height: 1;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .18s var(--ease);
}

.pop__send:hover { border-color: rgb(175 200 255 / 0.95); }

/* confirmação de envio */
.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(40 * var(--u));
  translate: -50% 0;
  margin: 0;
  padding: calc(12 * var(--u)) calc(20 * var(--u));
  border: 1px solid rgb(150 180 255 / 0.42);
  border-radius: calc(9 * var(--u));
  background: rgb(14 19 44 / 0.96);
  box-shadow: 0 calc(14 * var(--u)) calc(34 * var(--u)) rgb(2 4 12 / 0.6);
  max-width: calc(100vw - 32px);
  font-size: max(14px, calc(18 * var(--u)));
  line-height: 1.3;
  text-align: center;
  color: var(--ink-0);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* ==================================================== telas estreitas ===== */

@media (max-width: 900px), (max-aspect-ratio: 1/1) {
  /* no celular a unidade encolhe demais pro texto de apoio: piso em px */
  .setting__label { font-size: max(15px, calc(21 * var(--u))); }
  .setting__hint, .panel__foot { font-size: max(12px, calc(15 * var(--u))); }
  .btn { height: max(34px, calc(38 * var(--u))); font-size: max(11px, calc(14 * var(--u))); }
  .switch { width: 46px; height: 26px; }
  .switch::before { width: 18px; height: 18px; left: 3px; }
  .switch[aria-checked="true"]::before { left: calc(100% - 21px); }

  .board {
    height: auto;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    align-content: start;
    gap: calc(18 * var(--u));
    /* o topo quebra em duas linhas no celular (marca / mensagens + nível) */
    padding: calc(190 * var(--u)) calc(24 * var(--u)) calc(150 * var(--u));
  }

  .panel { min-height: calc(320 * var(--u)); }

  .panel__head { height: calc(58 * var(--u)); padding: 0 calc(24 * var(--u)); }
  .panel__body { padding: 0 calc(24 * var(--u)) calc(24 * var(--u)); }
  .cardback { width: calc(80 * var(--u)); height: calc(112 * var(--u)); }
  .toast { bottom: calc(120 * var(--u)); }
}
