/* JustChess — новости и трансляции шахмат
   Статическая заглушка: один файл стилей, без внешних ресурсов. */

:root {
  --chalk: #f6f6f2;
  --ivory: #e9e4d3;
  --sage: #9db292;
  --sage-soft: #dfe6d9;
  --green: #4f6f4d;
  --green-deep: #3c5a3b;
  --walnut: #4a3222;
  --walnut-deep: #2f1f15;
  --brass: #b08d57;
  --brass-soft: #e3d3b4;
  --ink: #1e1b17;
  --ink-soft: #5b554c;
  --signal: #b23a3a;

  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Cambria, Georgia, "Times New Roman", serif;

  --board: clamp(300px, 42vw, 540px);
  --sq: calc(var(--board) / 8);

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 18px;
  --shadow-soft: 0 18px 40px -22px rgba(47, 31, 21, .45), 0 4px 12px -6px rgba(47, 31, 21, .25);
  --measure: 66ch;
}

* { box-sizing: border-box; }

/* Декор героя (конь ::before и клетчатая кайма ::after) намеренно вылетает за
   край страницы. Одного `overflow-x: hidden` на body для этого мало — документ
   всё равно становится шире вьюпорта и экран едет вправо (замер: 380px → 645,
   1280px → 1348). `clip` на html режет вылет, не создавая scroll-контейнер,
   и сохраняет полноэкранный вылет декора. */
html { scroll-behavior: smooth; overflow-x: clip; }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--chalk);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--green-deep); text-decoration-color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--walnut); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 3px; }

h1, h2, h3 { font-weight: 600; line-height: 1.15; color: var(--walnut); margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 3.6vw, 3.05rem); }
h2 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); }
h3 { font-size: 1.25rem; }
p { margin: 0; max-width: var(--measure); }

.wrap { width: min(1160px, 100% - 2.5rem); margin-inline: auto; }

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

.masthead {
  display: flex; align-items: center; gap: 2rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--brass-soft);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--walnut); }
.brand-mark {
  display: grid; place-items: center;
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--walnut); color: var(--ivory);
  font-size: 1.55rem; line-height: 1;
  box-shadow: inset 0 0 0 2px var(--brass);
}
.brand-name { font-size: 1.55rem; font-weight: 700; letter-spacing: .01em; }
.brand-name em { font-style: italic; font-weight: 400; color: var(--green-deep); }

.menu { display: flex; gap: 1.6rem; margin-left: auto; }
.menu a { color: var(--ink); text-decoration: none; font-size: 1.02rem; position: relative; padding: .2rem 0; }
.menu a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 2px;
  background: var(--brass); transition: right .35s ease;
}
.menu a:hover::after, .menu a:focus-visible::after { right: 0; }

.live-pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .9rem .35rem .7rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--brass-soft); color: var(--walnut);
  text-decoration: none; font-size: .95rem; white-space: nowrap;
}
.live-dot {
  width: .6rem; height: .6rem; border-radius: 50%; background: var(--signal);
  box-shadow: 0 0 0 0 rgba(178, 58, 58, .55);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(178, 58, 58, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(178, 58, 58, 0); }
  100% { box-shadow: 0 0 0 0 rgba(178, 58, 58, 0); }
}

/* ---------- Герой ---------- */

.hero {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  padding: clamp(2.5rem, 5vw, 4.5rem) 0 clamp(3rem, 6vw, 5rem);
  isolation: isolate;
}
.hero::before {
  /* тень коня на стене зала */
  content: "♞"; position: absolute; z-index: -1;
  right: -2vw; top: -6vw;
  font-size: clamp(18rem, 42vw, 40rem); line-height: 1;
  color: var(--walnut); opacity: .045; transform: rotate(-12deg);
  pointer-events: none; user-select: none;
}
.hero::after {
  /* клетчатая кайма, тающая к центру */
  content: ""; position: absolute; z-index: -1; left: -10vw; right: -10vw; bottom: 0; height: 9rem;
  background: repeating-conic-gradient(var(--sage-soft) 0 25%, transparent 0 50%) 0 0 / 3rem 3rem;
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent);
          mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent);
  opacity: .7;
}

