/* ============================================================
   ТОКЕНЫ — утверждённая дизайн-система (ДИЗАЙН_ПРОЕКТА.md)
   ============================================================ */
:root {
  /* Светлый режим — «Топография» */
  --topo-bg: #F7F4ED;
  --topo-card: #FDFBF6;
  --topo-border: #DAD3C3;
  --topo-text: #1E1B15;
  --topo-text-secondary: #8A857A;
  --topo-accent: #D85A30;
  --topo-button-bg: #1E1B15;
  --topo-button-text: #F7F4ED;

  /* Тёмный режим — «Ночной кофе» (только экран ритуала) */
  --ritual-bg: #241A14;
  --ritual-card: #2A1F17;
  --ritual-border: #4A3626;
  --ritual-accent: #C98A54;
  --ritual-text: #F1E4D6;
  --ritual-text-muted: #8C6B50;

  /* Семантические (не меняются от темы) */
  --success-fg: #3B6D11;
  --success-bg: #97C459;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  background: var(--topo-bg);
  color: var(--topo-text);
}

.screen {
  height: 100vh;
  height: 100dvh;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.screen.visible { display: flex; }
.screen.hidden { display: none; }
#screen-main.visible { display: flex; }
.screen.no-pad.visible { display: flex; padding: 0; }

.logo-wrap { margin-top: 24px; margin-bottom: 8px; }
.logo { width: 120px; height: 120px; }

h1 { font-size: 30px; font-weight: 600; text-align: center; margin: 8px 0 28px; }
h2 { font-size: 19px; font-weight: 600; text-align: center; margin: 16px 0 8px; }

#city-select {
  width: 100%; max-width: 320px; height: 48px;
  border: 0.5px solid var(--topo-border); border-radius: 10px;
  padding: 0 12px; font-size: 16px; font-family: inherit;
  margin-bottom: 16px; background: var(--topo-card); color: var(--topo-text);
}

button {
  width: 100%; max-width: 320px; height: 50px;
  border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: 8px;
  transition: transform 0.35s ease;
}

/* Импульс: сжатие кнопки без отскока (см. motion-таблицу) */
button:active { transform: scale(0.97); }

#drop-btn, #route-btn, #arrive-btn, #story-submit-btn,
#vis-public-btn, #done-close-btn, #profile-save-btn {
  background: var(--topo-button-bg);
  color: var(--topo-button-text);
}

button:disabled { opacity: 0.6; }

button.secondary {
  background: transparent; border: 0.5px solid var(--topo-border); color: var(--topo-text);
  font-weight: 500;
}

.hint { font-size: 14px; color: var(--topo-text-secondary); margin-top: 14px; text-align: center; line-height: 1.5; }
.msg { font-size: 14px; color: var(--topo-accent); text-align: center; margin: 10px 0 0; }
.msg.hidden { display: none; }

#map {
  width: 100%; height: 42vh;
  /* Приглушающий фильтр поверх openfreemap/liberty — под палитру
     «Топография», без смены самого источника тайлов (стабильность). */
  filter: saturate(0.55) sepia(0.12) contrast(0.95);
}

/* Маркер разнесён на два вложенных элемента: внешний — только позиция
   (управляется MapLibre через transform), внутренний — только анимация
   появления. Раньше оба конфликтовали за один transform на одном узле. */
.map-marker {
  width: 22px; height: 22px;
}
.map-marker-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--topo-accent); border: 3px solid var(--topo-card);
  box-shadow: 0 0 0 4px rgba(216, 90, 48, 0.2);
  animation: markerDrop 0.4s ease-out;
}
@keyframes markerDrop {
  0%   { transform: scale(0.3); opacity: 0; }
  70%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.card { width: 100%; padding: 20px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.card-row { display: flex; justify-content: space-between; align-items: baseline; width: 100%; max-width: 320px; }
.card-title { font-size: 17px; font-weight: 600; }
.card-sub { font-size: 14px; color: var(--topo-text-secondary); }
.card-actions { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* --------------------- ЭКРАН РИТУАЛА — «Ночной кофе» --------------------- */
/* Единственный тёмный экран во всём приложении. Редкость момента = сила. */
#screen-ritual {
  background: var(--ritual-bg);
  color: var(--ritual-text);
}

#screen-ritual .ritual-text {
  font-family: 'Golos Text', 'Onest', sans-serif;
  font-size: 18px; line-height: 1.7; text-align: center;
  max-width: 340px; margin: 32px 0 24px;
  color: var(--ritual-text);
}

#screen-ritual .hint { color: var(--ritual-text-muted); }
#screen-ritual .msg { color: var(--ritual-accent); }
#screen-ritual .msg-neutral { color: var(--ritual-text-muted); }

.timer-wrap { position: relative; width: 120px; height: 120px; margin: 8px 0; }
.timer-ring { width: 120px; height: 120px; }
.timer-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 22px; font-weight: 600;
  color: var(--ritual-text);
}

