/* ==========================================================================
   Urdu Stemmer Demo — style.css
   Dark theme: charcoal + muted gold + deep emerald
   Classic Urdu editorial × modern enterprise software
   ========================================================================== */

/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Nastaliq+Urdu:wght@400;700&family=Noto+Naskh+Arabic:wght@400;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  /* Background */
  --bg-base:        #0f0f0f;
  --bg-surface:     #161616;
  --bg-card:        #1d1d1d;
  --bg-card-hover:  #242424;
  --bg-input:       #141414;
  --bg-border:      #2a2a2a;

  /* Gold accent */
  --gold-primary:   #c9a84c;
  --gold-muted:     #a8853a;
  --gold-faint:     rgba(201, 168, 76, 0.08);
  --gold-faint2:    rgba(201, 168, 76, 0.15);

  /* Emerald accent */
  --emerald:        #2d6a4f;
  --emerald-light:  #3d8b6a;
  --emerald-faint:  rgba(45, 106, 79, 0.15);

  /* Text */
  --text-primary:   #f0ead6;
  --text-secondary: #a8a090;
  --text-muted:     #6e6560;
  --text-gold:      #c9a84c;
  --text-emerald:   #52b788;

  /* Status */
  --changed-bg:     rgba(201, 168, 76, 0.10);
  --changed-border: rgba(201, 168, 76, 0.35);
  --unchanged-bg:   rgba(45, 106, 79, 0.10);
  --unchanged-border:rgba(45, 106, 79, 0.30);

  /* Radius / shadow */
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --shadow-card:    0 2px 16px rgba(0,0,0,0.4);
  --shadow-glow:    0 0 0 1px var(--bg-border);

  /* Typography */
  --font-ui:        'Inter', system-ui, sans-serif;
  --font-urdu:      'Noto Nastaliq Urdu', 'Noto Naskh Arabic', serif;
  --font-mono:      'Courier New', monospace;

  /* Transitions */
  --t-fast:         150ms ease;
  --t-mid:          280ms ease;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Geometric background pattern ────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 24px,
      rgba(201,168,76,0.025) 24px,
      rgba(201,168,76,0.025) 25px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 24px,
      rgba(201,168,76,0.025) 24px,
      rgba(201,168,76,0.025) 25px
    );
  pointer-events: none;
  z-index: 0;
}

/* ── Layout wrapper ────────────────────────────────────────────────────────── */
.page-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Top gold rule ─────────────────────────────────────────────────────────── */
.top-rule {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  margin-bottom: 0;
}

/* ── Header / Hero ─────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 52px 0 40px;
  border-bottom: 1px solid var(--bg-border);
  margin-bottom: 48px;
}

.hero-logo-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.hero-ornament {
  color: var(--gold-muted);
  font-size: 1.4rem;
  opacity: 0.7;
  user-select: none;
}

.hero h1 {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.1;
}

.hero h1 span.gold { color: var(--gold-primary); }

.hero-urdu-subtitle {
  font-family: var(--font-urdu);
  direction: rtl;
  font-size: 1.35rem;
  color: var(--text-gold);
  margin: 12px 0 6px;
  line-height: 2.2;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin-bottom: 24px;
}

/* ── Status badges ─────────────────────────────────────────────────────────── */
.badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border: 1px solid;
  text-transform: uppercase;
}

.badge-gold {
  background: var(--gold-faint);
  border-color: rgba(201,168,76,0.4);
  color: var(--gold-primary);
}

.badge-emerald {
  background: var(--emerald-faint);
  border-color: rgba(45,106,79,0.45);
  color: var(--text-emerald);
}

.badge-neutral {
  background: rgba(255,255,255,0.04);
  border-color: var(--bg-border);
  color: var(--text-secondary);
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

/* ── Section labels ────────────────────────────────────────────────────────── */
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Main workspace (two columns) ─────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

@media (max-width: 768px) {
  .workspace { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Word counter badge ────────────────────────────────────────────────────── */
#word-counter {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  padding: 3px 10px;
  border-radius: 999px;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

#word-counter.warn {
  color: var(--gold-primary);
  border-color: var(--gold-muted);
  background: var(--gold-faint);
}

#word-counter.over {
  color: #e07070;
  border-color: rgba(224,112,112,0.4);
  background: rgba(224,112,112,0.08);
}

/* ── Textarea ──────────────────────────────────────────────────────────────── */
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-urdu);
  font-size: 1.2rem;
  line-height: 2.0;
  padding: 16px 18px;
  resize: vertical;
  min-height: 140px;
  direction: rtl;
  text-align: right;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

textarea::placeholder {
  color: var(--text-muted);
  font-size: 1rem;
}

textarea:focus {
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px var(--gold-faint2);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  letter-spacing: 0.02em;
  user-select: none;
}

.btn-primary {
  background: var(--gold-primary);
  color: #0f0f0f;
  flex: 1;
}

.btn-primary:hover:not(:disabled) {
  background: #d4b05a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,168,76,0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--bg-border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--bg-border);
  background: var(--bg-card-hover);
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(15,15,15,0.3);
  border-top-color: #0f0f0f;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn-primary.loading .spinner { display: block; }
.btn-primary.loading .btn-label { display: none; }

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

/* ── Result area ───────────────────────────────────────────────────────────── */
.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  gap: 12px;
  text-align: center;
}

