/* Инструментът: начален екран, въпросник, резултат, checklist, форма. */

/* --- Заглавна лента ------------------------------------------------------- */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.masthead__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-block: var(--sp-3);
}
.masthead__mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--t-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.masthead__note { font-size: var(--t-xs); color: var(--ink-faint); }

/* Лентата е sticky, затова всичко, към което скачаме, си оставя място под нея —
   иначе заглавието на секцията изчезва зад нея при скок от препратка или при фокус. */
:where(h1, h2, h3, .ledger__row, .section) { scroll-margin-top: 5rem; }

/* --- Начален екран -------------------------------------------------------- */
.hero { padding: var(--sp-8) 0 var(--sp-7); }
.hero__eyebrow {
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: var(--sp-4);
}
.hero h1 { margin-bottom: var(--sp-5); }
.hero__sub {
  font-size: var(--t-md);
  color: var(--ink-2);
  max-width: 34rem;
  margin-bottom: var(--sp-6);
}
.hero__points {
  list-style: none;
  margin: 0 0 var(--sp-6);
  padding: 0;
  border-top: 1px solid var(--rule);
}
.hero__points li {
  border-bottom: 1px solid var(--rule);
  padding: var(--sp-3) 0 var(--sp-3) var(--sp-5);
  position: relative;
  color: var(--ink-2);
  font-size: var(--t-sm);
}
.hero__points li::before {
  content: '';
  position: absolute;
  left: 0; top: 1.45em;
  width: 10px; height: 1px;
  background: var(--accent);
}

/* --- Прогрес -------------------------------------------------------------- */
.progress {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding-block: var(--sp-3);
}
.progress__rail {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.progress__step {
  font-size: var(--t-xs);
  color: var(--ink-faint);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--rule);
  transition: color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress__step[data-state='done'] { color: var(--ink-muted); border-color: var(--accent); }
.progress__step[data-state='current'] { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.progress__count { font-size: var(--t-xs); color: var(--ink-faint); }

@media (max-width: 720px) {
  .progress__rail { grid-template-columns: 1fr; }
  .progress__step { display: none; border-bottom: 0; padding-bottom: 0; }
  .progress__step[data-state='current'] { display: block; }
  .progress__bar {
    height: 2px;
    background: var(--rule);
    margin-top: var(--sp-2);
  }
  .progress__bar span { display: block; height: 100%; background: var(--accent); transition: width 0.25s ease; }
}
@media (min-width: 721px) { .progress__bar { display: none; } }

/* --- Въпроси -------------------------------------------------------------- */
.screen { padding: var(--sp-6) 0 var(--sp-8); }
.screen__title {
  font-size: var(--t-xl);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--rule-strong);
}

.question { margin-bottom: var(--sp-7); border: 0; padding: 0; }
.question__head {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.question__no {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  line-height: 1;
  color: var(--rule-strong);
  min-width: 1.8ch;
  padding-top: 0.1em;
}
.question__text {
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 600;
  line-height: 1.35;
  padding: 0;
}
.question__help {
  font-size: var(--t-sm);
  color: var(--ink-muted);
  margin-top: var(--sp-2);
  font-family: var(--font-body);
  font-weight: 400;
}
.question[data-invalid='true'] .question__no { color: var(--st-risk); }

.options { display: flex; flex-direction: column; gap: 0; margin-left: calc(1.8ch + var(--sp-4)); }
@media (max-width: 560px) { .options { margin-left: 0; } }

.option { position: relative; display: block; }
.option input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.option__label {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.12s ease;
  font-size: var(--t-base);
}
.option:first-child .option__label { border-top: 1px solid var(--rule); }
.option__label:hover { background: var(--paper-2); }
.option__mark {
  flex: none;
  width: 18px; height: 18px;
  margin-top: 0.3em;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--paper);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.option input:checked + .option__label { background: var(--accent-soft); }
.option input:checked + .option__label .option__mark {
  border-color: var(--accent);
  border-width: 5px;
}
.option input:focus-visible + .option__label {
  box-shadow: var(--focus);
  border-radius: var(--radius);
}
.option__key {
  margin-left: auto;
  font-size: var(--t-xs);
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0 0.35em;
  align-self: center;
}
@media (max-width: 720px) { .option__key { display: none; } }

.autofilled-note {
  font-size: var(--t-xs);
  color: var(--st-warn);
  margin-top: var(--sp-2);
}

/* --- Долна лента ---------------------------------------------------------- */
.actionbar {
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--rule);
  padding-block: var(--sp-3);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  z-index: 16;
}
.actionbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}
.actionbar__msg { font-size: var(--t-sm); color: var(--st-risk); }

