/* =====================================================================
   TOP-FLYOUT.CSS — Panneau qui s'ouvre SOUS un bouton du haut
   (Paramètres, Courrier, Notifications).

   Même famille que side-flyout.css (même bordure, mêmes coins coupés,
   pas de fond sombre derrière), mais accroché en haut à droite au lieu
   d'à gauche : la gemme et le point d'ancrage sont donc en haut du
   panneau plutôt qu'à gauche.

   Structure HTML : voir <div class="top-flyout"> dans index.html.
   Rempli et positionné par js/top-flyout.js.
   ===================================================================== */


/* ---------------------------------------------------------------------
   1. CONTENEUR (positionné en JS : right, top, et --tf-gem-x)
   --------------------------------------------------------------------- */
.top-flyout {
  --tf-gem-x: 30px;         /* position horizontale de la gemme (alignée sur le bouton) */
  position: absolute;
  z-index: 13;
  top: 84px;
  right: 24px;
  width: 320px;
  animation: tf-slide-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.top-flyout[hidden] {
  display: none;
}

@keyframes tf-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Petite gemme dorée en haut du panneau, alignée sur le bouton cliqué */
.top-flyout-gem {
  position: absolute;
  left: var(--tf-gem-x);
  top: -6px;
  z-index: 2;
  width: 11px;
  height: 11px;
  margin-left: -5px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #fff1b8 0%, var(--gold, #d8a83e) 55%, #a8741f 100%);
  border: 1.5px solid var(--void, #090811);
  box-shadow: 0 0 8px rgba(216, 168, 62, 0.5);
}

/* Le panneau lui-même reprend exactement le style de .side-flyout-panel */
.top-flyout-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  background: linear-gradient(160deg, rgba(24, 14, 46, 0.99) 0%, rgba(10, 8, 20, 0.99) 100%);
  /* Petit flou de ce qu'il y a derrière : évite qu'un texte du jeu (une carte
     d'événement, par exemple) ne "transparaisse" derrière le panneau */
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(216, 168, 62, 0.55);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.top-flyout-panel::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(216, 168, 62, 0.18);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  pointer-events: none;
}


/* ---------------------------------------------------------------------
   2. BOUTON DU HAUT ACTIF (celui dont le panneau est ouvert)
   --------------------------------------------------------------------- */
.round-action.is-active .ra-diamond {
  border-color: var(--gold-light, #ffe18a);
  box-shadow:
    0 0 0 3px rgba(12, 9, 36, 0.85),
    0 0 0 4px rgba(216, 168, 62, 0.6),
    0 0 16px 3px rgba(216, 168, 62, 0.45),
    inset 0 0 8px rgba(255, 225, 138, 0.3);
}


/* ---------------------------------------------------------------------
   3. CONTENU — RÉGLAGES (onglet Paramètres)
   --------------------------------------------------------------------- */

/* Un bloc de réglage : icône/texte à gauche, contrôle (interrupteur, bouton) à droite */
.tf-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
}

.tf-row + .tf-row {
  border-top: 1px solid rgba(216, 168, 62, 0.18);
}

.tf-row-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a2a72 0%, #180f3c 60%, #0a0620 100%);
  box-shadow: 0 0 0 1.5px var(--gold-light, #ffe18a), 0 0 0 3px rgba(9, 8, 17, 0.9);
}

.tf-row-icon svg {
  width: 19px;
  height: 19px;
}

.tf-row-text {
  flex: 1;
  min-width: 0;
}

.tf-row-title {
  font-family: "Cinzel", serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--cream, #f5ead5);
}

.tf-row-sub {
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--muted, #b8aabf);
}

/* --- Interrupteur (case "Effets visuels") --- */
.tf-switch {
  flex: none;
  position: relative;
  width: 46px;
  height: 26px;
}

.tf-switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.tf-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(216, 168, 62, 0.4);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tf-switch-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e8e4ee, #a9a0bc);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.3, 1.3), background 0.2s ease;
}

.tf-switch input:checked + .tf-switch-track {
  background: rgba(156, 90, 197, 0.35);
  border-color: var(--gold-light, #ffe18a);
}

.tf-switch input:checked + .tf-switch-track::before {
  transform: translateX(20px);
  background: linear-gradient(180deg, #fff1b8, var(--gold, #d8a83e));
}

.tf-switch input:focus-visible + .tf-switch-track {
  outline: 2px solid var(--gold-light, #ffe18a);
  outline-offset: 2px;
}

/* --- Séparateur de section (au-dessus de "Compte Twitch" et "Code cadeau") --- */
.tf-section-label {
  margin: 14px 0 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-light, #ffe18a);
  opacity: 0.85;
}

.tf-row:first-child + .tf-section-label,
.tf-body > .tf-section-label:first-child {
  margin-top: 4px;
}

/* --- Bouton Twitch (connexion / déconnexion) --- */
.tf-twitch-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(216, 168, 62, 0.4);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tf-twitch-btn:hover {
  border-color: var(--gold-light, #ffe18a);
  background: rgba(0, 0, 0, 0.45);
}

.tf-twitch-btn svg {
  flex: none;
  width: 24px;
  height: 24px;
}

.tf-twitch-text {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.tf-twitch-main {
  font-family: "Cinzel", serif;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--cream, #f5ead5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tf-twitch-sub {
  margin-top: 1px;
  font-size: 10px;
  color: var(--muted, #b8aabf);
}

/* Petit point d'état (vert = connecté, gris = déconnecté) */
.tf-twitch-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6b6478;
}

.tf-twitch-btn.is-connected .tf-twitch-dot {
  background: #3ddc84;
  box-shadow: 0 0 6px rgba(61, 220, 132, 0.7);
}

.tf-twitch-btn.is-connected .tf-twitch-main {
  color: #3ddc84;
}

/* --- Champ + bouton pour le code cadeau --- */
.tf-code-row {
  display: flex;
  gap: 8px;
}

.tf-code-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cream, #f5ead5);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(216, 168, 62, 0.4);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.tf-code-input::placeholder {
  text-transform: none;
  letter-spacing: normal;
  color: var(--muted, #b8aabf);
  opacity: 0.7;
}

.tf-code-input:focus {
  outline: none;
  border-color: var(--gold-light, #ffe18a);
}

.tf-code-submit {
  flex: none;
  padding: 0 16px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  font-weight: 800;
  color: #2a1a00;
  background: linear-gradient(180deg, #fff1b8 0%, var(--gold, #d8a83e) 60%, #a8741f 100%);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: filter 0.15s ease;
}

.tf-code-submit:hover {
  filter: brightness(1.1);
}

.tf-code-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Message de retour (succès / erreur) sous le champ */
.tf-code-msg {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  min-height: 14px;
}

.tf-code-msg.is-ok {
  color: #3ddc84;
}

.tf-code-msg.is-error {
  color: #ff7a90;
}


/* ---------------------------------------------------------------------
   4. ACCESSIBILITÉ
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .top-flyout {
    animation: none;
  }

  .tf-switch-track,
  .tf-switch-track::before {
    transition: none;
  }
}
