/* === AI-гигиена · v2 — спокойная палитра, без bounce, AI-chat выглядит как реальный === */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Учебный спокойный фон — slate/cool gray, как Notion / Brilliant */
  --bg: #f7f8fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --ink: #1c2433;
  --ink-soft: #3d465a;
  --muted: #6b7585;
  --line: #e3e7ee;

  --accent: #4f5dff;
  --accent-dark: #3a47d6;
  --accent-soft: #eef0ff;

  --red: #c4392b;
  --red-soft: #fce6e2;
  --green: #2c6f3e;
  --green-soft: #dff0d8;
  --gold-soft: #fff3cc;

  --warn-bg: #fff7e0;
  --warn-border: #e6c34a;

  --chat-bg: #f3f4f8;
  --chat-border: #d8dde6;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(28, 20, 16, 0.05);
  --shadow: 0 2px 8px rgba(28, 20, 16, 0.06);

  --font-display: 'Fraunces', Georgia, serif;
  --font-text: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', Menlo, Monaco, 'Roboto Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

/* === Top bar === */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* === Channel promo card === */
.channel-promo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: linear-gradient(90deg, #eef0ff 0%, #f7f8fb 100%);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 13.5px;
  transition: background 0.2s;
}
.channel-promo:hover {
  background: linear-gradient(90deg, #e3e7ff 0%, #eef0ff 100%);
  color: var(--ink);
}
.promo-badge {
  background: var(--accent);
  color: white;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.promo-title {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.promo-cta {
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
  box-shadow: 0 1px 3px rgba(79, 93, 255, 0.25);
}
.channel-promo:hover .promo-cta {
  background: var(--accent-dark);
  transform: translateX(2px);
}
@media (max-width: 600px) {
  .promo-cta {
    padding: 6px 10px;
    font-size: 11.5px;
  }
  .channel-promo { padding: 10px 14px; gap: 8px; }
  .promo-title { font-size: 13px; }
}

/* === Постоянная навигация между кейсами === */
.case-nav-persistent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 18px;
  font-size: 13.5px;
}
.case-nav-persistent.bottom { margin: 24px 0 0; }
.case-nav-persistent .nav-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}
.case-nav-persistent .nav-link:hover {
  background: var(--accent-soft, #eef0ff);
  color: var(--accent-dark);
}
.case-nav-persistent .nav-link.home {
  color: var(--ink-soft);
  font-size: 12.5px;
  flex-shrink: 0;
  max-width: none;
}
.case-nav-persistent .nav-link.next { text-align: right; }
@media (max-width: 600px) {
  .case-nav-persistent { font-size: 12.5px; padding: 10px 12px; gap: 6px; }
  .case-nav-persistent .nav-link.home { display: none; }
  .case-nav-persistent .nav-link { max-width: 48%; }
  .case-nav-persistent.bottom .nav-link {
    /* На мобиле в нижней навигации показываем только номера, не названия */
    font-size: 13px;
  }
}

/* === Subscribe block (для finish + после кейса) === */
.subscribe-block {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  background: linear-gradient(135deg, #eef0ff 0%, #f7f8fb 100%);
  border: 1px solid var(--accent-soft, #d9dcff);
  border-radius: 10px;
  margin: 20px 0;
}
.subscribe-text { flex: 1; min-width: 0; }
.subscribe-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 4px;
}
.subscribe-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.subscribe-btn { flex-shrink: 0; }
.subscribe-block.subscribe-secondary {
  background: white;
  border: 1px dashed var(--line);
  padding: 14px 18px;
  margin: 18px 0 4px;
}
.subscribe-secondary .subscribe-title { font-size: 15px; }
.subscribe-secondary .subscribe-desc { font-size: 13px; }
.btn-tg {
  display: inline-block;
  background: #0088cc;
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-tg:hover { background: #0077b3; color: white; }
@media (max-width: 700px) {
  .subscribe-block { flex-direction: column; align-items: stretch; gap: 14px; padding: 18px; }
  .subscribe-btn { width: 100%; text-align: center; }
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-logo { width: 26px; height: 26px; }
.progress-pill {
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: white;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

/* === Layout === */
.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 80px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 880px) {
  .layout { grid-template-columns: 1fr 240px; }
}
.content { min-width: 0; }

/* === Headings === */
h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
@media (min-width: 720px) { h1 { font-size: 36px; } }

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 28px 0 12px;
}

h3 {
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 16px;
  margin: 16px 0 8px;
}

.subtitle {
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0 0 24px;
  line-height: 1.55;
}

.case-num-marker {
  font-family: var(--font-text);
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.episode-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* === Cards (общие) === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 16px 0;
}
.card-label {
  font-family: var(--font-text);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

/* === Фактура === */
.card.factura {
  background: #fefdf8;
  border: 1px solid var(--line);
  position: relative;
}
.card.factura::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card.factura .answer-text {
  font-family: var(--font-mono);
  font-size: 13.5px;
  white-space: pre-wrap;
  color: var(--ink);
  line-height: 1.55;
}

/* === Цена ошибки === */
.cost-card {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 14px 0 24px;
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.5;
}
.cost-card .cost-label {
  font-size: 11px;
  font-weight: 700;
  color: #8a5a18;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

/* === Запрос (промпт-карточка) === */
.card.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
}
.prompt-text {
  font-family: var(--font-mono);
  font-size: 13px;
  background: #f8f4ea;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  color: var(--ink);
  border: 1px solid var(--line);
  line-height: 1.5;
}

/* === AI-chat (плохой ответ — как реальный ChatGPT/Claude) === */
.card.ai-chat {
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}
.ai-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: white;
  border-bottom: 1px solid var(--chat-border);
  font-size: 13px;
}
.ai-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1b1b1b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.ai-name {
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}
.ai-counter {
  font-size: 12px;
  color: var(--muted);
}
.ai-counter strong { color: var(--accent-dark); font-weight: 700; }
.ai-chat-body {
  padding: 16px 20px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--ink-soft);
}
.ai-chat-hint {
  padding: 10px 20px;
  background: #fffaf0;
  border-top: 1px solid var(--chat-border);
  font-size: 13px;
  color: var(--muted);
}

/* === Hotspot === */
.hotspot {
  cursor: pointer;
  border-bottom: 2px dotted var(--accent);
  background: transparent;
  padding: 0 2px;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.hotspot:hover {
  background: var(--accent-soft);
  border-color: var(--accent-dark);
}
.hotspot.found {
  background: var(--red-soft);
  border-color: var(--red);
  border-style: solid;
  color: var(--red);
  cursor: default;
}
.hotspot.found::after { content: ' ✓'; font-weight: 700; color: var(--red); }

/* === Inline-разбор === */
.explanation {
  background: white;
  border: 1px solid var(--red-soft);
  border-left: 4px solid var(--red);
  padding: 14px 18px;
  margin: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.55;
}
.explanation .exp-claim { margin-bottom: 6px; color: var(--red); }
.explanation .exp-source { margin-bottom: 8px; color: var(--ink-soft); }
.explanation .exp-text { color: var(--ink); }

/* === Hint controls === */
.hint-controls {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  background: white;
  border-top: 1px solid var(--chat-border);
}
.btn-text {
  background: transparent;
  border: none;
  color: var(--accent-dark);
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-text:hover { background: var(--accent-soft); }

/* === Кнопки === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: white; }
.btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: var(--bg-elev); color: var(--ink); }
.btn.big {
  padding: 14px 26px;
  font-size: 16px;
}

/* === Правило-табличка (без bounce, плоско и спокойно) === */
.rule-plank {
  margin: 32px 0;
  background: var(--ink);
  color: white;
  padding: 22px 26px;
  border-radius: var(--radius);
  text-align: left;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.35;
}
.rule-plank .label {
  display: block;
  font-family: var(--font-text);
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

/* === Side-by-side === */
.compare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 18px 0;
}
@media (min-width: 760px) {
  .compare { grid-template-columns: 1fr 1fr; }
}
.card.good {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
}
.card.good .prompt-text { background: #f3f8f1; }
.card.good .answer-text {
  font-family: var(--font-mono);
  font-size: 13.5px;
  white-space: pre-wrap;
  line-height: 1.55;
}

/* === Footer nav === */
.case-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  gap: 16px;
  flex-wrap: wrap;
}

/* === Sidebar — Карта === */
.escape-map {
  position: sticky;
  top: 80px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  font-size: 13px;
}
.escape-map h4 {
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.map-episode { margin-bottom: 14px; }
.map-episode-name {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.map-cases { display: flex; gap: 6px; flex-wrap: wrap; }
.map-case {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.map-case:hover:not(.locked) { border-color: var(--accent); color: var(--accent-dark); }
.map-case.done {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}
.map-case.current {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: white;
}
.map-case.locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* === Home === */
.home-hero { margin-bottom: 28px; }
.continue-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 18px 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
}
.continue-card .info { flex: 1; }
.continue-card .info-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}
.continue-card .info-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
}

/* === Mobile === */
@media (max-width: 879px) {
  .escape-map {
    position: static;
    margin-top: 24px;
  }
  .layout { padding: 20px 16px 60px; }
  h1 { font-size: 26px; }
}

[x-cloak] { display: none !important; }

/* === A11y: skip link, focus indicators, sr-only === */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 999;
  background: var(--ink);
  color: white;
  padding: 10px 18px;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus {
  left: 0;
  outline: 2px solid var(--accent);
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Универсальный focus-visible */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.btn:focus-visible,
.btn.secondary:focus-visible {
  outline-offset: 3px;
}

/* === Touch targets ≥44px на мобильном === */
@media (max-width: 879px) {
  .btn { min-height: 44px; padding: 12px 22px; }
  .btn-text { min-height: 36px; padding: 8px 12px; }
  .question-option { min-height: 44px; }
  .map-case { width: 36px; height: 36px; font-size: 13px; }
  .case-link, .continue-card .btn { min-height: 48px; }
  body { font-size: 16px; }
  .answer-text { font-size: 15px; }
  .ai-chat-body { font-size: 15px; }
}

/* === prefers-reduced-motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === Mobile bottom safe-area === */
@supports (padding: max(0px)) {
  .layout {
    padding-bottom: max(60px, env(safe-area-inset-bottom));
  }
}