/* --- Резултат ------------------------------------------------------------- */
.result { padding: var(--sp-7) 0 var(--sp-6); }
.result__urgent {
  border-left: 3px solid var(--st-warn);
  background: var(--st-warn-soft);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--t-sm);
  font-weight: 500;
  margin-bottom: var(--sp-5);
}
.result__band {
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--sp-4);
  display: inline-block;
  padding: 0.35em 0.7em;
  border-radius: 2px;
}
.result[data-overall='high'] .result__band { background: var(--st-risk-soft); color: var(--st-risk); }
.result[data-overall='medium'] .result__band { background: var(--st-warn-soft); color: var(--st-warn); }
.result[data-overall='low'] .result__band { background: var(--st-ok-soft); color: var(--st-ok); }
.result[data-overall='prep'] .result__band { background: var(--paper-3); color: var(--ink-muted); }

.result h1 { font-size: var(--t-2xl); margin-bottom: var(--sp-4); }
.result__body { font-size: var(--t-md); color: var(--ink-2); max-width: 36rem; }

.disclaimer {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: var(--sp-4) 0;
  margin: var(--sp-6) 0;
  font-size: var(--t-sm);
  color: var(--ink-muted);
}
.disclaimer strong { color: var(--ink-2); }

/* --- Четирите области ----------------------------------------------------- */
.ledger { margin: var(--sp-6) 0; border-top: 1px solid var(--rule-strong); }
.ledger__row {
  border-bottom: 1px solid var(--rule);
  border-left: 4px solid var(--rule-strong);
  padding: var(--sp-5) var(--sp-4);
}
.ledger__row[data-status='ok'] { border-left-color: var(--st-ok); }
.ledger__row[data-status='warn'] { border-left-color: var(--st-warn); }
.ledger__row[data-status='risk'] { border-left-color: var(--st-risk); }
.ledger__row[data-status='na'] { border-left-color: var(--rule); }

.ledger__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.ledger__name { font-family: var(--font-display); font-size: var(--t-lg); font-weight: 600; }
.ledger__verdict { color: var(--ink-2); margin-bottom: var(--sp-3); }
.ledger__next { margin: 0; padding-left: var(--sp-5); font-size: var(--t-sm); color: var(--ink-muted); }
.ledger__next li { margin-bottom: var(--sp-1); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.3em 0.6em;
  border-radius: 2px;
  white-space: nowrap;
}
.chip svg { width: 0.95em; height: 0.95em; }
.chip[data-status='ok'] { background: var(--st-ok-soft); color: var(--st-ok); }
.chip[data-status='warn'] { background: var(--st-warn-soft); color: var(--st-warn); }
.chip[data-status='risk'] { background: var(--st-risk-soft); color: var(--st-risk); }
.chip[data-status='na'] { background: var(--st-na-soft); color: var(--st-na); }

/* --- Checklist ------------------------------------------------------------ */
.checklist { margin: var(--sp-7) 0; }
.checklist__intro { color: var(--ink-muted); font-size: var(--t-sm); margin-bottom: var(--sp-5); }

.section { border-top: 1px solid var(--rule); }
.section > summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 600;
}
.section > summary::-webkit-details-marker { display: none; }
.section__chev { margin-left: auto; color: var(--ink-faint); transition: transform 0.2s ease; }
.section[open] .section__chev { transform: rotate(180deg); }
.section__body { padding: 0 0 var(--sp-5); }
.section__priority {
  border-left: 3px solid var(--st-risk);
  background: var(--st-risk-soft);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: var(--t-sm);
}
.section__lead { font-size: var(--t-sm); color: var(--ink-muted); margin-bottom: var(--sp-3); }
.section__items { list-style: none; margin: 0; padding: 0; }
.section__items li {
  position: relative;
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-6);
  border-bottom: 1px solid var(--paper-3);
  font-size: var(--t-sm);
}
.section__items li::before {
  content: '';
  position: absolute;
  left: 0; top: 1.05em;
  width: 14px; height: 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
}
.flag-check {
  display: inline-block;
  font-size: var(--t-xs);
  color: var(--st-warn);
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 0.35em;
  margin-left: 0.4em;
  vertical-align: 0.1em;
  white-space: nowrap;
}

