/* ============================================================================
   QIRAAYA — App design tokens (v4)
   Cairo → logo mark only (bold, geometric, works small)
   Noto Naskh Arabic → all reading text (clean modern Naskh, built for screens)
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@700;800&family=Noto+Naskh+Arabic:wght@400;500;600;700&display=swap');

@font-face { font-family: 'Inter'; src: url('./fonts/Inter-Regular.ttf') format('truetype'); font-weight: 100 900; }

:root {
  --teal:          #0F9B8E;
  --teal-deep:      #0A6F65;
  --teal-tint:      #E3F5F1;
  --coral:          #EF7A52;
  --coral-deep:      #C65B37;
  --gold:           #E8A93A;
  --gold-deep:       #B9821F;
  --cream:          #FFF9F0;
  --panel:          #FFFFFF;
  --panel-dim:       #FBF3E6;
  --line:           #EFE1CB;
  --ink:            #2B2320;
  --ink-soft:        #82766A;
  --known-green:     #35A06A;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 10px 28px -14px rgba(43, 35, 32, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
}

body { min-height: 100vh; }
a { color: inherit; }

/* ---------------------------------------------------------------------------
   Top navigation
   --------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  font-family: 'Cairo', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--teal-deep);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.topbar .brand small {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.topbar nav {
  display: flex;
  gap: 4px;
  background: var(--panel-dim);
  padding: 4px;
  border-radius: 999px;
}
.topbar nav a {
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active { background: var(--teal); color: white; }
.topbar .user-chip {
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .user-chip button {
  font: inherit;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  color: var(--ink-soft);
  cursor: pointer;
}
.topbar .user-chip button:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ---------------------------------------------------------------------------
   Toggle bar (script / translation)
   --------------------------------------------------------------------------- */
