/* Async Research Assistant — UI.
 *
 * Xarici sriftt ve ya CSS kitabxanasi YOXDUR ve bu qesdlidir: sehife
 * Google Fonts-a getse, saytin gizliliyi ucun uc uncu terefe sorgu acilir ve
 * ilk boyanma xarici seliqeye bagli olur. Sistem srift desti her platformada
 * yaxsi gorunur ve sifir bayt yuklenir.
 *
 * Reng sistemi: bir dene vurgu (accent) ve bir dene sethi (surface) rampasi.
 * Isiqli/qaranliq `prefers-color-scheme` ile avtomatikdir — sayta nizamlayici
 * qoyulmayib, cunki saxlanilacaq veziyyet yeri yoxdur (localStorage bir
 * sorgu-cavab aletinde artiqdir).
 */

:root {
  --bg: #fbfaf8;
  --bg-elev: #ffffff;
  --grid: #00000008;
  --text: #17171a;
  --text-dim: #5d6068;
  --text-faint: #8b8f98;
  --line: #e6e4df;
  --line-soft: #f0eeea;

  --accent: #b4502a;
  --accent-soft: #b4502a14;
  --accent-line: #b4502a33;

  --warn: #8a6100;
  --warn-soft: #f5b62a1f;
  --danger: #a32d20;
  --danger-soft: #a32d2012;

  --wiki: #3a5f9e;
  --arxiv: #9a3b2f;
  --web: #3f7a52;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px #0000000a, 0 8px 24px -12px #00000018;
  --maxw: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --bg-elev: #1b1b1e;
    --grid: #ffffff06;
    --text: #edecea;
    --text-dim: #a6a7ad;
    --text-faint: #7b7d85;
    --line: #2e2e33;
    --line-soft: #242428;

    --accent: #e0835c;
    --accent-soft: #e0835c1a;
    --accent-line: #e0835c3d;

    --warn: #e8b55c;
    --warn-soft: #e8b55c1a;
    --danger: #e8837a;
    --danger-soft: #e8837a14;

    --wiki: #7ba3e0;
    --arxiv: #e08f80;
    --web: #7ec095;

    --shadow: 0 1px 2px #00000040, 0 8px 24px -12px #00000070;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Cox zeif setli fon. `fixed` sehife sursende terpenmesin deye. */
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, #000 35%, transparent 100%);
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

/* --- ust zolaq ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 9px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.brand-text small { font-size: 11.5px; color: var(--text-faint); }

.quota {
  font-size: 12px; color: var(--text-dim); text-align: right;
  font-variant-numeric: tabular-nums; flex: none;
}
.quota b { color: var(--text); font-weight: 600; }
.quota.low b { color: var(--warn); }

/* --- hero ----------------------------------------------------------------- */
.hero { padding: 52px 0 26px; }
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 5.5vw, 40px); line-height: 1.12;
  font-weight: 660; letter-spacing: -0.028em;
}
.hero p { margin: 0; color: var(--text-dim); font-size: 16px; max-width: 58ch; }

/* --- paneller ------------------------------------------------------------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* --- sual sahesi ---------------------------------------------------------- */
.field { position: relative; }

textarea#question {
  width: 100%; display: block; resize: vertical; min-height: 84px;
  padding: 4px 2px 10px; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 17px; line-height: 1.55;
}
textarea#question::placeholder { color: var(--text-faint); }
textarea#question:focus { outline: none; }

.field-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 10px; border-top: 1px solid var(--line-soft);
}
.counter { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 600; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #fff;
  font: inherit; font-size: 14.5px; font-weight: 560; letter-spacing: -0.005em;
  transition: filter .15s, transform .08s, opacity .15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { width: 15px; height: 15px; }

/* --- menbe secimi --------------------------------------------------------- */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.sources { display: contents; border: 0; margin: 0; padding: 0; }
.sources legend {
  font-size: 12px; color: var(--text-faint); padding: 0 4px 0 0; float: left; line-height: 30px;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent;
  font-size: 13px; color: var(--text-dim);
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.pill:hover { border-color: var(--text-faint); }
.pill input { accent-color: var(--accent); margin: 0; width: 14px; height: 14px; }
.pill:has(input:checked) {
  border-color: var(--accent-line); background: var(--accent-soft); color: var(--text);
}
.pill:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-wide { margin-left: auto; }

/* --- numune suallar ------------------------------------------------------- */
.examples {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin-top: 12px;
}
.examples-label { font-size: 12px; color: var(--text-faint); }
.chip {
  border: 1px dashed var(--line); background: transparent; color: var(--text-dim);
  border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px;
  cursor: pointer; text-align: left;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-style: solid; border-color: var(--accent-line); color: var(--text); background: var(--accent-soft); }

/* --- gedis ---------------------------------------------------------------- */
.progress { margin-top: 18px; }
.progress-head { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); }
.progress-head .elapsed { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-faint); font-size: 13px; }

.spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent-line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.track { height: 3px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 12px; }
.bar {
  height: 100%; width: 0%; border-radius: 3px; background: var(--accent);
  /* Genislik JS-den gelir; kecid onu yumsaldir ki, tick-ler siçrayis kimi
     gorunmesin. */
  transition: width .9s cubic-bezier(.22,.61,.36,1);
}

.stages { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.stages li {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-faint);
}

/* Herekete hessasliq ayari acıqdirsa animasiyalari dayandir. Spinner burada
   informasiya dasiyir, ona gore tamamile silinmir — sadece donur ve bar
   sicramir. */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .bar { transition: none; }
  * { scroll-behavior: auto !important; }
}

/* --- xeta ----------------------------------------------------------------- */
.error {
  margin-top: 18px; border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: var(--danger-soft); color: var(--danger); font-size: 14.5px;
}

/* --- cavab ---------------------------------------------------------------- */
#result { margin-top: 18px; }
.answer { padding: 20px; }
.answer-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.answer-head h2 {
  margin: 0; font-size: 15px; font-weight: 600; color: var(--text-dim);
  letter-spacing: -0.01em; flex: 1;
}

.badge {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; flex: none;
  border: 1px solid var(--line); color: var(--text-faint); white-space: nowrap;
}
.badge-warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.prose { font-size: 17px; line-height: 1.72; letter-spacing: -0.003em; }
.prose p { margin: 0 0 1em; }
.prose p:last-child { margin-bottom: 0; }
.prose .note {
  margin-top: 1.1em; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); font-size: 13.5px; line-height: 1.5;
}

/* Sitat isaresi: metnin icinde [1]. Kicik, amma toxunula bilen olcude. */
.cite {
  display: inline-block; min-width: 18px; padding: 0 5px; margin: 0 1px;
  border-radius: 5px; background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent); font-size: 11.5px; font-weight: 600; line-height: 16px;
  text-align: center; text-decoration: none; vertical-align: 1.5px;
}
.cite:hover { background: var(--accent); color: #fff; }

.timings {
  margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--line-soft);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.timing { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; }
.timing.failed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot.wikipedia { background: var(--wiki); }
.dot.arxiv { background: var(--arxiv); }
.dot.web { background: var(--web); }
.timing .cached { color: var(--accent); font-weight: 600; }
.timings .total { margin-left: auto; }

/* --- menbeler ------------------------------------------------------------- */
.refs { margin-top: 22px; }
.refs h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .07em; }
.refs-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }

.ref {
  display: grid; grid-template-columns: 26px 1fr; gap: 11px;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev); scroll-margin-top: 76px;
  transition: border-color .2s, background .2s;
}
.ref:target { border-color: var(--accent); background: var(--accent-soft); }
.ref-num {
  font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 6px; height: 21px; display: grid; place-items: center;
}
.ref-title { font-size: 14.5px; font-weight: 560; letter-spacing: -0.008em; }
.ref-title a { color: var(--text); text-decoration: none; }
.ref-title a:hover { color: var(--accent); text-decoration: underline; }
.ref-meta { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 11.5px; color: var(--text-faint); }
.origin { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.origin.wikipedia { color: var(--wiki); }
.origin.arxiv { color: var(--arxiv); }
.origin.web { color: var(--web); }
.ref-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ref-snippet { margin-top: 7px; font-size: 13px; line-height: 1.55; color: var(--text-dim); }

/* --- alt ------------------------------------------------------------------ */
.site-foot { padding: 40px 20px 48px; }
.site-foot p { margin: 0; font-size: 12px; color: var(--text-faint); line-height: 1.6; }

/* --- dar ekran ------------------------------------------------------------ */
@media (max-width: 560px) {
  .hero { padding: 34px 0 20px; }
  .quota { display: none; }          /* dar ekranda ad ile kvota toqqusur */
  .pill-wide { margin-left: 0; }
  .answer { padding: 16px; }
  .prose { font-size: 16px; }
  .timings .total { margin-left: 0; }
}

/* --- menbe qeydi ---------------------------------------------------------- */
/* arXiv (ve ya baska bir menbe) defaultda sonuludursa sebebi burada yazilir.
   Bezek deyil — istifadeci uc menbe gozleyib iki alanda sebebini bilmelidir. */
.source-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 24%, transparent);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.55;
}
.source-note strong { color: var(--warn); font-weight: 600; }
.source-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--line-soft); color: var(--text);
}
