/*
 * EduGames - Interactive Learning Games
 * (c) 2025-2026 Prof. N. All rights reserved.
 *
 * File:    styles/components/dialog.css
 * Updated: 2026-10-04 10:25
 * Purpose: Popups: confirm, help, feedback, join, leaderboard, and toast messages.
 */

/* Confirmation dialog (UIUtils.confirm) */
.confirm-dialog {
  border: 1px solid var(--border-color, #ccc);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  max-width: 24rem;
  background: var(--bg-panel, #fff);
  color: var(--text-primary, #212529);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.confirm-message {
  margin: 0 0 1rem;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.confirm-actions button {
  padding: 0.4rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--border-color, #ccc);
  cursor: pointer;
}

.confirm-actions .confirm-ok {
  background: var(--color-primary);
  color: #fff;
  border-color: transparent;
}

/* Feature dialogs: score records and feedback */
.app-dialog {
  border: 1px solid var(--border-color, #ccc);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  width: min(92vw, 640px);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-panel, #fff);
  color: var(--text-primary, #212529);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.app-dialog-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

.app-dialog-note {
  margin: 0 0 1rem;
  color: var(--text-secondary, #6c757d);
  font-size: 0.9rem;
}

.app-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.app-dialog button {
  padding: 0.4rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--border-color, #ccc);
  background: var(--bg-panel, #fff);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-dialog button.app-dialog-primary {
  background: var(--color-primary);
  border-color: transparent;
  color: #fff;
}

.app-dialog button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Leaderboard (score records): a raised, tilting panel with a gold header */
.records-dialog {
  --rd-gold: var(--color-warning);
  padding: 0;
  width: min(94vw, 640px);
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-panel, #fff);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 2px 0 rgba(0, 0, 0, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.45),
    0 40px 80px rgba(0, 0, 0, 0.25);
  transform-origin: 50% 100%;
  animation: rd-open 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

.records-dialog::backdrop {
  background: rgba(8, 14, 30, 0.55);
  backdrop-filter: blur(2px);
  animation: rd-fade 0.25s ease-out both;
}

.records-dialog.dialog-closing {
  animation: rd-close 0.2s ease-in both;
}

.records-dialog.dialog-closing::backdrop {
  animation: rd-fade-out 0.2s ease-in both;
}

.rd-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.2rem;
  color: #fff;
  background: linear-gradient(135deg, #0b3d91 0%, #1565c0 55%, #2f8cf0 100%);
  border-bottom: 3px solid var(--rd-gold);
}

.rd-trophy {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.35rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe082, #ffb300);
  fill: none;
  stroke: #5d3b00;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.rd-title {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.rd-note {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  opacity: 0.9;
}

/* one icon button per game; the name is in the tooltip */
.rd-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem 0.3rem;
}

.records-dialog .rd-tab {
  width: 46px;
  height: 46px;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bg-app, #f4f4f9);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 4px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.rd-tab img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.records-dialog .rd-tab:hover {
  transform: translateY(-2px);
}

.records-dialog .rd-tab[aria-selected="true"] {
  border-color: var(--rd-gold);
  background: color-mix(in srgb, var(--rd-gold) 22%, var(--bg-panel, #fff));
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.records-dialog .rd-tab:focus-visible,
.records-dialog button:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.rd-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.3rem 1.2rem 0.5rem;
}

.rd-game {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-primary, #212529);
}

.rd-order {
  display: flex;
  gap: 0.3rem;
}

/* small, bold buttons */
.records-dialog button {
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.records-dialog .rd-order button[aria-pressed="true"],
.records-dialog .rd-close {
  background: var(--color-primary);
  border-color: transparent;
  color: #fff;
}

.rd-body {
  padding: 0 1.2rem;
  min-height: 7rem;
  max-height: 46vh;
  overflow: auto;
}

.rd-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 0.85rem;
}

.rd-table th {
  position: sticky;
  top: 0;
  padding: 0.3rem 0.5rem;
  background: var(--bg-panel, #fff);
  color: var(--text-secondary, #6c757d);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.rd-table td {
  padding: 0.4rem 0.5rem;
  background: var(--bg-app, #f4f4f9);
}

.rd-table td:first-child { border-radius: 8px 0 0 8px; }
.rd-table td:last-child { border-radius: 0 8px 8px 0; }

.rd-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text-secondary, #6c757d) 22%, transparent);
  font-weight: 800;
}

.rd-score {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary, #212529);
}

.rd-place-1 td { background: color-mix(in srgb, var(--color-warning) 26%, var(--bg-panel, #fff)); }
.rd-place-2 td { background: color-mix(in srgb, #b0bec5 28%, var(--bg-panel, #fff)); }
.rd-place-3 td { background: color-mix(in srgb, #d08a4c 26%, var(--bg-panel, #fff)); }

.rd-place-1 .rd-rank { background: radial-gradient(circle at 35% 30%, #ffe082, #ffb300); color: #4a2f00; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
.rd-place-2 .rd-rank { background: radial-gradient(circle at 35% 30%, #f5f7f8, #aeb9bf); color: #26323a; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
.rd-place-3 .rd-rank { background: radial-gradient(circle at 35% 30%, #f0b27a, #b3702f); color: #3b2108; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }

.records-empty {
  margin: 1.5rem 0;
  text-align: center;
  color: var(--text-secondary, #6c757d);
}

.rd-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.8rem 1.2rem 1rem;
}

@media (max-width: 480px) {
  .rd-table th:nth-child(5),
  .rd-table td:nth-child(5) {
    display: none;
  }
}

@keyframes rd-open {
  from { opacity: 0; transform: perspective(900px) translateY(40px) rotateX(-22deg) scale(0.9); }
  to { opacity: 1; transform: perspective(900px) translateY(0) rotateX(0) scale(1); }
}

@keyframes rd-close {
  from { opacity: 1; transform: perspective(900px) translateY(0) rotateX(0) scale(1); }
  to { opacity: 0; transform: perspective(900px) translateY(30px) rotateX(18deg) scale(0.92); }
}

@keyframes rd-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rd-fade-out { from { opacity: 1; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .records-dialog,
  .records-dialog::backdrop,
  .records-dialog .rd-tab {
    animation: none;
    transition: none;
  }
}

/* Feedback */
.feedback-types {
  border: 0;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.feedback-field {
  display: block;
  margin-bottom: 0.75rem;
}

.feedback-field > span {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary, #6c757d);
}

.feedback-field textarea,
.feedback-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background: var(--bg-app, #fff);
  color: inherit;
  font: inherit;
}

.feedback-check {
  display: block;
  font-size: 0.9rem;
}

.dialog-status {
  min-height: 1.25rem;
  margin: 0.5rem 0 0;
}

.dialog-ok {
  color: var(--text-success);
}

.dialog-error {
  color: var(--text-danger);
}

/* Game help */
.help-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.help-steps li + li {
  margin-top: 0.4rem;
}

.help-dialog {
  box-sizing: border-box;
}

.help-steps {
  list-style: decimal;
}

/* Toast messages (UIUtils.showNotification) */
#toast-container {
  position: fixed;
  top: 4.5rem; /* under the sticky header, so the toasts never cover its buttons */
  right: 20px;
  z-index: var(--z-index-toast, 9999);
}

.toast {
  min-width: 200px;
  margin-bottom: 10px;
  padding: 12px 20px;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  color: #fff;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-info { background-color: var(--color-info); }
.toast-success { background-color: var(--color-success); }
.toast-error { background-color: var(--color-danger); }
.toast-warning { background-color: var(--color-warning); color: #212529; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