.kicker { color: var(--signal); font-style: italic; font-size: 1.05rem; margin-bottom: .6rem; }
.kicker::before { content: "●"; font-style: normal; font-size: .7em; margin-right: .5rem; vertical-align: .1em; }
.lede { font-size: 1.2rem; color: var(--ink-soft); margin-top: 1rem; }

.clocks {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  margin-top: 1.8rem; max-width: 34rem;
  background: var(--brass-soft); border: 1px solid var(--brass-soft); border-radius: var(--radius-m);
  overflow: hidden;
}
.player { background: #fff; padding: .9rem 1.1rem; display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; }
.player .piece-badge {
  width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem; line-height: 1;
}
.player.white .piece-badge { background: var(--ivory); color: var(--walnut); }
.player.black .piece-badge { background: var(--walnut); color: var(--ivory); }
/* min-width:0 — иначе длинный ник распирает грид и срезает часы */
.player .name { font-weight: 600; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.player .rating { display: block; font-size: .85rem; color: var(--ink-soft); font-weight: 400; }
.player .clock { font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--walnut); white-space: nowrap; }
.player.to-move .clock { color: var(--green-deep); }

.moves {
  list-style: none; margin: 1.3rem 0 0; padding: .8rem 1.1rem;
  display: flex; flex-wrap: wrap; gap: .35rem 1.1rem;
  background: var(--sage-soft); border-radius: var(--radius-m); max-width: 34rem;
  font-size: 1.02rem;
}
.moves li { color: var(--walnut); }
.moves .n { color: var(--brass); margin-right: .3rem; }
.moves .cur { background: #fff; padding: 0 .4rem; border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--brass-soft); }

.btn {
  display: inline-block; margin-top: 1.8rem;
  padding: .7rem 1.4rem; border-radius: 999px;
  background: var(--green); color: #fff; text-decoration: none; font-size: 1.02rem;
  box-shadow: 0 10px 22px -12px rgba(79, 111, 77, .8);
  transition: background .25s ease, transform .25s ease;
}
.btn:hover { background: var(--green-deep); color: #fff; transform: translateY(-1px); }

/* ---------- Доска ---------- */

.board-wrap { position: relative; padding: 1.2rem 1.6rem 1.7rem 1.2rem; }
.board-frame {
  position: relative;
  padding: calc(var(--sq) * .28);
  background: linear-gradient(145deg, #6b4a34, var(--walnut) 55%, #3b2619);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(255, 255, 255, .08);
  animation: set-board 1.2s ease-out both;
}
.board-frame::before {
  content: ""; position: absolute; inset: calc(var(--sq) * .14);
  border: 1px solid var(--brass); border-radius: 10px; opacity: .7; pointer-events: none;
}
.board {
  position: relative;
  display: grid; grid-template-columns: repeat(8, var(--sq)); grid-template-rows: repeat(8, var(--sq));
  background: repeating-conic-gradient(var(--sage) 0 25%, var(--ivory) 0 50%) 0 0 / calc(var(--sq) * 2) calc(var(--sq) * 2);
  border-radius: 4px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(47, 31, 21, .35);
}
.pc {
  display: grid; place-items: center;
  font-size: calc(var(--sq) * .8); line-height: 1;
  position: relative; z-index: 1;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .28));
  animation: place .55s cubic-bezier(.2, .9, .3, 1.3) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.pc.w { color: #f5f0e1; text-shadow: 0 0 1px #3a2a1e, 0 0 2px rgba(58, 42, 30, .8); }
.pc.b { color: #2a2119; text-shadow: 0 0 1px rgba(255, 255, 255, .25); }

.coords { position: absolute; display: flex; justify-content: space-around; color: var(--brass); font-size: .82rem; font-style: italic; }
.coords.files { left: 1.2rem; right: 1.6rem; bottom: .35rem; padding-inline: calc(var(--sq) * .28); }
.coords.ranks { flex-direction: column-reverse; top: 1.2rem; bottom: 1.7rem; left: -.1rem; padding-block: calc(var(--sq) * .28); }

@keyframes set-board {
  from { opacity: 0; transform: translateY(18px) rotate(-1.5deg); }
  to   { opacity: 1; transform: none; }
}
@keyframes place {
  from { opacity: 0; transform: translateY(-40%) scale(.6); }
  to   { opacity: 1; transform: none; }
}

/* лёгкое покачивание фигуры под курсором — единственное движение по наведению */
.board .pc { transition: transform .3s cubic-bezier(.2, .9, .3, 1.3); }
.board .pc:hover { transform: translateY(-14%) scale(1.06); z-index: 2; }

/* Доску ведёт трансляция: перерисовка идёт каждый ход, и каскад появления
   перезапускался бы на всех 32 фигурах — доска мерцала. Каскад оставляем
   только первой, серверной отрисовке. */
.board.live .pc { animation: none; opacity: 1; }

/* ---------- Бегущая строка ---------- */

.ticker {
  border-block: 1px solid var(--brass-soft);
  background: #fff;
  overflow: hidden; white-space: nowrap;
}
.ticker-track {
  display: inline-flex; gap: 2.4rem; padding: .7rem 0;
  animation: ticker 48s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-track span { color: var(--walnut); }
.ticker-track .res { color: var(--green-deep); font-weight: 600; }
.ticker-track .sep { color: var(--brass); }
@keyframes ticker { to { transform: translateX(-50%); } }

/* ---------- Секции ---------- */

section.block { padding: clamp(3rem, 6vw, 5.5rem) 0; }
.block-head { display: flex; align-items: baseline; gap: 1.2rem; margin-bottom: 2rem; }
.block-head .rule { flex: 1; height: 1px; background: var(--brass-soft); }
.block-head .more { color: var(--green-deep); font-style: italic; }

/* Новости */
.news-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 2.4rem; align-items: start; }
.lead {
  display: grid; gap: 1.2rem;
  background: #fff; border-radius: var(--radius-l); overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.lead .art { aspect-ratio: 16 / 9; }
.lead .body { padding: 0 1.8rem 1.8rem; }
.lead h3 { font-size: 1.7rem; }
.lead .lede { font-size: 1.05rem; margin-top: .7rem; }
.stamp { font-style: italic; color: var(--ink-soft); font-size: .92rem; }
.stamp + h3, .stamp + h2 { margin-top: .5rem; }

.art {
  position: relative; display: grid; place-items: center; overflow: hidden;
  background: repeating-conic-gradient(var(--a) 0 25%, var(--b) 0 50%) 0 0 / 3rem 3rem;
}
.art::before {
  content: attr(data-piece);
  font-size: clamp(5rem, 9vw, 8rem); line-height: 1; color: var(--c);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .25));
  transition: transform .5s ease;
}
.lead:hover .art::before, .brief:hover .art::before { transform: translateY(-4px) rotate(-3deg); }
.art.t-sage   { --a: var(--sage); --b: var(--ivory); --c: var(--walnut); }

/* Обложка турнира: картинку скачал бекенд, лежит на своём домене.
   Пока её нет — остаётся CSS-диаграмма из клеток и фигуры. */
.art > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art.has-img::before { content: none; }
.art.t-walnut { --a: #6b4a34; --b: #8b6a52; --c: var(--ivory); }
.art.t-green  { --a: var(--green); --b: #6f8c6c; --c: var(--ivory); }
.art.t-brass  { --a: var(--brass); --b: var(--brass-soft); --c: var(--walnut-deep); }
.art.t-slate  { --a: #6c7a8a; --b: #9aa6b2; --c: #f6f6f2; }

.briefs { display: grid; gap: 1.1rem; }
.brief {
  display: grid; grid-template-columns: 8.6rem minmax(0, 1fr); gap: 1.1rem; align-items: center;
  padding: .7rem; border-radius: var(--radius-m); background: #fff;
  border: 1px solid transparent; transition: border-color .3s ease;
}
.brief:hover { border-color: var(--brass-soft); }
.brief .art { width: 8.6rem; height: 5.4rem; border-radius: var(--radius-s); background-size: 1.55rem 1.55rem; }
.brief .art::before { font-size: 3rem; }
.brief h3 { font-size: 1.12rem; }
.brief h3 a { color: var(--walnut); text-decoration: none; }
.brief h3 a:hover { text-decoration: underline; text-decoration-color: var(--brass); }
.brief .stamp { display: block; margin-top: .25rem; }

/* Расписание */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; max-width: 46rem; }
.timeline::before { content: ""; position: absolute; left: 6.6rem; top: .6rem; bottom: .6rem; width: 1px; background: var(--brass-soft); }
.timeline li { display: grid; grid-template-columns: 5.8rem 1.6rem 1fr; gap: .4rem; padding: .9rem 0; align-items: baseline; }
.timeline time { color: var(--ink-soft); font-style: italic; text-align: right; }
.timeline .knot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--chalk); border: 2px solid var(--brass); justify-self: center; align-self: center; }
.timeline li.live .knot { background: var(--signal); border-color: var(--signal); }
.timeline .what { color: var(--walnut); font-weight: 600; }
.timeline .who { display: block; color: var(--ink-soft); font-weight: 400; font-size: .95rem; }

/* Задача дня */
.puzzle { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(2rem, 4vw, 4rem); align-items: center;
  background: #fff; border-radius: var(--radius-l); padding: clamp(1.4rem, 3vw, 2.6rem); box-shadow: var(--shadow-soft); }
.puzzle .board-frame { --sq: clamp(30px, 4.2vw, 46px); animation: none; }
.puzzle .board { --sq: clamp(30px, 4.2vw, 46px); }
.puzzle .pc { animation: none; font-size: calc(var(--sq) * .78); }
.puzzle details { margin-top: 1.2rem; border-top: 1px solid var(--brass-soft); padding-top: 1rem; }
.puzzle summary { cursor: pointer; color: var(--green-deep); font-style: italic; list-style: none; }
.puzzle summary::-webkit-details-marker { display: none; }
.puzzle summary::before { content: "♙"; margin-right: .5rem; display: inline-block; transition: transform .35s ease; }
.puzzle details[open] summary::before { transform: rotate(90deg); }
.puzzle details p { margin-top: .7rem; }
.solution { font-size: 1.3rem; color: var(--walnut); font-weight: 600; }

/* ---------- Подвал ---------- */

footer { margin-top: 2rem; border-top: 1px solid var(--brass-soft); background: #fff; }
.foot { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; padding: 2.6rem 0 2rem; }
.foot h3 { font-size: 1.05rem; margin-bottom: .6rem; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.foot a { text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot p { color: var(--ink-soft); font-size: .98rem; }
.legal { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 0 1.6rem; color: var(--ink-soft); font-size: .9rem; border-top: 1px solid var(--brass-soft); }
.legal .pieces { letter-spacing: .3em; color: var(--brass); }

/* ---------- Адаптив ---------- */

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .board-wrap { justify-self: center; --board: min(88vw, 520px); }
  .hero::before { font-size: 22rem; right: -8rem; top: -4rem; }
  .news-layout { grid-template-columns: 1fr; }
  .puzzle { grid-template-columns: 1fr; justify-items: center; }
  .puzzle .board-frame, .puzzle .board { --sq: min(10vw, 46px); }
  .foot { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .masthead { flex-wrap: wrap; gap: .8rem 1.2rem; }
  .menu { order: 3; width: 100%; margin-left: 0; gap: 1.1rem; overflow-x: auto; padding-bottom: .2rem; }
  .live-pill { margin-left: auto; }
  .clocks { grid-template-columns: 1fr; }
  .brief { grid-template-columns: 6.4rem minmax(0, 1fr); }
  .brief .art { width: 6.4rem; height: 4rem; }
  .timeline::before { left: 4.9rem; }
  .timeline li { grid-template-columns: 4.1rem 1.6rem 1fr; }
  .foot { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .live-dot { box-shadow: none; }
}