.toggle-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-dim);
  font-size: 13px;
  flex-wrap: wrap;
}
.toggle-group { display: flex; align-items: center; gap: 8px; }
.toggle-group span.label { color: var(--ink-soft); font-weight: 700; }
.toggle-btns {
  display: flex;
  background: var(--panel);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.toggle-btns button {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.toggle-btns button.active { background: var(--teal); color: white; }
.switch-btn {
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.switch-btn.active { background: var(--teal); color: white; }

/* ---------------------------------------------------------------------------
   Layout shell: chapter list + reading pane
   --------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 57px);
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .chapter-list { display: none; }
  .chapter-list.open { display: block; }
}

.chapter-list {
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--panel-dim);
}
.chapter-list .group-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 6px 6px 10px;
}
.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 0 var(--line);
  transition: transform .1s ease, box-shadow .1s ease;
}
.chapter-item:hover { transform: translateY(-1px); box-shadow: 0 3px 0 0 var(--line); }
.chapter-item.active {
  background: var(--teal);
  border-color: var(--teal-deep);
  color: #fff;
  box-shadow: 0 2px 0 0 var(--teal-deep);
}
.chapter-item .num {
  font-size: 11px; font-weight: 800; color: var(--ink-soft); width: 20px; flex-shrink: 0;
  background: var(--panel-dim); border-radius: 999px; text-align: center; padding: 3px 0;
}
.chapter-item.active .num { color: white; background: rgba(255,255,255,0.2); }
.chapter-item .titles { display: flex; flex-direction: column; min-width: 0; }
.chapter-item .title-en { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-item .title-ar { font-family: 'Noto Naskh Arabic', serif; font-weight: 500; font-size: 13px; opacity: 0.8; }
.chapter-item .lock { margin-left: auto; font-size: 12px; opacity: 0.5; flex-shrink: 0; }

/* ---------------------------------------------------------------------------
   Reading pane — wide, full-bleed feel
   --------------------------------------------------------------------------- */
.reader {
  padding: 40px clamp(24px, 5vw, 80px);
  max-width: 1200px;
}
.reader-head { margin-bottom: 32px; }
.reader-head .chapter-num {
  display: inline-block;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold-deep); background: rgba(232, 169, 58, 0.15);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 10px;
}
.reader-head h1 {
  font-family: 'Noto Naskh Arabic', serif; font-weight: 700; font-size: 48px; color: var(--teal-deep); margin: 0 0 4px;
  direction: rtl;
}
.reader-head h2 {
  font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-weight: 400; font-size: 17px;
  color: var(--ink-soft); margin: 0 0 10px;
}
.reader-head .situ {
  font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 14px; color: var(--ink-soft);
  line-height: 1.55; max-width: 70ch;
}

.block { margin-bottom: 24px; max-width: 100%; }
.block.line { margin-left: 18px; padding: 16px 20px; background: var(--panel); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.block.narr { padding: 4px 0; }
.speaker { font-size: 11.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 6px; color: var(--teal-deep); }
.ar-line {
  font-family: 'Noto Naskh Arabic', serif; font-weight: 500; font-size: 30px; line-height: 2; direction: rtl; text-align: right;
}
.ar-line.narr { color: var(--ink-soft); font-size: 27px; border-right: 3px solid var(--gold); padding-right: 16px; }
.en-line { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 15px; color: var(--ink-soft); margin-top: 6px; direction: ltr; text-align: left; }

/* clickable words */
.w {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
  transition: background .12s ease;
  border-bottom: 3px solid transparent;
}
.w:hover { background: var(--teal-tint); }
.w.status-new     { border-bottom-color: transparent; }
.w.status-learning{ border-bottom-color: var(--coral); }
.w.status-known   { border-bottom-color: var(--known-green); }

/* ---------------------------------------------------------------------------
   Word popup (slide-up card)
   --------------------------------------------------------------------------- */
.popup-overlay {
  position: fixed; inset: 0; background: rgba(43, 35, 32, 0.35);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  animation: fadeIn .15s ease;
}
@media (min-width: 640px) { .popup-overlay { align-items: center; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.popup-card {
  background: var(--panel);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-card);
  width: 100%; max-width: 420px;
  padding: 28px 24px 24px;
  animation: slideUp .18s ease;
}
@media (min-width: 640px) { .popup-card { border-radius: var(--radius); } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.popup-card .word-ar { font-family: 'Noto Naskh Arabic', serif; font-weight: 700; font-size: 42px; color: var(--teal-deep); direction: rtl; }
.popup-card .word-tr { font-family: Georgia, serif; font-style: italic; color: var(--ink-soft); font-size: 14px; margin-top: 2px; }
.popup-card .word-en { font-size: 17px; font-weight: 700; margin-top: 10px; }
.popup-card .word-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
.popup-card .word-example { margin-top: 14px; padding: 12px 14px; background: var(--panel-dim); border-radius: var(--radius-sm); }
.popup-card .word-example .ex-ar { font-family: 'Noto Naskh Arabic', serif; font-weight: 500; font-size: 18px; direction: rtl; }
.popup-card .word-example .ex-en { font-family: Georgia, serif; font-style: italic; font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

.status-buttons { display: flex; gap: 10px; margin-top: 18px; }
.status-buttons button {
  flex: 1; font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 11px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: white; color: var(--ink); cursor: pointer;
  box-shadow: 0 2px 0 0 var(--line);
  transition: transform .08s ease;
}
.status-buttons button:hover { transform: translateY(-1px); }
.status-buttons button:active { transform: translateY(1px); box-shadow: none; }
.status-buttons button.is-active.learning { background: var(--coral); border-color: var(--coral-deep); color: white; box-shadow: 0 2px 0 0 var(--coral-deep); }
.status-buttons button.is-active.known { background: var(--known-green); border-color: #268053; color: white; box-shadow: 0 2px 0 0 #268053; }

.popup-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 18px; color: var(--ink-soft); cursor: pointer;
}

/* ---------------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.auth-card .brand { font-family: 'Cairo', sans-serif; font-weight: 800; font-size: 34px; color: var(--teal-deep); text-align: center; margin-bottom: 4px; }
.auth-card .tagline { text-align: center; font-size: 13px; color: var(--ink-soft); margin-bottom: 26px; }
.auth-card label { font-size: 12.5px; font-weight: 700; display: block; margin: 14px 0 6px; }
.auth-card input {
  width: 100%; font: inherit; font-size: 14px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--cream);
}
.auth-card input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.auth-card button.primary {
  width: 100%; margin-top: 20px; font: inherit; font-weight: 800; font-size: 15px;
  padding: 13px; border-radius: var(--radius-sm); border: none; background: var(--teal); color: white;
  cursor: pointer; box-shadow: 0 3px 0 0 var(--teal-deep);
  transition: transform .08s ease;
}
.auth-card button.primary:hover { filter: brightness(1.04); }
.auth-card button.primary:active { transform: translateY(2px); box-shadow: none; }
.auth-card .switch { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 18px; }
.auth-card .switch button { background: none; border: none; color: var(--teal-deep); font-weight: 700; cursor: pointer; font: inherit; }
.auth-card .error { font-size: 12.5px; color: var(--coral-deep); margin-top: 10px; }
.auth-card .referral-note { font-size: 11px; color: var(--ink-soft); margin-top: 6px; background: var(--panel-dim); padding: 6px 10px; border-radius: 6px; }

/* ---------------------------------------------------------------------------
   Subscribe plan cards
   --------------------------------------------------------------------------- */
.plans-container { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0; }
.plan-card {
  border: 2px solid var(--line); border-radius: var(--radius); padding: 20px;
  text-align: center; cursor: pointer; background: var(--panel);
  box-shadow: 0 2px 0 0 var(--line);
  transition: transform .1s ease;
}
.plan-card:hover { transform: translateY(-2px); }
.plan-card.selected { border-color: var(--teal); background: var(--teal-tint); box-shadow: 0 3px 0 0 var(--teal-deep); }
.plan-card .price { font-size: 30px; font-weight: 800; color: var(--teal-deep); margin: 12px 0 4px; }
.plan-card .period { font-size: 12px; color: var(--ink-soft); margin-bottom: 10px; }
.plan-card .description { font-size: 12.5px; color: var(--ink-soft); }
@media (max-width: 600px) { .plans-container { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------------
   Review (Anki-style) page
   --------------------------------------------------------------------------- */
.review-shell {
  max-width: 560px; margin: 0 auto; padding: 48px 20px; text-align: center;
}
.review-progress { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 24px; font-weight: 700; }
.review-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 56px 32px; box-shadow: var(--shadow-card); min-height: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.review-card .word-ar { font-family: 'Noto Naskh Arabic', serif; font-weight: 700; font-size: 52px; color: var(--teal-deep); direction: rtl; }
.review-card .word-harakat { font-family: 'Noto Naskh Arabic', serif; font-weight: 700; font-size: 52px; color: var(--teal-deep); direction: rtl; }
.review-card .reveal { margin-top: 20px; }
.review-card .word-en { font-size: 20px; font-weight: 700; }
.review-card .word-tr { font-family: Georgia, serif; font-style: italic; color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.review-card .tap-hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 24px; cursor: pointer; font-weight: 700; }

.grade-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.grade-buttons button {
  font: inherit; font-size: 12px; font-weight: 800; padding: 13px 6px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; color: white;
  transition: transform .08s ease;
}
.grade-buttons button:active { transform: translateY(2px); }
.grade-buttons button.again { background: #D64A3A; box-shadow: 0 3px 0 0 #A6362A; }
.grade-buttons button.hard  { background: var(--coral); box-shadow: 0 3px 0 0 var(--coral-deep); }
.grade-buttons button.good  { background: var(--teal); box-shadow: 0 3px 0 0 var(--teal-deep); }
.grade-buttons button.easy  { background: var(--known-green); box-shadow: 0 3px 0 0 #268053; }
.grade-buttons button span { display: block; font-size: 10px; font-weight: 600; opacity: 0.85; margin-top: 2px; }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--ink-soft);
}
.empty-state .icon { font-size: 42px; margin-bottom: 14px; }
.empty-state h3 { font-family: Georgia, serif; font-style: italic; font-weight: 400; color: var(--ink); font-size: 19px; }
.empty-state p { font-size: 13.5px; max-width: 40ch; margin: 8px auto 0; }
.empty-state a.cta {
  display: inline-block; margin-top: 18px; background: var(--teal); color: white;
  text-decoration: none; font-size: 13px; font-weight: 800; padding: 11px 20px; border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 0 var(--teal-deep);
}
