/* خاطره بازی — mobile-first, RTL */

:root {
  --bg: #1c1024;
  --bg-soft: #271733;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #f5eefb;
  --text-dim: #b9a8c9;
  --accent: #b56cf0;
  --accent-2: #ff8fb1;
  --error: #ff6b81;
  --radius: 20px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.9;
  overflow-x: hidden;
  /* Paint immediately with system fonts while Vazirmatn loads */
  font-synthesis: none;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vmax 60vmax at 85% -10%, rgba(181, 108, 240, 0.28), transparent 60%),
    radial-gradient(50vmax 50vmax at -10% 100%, rgba(255, 143, 177, 0.18), transparent 60%),
    var(--bg);
}

.hidden {
  display: none !important;
}

/* ---------- layout ---------- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand {
  margin: 0;
  font-weight: 800;
  font-size: 1.9rem;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand.small {
  font-size: 1.25rem;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.logout,
.back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 12px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  transition: color 0.2s, border-color 0.2s;
}

.logout:active,
.back:active,
.logout:hover,
.back:hover {
  color: var(--text);
  border-color: var(--accent);
}

.site-footer {
  margin-top: 40px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ---------- chat bubbles ---------- */
.chat-bubble {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  border-bottom-right-radius: 6px;
  padding: 14px 16px;
  margin: 10px 0;
  font-size: 0.95rem;
  animation: rise 0.45s ease both;
}

.chat-bubble.big {
  font-size: 1.05rem;
  white-space: pre-line;
  min-height: 7.5em;
}

.chat-bubble.error {
  border-color: var(--error);
  color: var(--error);
  background: rgba(255, 107, 129, 0.08);
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  vertical-align: -0.2em;
  background: var(--accent);
  margin-inline-start: 2px;
  animation: blink 0.9s steps(1) infinite;
}

.caret.done {
  display: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- login ---------- */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: rise 0.5s ease both;
}

.logo-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(181, 108, 240, 0.35), rgba(255, 143, 177, 0.25));
  border: 1px solid var(--card-border);
}

.tagline {
  margin: 4px 0 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.chat-step .chat-bubble {
  text-align: right;
}

.field-row input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  text-align: right;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 108, 240, 0.2);
}

.btn {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s;
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
}

.btn:active {
  transform: scale(0.97);
}

/* ---------- episodes list ---------- */
.episodes {
  display: grid;
  gap: 12px;
}

.episode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.2s;
  animation: rise 0.45s ease both;
}

.episode-card:active {
  transform: scale(0.985);
}

.episode-card:hover {
  border-color: var(--accent);
}

.episode-art {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  color: #fff;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.episode-info h2 {
  margin: 0;
  font-size: 1rem;
}

.episode-info p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.7;
}

.chevron {
  margin-inline-start: auto;
  color: var(--text-dim);
  font-size: 1.4rem;
}

/* ---------- player ---------- */
.greeting-box {
  margin-bottom: 26px;
}

.player-section {
  padding-top: 8px;
}

.player-card {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.disc {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.35) 18%, transparent 19%),
    conic-gradient(from 0deg, #3a2450, #58346f, #3a2450, #58346f, #3a2450);
  border: 1px solid var(--card-border);
}

.disc.spinning {
  animation: spin 6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.episode-title {
  margin: 0;
  font-size: 1.1rem;
}

.episode-desc {
  margin: 6px 0 20px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.player-section:focus {
  outline: none;
}

.player-section:focus-visible .player-card {
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.4),
    0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
}

.progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  direction: ltr;
}

.percent {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.total-duration {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
  direction: ltr;
}

.time {
  font-size: 0.75rem;
  color: var(--text-dim);
  min-width: 42px;
  font-variant-numeric: tabular-nums;
}

.time.remain {
  text-align: right;
}

input[type="range"] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--progress, 0%), rgba(255, 255, 255, 0.15) var(--progress, 0%));
  outline: none;
  cursor: pointer;
  transition: height 0.15s ease;
}

input[type="range"]:not(.scrubbing) {
  transition:
    height 0.15s ease,
    background-size 0.08s linear;
}

input[type="range"]:hover,
input[type="range"]:focus-visible,
input[type="range"].scrubbing {
  height: 10px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]:active::-webkit-slider-thumb,
input[type="range"].scrubbing::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: grab;
  transition: transform 0.15s ease;
}

input[type="range"]:active::-moz-range-thumb,
input[type="range"].scrubbing::-moz-range-thumb {
  cursor: grabbing;
  transform: scale(1.15);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 22px;
}

.ctl {
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 12px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.ctl:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--card-border));
}

.ctl:active {
  transform: scale(0.92);
}

.ctl:disabled {
  opacity: 0.7;
  cursor: wait;
}

.ctl.play {
  position: relative;
  width: 74px;
  height: 74px;
  padding: 0;
  font-size: 1.6rem;
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 30px rgba(181, 108, 240, 0.4);
  display: grid;
  place-items: center;
}

.ctl.play:hover:not(:disabled) {
  transform: scale(1.04);
  border: none;
}

.ctl.play:active:not(:disabled) {
  transform: scale(0.94);
}

.play-icon {
  line-height: 1;
}

.buffer-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.player-card.is-buffering .disc {
  opacity: 0.75;
}

.player-card.is-buffering .percent {
  color: var(--text-dim);
}

/* ---------- larger screens ---------- */
@media (min-width: 700px) {
  .page {
    padding-top: 40px;
  }

  .brand {
    font-size: 2.2rem;
  }

  .episode-info h2 {
    font-size: 1.1rem;
  }
}
