/* =============================================================
   ПАРТИЯ — styles.css
   Тёмный литературный дизайн, шахматная атмосфера
   Палитра: #0a0a0a фон, #c9a84c золото
   Fonts: Playfair Display (заголовки), Cormorant Garamond (текст)
   ============================================================= */

:root {
  --bg:           #0a0a0a;
  --bg-elev:      #111111;
  --bg-soft:      #161616;
  --text:         #e8e3d8;
  --text-dim:     #9a948a;
  --text-muted:   #5c574d;
  --gold:         #c9a84c;
  --gold-dim:     #7a6a34;
  --gold-bright:  #e8c964;
  --line:         #26221b;
  --shadow:       0 20px 60px rgba(0,0,0,.6);
  --max-read:     720px;

  --serif-head:   "Playfair Display", Georgia, serif;
  --serif-body:   "Cormorant Garamond", "Times New Roman", serif;
  --mono:         "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  background: var(--bg);
  /* subtle vignette via radial gradient */
}

body {
  font-family: var(--serif-body);
  font-weight: 400;
  font-size: clamp(17px, 1.05vw + 14px, 21px);
  line-height: 1.7;
  color: var(--text);
  background:
    radial-gradient(ellipse at top, #131110 0%, var(--bg) 50%) fixed,
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--gold); color: var(--bg); }

/* ============== Progress bar ============== */
.progress {
  position: fixed; inset: 0 auto auto 0;
  width: 0%; height: 3px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright));
  z-index: 100;
  transition: width .08s linear;
  box-shadow: 0 0 12px rgba(201,168,76,.4);
}

/* ============== Chessboard background ============== */
.chessboard-bg {
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .035;
  background-image:
    linear-gradient(45deg, var(--gold) 25%, transparent 25%),
    linear-gradient(-45deg, var(--gold) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--gold) 75%),
    linear-gradient(-45deg, transparent 75%, var(--gold) 75%);
  background-size: 80px 80px;
  background-position: 0 0, 0 40px, 40px -40px, -40px 0;
  z-index: -1;
}

/* ============== Knight: scroll-to-top кнопка ============== */
.clock-ticker {
  position: fixed;
  right: 22px; bottom: 22px;
  width: 56px; height: 56px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  color: var(--gold-dim);
  background: rgba(10,10,10,.6);
  backdrop-filter: blur(6px);
  z-index: 10;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px) scale(.9);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s cubic-bezier(.2,.9,.3,1.05),
              color .2s, border-color .2s, background .2s;
}
.clock-ticker.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.clock-ticker:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: rgba(10,10,10,.8);
}
.clock-ticker:active { transform: scale(.92); }
.clock-ticker:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ============== Header / TOC ============== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,10,10,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  font-family: var(--serif-head);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .14em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand .piece { color: var(--gold); font-size: 22px; }
.toc-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 8px 14px;
  font: 12px/1 var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: color .2s, border-color .2s;
}
.toc-toggle:hover { color: var(--gold); border-color: var(--gold-dim); }

