/* ── IMPORTS ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,400&family=DM+Sans:wght@300;400;500&family=JetBrains+Mono:wght@400;500&family=Noto+Nastaliq+Urdu:wght@400;700&display=swap');

/* ── TOKENS ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #120b07;
  --surface:     #1a0f0a;
  --card:        #221410;
  --card-hover:  #2a1a13;
  --border:      #33190f;
  --border-hi:   #4a2515;

  --gold:        #d4a853;
  --gold-lt:     #e8c97a;
  --gold-dim:    rgba(212,168,83,0.10);
  --gold-glow:   rgba(212,168,83,0.28);
  --rust:        #c4602a;
  --rust-dim:    rgba(196,96,42,0.12);
  --rust-glow:   rgba(196,96,42,0.25);

  --cream:       #f0e4c8;
  --text:        #ddd0b8;
  --text-muted:  #7a6050;
  --text-faint:  #3d2418;

  /* Nexus accent — used sparingly */
  --nx-cyan:     #00D4FF;
  --nx-cyan-dim: rgba(0,212,255,0.08);

  --radius:      12px;
  --radius-pill: 100px;
  --ease:        0.2s ease;
}

/* ── RESET ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── BODY ────────────────────────────────────────────────────────────────── */
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 55% 35% at 10% 5%,  rgba(196,96,42,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 45% 30% at 90% 95%, rgba(212,168,83,0.05) 0%, transparent 60%);
}

/* ── HEADER ──────────────────────────────────────────────────────────────── */
header {
  position: relative;
  text-align: center;
  padding: 48px 24px 30px;
  border-bottom: 1px solid var(--border);
}

/* top line decoration */
header::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 500px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--rust), var(--gold), transparent);
  opacity: 0.45;
}

.header-brand {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--nx-cyan);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  margin-bottom: 20px;
  opacity: 0.7;
}

.header-script {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  color: var(--gold);
  line-height: 1.7;
  text-shadow: 0 0 50px var(--gold-glow), 0 0 100px rgba(212,168,83,0.08);
  margin-bottom: 10px;
}

.header-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.header-domain {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.14em;
  opacity: 0.4;
}

/* ── CONTROLS ────────────────────────────────────────────────────────────── */
.controls {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 0;
}

.search-wrap { position: relative; margin-bottom: 14px; }

.search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  padding: 10px 20px 10px 42px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.search-input::placeholder { color: var(--text-muted); }

/* ── CATEGORY NAV ────────────────────────────────────────────────────────── */
.cat-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 4px;
}

.cat-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
}
.cat-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-dim);
}
.cat-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

/* ── TIPS BAR ────────────────────────────────────────────────────────────── */
.tips-bar {
  max-width: 960px;
  margin: 18px auto 0;
  padding: 0 20px;
}
.tips-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rust);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 0.79rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.tips-inner strong { color: var(--gold); }

/* ── MAIN ────────────────────────────────────────────────────────────────── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ── SECTION ─────────────────────────────────────────────────────────────── */
.section {
  margin-bottom: 44px;
  animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 3px;
}

.section-icon { font-size: 1.1rem; }

.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--cream);
  letter-spacing: 0.01em;
}

.section-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-left: auto;
  opacity: 0.6;
}

.section-subtitle {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-bottom: 15px;
  letter-spacing: 0.02em;
}

/* ── PHRASE GRID ─────────────────────────────────────────────────────────── */
.phrase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

/* ── PHRASE CARD ─────────────────────────────────────────────────────────── */
.phrase-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  cursor: pointer;
  transition: all var(--ease);
  position: relative;
  overflow: hidden;
  user-select: none;
}

.phrase-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--gold-dim), transparent 60%);
  opacity: 0;
  transition: opacity var(--ease);
  pointer-events: none;
}

.phrase-card:hover {
  border-color: var(--gold);
  background: var(--card-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.5), 0 0 0 1px var(--gold-dim);
}
.phrase-card:hover::after { opacity: 1; }
.phrase-card:active { transform: translateY(0); }

.phrase-card.playing {
  border-color: var(--rust);
  box-shadow: 0 0 24px var(--rust-glow);
}
.phrase-card.playing::after {
  background: linear-gradient(135deg, var(--rust-dim), transparent 60%);
  opacity: 1;
}

/* Play badge */
.play-badge {
  position: absolute;
  top: 10px; left: 12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  color: var(--text-muted);
  transition: all var(--ease);
  z-index: 1;
}
.phrase-card:hover .play-badge {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
}
.phrase-card.playing .play-badge {
  background: var(--rust);
  border-color: var(--rust);
  color: white;
  animation: pulse 0.9s ease infinite alternate;
}

@keyframes pulse {
  from { box-shadow: 0 0 0 0 var(--rust-glow); }
  to   { box-shadow: 0 0 0 6px transparent; }
}

/* Card content */
.phrase-urdu {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: 1.45rem;
  color: var(--gold);
  text-align: right;
  direction: rtl;
  line-height: 1.9;
  margin-bottom: 10px;
  min-height: 50px;
}

.phrase-roman {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--cream);
  margin-bottom: 4px;
  line-height: 1.3;
}

.phrase-es {
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { color: var(--text-muted); font-size: 0.85rem; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: var(--card);
  border: 1px solid var(--border-hi);
  color: var(--cream);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  transition: transform 0.3s ease;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ── FOOTER ──────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  opacity: 0.45;
}
footer a { color: var(--gold); text-decoration: none; }
footer a:hover { opacity: 0.7; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 36px 16px 24px; }
  .controls, .tips-bar { padding-left: 16px; padding-right: 16px; }
  main { padding: 24px 16px 60px; }
  .phrase-grid { grid-template-columns: 1fr; }
  .cat-btn { font-size: 0.7rem; padding: 5px 11px; }
}

/* ── MODE TOGGLE ─────────────────────────────────────────────────────────── */
.mode-toggle {
  display: inline-flex;
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 3px;
}

.mode-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--ease);
}
.mode-btn:hover { color: var(--gold); }
.mode-btn.active {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--border-hi);
}

/* ── ES-PRIMARY (for ur→es mode, Spanish is the big text) ───────────────── */
.phrase-es-primary {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--cream);
  line-height: 1.4;
  margin-bottom: 8px;
  min-height: 40px;
}

.phrase-bottom {
  margin-top: 6px;
  margin-bottom: 0;
}
