/* ============================================================
   مساجلة — Musajala — Design System v2 (Bold Minimal)
   ============================================================ */

/* --- Design Tokens --- */
:root {
  --bg: #000000;
  --bg-card: #080808;
  --bg-input: #0d0d0d;
  --bg-hover: #111111;

  --border: #222222;
  --border-active: #444444;

  --text: #f0f0f0;
  --text-mid: #aaaaaa;
  --text-muted: #666666;
  --text-poetry: #ffffff;

  --accent: #ffffff;
  --accent-dim: #cccccc;
  --success: #4ade80;
  --error: #ff6b6b;

  /* Typography */
  --font-ar: 'IBM Plex Sans Arabic', 'Segoe UI', sans-serif;
  --font-poetry: 'Amiri', 'Noto Naskh Arabic', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 40px;
  --s5: 64px;

  --dur: 200ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg: #f5f4f2;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #edeceb;

  --border: #ddd;
  --border-active: #bbb;

  --text: #111111;
  --text-mid: #555555;
  --text-muted: #999999;
  --text-poetry: #000000;

  --accent: #111111;
  --accent-dim: #333333;
  --success: #16a34a;
  --error: #dc2626;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ar);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 300ms ease, color 300ms ease;
}

#app {
  min-height: calc(100dvh - 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

a { color: var(--accent); text-decoration: none; }

::selection { background: rgba(255, 255, 255, 0.15); color: #fff; }
[data-theme="light"] ::selection { background: rgba(0, 0, 0, 0.12); color: #000; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 300ms ease, border-color 300ms ease;
}

.topbar__brand {
  font-family: var(--font-ar);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.topbar__link {
  color: var(--text-mid) !important;
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--dur) ease;
}

.topbar__link:hover { color: var(--text) !important; }

.topbar__meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-mid);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--dur) ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-active); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
.fade-in { animation: fadeIn 350ms var(--ease) both; }
.slide-up { animation: slideUp 450ms var(--ease) both; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  border: 2px solid var(--border-active);
  background: transparent;
  color: var(--text);
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) ease;
  text-decoration: none;
  line-height: 1;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
}
.btn--primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn--ghost {
  border-color: transparent;
  color: var(--text-mid);
  font-weight: 500;
}
.btn--ghost:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); }

.btn--small { padding: 10px 18px; font-size: 0.85rem; }

.btn--wide {
  width: 100%;
  padding: 18px;
  font-size: 1.1rem;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--s3); }

.form-label {
  display: block;
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s1);
}

.form-textarea {
  width: 100%;
  padding: 16px;
  font-family: var(--font-poetry);
  font-size: 1.3rem;
  color: var(--text-poetry);
  background: var(--bg-input);
  border: 2px solid var(--border);
  outline: none;
  transition: border-color var(--dur) ease;
  direction: rtl;
  line-height: 2;
  resize: none;
  min-height: 100px;
}

.form-textarea::placeholder { color: var(--text-muted); font-size: 1.1rem; }
.form-textarea:focus { border-color: var(--accent); }

.form-hint {
  font-family: var(--font-ar);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--s1);
}

.error-message {
  font-family: var(--font-ar);
  font-size: 0.9rem;
  color: var(--error);
  font-weight: 600;
  padding: var(--s1) 0;
  margin-bottom: var(--s2);
}

/* ============================================================
   FOCUS CARD — the single-action container used everywhere
   ============================================================ */
.focus-card {
  width: 100%;
  max-width: 520px;
  padding: var(--s4) var(--s3);
  text-align: center;
}

.focus-card__title {
  font-family: var(--font-ar);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s4);
  line-height: 1.5;
}

.focus-card__actions {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  margin-top: var(--s3);
}

/* ============================================================
   HOME VIEW
   ============================================================ */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 52px);
  text-align: center;
  padding: var(--s4) var(--s3);
  max-width: 580px;
}

.home__title {
  font-family: var(--font-ar);
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: var(--s3);
}

.home__subtitle {
  font-family: var(--font-ar);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text-mid);
  line-height: 1.9;
  margin-bottom: var(--s5);
}

/* ============================================================
   POEM VIEW
   ============================================================ */
.poem-view {
  padding: var(--s3);
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.back-link {
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--s1) 0;
  transition: color var(--dur) ease;
}
.back-link:hover { color: var(--text); }

/* Header */
.poem-header {
  padding: var(--s4) 0 var(--s3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s3);
  text-align: center;
}

.poem-header__title {
  font-family: var(--font-ar);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s1);
}

.poem-header__players {
  font-family: var(--font-ar);
  font-size: 0.95rem;
  color: var(--text-mid);
  font-weight: 500;
}

/* --- Bayt (Verse) --- */
.poem-body { margin-bottom: var(--s3); }

.bayt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s3) var(--s2);
  border-bottom: 1px solid var(--border);
  animation: slideUp 500ms var(--ease) both;
}

.bayt__shatr {
  flex: 1;
  text-align: center;
  font-family: var(--font-poetry);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  line-height: 2.4;
  color: var(--text-poetry);
}

.bayt__divider {
  color: var(--text-muted);
  font-size: 0.6rem;
  opacity: 0.4;
  flex-shrink: 0;
}

.bayt__number {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.bayt__authors {
  display: flex;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s1) 0;
}
.bayt__author {
  font-family: var(--font-ar);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Pending Shatr --- */
.pending-shatr {
  text-align: center;
  padding: var(--s4) var(--s3);
  margin-bottom: var(--s3);
  border: 2px dashed var(--border);
  background: var(--bg-card);
}

.pending-shatr__label {
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: var(--s2);
}

.pending-shatr__text {
  font-family: var(--font-poetry);
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  color: var(--text-poetry);
  line-height: 2.2;
  font-weight: 700;
}

.pending-shatr__author {
  font-family: var(--font-ar);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--s2);
}

