/* Сталкер Інфографік — темна тема у стилі польового КПК. Власне оформлення, без ассетів гри. */

:root {
  --bg: #11130f;
  --bg-2: #161912;
  --surface: #1c2018;
  --surface-2: #232820;
  --border: #30362b;
  --border-2: #414939;
  --text: #dedbcb;
  --muted: #8f8e7e;
  --accent: #d4ad3a;
  --accent-ink: #1a1606;
  --danger: #d0664f;
  --ok: #7fb36a;
  --radius: 8px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Noto Serif", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(212, 173, 58, 0.05), transparent 60%) no-repeat var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
}
body.panel-open { overflow: hidden; }
@media (min-width: 1100px) { body.panel-open { overflow: auto; } }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

main { max-width: 980px; margin: 0 auto; padding: 24px 20px 80px; }
h1, h2 { line-height: 1.2; font-weight: 650; letter-spacing: 0.01em; }
h1 { font-size: 1.9rem; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
code { font-family: var(--mono); font-size: 0.85em; color: var(--muted); }

/* --- Шапка --- */

.site-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(17, 19, 15, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.nav { display: flex; gap: 4px; }
.nav a, .langs a {
  color: var(--muted); padding: 4px 10px; border-radius: 6px; font-size: 0.93rem;
}
.nav a:hover, .langs a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav a.active, .langs a.active { color: var(--text); background: var(--surface-2); }
.langs { display: flex; gap: 2px; font-family: var(--mono); font-size: 0.8rem; }
.account { display: flex; align-items: center; gap: 12px; font-size: 0.93rem; }
.who { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 0.72rem; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border-2); color: var(--muted); white-space: nowrap;
}
.badge-moderator { color: var(--ok); border-color: rgba(127, 179, 106, 0.45); }
.badge-admin { color: var(--accent); border-color: rgba(212, 173, 58, 0.5); }

/* --- Кнопки й поля --- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); font: inherit; font-weight: 600; font-size: 0.93rem;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-2); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: rgba(208, 102, 79, 0.5); }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
button.link:hover { color: var(--text); }
.icon-btn {
  background: none; border: 1px solid transparent; color: var(--muted); font-size: 1.1rem;
  width: 34px; height: 34px; border-radius: 6px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }

input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-2); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="color"] { padding: 2px; height: 38px; width: 56px; }
textarea { resize: vertical; line-height: 1.55; }
label { display: flex; flex-direction: column; gap: 4px; }
label > span:first-child, .label { font-size: 0.85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
label.check > span:first-child { font-size: inherit; color: inherit; }
.hint { color: var(--muted); font-size: 0.82rem; }
.error { color: var(--danger); margin: 8px 0; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 10px; padding: 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 6px; }
.row > label { flex: 1 1 140px; }
.row > .narrow { flex: 0 1 110px; }
.row > .medium { flex: 0 1 240px; }
.row > .grow { flex: 2 1 240px; }
.row > .self-end { align-self: flex-end; flex: 0 0 auto; padding-bottom: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.notice { color: var(--muted); padding: 24px 0; list-style: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; transition: 0.25s;
  background: var(--surface-2); border: 1px solid var(--border-2);
  padding: 10px 18px; border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-error { border-color: var(--danger); color: #f0b3a5; }

/* --- Фішки сюжетних ліній --- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  background: transparent; border: 1px solid var(--border-2);
  color: var(--text); font: inherit; font-size: 0.88rem; cursor: pointer;
}
.chip:hover { border-color: var(--c, var(--border-2)); }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border-color: var(--c);
}
.chip.static { cursor: default; }
.chip.small, .chips.small .chip { padding: 2px 9px; font-size: 0.78rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
td .chip { margin: 2px 4px 2px 0; }

/* --- Таймлайн --- */

.hero { padding: 28px 0 18px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.tagline { color: var(--muted); margin: 0; font-size: 1.05rem; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 8px 0 6px; }
.toolbar .chips { flex: 1 1 400px; }
.search { flex: 0 1 260px; }
.count { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); margin: 6px 0 18px; min-height: 1.3em; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 0; width: 2px;
  background: linear-gradient(var(--border-2), var(--border) 85%, transparent);
}
.year { position: relative; margin-bottom: 26px; }
.year-label {
  position: sticky; top: 58px; z-index: 5;
  display: inline-block; margin: 0 0 10px; padding: 3px 12px 3px 0;
  font-family: var(--mono); font-size: 1.3rem; font-weight: 700; color: var(--accent);
  background: var(--bg);
}
.year-label::before {
  content: ""; display: inline-block; width: 16px; height: 16px; margin-right: 14px;
  vertical-align: -2px; border-radius: 3px; transform: rotate(45deg) scale(0.8);
  background: var(--accent); box-shadow: 0 0 0 4px var(--bg);
}
.entries { list-style: none; margin: 0; padding: 0; }
.entry { --c: var(--muted); position: relative; padding-left: 34px; margin: 0 0 8px; }
.entry .node {
  position: absolute; left: 3px; top: 16px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--c);
}
.entry-card {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "date lines" "title lines";
  gap: 2px 12px; align-items: center;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--c);
  color: var(--text); transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.entry-card:hover, .entry-card:focus-visible {
  text-decoration: none; background: var(--surface-2); border-color: var(--c); transform: translateX(2px);
}
.entry-card.current { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: var(--c); }
.entry-card:hover + .node, .entry:hover .node { background: var(--c); }
.entry-date { grid-area: date; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.entry-title { grid-area: title; font-weight: 600; }
.entry-lines { grid-area: lines; display: flex; gap: 4px; }

.tooltip {
  position: fixed; z-index: 40; max-width: 360px; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); font-size: 0.9rem;
}
.tooltip strong { display: block; margin-bottom: 4px; }
.tooltip p { margin: 0; color: var(--muted); font-family: var(--serif); line-height: 1.5; }

