/* Learnify AI palette, from the plan (section 7): Multan tile cobalt and Kashi teal on paper cream.
   No purple gradients. Status is never colour alone: every badge has an icon + word. */
:root {
  --cobalt: #1d4e89;
  --cobalt-dark: #153a68;
  --teal: #0f766e;
  --cream: #faf6ee;
  --white: #ffffff;
  --ink: #1b2430;
  --slate: #566070;
  --sand: #e3dac9;
  --terracotta: #b94e1f;
  --success: #2a7248;
  --success-bg: #e6f3ea;
  --warning: #8a5c00;
  --warning-bg: #fff4db;
  --error: #b3261e;
  --error-bg: #fbe9e7;
  --info-bg: #e8eef7;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.6;
}
h1, h2, h3 { font-family: "Source Serif 4", Georgia, serif; color: var(--cobalt); line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 40px; } h2 { font-size: 28px; } h3 { font-size: 20px; }
p { margin: 0 0 12px; }
a { color: var(--cobalt); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.kicker { color: var(--teal); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--slate); }
.mono, code { font-family: "Noto Sans Mono", ui-monospace, monospace; }

/* Tile band: thin geometric Multan-tile motif, subtle, under header / above footer. */
.tile-band {
  height: 12px;
  background:
    repeating-linear-gradient(45deg, var(--cobalt) 0 8px, transparent 8px 16px),
    repeating-linear-gradient(-45deg, var(--teal) 0 8px, transparent 8px 16px),
    var(--info-bg);
  opacity: .55;
}

header.site { background: var(--white); border-bottom: 1px solid var(--sand); }
.header-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.wordmark { font-family: "Source Serif 4", Georgia, serif; font-size: 28px; font-weight: 700; color: var(--cobalt); text-decoration: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--sand); border-radius: 999px; padding: 4px 12px;
  font-size: 14px; background: var(--cream); color: var(--ink); min-height: 32px;
}
.chip.offline { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); font-weight: 700; }
.chip.ai { background: #e3f2f0; border-color: var(--teal); color: var(--teal); font-weight: 700; }
nav.main { margin-left: auto; display: flex; gap: 16px; flex-wrap: wrap; }
nav.main a { font-size: 14px; }

section { padding: 40px 0; }
.hero { padding-top: 40px; }
.hero p.lede { font-size: 20px; max-width: 640px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 8px; border: 1px solid transparent;
  font-size: 16px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-dark); }
.btn-secondary { background: var(--white); color: var(--teal); border-color: var(--teal); }
.btn-terracotta { background: var(--terracotta); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, button:focus-visible, textarea:focus-visible,
select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--teal); outline-offset: 2px;
}
.example {
  background: var(--white); border: 1px solid var(--sand); border-radius: var(--radius);
  padding: 16px; margin-top: 24px; max-width: 640px;
}
.example .from, .example .to { margin: 4px 0; }
.example .to { color: var(--teal); font-weight: 700; }

.notice {
  background: var(--info-bg); border: 1px solid var(--cobalt); border-radius: var(--radius);
  padding: 16px; margin-top: 24px;
}
.notice summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }

/* Tool layout: two columns on desktop, one column on mobile. */
.tool-grid { display: grid; grid-template-columns: 40% 60%; gap: 24px; align-items: start; }
@media (max-width: 899px) { .tool-grid { grid-template-columns: 1fr; } }
.card { background: var(--white); border: 1px solid var(--sand); border-radius: var(--radius); padding: 16px; }
label { display: block; font-weight: 700; margin: 12px 0 4px; }
textarea, select {
  width: 100%; border: 1px solid var(--sand); border-radius: 8px; padding: 12px;
  font: inherit; background: var(--white); color: var(--ink); min-height: 44px;
}
textarea { min-height: 180px; resize: vertical; }
textarea:focus, select:focus { border: 2px solid var(--cobalt); outline: none; }
textarea[aria-invalid="true"] { border: 2px solid var(--error); }
.field-error { color: var(--error); font-weight: 700; margin-top: 8px; }
.field-error::before { content: "✕ "; }
.number-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); border-radius: 8px; padding: 12px; font-weight: 700; }
.char-count { font-size: 14px; color: var(--slate); text-align: right; }
.sample-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sample-btn { min-height: 44px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--teal); background: var(--white); color: var(--teal); font-weight: 700; cursor: pointer; }
.sample-btn:hover { background: #e3f2f0; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--sand); margin-bottom: 16px; }
.tab {
  min-height: 44px; padding: 10px 16px; border: none; background: none; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--slate); border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--cobalt); border-bottom-color: var(--cobalt); }
.tabpanel[hidden] { display: none; }