/* --- Turn Form --- */
.turn-form {
  border: 2px solid var(--border);
  background: var(--bg-card);
  margin-bottom: var(--s3);
}

.turn-form__header {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.turn-form__title {
  font-family: var(--font-ar);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.turn-form__body { padding: var(--s3); }

.turn-form__actions {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border);
}

.turn-form__actions .btn {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 18px;
  width: 100%;
}
.turn-form__actions .btn:last-child { border-bottom: none; }

/* --- Waiting State --- */
.waiting-message {
  text-align: center;
  padding: var(--s5) var(--s3);
  border: 2px dashed var(--border);
  margin-bottom: var(--s3);
}

.waiting-message__icon {
  font-size: 1.5rem;
  margin-bottom: var(--s2);
  animation: blink 2s ease-in-out infinite;
}

.waiting-message__text {
  font-family: var(--font-ar);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s1);
}

.waiting-message__dots::after { content: ''; animation: dots 1.5s steps(1) infinite; }

.waiting-message__hint {
  font-family: var(--font-ar);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--s2);
}

/* --- Share Section --- */
.share-section {
  border: 1px solid var(--border);
  margin-bottom: var(--s3);
}

.share-section__header {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
}

.share-section__title {
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.share-section__body { padding: var(--s3); }

.share-link {
  display: flex;
  align-items: center;
  gap: var(--s1);
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: var(--s1) var(--s2);
  margin-bottom: var(--s2);
  direction: ltr;
}

.share-link__url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.share-link__copy {
  cursor: pointer;
  padding: var(--s1);
  color: var(--text-muted);
  transition: color var(--dur) ease;
  background: none;
  border: none;
  font-size: 0.85rem;
}
.share-link__copy:hover { color: var(--text); }

.share-buttons {
  display: flex;
  gap: var(--s1);
  flex-wrap: wrap;
}

/* ============================================================
   MANUSCRIPT — Closed Poem
   ============================================================ */
.manuscript {
  border: 2px solid var(--border);
  margin-bottom: var(--s3);
}

.manuscript__header {
  padding: var(--s3);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.manuscript__label {
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: var(--s1);
}

.manuscript__title {
  font-family: var(--font-ar);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.manuscript__body { padding: 0; }
.manuscript .bayt { margin-bottom: 0; }
.manuscript .bayt__shatr { font-size: clamp(1.15rem, 2.8vw, 1.5rem); }

.manuscript__footer {
  padding: var(--s3);
  border-top: 1px solid var(--border);
  text-align: center;
}

.manuscript__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: var(--success);
  padding: 6px 16px;
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: var(--s2);
}

.manuscript__authors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  margin-bottom: var(--s2);
}

.manuscript__author-name {
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 600;
}

.manuscript__author-name--a { color: var(--text); }
.manuscript__author-name--b { color: var(--text-mid); }
.manuscript__author-divider { color: var(--text-muted); font-size: 0.6rem; }

.manuscript__meta {
  font-family: var(--font-ar);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: var(--s3);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 28px;
  pointer-events: none;
  opacity: 0;
  transition: all 300ms var(--ease);
  z-index: 1000;
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .bayt { flex-direction: column; gap: 4px; padding: var(--s2); }
  .bayt__divider { transform: rotate(0deg); margin: 4px 0; }
  .bayt__number { display: none; }
  .manuscript__authors { flex-direction: column; gap: var(--s1); }
  .topbar { padding: 0 var(--s2); }
  .focus-card { padding: var(--s3) var(--s2); }
}

/* ── Auth Modal ── */
.auth-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.auth-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal {
  background: #1a1a1a;
  color: #f0f0f0;
  width: 90%;
  max-width: 420px;
  padding: 32px;
  border: 1px solid #333;
  border-radius: 12px;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.25s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .auth-modal {
  background: #ffffff;
  color: #111111;
  border-color: #e0e0e0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.auth-modal-backdrop.active .auth-modal {
  transform: translateY(0);
}

.auth-close {
  position: absolute;
  top: 16px;
  left: 16px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  line-height: 1;
  padding: 4px;
}

.auth-close:hover {
  color: #f0f0f0;
}

[data-theme="light"] .auth-close:hover {
  color: #111;
}

.auth-title {
  font-family: var(--font-ar);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.auth-form-group {
  margin-bottom: 16px;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: var(--font-ar);
  border: 1px solid #444;
  background: #111;
  color: #f0f0f0;
  outline: none;
  border-radius: 8px;
  transition: border-color 0.15s ease;
}

[data-theme="light"] .auth-input {
  background: #f5f5f5;
  border-color: #ccc;
  color: #111;
}

.auth-input:focus {
  border-color: #888;
}

[data-theme="light"] .auth-input:focus {
  border-color: #666;
}

.auth-input::placeholder {
  color: #666;
}

[data-theme="light"] .auth-input::placeholder {
  color: #999;
}

.auth-error {
  color: #ff6b6b;
  font-size: 0.85rem;
  margin-bottom: 16px;
  text-align: center;
  display: none;
}

/* Google Sign-In Button */
.auth-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font-ar);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.auth-btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 2px 8px rgba(60,64,67,.15);
}

.auth-btn-google svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #666;
  font-size: 0.85rem;
  margin: 24px 0;
  gap: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #333;
}

[data-theme="light"] .auth-divider::before,
[data-theme="light"] .auth-divider::after {
  border-color: #ddd;
}

/* OTP */
.otp-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.otp-input {
  text-align: center;
  letter-spacing: 0.5em;
  font-size: 1.5rem;
  font-family: var(--font-mono);
  padding: 16px !important;
}