.result-placeholder-icon {
  font-size: 2.4rem;
  opacity: 0.4;
}

.result-placeholder p {
  font-size: 0.88rem;
  max-width: 200px;
  line-height: 1.5;
}

.result-content { display: none; }
.result-content.visible { display: block; }

.result-block {
  margin-bottom: 20px;
}

.result-block-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-text {
  font-family: var(--font-urdu);
  direction: rtl;
  text-align: right;
  font-size: 1.25rem;
  line-height: 2.2;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  word-break: break-word;
}

.result-text.stemmed {
  color: var(--text-gold);
  border-color: rgba(201,168,76,0.2);
  background: var(--gold-faint);
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

/* ── Stats row ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bg-border);
}

.stat-chip {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  padding: 4px 10px;
  border-radius: 999px;
}

.stat-chip span {
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Validation message ────────────────────────────────────────────────────── */
#validation-msg {
  display: none;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid;
  line-height: 1.5;
}

#validation-msg.error {
  background: rgba(224,112,112,0.08);
  border-color: rgba(224,112,112,0.3);
  color: #e07070;
}

#validation-msg.warn {
  background: var(--gold-faint);
  border-color: rgba(201,168,76,0.3);
  color: var(--gold-primary);
}

/* ── Word table ────────────────────────────────────────────────────────────── */
.word-table-section {
  display: none;
  margin-bottom: 32px;
}

.word-table-section.visible { display: block; }

.word-table-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.word-table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--bg-border);
}

.word-table th.urdu-col { text-align: right; }

.word-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.word-table tr:last-child td { border-bottom: none; }

.word-table tr:hover td { background: rgba(255,255,255,0.02); }

.word-cell {
  font-family: var(--font-urdu);
  direction: rtl;
  text-align: right;
  font-size: 1.1rem;
  line-height: 1.8;
}

.arrow-cell {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.status-changed {
  background: var(--changed-bg);
  border: 1px solid var(--changed-border);
  color: var(--gold-primary);
}

.status-unchanged {
  background: var(--unchanged-bg);
  border: 1px solid var(--unchanged-border);
  color: var(--text-emerald);
}

.word-cell.changed { color: var(--gold-primary); }
.word-cell.unchanged { color: var(--text-emerald); }

/* ── Info bar ──────────────────────────────────────────────────────────────── */
.info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 48px;
}

.info-item {
  flex: 1;
  min-width: 140px;
  padding: 18px 22px;
  border-right: 1px solid var(--bg-border);
}

.info-item:last-child { border-right: none; }

.info-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.info-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.info-value.gold { color: var(--gold-primary); }

@media (max-width: 640px) {
  .info-item { border-right: none; border-bottom: 1px solid var(--bg-border); }
  .info-item:last-child { border-bottom: none; }
}

/* ── Examples section ──────────────────────────────────────────────────────── */
.section-heading {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 48px;
}

.example-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  cursor: pointer;
}

.example-card:hover {
  border-color: var(--gold-muted);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.example-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.example-text {
  font-family: var(--font-urdu);
  direction: rtl;
  text-align: right;
  font-size: 1.05rem;
  line-height: 2.0;
  color: var(--text-primary);
  margin-bottom: 14px;
  word-break: break-word;
}

.example-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Evaluation section ────────────────────────────────────────────────────── */
.eval-section {
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  background: var(--bg-card);
  margin-bottom: 48px;
  position: relative;
  overflow: hidden;
}

.eval-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--emerald), var(--emerald-light), var(--emerald));
}

.eval-header {
  margin-bottom: 28px;
}

.eval-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 580px) {
  .eval-grid { grid-template-columns: 1fr; }
}

.eval-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
}

.eval-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-emerald);
  line-height: 1.1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.eval-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.eval-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--bg-border);
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 28px 0 0;
  border-top: 1px solid var(--bg-border);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.8;
}

.site-footer a {
  color: var(--gold-muted);
  text-decoration: none;
}

.site-footer a:hover { color: var(--gold-primary); }

/* ── Error / API state overlay ─────────────────────────────────────────────── */
.api-error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(224,112,112,0.07);
  border: 1px solid rgba(224,112,112,0.25);
  border-radius: var(--radius-md);
  color: #e07070;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 16px;
  display: none;
}

.api-error.visible { display: flex; }

.api-error-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ── Copy-success flash ────────────────────────────────────────────────────── */
.copy-flash {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--gold-muted);
  color: var(--gold-primary);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 9999;
}

.copy-flash.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Decorative arch/divider ───────────────────────────────────────────────── */
.gold-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 40px 0;
}

.gold-divider::before,
.gold-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bg-border));
}

.gold-divider::before { background: linear-gradient(90deg, transparent, var(--bg-border)); }
.gold-divider::after  { background: linear-gradient(90deg, var(--bg-border), transparent); }

.gold-divider-icon {
  color: var(--gold-muted);
  font-size: 1rem;
  opacity: 0.6;
  user-select: none;
}

/* ── Fade-in animation for result ──────────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-content.visible,
.word-table-section.visible {
  animation: fade-up 0.3s ease forwards;
}

/* ── Scrollbar (webkit) ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