/* --- Панель з текстом записки --- */

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(600px, 100%); overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border-2);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.45);
  transform: translateX(105%); transition: transform 0.25s ease; visibility: hidden;
}
.panel.open { transform: none; visibility: visible; }
.panel:focus { outline: none; }
.panel-inner { padding: 22px 28px 40px; }
.panel-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-date { font-family: var(--mono); color: var(--accent); font-size: 0.9rem; }
.panel h2 { font-size: 1.5rem; margin: 14px 0 16px; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.fallback { font-size: 0.85rem; color: var(--accent); border-left: 2px solid var(--accent); padding-left: 10px; }
.source { color: var(--muted); font-size: 0.92rem; }
.backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.45); }
@media (min-width: 1100px) {
  .backdrop { display: none; }
  body.panel-open main { margin-right: 620px; margin-left: max(20px, calc(50vw - 790px)); }
}

/* Текст записки — «папір» серифом, щоб відрізнявся від інтерфейсу. */
.note-body { font-family: var(--serif); font-size: 1.08rem; line-height: 1.7; color: #e8e4d2; }
.note-body p { margin: 0 0 1em; }
.note-body strong { color: #fff6d8; }

/* --- Форми входу --- */

.page-auth main { max-width: 420px; padding-top: 60px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h1 { margin-bottom: 4px; }
.switch { font-size: 0.9rem; text-align: center; }

/* --- Керування, редактор, адмінка --- */

.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.page-head h1 { margin: 0; flex: 1; }
.back { flex-basis: 100%; font-size: 0.9rem; }
.section-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; flex: 1; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.82rem; padding: 6px 10px; border-bottom: 1px solid var(--border-2); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr.deleted td { opacity: 0.5; }
.table tr.pending td { background: rgba(212, 173, 58, 0.06); }
.table td.actions { text-align: right; }
.table td.actions .btn { margin: 0 0 4px 6px; }
.table .num { text-align: right; }
.tag {
  display: inline-block; margin-left: 8px; font-size: 0.72rem; padding: 0 6px; border-radius: 4px;
  background: var(--surface-2); color: var(--muted); vertical-align: 1px;
}
.tag.warn { color: var(--accent); }

.storylines { display: flex; flex-direction: column; gap: 4px; }
.storyline-row { display: flex; gap: 14px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.storyline-row.deleted { opacity: 0.5; }
.storyline-row .grow { flex: 1; }
.storyline-row p { margin: 4px 0 0; font-size: 0.9rem; }
.storyline-row .actions { display: flex; gap: 6px; }
.swatch { width: 18px; height: 18px; border-radius: 4px; background: var(--c, var(--muted)); margin-top: 3px; flex: none; }
.storyline-form { padding: 14px; margin: 8px 0; border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--bg-2); }
.storyline-form .actions { display: flex; gap: 8px; margin-top: 10px; }
.lang-block { margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
  padding: 6px 12px; border: 1px solid var(--border-2); border-radius: 999px;
}
.chip-check:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 14px; font: inherit; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.lang-panel { display: flex; flex-direction: column; gap: 14px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split .preview {
  min-height: 200px; max-height: 520px; overflow-y: auto; margin-top: 4px;
  padding: 12px 16px; border: 1px dashed var(--border-2); border-radius: 6px; font-size: 1rem;
}
.body-input { font-family: var(--serif); font-size: 1rem; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.history summary { cursor: pointer; font-weight: 600; }
.history ol { margin: 12px 0 0; padding-left: 20px; font-size: 0.9rem; }
.history li { margin-bottom: 4px; }

.journal { list-style: none; margin: 0; padding: 0; }
.journal-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.journal-line { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.journal-line .tag { margin: 0; }
.action-create { color: var(--ok) !important; }
.action-delete { color: var(--danger) !important; }
.action-revert { color: var(--accent) !important; }
.diff { margin-top: 6px; }
.diff summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.diff-row { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 8px; margin-top: 8px; }
.diff-field { color: var(--muted); font-size: 0.85rem; }
.diff pre {
  margin: 0; padding: 6px 8px; border-radius: 4px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 0.78rem; max-height: 240px; overflow-y: auto;
}
.diff-before { background: rgba(208, 102, 79, 0.1); }
.diff-after { background: rgba(127, 179, 106, 0.1); }

@media (max-width: 720px) {
  main { padding: 16px 14px 60px; }
  .site-header { gap: 10px; padding: 8px 14px; }
  .split { grid-template-columns: 1fr; }
  .diff-row { grid-template-columns: 1fr; }
  .panel-inner { padding: 18px 18px 40px; }
  .search { flex: 1 1 100%; }
  .year-label { top: 96px; }
}
