/* КОДЕКС protocol — публичные анонсы материалов (/library/).
   Токены и вид совпадают со статьями; от /articles/ ничего не зависит. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-solid: #070604; --bg-2: #0f0d0a; --bg-card: #131109;
  --fg: #f4ead8; --fg-dim: #c8b696; --fg-muted: #9a8c7a;
  --gold: #d4aa52; --gold-light: #edcf7e; --gold-dim: #9a7830;
  --border: #252018; --border-soft: #332d22;
  --maxw: 760px;
}
body.light {
  --bg-solid: #f5f0e6; --bg-2: #ede7d9; --bg-card: #e8e1d2;
  --fg: #16120c; --fg-dim: #4a4236; --fg-muted: #6f634f;
  --gold: #9a7418; --gold-light: #7a5c10; --gold-dim: #7a5c10;
  --border: #d8ceba; --border-soft: #c8bca8;
}

html { font-size: clamp(1rem, 1.25vw, 1.25rem); }

body {
  background: var(--bg-solid);
  color: var(--fg);
  font-family: 'Exo 2', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

* { scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-soft); border-radius: 7px;
  border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); background-clip: padding-box; }

a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* NAV */
.codex-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(7,6,4,.88);
  backdrop-filter: blur(14px);
}
body.light .codex-nav { background: rgba(245,240,230,.92); }
.nav-logo {
  display: flex; align-items: center; gap: .6rem;
  font-family: 'Playfair Display SC', serif; font-weight: 600;
  font-size: 1.2rem; letter-spacing: .2em;
  color: var(--fg); text-decoration: none;
}
.nav-logo img { height: 22px; width: auto; }
.nav-logo em { font-style: normal; color: var(--gold); }
.nav-right { display: flex; align-items: center; gap: 1.25rem; }
.nav-login {
  font-size: .875rem; letter-spacing: .08em;
  color: var(--gold-light); text-decoration: none;
  border: 1px solid var(--gold-dim); padding: .45rem 1rem;
  transition: background .2s, color .2s;
}
.nav-login:hover { background: var(--gold-dim); color: var(--bg-solid); }
.theme-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--fg-muted); font-size: 1.15rem; line-height: 1;
  padding: .35rem; transition: color .2s;
}
.theme-toggle:hover { color: var(--fg-dim); }

/* PAGE */
.page { padding: 6.5rem clamp(1.25rem, 5vw, 2rem) 5rem; }
.teaser { max-width: var(--maxw); margin: 0 auto; }

.crumbs { font-size: .875rem; color: var(--fg-muted); margin-bottom: 2rem; }
.crumbs a { color: var(--fg-muted); text-decoration: none; transition: color .2s; }
.crumbs a:hover { color: var(--gold-light); }
.crumbs span { color: var(--gold-dim); margin: 0 .5rem; }

.article-num {
  display: block; font-size: .875rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 1.25rem;
}
.article-title {
  font-family: 'Playfair Display SC', serif; font-weight: 500;
  font-size: clamp(2.2rem, 5.2vw, 3.8rem); line-height: 1.04;
  letter-spacing: -.01em; color: var(--fg); margin-bottom: 1.5rem;
  overflow-wrap: break-word;
}
.article-title em { font-style: normal; color: var(--gold); }
.article-lead {
  font-size: clamp(1.15rem, 2.2vw, 1.45rem); font-weight: 300; font-style: italic;
  color: var(--fg-dim); line-height: 1.6;
  margin-bottom: 1.75rem; padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: .5rem 1.75rem;
  font-size: .875rem; letter-spacing: .06em; color: var(--fg-muted);
  margin-bottom: 3rem;
}
.article-meta b { color: var(--fg-dim); font-weight: 400; }

/* OUTLINE */
.outline h2, .others h2 {
  font-family: 'Playfair Display SC', serif; font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.2; margin-bottom: 1.25rem;
}
.outline ol { list-style: none; border-top: 1px solid var(--border); }
.outline li {
  display: flex; gap: 1rem; align-items: baseline;
  padding: .9rem 0; border-bottom: 1px solid var(--border);
  font-size: 1.1rem; color: var(--fg-dim);
}
.outline-num {
  flex: none; min-width: 2rem;
  font-size: .9rem; letter-spacing: .12em; color: var(--gold);
}
.outline-text { min-width: 0; overflow-wrap: anywhere; }

/* CTA */
.cta {
  margin: 3.5rem 0;
  padding: clamp(1.25rem, 4vw, 2rem);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-left-width: 3px; border-left-color: var(--gold);
}
.cta h2 {
  font-family: 'Playfair Display SC', serif; font-weight: 500;
  font-size: clamp(1.4rem, 2.6vw, 1.8rem); line-height: 1.25; margin-bottom: .75rem;
}
.cta p { color: var(--fg-dim); font-size: 1.05rem; margin-bottom: 1.5rem; }
.cta-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .8rem 1.6rem; font-size: 1rem; letter-spacing: .06em;
  text-decoration: none; border: 1px solid var(--gold);
  transition: background .2s, color .2s, border-color .2s;
}
.btn-primary { background: var(--gold); color: #070604; }
body.light .btn-primary { color: #f5f0e6; }
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }
body.light .btn-primary:hover { background: var(--gold-dim); border-color: var(--gold-dim); }
.btn-secondary { background: transparent; color: var(--gold-light); border-color: var(--gold-dim); }
.btn-secondary:hover { background: var(--gold-dim); color: var(--bg-solid); }

/* OTHERS */
.others ul { list-style: none; border-top: 1px solid var(--border); margin-bottom: 2rem; }
.others li a {
  display: flex; gap: 1rem; align-items: baseline;
  padding: .8rem 0; border-bottom: 1px solid var(--border);
  font-size: 1.1rem; color: var(--fg-dim); text-decoration: none;
  transition: color .2s, padding-left .2s;
}
.others li a:hover { color: var(--gold-light); padding-left: .4rem; }
.other-num { flex: none; min-width: 2.5rem; font-size: .9rem; letter-spacing: .12em; color: var(--gold); }
.home-link { font-size: 1rem; color: var(--fg-muted); text-decoration: none; border-bottom: 1px solid var(--border-soft); }
.home-link:hover { color: var(--gold-light); border-color: var(--gold-dim); }

@media (max-width: 480px) {
  .nav-logo-text { letter-spacing: .12em; font-size: 1rem; }
  .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