/* Дыхание кольца таймера — scale 1 → 1.035, ~4с цикл (см. motion-таблицу) */
#timer-circle {
  animation: ringBreathe 4s ease-in-out infinite;
  transform-origin: center;
}
@keyframes ringBreathe {
  0%, 100% { transform: rotate(-90deg) scale(1); }
  50%      { transform: rotate(-90deg) scale(1.035); }
}

#screen-ritual .visibility-label { color: var(--ritual-text); }
#screen-ritual .visibility-seg {
  border-color: var(--ritual-border);
}
#screen-ritual .visibility-seg button {
  color: var(--ritual-text); border-left-color: var(--ritual-border);
}
#screen-ritual .visibility-seg button.v-active {
  background: var(--ritual-accent); color: var(--ritual-bg);
}
#screen-ritual button.secondary {
  border-color: var(--ritual-border); color: var(--ritual-text);
}

/* --------------------------------------------------------------------- */

#story-text {
  width: 100%; max-width: 320px; border: 0.5px solid var(--topo-border);
  border-radius: 10px; padding: 12px; font-size: 16px; margin: 16px 0;
  font-family: inherit; resize: vertical;
  background: var(--topo-card); color: var(--topo-text);
}

.msg-neutral { font-size: 14px; color: var(--topo-text-secondary); text-align: center; margin: 10px 0 0; max-width: 320px; }
.msg-neutral.hidden { display: none; }

.link-btn {
  width: auto; max-width: none; height: auto; background: transparent;
  border: none; color: var(--topo-accent); font-size: 14px; font-weight: 500;
  margin-top: 12px; padding: 4px;
}

.star-rating { display: flex; gap: 6px; margin: 8px 0 4px; }
.star-rating .star {
  width: 42px; height: 42px; max-width: none; border: none; background: transparent;
  font-size: 30px; line-height: 1; color: var(--topo-border); margin: 0; padding: 0;
}
.star-rating .star.active { color: var(--topo-accent); }

.history-list {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; margin-top: 16px;
  flex: 1; min-height: 0; overflow-y: auto;
}
.history-entry {
  border: 0.5px solid var(--topo-border); border-radius: 12px; padding: 14px 16px;
  background: var(--topo-card);
  display: flex; flex-direction: column; gap: 6px;
}
.history-entry .entry-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--topo-text-secondary); }
.history-entry .entry-text { font-size: 15px; }
.history-entry .entry-stars { color: var(--topo-accent); font-size: 14px; }
.history-empty { font-size: 14px; color: var(--topo-text-secondary); text-align: center; margin-top: 24px; }

.visibility-block { width: 100%; max-width: 320px; margin: 20px 0 4px; }
.visibility-label { font-size: 14px; font-weight: 600; margin: 0 0 8px; text-align: center; }
.visibility-seg { display: flex; border: 0.5px solid var(--topo-border); border-radius: 10px; overflow: hidden; }
.visibility-seg button {
  flex: 1; border: none; border-radius: 0; margin: 0; height: 40px;
  font-size: 13px; font-weight: 500; background: transparent; color: var(--topo-text);
  border-left: 0.5px solid var(--topo-border);
}
.visibility-seg button:first-child { border-left: none; }
.visibility-seg button.v-active { background: var(--topo-button-bg); color: var(--topo-button-text); }

#profile-nickname {
  width: 100%; max-width: 320px; height: 48px; border: 0.5px solid var(--topo-border);
  border-radius: 10px; padding: 0 12px; font-size: 16px; font-family: inherit;
  margin: 16px 0 12px; background: var(--topo-card); color: var(--topo-text);
}
#profile-bio {
  width: 100%; max-width: 320px; border: 0.5px solid var(--topo-border);
  border-radius: 10px; padding: 12px; font-size: 16px; font-family: inherit;
  resize: vertical; margin-bottom: 8px; background: var(--topo-card); color: var(--topo-text);
}

/* Семантика успеха (галочка прибытия и т.п.) — задел на будущее,
   см. ДИЗАЙН_ПРОЕКТА.md раздел 2 */
.success-text { color: var(--success-fg); }
.success-badge { background: var(--success-bg); color: var(--success-fg); }