/* --- CTA и форма ---------------------------------------------------------- */
.cta {
  border: 1px solid var(--rule-strong);
  background: var(--paper-2);
  padding: var(--sp-6) var(--sp-5);
  margin: var(--sp-7) 0;
}
.cta h2 { font-size: var(--t-lg); }
.cta__intro { color: var(--ink-2); font-size: var(--t-sm); margin-bottom: var(--sp-5); }

.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: var(--t-sm); font-weight: 500; margin-bottom: var(--sp-2); }
.field label .hint { color: var(--ink-faint); font-weight: 400; }
.field input[type='text'],
.field input[type='email'],
.field input[type='tel'],
.field textarea {
  width: 100%;
  font: inherit;
  font-size: var(--t-base);
  padding: 0.65em 0.75em;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
.field textarea { min-height: 6em; resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { box-shadow: var(--focus); }
.field--inline { display: flex; gap: var(--sp-5); align-items: center; flex-wrap: wrap; }
.field--inline label { margin: 0; }

.radio-inline { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--t-sm); }

.consent {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin: var(--sp-5) 0 var(--sp-4);
}
.consent input { margin-top: 0.35em; flex: none; width: 18px; height: 18px; accent-color: var(--accent); }

.privacy-note {
  font-size: var(--t-xs);
  color: var(--ink-muted);
  line-height: 1.6;
  border-top: 1px solid var(--rule);
  padding-top: var(--sp-3);
  margin-top: var(--sp-4);
}

.form-msg { font-size: var(--t-sm); margin-top: var(--sp-3); }
.form-msg[data-kind='error'] { color: var(--st-risk); }
.form-msg[data-kind='ok'] { color: var(--st-ok); }

.success {
  border-left: 3px solid var(--st-ok);
  background: var(--st-ok-soft);
  padding: var(--sp-5);
}
.success h2 { font-size: var(--t-lg); margin-bottom: var(--sp-3); }

/* --- Одит (?debug=1) ------------------------------------------------------ */
.audit {
  margin: var(--sp-7) 0;
  border: 1px dashed var(--rule-strong);
  padding: var(--sp-5);
  background: var(--paper-2);
  font-size: var(--t-sm);
}
.audit h2 { font-size: var(--t-md); }
.audit table { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-5); font-size: var(--t-xs); }
.audit th, .audit td { text-align: left; padding: var(--sp-2) var(--sp-2); border-bottom: 1px solid var(--rule); vertical-align: top; }
.audit th { color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.audit pre {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: var(--sp-3);
  overflow-x: auto;
  font-size: 0.72rem;
  line-height: 1.5;
}
.audit .fired { color: var(--st-risk); font-weight: 600; }
.audit .skipped { color: var(--ink-faint); }

/* --- Футър ---------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--rule);
  margin-top: var(--sp-8);
  padding: var(--sp-6) 0 var(--sp-7);
  font-size: var(--t-xs);
  color: var(--ink-muted);
  line-height: 1.7;
}
.footer__id { color: var(--ink-2); font-weight: 500; }
.footer a { color: var(--ink-2); }

/* --- Появяване ------------------------------------------------------------ */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.rise > * { animation: rise 0.42s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }
.rise > *:nth-child(1) { animation-delay: 0ms; }
.rise > *:nth-child(2) { animation-delay: 40ms; }
.rise > *:nth-child(3) { animation-delay: 80ms; }
.rise > *:nth-child(4) { animation-delay: 120ms; }
.rise > *:nth-child(5) { animation-delay: 160ms; }
.rise > *:nth-child(6) { animation-delay: 200ms; }
.rise > *:nth-child(n + 7) { animation-delay: 240ms; }

[hidden] { display: none !important; }