.toc {
  position: absolute;
  right: 24px; top: calc(100% + 8px);
  width: min(340px, 90vw);
  max-height: 72vh;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px 8px;
  box-shadow: var(--shadow);
  display: none;
}
.toc.open { display: block; animation: fadeIn .18s ease-out; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { margin: 0; }
.toc a {
  display: flex; align-items: baseline; gap: 14px;
  padding: 8px 18px;
  color: var(--text-dim);
  text-decoration: none;
  font-family: var(--serif-body);
  font-size: 16px;
  transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.toc a:hover,
.toc a.active {
  color: var(--text);
  background: var(--bg-soft);
  border-left-color: var(--gold);
}
.toc-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold-dim);
  min-width: 22px;
  text-align: right;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ============== Cover ============== */
.cover {
  min-height: 92vh;
  display: grid;
  place-items: center;
  padding: 60px 24px;
  position: relative;
}
.cover-inner { text-align: center; max-width: 560px; }
.cover-piece {
  font-size: clamp(80px, 14vw, 160px);
  color: var(--gold);
  line-height: 1;
  margin-bottom: 24px;
  text-shadow: 0 0 60px rgba(201,168,76,.25);
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.cover-title {
  font-family: var(--serif-head);
  font-weight: 700;
  font-size: clamp(56px, 10vw, 110px);
  letter-spacing: .3em;
  margin: 0 0 .3em 0;
  line-height: 1;
  color: var(--text);
  text-indent: .3em; /* компенсация tracking для центровки */
}
.cover-author {
  font-style: italic;
  font-size: 20px;
  color: var(--text-dim);
  margin: 0 0 3em 0;
  letter-spacing: .08em;
}
.cover-epigraph {
  margin: 0 auto 3em auto;
  max-width: 420px;
  padding: 0;
  border: none;
  font-family: var(--serif-body);
  font-size: clamp(19px, 2vw, 24px);
  font-style: italic;
  color: var(--text-dim);
  position: relative;
}
.cover-epigraph::before,
.cover-epigraph::after {
  content: "";
  display: block;
  width: 60px; height: 1px;
  background: var(--gold-dim);
  margin: 20px auto;
}
.cover-epigraph p { margin: 0; }
.cover-cta {
  display: inline-block;
  font: 12px/1 var(--mono);
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  padding: 14px 28px;
  border: 1px solid var(--gold-dim);
  transition: all .25s;
  border-radius: 2px;
}
.cover-cta:hover {
  color: var(--bg);
  background: var(--gold);
  border-color: var(--gold);
}

/* ============== Separator ============== */
.separator {
  text-align: center;
  padding: 80px 24px 40px;
  font-size: 20px;
  letter-spacing: 1.6em;
  color: var(--gold-dim);
  opacity: .7;
}

/* ============== Section (chapter) ============== */
.section {
  max-width: var(--max-read);
  margin: 0 auto;
  padding: 80px 24px 60px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .9s cubic-bezier(.2,.7,.3,1), transform .9s cubic-bezier(.2,.7,.3,1);
}
.section.in-view { opacity: 1; transform: none; }

.section-head {
  text-align: center;
  margin-bottom: 3em;
}
.section-piece {
  font-size: 42px;
  color: var(--gold);
  display: block;
  margin-bottom: 14px;
  line-height: 1;
}
.section-kicker {
  font: 11px/1 var(--mono);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin: 0 0 1em 0;
}
.section-pos {
  color: var(--text-muted);
  letter-spacing: .2em;
}
.section-title {
  font-family: var(--serif-head);
  font-weight: 700;
  font-size: clamp(32px, 5vw, 56px);
  letter-spacing: .06em;
  margin: .2em 0 .8em 0;
  color: var(--text);
  line-height: 1.1;
}
.section-rule {
  width: 60px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 0 auto;
}

/* Body text */
.section-body p {
  margin: 0 0 1.4em 0;
  text-align: justify;
  hyphens: auto;
}
.section-body p.first { text-indent: 0; }
.section-body p { text-indent: 2em; }
.section-body p.first { text-indent: 0; }

/* Drop cap */
.drop {
  font-family: var(--serif-head);
  float: left;
  font-size: 4.8em;
  line-height: .85;
  padding: 4px 10px 0 0;
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 30px rgba(201,168,76,.18);
}

/* ============== Clock-tick pull quote ============== */
.clock-tick {
  margin: 2.6em auto;
  padding: 28px 32px;
  max-width: 560px;
  text-align: center;
  position: relative;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.clock-tick::before,
.clock-tick::after {
  content: "◆";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold-dim);
  font-size: 10px;
  background: var(--bg);
  padding: 0 10px;
}
.clock-tick::before { top: -6px; }
.clock-tick::after  { bottom: -6px; }
.clock-label {
  display: inline-block;
  font: 10px/1 var(--mono);
  letter-spacing: .4em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}
.clock-tick blockquote {
  margin: 0;
  font-family: var(--serif-head);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.45;
  color: var(--text);
}

/* ============== Endmark ============== */
.endmark {
  padding: 120px 24px 80px;
  text-align: center;
}
.endmark-piece { font-size: 80px; color: var(--gold); margin: 0 0 20px 0; line-height: 1; }
.endmark-text  { font-family: var(--serif-head); font-style: italic; color: var(--text-dim); letter-spacing: .2em; margin: 0; }

/* ============== Footer ============== */
.site-footer {
  padding: 40px 24px 60px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border-top: 1px solid var(--line);
}
.site-footer p { margin: .4em 0; }
.site-footer a { color: var(--gold-dim); text-decoration: none; }
.site-footer a:hover { color: var(--gold); }

/* ============== Resume reading button ============== */
.resume-btn {
  position: fixed;
  left: 22px; bottom: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 360px;
  padding: 12px 18px 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--text);
  text-align: left;
  font-family: var(--serif-body);
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(20px) scale(.96);
  transition: opacity .3s ease, transform .3s cubic-bezier(.2,.9,.3,1.05), border-color .2s, background .2s;
  z-index: 60;
}
.resume-btn.show { opacity: 1; transform: none; }
.resume-btn:hover {
  border-color: var(--gold);
  background: var(--bg-soft);
}
.resume-arrow {
  color: var(--gold);
  font-size: 24px;
  line-height: 1;
  padding-top: 2px;
}
.resume-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.resume-kicker {
  font: 9px/1 var(--mono);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.resume-where {
  font-family: var(--serif-head);
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.resume-pct {
  font: 11px/1 var(--mono);
  color: var(--text-muted);
  letter-spacing: .1em;
  margin-top: 2px;
}
.resume-close {
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  align-self: flex-start;
  transition: color .15s;
}
.resume-close:hover { color: var(--text); }

@media (max-width: 680px) {
  .resume-btn { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ============== Responsive ============== */
@media (max-width: 680px) {
  .site-nav { padding: 10px 16px; }
  .section { padding: 50px 18px 40px; }
  .drop { font-size: 3.8em; padding: 2px 6px 0 0; }
  .clock-tick { padding: 22px 18px; }
  .cover-epigraph::before,
  .cover-epigraph::after { width: 40px; margin: 14px auto; }
}

/* ============== Print ============== */
@media print {
  :root { --bg: #fff; --text: #111; --gold: #8a6d1a; --line: #ccc; }
  .site-header, .toc, .clock-ticker, .progress, .chessboard-bg, .cover-cta { display: none !important; }
  body { background: #fff; color: #111; }
  .section { page-break-before: always; opacity: 1; transform: none; }
}

/* ============== Reduced motion ============== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .section, .cover-piece { animation: none !important; transition: none !important; opacity: 1; transform: none; }
}