.mode-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px;
  font-size: 14px; font-weight: 700; border: 1px solid transparent; min-height: 32px;
}
.badge.ok { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.badge.err { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.takeaway { font-size: 20px; font-family: "Source Serif 4", Georgia, serif; color: var(--cobalt); }
.passage-original { background: var(--cream); border: 1px solid var(--sand); border-radius: 8px; padding: 12px; }
.passage-original .sent { border-radius: 4px; padding: 1px 2px; }
.passage-original .sent.hl { background: #ffe9a8; outline: 2px solid var(--terracotta); }
.term { border-bottom: 2px solid var(--teal); font-weight: 700; }
.urdu { font-family: "Noto Nastaliq Urdu", "Noto Sans", serif; font-size: 18px; line-height: 2; }
[dir="rtl"] { text-align: right; }
/* Non-Latin scripts get their own font, picked up from the lang attribute
   the app sets on local-meaning text (Urdu, Arabic, Bengali, Hindi, Chinese). */
[lang="ar"] { font-family: "Noto Naskh Arabic", "Noto Sans", serif; }
[lang="bn"] { font-family: "Noto Sans Bengali", "Noto Sans", sans-serif; }
[lang="hi"] { font-family: "Noto Sans Devanagari", "Noto Sans", sans-serif; }
[lang="zh"] { font-family: "Noto Sans SC", "Noto Sans", sans-serif; }
.lang-strip { margin-top: 12px; font-size: 14px; color: var(--muted); letter-spacing: .2px; }

.glossary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 599px) { .glossary { grid-template-columns: 1fr; } }
.glossary article { border: 1px solid var(--sand); border-radius: 8px; padding: 12px; }
.glossary h3 { margin-bottom: 4px; }

.quiz-item { border: 1px solid var(--sand); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.quiz-item.answered-correct { border-color: var(--success); }
.quiz-item.answered-wrong { border-color: var(--error); }
.options { display: grid; gap: 8px; margin: 12px 0; }
.option {
  min-height: 44px; text-align: left; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--sand); background: var(--white); font: inherit; cursor: pointer;
}
.option:hover { background: var(--info-bg); }
.option.correct { background: var(--success-bg); border-color: var(--success); font-weight: 700; }
.option.wrong { background: var(--error-bg); border-color: var(--error); font-weight: 700; }
.option:disabled { cursor: default; opacity: 1; }
.feedback { margin-top: 8px; }
.evidence { background: var(--cream); border-left: 4px solid var(--teal); padding: 8px 12px; margin-top: 8px; }
.link-btn { background: none; border: none; color: var(--cobalt); font: inherit; font-weight: 700; cursor: pointer; min-height: 44px; padding: 8px 4px; text-decoration: underline; }

.score-ring {
  width: 120px; height: 120px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; margin: 16px auto; text-align: center;
  background: conic-gradient(var(--teal) calc(var(--score, 0) * 1%), var(--sand) 0);
}
.score-ring span { background: var(--white); width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Flashcards: plain show/hide flip (no 3D transform. 3D flips do not
   render reliably inside a <button> in some browsers, and the back face
   never became visible in the 21 Nov live click-through). */
.flash-wrap { text-align: center; }
.flashcard {
  display: block; width: 100%; max-width: 420px; min-height: 220px; margin: 0 auto 16px;
  background: none; border: none; cursor: pointer; font: inherit;
}
.flash-inner { display: block; position: relative; width: 100%; min-height: 220px; }
.flash-face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 24px;
  background: var(--white); border: 1px solid var(--sand); border-radius: var(--radius);
}
.flash-back { display: none; background: var(--info-bg); }
.flashcard.flipped .flash-front { display: none; }
.flashcard.flipped .flash-back { display: flex; animation: flip-in .2s ease-out; }
@keyframes flip-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.flash-term { font-family: "Source Serif 4", Georgia, serif; font-size: 28px; color: var(--cobalt); }
.progress { font-weight: 700; }

/* Skeleton loading */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--sand) 25%, #f2ecdf 50%, var(--sand) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; min-height: 20px; margin: 8px 0; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.fade-in { animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 599px) { .steps { grid-template-columns: 1fr; } }
.step-num { font-family: "Source Serif 4", Georgia, serif; font-size: 28px; color: var(--terracotta); font-weight: 700; }
table.results { border-collapse: collapse; width: 100%; }
table.results th, table.results td { border: 1px solid var(--sand); padding: 8px 12px; text-align: left; }
table.results th { background: var(--info-bg); }
footer.site { background: var(--white); border-top: 1px solid var(--sand); padding: 24px 0; }
footer.site p { margin: 0 0 8px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