/* --------------------------- ВХОДНОЙ ЭКРАН --------------------------- */

#screen-welcome { justify-content: flex-start; padding-bottom: 40px; }

.welcome-logo-zone {
  width: 100%; height: 30vh; min-height: 140px;
  display: flex; align-items: center; justify-content: center;
}
.logo-hero { width: 170px; height: 170px; }

.welcome-center {
  flex: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.tagline {
  font-family: 'Golos Text', 'Onest', sans-serif;
  font-style: normal;
  font-size: 19px; line-height: 1.7; text-align: center;
  color: var(--topo-text-secondary); margin: 14px 0 0;
}

.btn-accent {
  background: var(--topo-accent) !important;
  color: var(--topo-card) !important;
}

/* --------------------------- ХАБ (выбор сервиса) ----------------------- */

#screen-hub { justify-content: center; gap: 16px; }

.hub-block {
  width: 100%; max-width: 320px; height: auto; min-height: 84px;
  background: var(--topo-card); border: 0.5px solid var(--topo-border);
  border-radius: 14px; padding: 16px 18px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
}
.hub-title { font-size: 17px; font-weight: 600; color: var(--topo-text); }
.hub-tagline {
  font-family: 'Golos Text', 'Onest', sans-serif; font-style: normal;
  font-size: 14px; color: var(--topo-text-secondary); line-height: 1.4;
}
.hub-block-preview { opacity: 0.5; }

/* --------------------------- НАВИГАЦИЯ К МОДУЛЯМ ---------------------- */

.jbb-nav {
  margin-top: 28px; border-top: 0.5px solid var(--topo-border);
  padding-top: 12px; width: 100%; max-width: 320px;
  display: flex; flex-direction: column; align-items: center;
}

/* --------------------------- ПРОТОКОЛ --------------------------------- */

#screen-protocol-step { padding-left: 5vw; padding-right: 5vw; }

.protocol-progress-wrap { position: relative; width: 60px; height: 60px; margin: 8px 0 4px; flex-shrink: 0; }
.protocol-progress-ring { width: 60px; height: 60px; }
.protocol-progress-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 12px; font-weight: 600; color: var(--topo-text-secondary);
}

#protocol-question.ritual-text { max-width: none; width: 100%; text-align: left; }
#protocol-question p { margin: 0 0 14px; }
#protocol-question strong, .ritual-text strong { font-weight: 600; }

#protocol-answer {
  width: 100%; max-width: none;
  height: 45vh; min-height: 220px;
  font-size: 16px; font-family: inherit;
  border: 0.5px solid var(--topo-border); border-radius: 10px; padding: 14px;
  resize: none; background: var(--topo-card); color: var(--topo-text);
  margin: 10px 0;
}

#protocol-next-btn, #protocol-cancel-btn { flex-shrink: 0; }

/* Глобальная кнопка "В начало" — появляется на всех экранах, кроме входного */
#global-home-btn { margin-top: 20px; }

#protocol-final-list .entry-text p { margin: 0 0 10px; }
#protocol-final-list .entry-text strong { font-weight: 600; }

.timeline-tag { font-weight: 600; color: var(--topo-accent); }
.timeline-linked { border-left: 3px solid var(--topo-accent); }
.timeline-vector-tag {
  margin-top: 8px; font-size: 12px; color: var(--topo-accent);
  font-weight: 500; cursor: pointer;
}

/* --------------------------- ХРАНИЛИЩЕ --------------------------------- */

.storage-gates { width: 100%; display: flex; flex-direction: column; align-items: center; margin-top: 12px; }
.gate-row { width: 100%; max-width: 320px; display: flex; align-items: center; gap: 8px; }
.gate-row button { margin-top: 8px; }
.gate-badge {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--success-bg); color: var(--success-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; margin-top: 8px;
}
#storage-evidence-list { text-align: left; width: 100%; max-width: 320px; margin-top: 8px; }
#storage-gate-result { width: 100%; max-width: 320px; text-align: left; white-space: pre-line; }

.timeline-filter {
  width: 100%; max-width: 340px; display: flex; flex-wrap: wrap; gap: 6px;
  margin: 8px 0 4px;
}
.timeline-filter-btn {
  width: auto; max-width: none; height: 30px; margin: 0; padding: 0 12px;
  font-size: 12px; font-weight: 500; border-radius: 8px;
  background: transparent; border: 0.5px solid var(--topo-border); color: var(--topo-text);
}
.timeline-filter-btn.active { background: var(--topo-accent); color: var(--topo-card); border-color: var(--topo-accent); }

