/* SawalAI — dark indigo/violet theme, mobile-first */
:root {
  --bg: #0d0d1a;
  --bg2: #12122a;
  --card: #1a1a32;
  --line: #2b2b4d;
  --text: #f1f1fa;
  --muted: #a7a7c8;
  --indigo: #6366f1;
  --violet: #a855f7;
  --grad: linear-gradient(135deg, #6366f1, #a855f7);
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background:
    linear-gradient(rgba(13, 13, 26, 0.85), rgba(13, 13, 26, 0.9)),
    url("bg.jpg") center top / cover no-repeat fixed,
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.65;
}
a { color: #b9bdfc; }
img, svg { vertical-align: middle; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
  background: rgba(13, 13, 26, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.25rem; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.nav-links a:hover { color: var(--text); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 64px 20px 48px;
  background:
    radial-gradient(600px 300px at 20% 0%, rgba(99, 102, 241, 0.25), transparent),
    radial-gradient(600px 300px at 80% 10%, rgba(168, 85, 247, 0.22), transparent);
}
.hero-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; z-index: 0;
}
.hero-shade {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(rgba(13, 13, 26, 0.55), rgba(13, 13, 26, 0.78));
}
.hero > *:not(.hero-video):not(.hero-shade) { position: relative; z-index: 2; }
.badge {
  display: inline-block;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 6px 16px; border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--indigo);
  color: #c9ccff; margin-bottom: 18px;
}
.hero h1 { font-size: 2.4rem; line-height: 1.2; margin-bottom: 14px; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); max-width: 560px; margin: 0 auto 26px; font-size: 1.05rem; }
.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 30px; }
.btn {
  display: inline-block; text-decoration: none; cursor: pointer;
  padding: 12px 26px; border-radius: 999px; font-weight: 700; font-size: 1rem;
  border: 1px solid transparent;
}
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--indigo); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.stats { display: flex; gap: 36px; justify-content: center; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 1.5rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats span { color: var(--muted); font-size: 0.85rem; }

/* ---------- sections / cards ---------- */
.section { padding: 44px 20px; max-width: 1020px; margin: 0 auto; }
.section h2 { text-align: center; font-size: 1.7rem; margin-bottom: 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.steps, .grid { display: grid; gap: 16px; margin-top: 24px; grid-template-columns: 1fr; }
.step-num {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.step h3 { margin-bottom: 8px; }
.step p { color: var(--muted); font-size: 0.95rem; }

/* ---------- chat ---------- */
.chat-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px; margin-top: 20px;
  max-width: 720px; margin-left: auto; margin-right: auto;
}
.key-panel { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.key-status { font-size: 0.9rem; margin-bottom: 10px; color: var(--muted); }
.key-status.ok { color: #7ef0a0; }
.key-row { display: flex; gap: 8px; flex-wrap: wrap; }
.key-row input {
  flex: 1; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 14px; font-size: 0.9rem;
}
.tiny { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--indigo); color: #c9ccff;
  border-radius: 999px; padding: 7px 15px; font-size: 0.85rem; cursor: pointer;
}
.chip:hover { background: rgba(99, 102, 241, 0.25); }
.chat-box {
  min-height: 220px; max-height: 380px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 6px 2px; margin-bottom: 12px;
}
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 0.95rem; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.loading { color: var(--muted); font-style: italic; }
.msg.error { border-color: #f87171; color: #fca5a5; }
.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; color: var(--text); padding: 12px 18px; font-size: 0.95rem;
}
.chat-form input:focus { outline: none; border-color: var(--indigo); }

/* ---------- articles ---------- */
.article-card { text-decoration: none; color: var(--text); display: block; transition: transform 0.15s, border-color 0.15s; }
.article-card:hover { transform: translateY(-3px); border-color: var(--indigo); }
.art-emoji { font-size: 2rem; margin-bottom: 10px; }
.article-card h3 { margin-bottom: 6px; }
.article-card p { color: var(--muted); font-size: 0.92rem; margin-bottom: 10px; }
.read { color: #b9bdfc; font-weight: 700; font-size: 0.9rem; }

/* ---------- faq ---------- */
.faq-item { margin-bottom: 12px; }
.faq-item summary { cursor: pointer; font-weight: 700; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "+ "; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }
.faq-item[open] summary::before { content: "− "; }
.faq-item p { color: var(--muted); margin-top: 10px; font-size: 0.95rem; }

/* ---------- article pages ---------- */
.article-wrap { max-width: 720px; margin: 0 auto; padding: 36px 20px 20px; }
.article-wrap .art-emoji { font-size: 3rem; }
.article-wrap h1 { font-size: 1.9rem; margin: 12px 0 6px; }
.meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 24px; }
.article-body h2 { font-size: 1.3rem; margin: 28px 0 10px; color: #c9ccff; }
.article-body p, .article-body li { color: #d7d7e8; margin-bottom: 12px; }
.article-body ul, .article-body ol { padding-left: 22px; }
.article-body b, .article-body strong { color: #fff; }
.cta-box {
  margin: 32px 0; padding: 22px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(168,85,247,0.18));
  border: 1px solid var(--indigo); text-align: center;
}
.cta-box p { margin-bottom: 14px; }
.back-link { display: inline-block; margin: 10px 0 30px; text-decoration: none; }

/* ---------- footer ---------- */
footer { text-align: center; padding: 34px 20px 44px; border-top: 1px solid var(--line); color: var(--muted); }
footer .tiny { max-width: 640px; margin: 10px auto 0; }

/* ---------- desktop ---------- */
@media (min-width: 700px) {
  .hero h1 { font-size: 3.2rem; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 60px 24px; }
}

/* Videos section */
.video-card { padding: 12px; }
.video-card video { width: 100%; border-radius: 10px; display: block; background: #000; }
.video-card .caption { margin: 10px 4px 2px; font-size: 0.95rem; color: var(--muted); }

/* ---------- scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- card hover ---------- */
.card { transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease; }
a.card:hover, .card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(99, 102, 241, 0.18); border-color: rgba(99, 102, 241, 0.45); }

/* ---------- back to top ---------- */
#toTop {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: #fff;
  font-size: 1.3rem; cursor: pointer; opacity: 0; pointer-events: none;
  transform: translateY(12px); transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#toTop.show { opacity: 1; pointer-events: auto; transform: none; }
#toTop:hover { border-color: rgba(99, 102, 241, 0.6); }

/* ---------- share rail ---------- */
#share-rail {
  position: fixed; left: 14px; top: 50%; transform: translateY(-50%); z-index: 60;
  display: none; flex-direction: column; gap: 10px;
}
@media (min-width: 1100px) { #share-rail { display: flex; } }
.sh {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line); color: #fff;
  text-decoration: none; font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.sh:hover { transform: scale(1.12); border-color: rgba(99, 102, 241, 0.6); }
.sh-fb { font-family: sans-serif; }

/* ---------- nav/footer links ---------- */
.nav-links a, footer a { color: inherit; }
footer a { text-decoration: underline; }

/* ---------- article search ---------- */
.search-wrap { position: relative; max-width: 520px; margin: 18px auto 0; }
#article-search {
  width: 100%; padding: 12px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: #fff; font-size: 1rem;
}
#article-search:focus { outline: none; border-color: rgba(99, 102, 241, 0.7); }
.search-results {
  position: absolute; top: 110%; left: 0; right: 0; z-index: 50;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); text-align: left;
}
.sr-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; text-decoration: none; color: inherit; }
.sr-item:hover { background: rgba(99, 102, 241, 0.12); }
.sr-lang {
  flex: none; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  background: rgba(99, 102, 241, 0.2); border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 6px; padding: 2px 7px; color: #c7c9ff;
}
.sr-title { font-size: 0.92rem; }
.sr-empty { padding: 14px; color: var(--muted); font-size: 0.9rem; text-align: center; }

.article-hero{width:100%;max-height:380px;object-fit:cover;border-radius:12px;margin:0 0 1.2rem}
.card-thumb{width:100%;height:150px;object-fit:cover;border-radius:8px;margin-bottom:.6rem}

/* ---------- cinematic upgrades ---------- */
#starfield { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1 !important; pointer-events: none; }
.hero > #starfield { position: absolute; }

/* marquee / running text strip */
.marquee { overflow: hidden; background: rgba(5,5,16,.85); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .7rem 0; }
.marquee-track { display: inline-flex; align-items: center; gap: 2.5rem; white-space: nowrap; padding-right: 2.5rem; animation: marquee 26s linear infinite; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .82rem; color: #c7d2fe; }
.marquee-track i { color: #a855f7; font-style: normal; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* rainbow gradient border on chat card */
.chat-card { border: 2px solid transparent; background: linear-gradient(var(--bg2), var(--bg2)) padding-box, linear-gradient(135deg, #3b82f6, #a855f7, #ec4899, #f97316) border-box; }

/* neon ring cinema panel */
.cinema-panel { position: relative; overflow: hidden; background: #05050f; border-radius: 24px; margin: 3rem auto; max-width: 1020px; width: calc(100% - 40px); padding: 4.5rem 1.5rem; text-align: center; border: 1px solid var(--line); }
.neon-ring { position: absolute; left: 50%; top: 50%; width: min(78vw, 430px); height: min(78vw, 430px); transform: translate(-50%,-50%); border-radius: 50%; border: 3px solid rgba(96,165,250,.85); box-shadow: 0 0 60px 10px rgba(59,130,246,.5), 0 0 140px 40px rgba(59,130,246,.22), inset 0 0 60px rgba(59,130,246,.3); animation: ringPulse 4s ease-in-out infinite; pointer-events: none; }
@keyframes ringPulse { 50% { box-shadow: 0 0 90px 20px rgba(59,130,246,.65), 0 0 190px 60px rgba(59,130,246,.28), inset 0 0 80px rgba(59,130,246,.4); } }
.cinema-inner { position: relative; z-index: 1; }
.cinema-inner h2 { font-size: 2rem; margin-bottom: .6rem; }
.cinema-inner p { color: var(--muted); margin-bottom: 1.4rem; }
.btn-glow { box-shadow: 0 0 24px rgba(168,85,247,.55); }

/* giant footer wordmark */
.giant-word { font-size: clamp(3.5rem, 17vw, 13rem); font-weight: 900; letter-spacing: .04em; line-height: 1; text-align: center; user-select: none; margin: 1rem 0 .5rem; background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.02)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* sticky bottom CTA */
#sticky-cta { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 90px); background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; font-weight: 700; padding: .8rem 1.7rem; border-radius: 999px; z-index: 60; text-decoration: none; box-shadow: 0 8px 30px rgba(99,102,241,.55); transition: transform .35s ease; font-size: .95rem; }
#sticky-cta.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .marquee-track, .neon-ring { animation: none; }
  #sticky-cta { transition: none; }
}

/* ---------- AI image studio ---------- */
.studio-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.studio-row input[type="text"] { flex: 1; min-width: 180px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 14px; font-size: .95rem; }
.studio-row select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 12px; font-size: .9rem; }
.studio-out { min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px 0; }
.studio-img { max-width: 100%; max-height: 520px; border-radius: 12px; border: 1px solid var(--line); }
.studio-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.studio-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--violet); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---------- topics sidebar ---------- */
.articles-layout { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.topics-sidebar { position: sticky; top: 76px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; max-height: calc(100vh - 100px); overflow-y: auto; }
.topics-sidebar h3 { font-size: 1.05rem; margin-bottom: 10px; }
#topic-search { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 9px 12px; font-size: .9rem; margin-bottom: 6px; }
.topic-cat { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 0 6px; }
.topic-item { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 6px; cursor: pointer; color: var(--text); text-align: left; font-size: .9rem; font-family: inherit; }
.topic-item:hover { background: var(--card); border-color: var(--line); }
.topic-item.active { background: rgba(99,102,241,.15); border-color: var(--indigo); }
.topic-item img { width: 52px; height: 36px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.topic-item .tname { flex: 1; }
.topic-item .tcount { font-size: .75rem; color: var(--muted); background: var(--card); border-radius: 999px; padding: 1px 8px; flex-shrink: 0; }
#topic-reset { width: 100%; margin-top: 10px; }
.topic-empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 12px 0; }
@media (max-width: 900px) {
  .articles-layout { grid-template-columns: 1fr; }
  .topics-sidebar { position: static; max-height: 430px; order: -1; }
}
