/* Playable chess guide styles for /blog_posts/chess-openings-middlegame-endgame-guide.html.
   chess-post.js builds the boards and figures into each <figure class="hv" data-hv="...">; the
   <p class="hv-fallback"> inside is the text version for agents and no-JS readers.
   Colors use the post tokens from css/blog_post.css plus board colors, defined for both themes. */

.hv {
  --lt: #ecdfc6; --dk: #b08a64;           /* board squares */
  --on-lt: #8a6a4a; --on-dk: #f6ecdb;     /* coordinates on those squares */
  --last: rgba(250, 204, 21, 0.45);
  --mark: rgba(13, 148, 136, 0.42);
  --chk: rgba(220, 38, 38, 0.55);
  --arrow: rgba(13, 118, 110, 0.85);
  --good: #15803d; --bad: #dc2626;
  --pw-fill: #fbfaf6; --pw-line: #23262d;
  --pb-fill: #2a2d33; --pb-line: #0d0e11; --pb-detail: #d8d4c8;
  margin: 2rem 0 2.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}
[data-post-theme="dark"] .hv {
  --lt: #c9b597; --dk: #8c6a4b;
  --on-lt: #6b5038; --on-dk: #f1e6d3;
  --last: rgba(250, 204, 21, 0.4);
  --mark: rgba(94, 234, 212, 0.45);
  --chk: rgba(248, 113, 113, 0.6);
  --arrow: rgba(4, 120, 87, 0.9);
  --good: #4ade80; --bad: #f87171;
}
.hv figcaption { margin-top: 0.75rem; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.hv figcaption strong { color: var(--text); }
.hv-fallback { color: var(--muted); font-size: 0.92rem; }
.hv.bleed { width: min(1180px, calc(100vw - 32px)); margin-left: calc(50% - min(590px, 50vw - 16px)); box-sizing: border-box; }

/* chapter numbers on sections that open with a figure */
.post-content { counter-reset: chapter; }
.post-content h2:has(+ figure.hv) { counter-increment: chapter; margin-top: 3.5rem; font-size: clamp(1.45rem, 3.2vw, 2rem); line-height: 1.2; }
.post-content h2:has(+ figure.hv)::before {
  content: "Chapter " counter(chapter);
  display: block; width: max-content; margin-bottom: 0.5rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent); padding: 0.2rem 0.65rem; border-radius: 999px;
}

/* pieces */
.cp-white .pf { fill: var(--pw-fill); stroke: var(--pw-line); stroke-width: 1.5; stroke-linejoin: round; }
.cp-white .pl { fill: none; stroke: var(--pw-line); stroke-width: 1.5; stroke-linecap: round; }
.cp-white .pe { fill: var(--pw-line); }
.cp-black .pf { fill: var(--pb-fill); stroke: var(--pb-line); stroke-width: 1.5; stroke-linejoin: round; }
.cp-black .pl { fill: none; stroke: var(--pb-detail); stroke-width: 1.4; stroke-linecap: round; }
.cp-black .pe { fill: var(--pb-detail); }

/* buttons */
.cg-btn { font: inherit; font-size: 0.9rem; font-weight: 600; padding: 0.45rem 0.85rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; line-height: 1.2; }
.cg-btn:hover:not(:disabled) { border-color: var(--accent); }
.cg-btn:disabled { opacity: 0.5; cursor: default; }
.cg-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cg-btn.icon { padding: 0.45rem 0.7rem; min-width: 2.4rem; }
.cg-btn:focus-visible, .cg-tab:focus-visible, .op-chip:focus-visible, .mob-btn:focus-visible, .lp-moves button:focus-visible, .rt-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.ok { color: var(--good); }
.bad { color: var(--bad); }
.kicker { margin: 0 0 0.25rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* the board */
.cb { width: 100%; max-width: 460px; margin: 0 auto; touch-action: manipulation; }
.cb.small { max-width: 300px; }
.cb svg { display: block; width: 100%; height: auto; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 0 var(--border), 0 6px 20px rgba(0, 0, 0, 0.08); }
.cb .lt { fill: var(--lt); } .cb .dk { fill: var(--dk); }
.cb .cb-coords text { font-size: 10px; font-weight: 700; pointer-events: none; }
.cb .on-lt { fill: var(--on-lt); } .cb .on-dk { fill: var(--on-dk); }
.cb .last { fill: var(--last); }
.cb .mark { fill: var(--mark); }
.cb .check { fill: var(--chk); }
.cb .heat { fill: var(--accent); }
.cb .heat-n { font-size: 17px; font-weight: 700; fill: var(--pw-line); pointer-events: none; }
.cb .cb-pcs use { transition: none; }
.cb .cb-pcs use.moving { transition: transform 0.28s ease; }
.cb .cb-dots circle { fill: rgba(20, 20, 20, 0.28); pointer-events: none; }
.cb .cb-dots circle.ring { fill: none; stroke: rgba(20, 20, 20, 0.3); stroke-width: 4; }
.cb .cb-dots rect.sel { fill: rgba(250, 204, 21, 0.5); pointer-events: none; }
.cb .cb-arrows { opacity: 0.85; }
.cb .cb-arrows line { stroke: var(--arrow); stroke-width: 8; stroke-linecap: round; }
.cb .cb-arrows path { fill: var(--arrow); }
.cb .cb-arrows { pointer-events: none; }
.cb.interactive svg { cursor: pointer; }
.cb.shake { animation: cg-shake 0.35s; }
@keyframes cg-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .cb.shake { animation: none; } .cb .cb-pcs use.moving { transition: none; } }

.cb-type { display: flex; gap: 0.5rem; align-items: flex-end; margin: 0.6rem 0; flex-wrap: wrap; }
.cb-type label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--muted); flex: 1 1 8rem; }
.cb-type input { font: inherit; font-size: 1rem; padding: 0.4rem 0.6rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); width: 100%; box-sizing: border-box; }
.cb-type input[aria-invalid="true"] { border-color: var(--bad); }
.cb-type input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* tabs */
.cg-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.cg-tab { font: inherit; font-size: 0.86rem; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); cursor: pointer; }
.cg-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cg-tab .tick, .op-chip .tick { display: none; margin-left: 0.3rem; color: var(--good); }
.cg-tab[aria-selected="true"] .tick { color: inherit; }
.cg-tab.done .tick, .op-chip.done .tick { display: inline; }

/* line player */
.lp { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.lp-ctrl { display: flex; justify-content: center; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.lp-side { min-width: 0; }
.lp-note { min-height: 3.2em; margin: 0.25rem 0 0.75rem; line-height: 1.5; }
.lp-note .who { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0.3rem; }
.lp-moves { list-style: none; margin: 0; padding: 0.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.15rem 0.5rem; max-height: 13rem; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: 0.86rem; position: relative; }
.lp-moves li { display: flex; align-items: center; gap: 0.2rem; }
.lp-moves .n { color: var(--muted); min-width: 1.9rem; }
.lp-moves button { font: inherit; background: none; border: 0; color: var(--text); padding: 0.1rem 0.3rem; border-radius: 6px; cursor: pointer; }
.lp-moves button.on { background: var(--accent); color: var(--accent-ink); }

/* hero */
.hero-head h3 { margin: 0 0 0.6rem; font-size: clamp(1.15rem, 2.4vw, 1.5rem); line-height: 1.25; }
.hero-head h3 span { color: var(--muted); font-weight: 400; }
.hero-meter { display: grid; gap: 0.35rem; margin-bottom: 0.75rem; }
.mt-row { display: grid; grid-template-columns: 11rem 2.6rem 1fr; align-items: center; gap: 0.5rem; font-size: 0.86rem; }
.mt-row span { color: var(--muted); }
.mt-row i { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.mt-row em { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.mt-row:nth-child(2) em { background: var(--muted); }

/* daily card */
.daily-top { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.daily-btns { display: flex; gap: 0.4rem; }
.daily-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.daily-cards { display: grid; gap: 0.7rem; }
.dc { border: 1px solid var(--border); border-radius: 14px; padding: 0.75rem 0.9rem; background: var(--bg); }
.dc p { margin: 0.3rem 0 0; line-height: 1.5; font-size: 0.95rem; }
.dc-tag { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.daily-solved { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* puzzle */
.pz { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.pz.compact { grid-template-columns: minmax(0, 1fr); }
.pz.compact .cb { max-width: 360px; }
.pz-head { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.pz-motif { font-weight: 700; font-size: 1.05rem; }
.pz-turn { font-size: 0.78rem; padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pz-status { min-height: 3em; line-height: 1.5; margin: 0.5rem 0 0.25rem; }
.pz-line { font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-weight: 700; margin-right: 0.3rem; }
.pz-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* openings */
.op-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.6rem 1rem; margin-bottom: 0.8rem; }
.op-group { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.op-g { width: 100%; font-size: 0.8rem; font-weight: 700; color: var(--muted); font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); }
.op-chip { font: inherit; font-size: 0.85rem; padding: 0.35rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.op-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; }
.op-mode { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.op-title { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.op-title h4 { margin: 0; font-size: 1.15rem; }
.op-eco, .op-lvl { font-size: 0.75rem; padding: 0.12rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.op-idea { margin: 0 0 0.5rem; line-height: 1.5; }
.op-info dl { margin: 0 0 0.75rem; font-size: 0.92rem; line-height: 1.45; }
.op-info dt { font-weight: 700; margin-top: 0.4rem; }
.op-info dd { margin: 0.1rem 0 0; color: var(--muted); }
.op-train { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.op-status { min-height: 3em; line-height: 1.5; }
.op-prog { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: center; font-size: 0.85rem; color: var(--muted); margin: 0.4rem 0 0.8rem; }
.op-prog i { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.op-prog em { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }

.trap-head h4, .eg-head h4 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.trap-res { margin: 0 0 0.4rem; font-weight: 700; color: var(--bad); }
.eg-res { display: inline-block; font-size: 0.8rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; margin-bottom: 0.4rem; }
.eg-res.win { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.eg-res.draw { background: var(--surface-2); color: var(--text); }

/* mobility */
.mob-pick { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.mob-btn { display: flex; align-items: center; gap: 0.3rem; font: inherit; font-size: 0.88rem; font-weight: 600; padding: 0.25rem 0.75rem 0.25rem 0.35rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; text-transform: capitalize; }
.mob-btn svg { width: 28px; height: 28px; }
.mob-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mob-body { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.tile { border: 1px solid var(--border); border-radius: 14px; padding: 0.6rem 0.8rem; background: var(--bg); }
.tile b { display: block; font-size: 1.6rem; line-height: 1.1; }
.tile span { font-size: 0.82rem; color: var(--muted); }
.mob-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.mob-note { line-height: 1.5; }

/* plans */
.plan { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.plan-txt h4 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.plan-txt p { line-height: 1.55; }
.plan-key { font-size: 0.82rem; color: var(--muted); }

/* KPK */
.kpk { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.kpk-goal { margin-top: 0; line-height: 1.5; }
.kpk-verdict { display: inline-flex; flex-direction: column; padding: 0.45rem 0.8rem; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); }
.kpk-verdict span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.kpk-verdict b { font-size: 1.1rem; }
.kpk-verdict.win b { color: var(--good); }
.kpk-status { min-height: 3em; line-height: 1.5; }
.kpk-tip { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }

/* routine */
.rt { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.rt-pic svg { display: block; width: 100%; height: auto; }
.rt-ring { fill: none; stroke: var(--border); stroke-width: 3; stroke-dasharray: 6 6; }
.rt-node { cursor: pointer; }
.rt-node circle { fill: var(--bg); stroke: var(--accent); stroke-width: 3; }
.rt-node text { font-size: 20px; font-weight: 700; fill: var(--text); pointer-events: none; }
.rt-node.on circle { fill: var(--accent); }
.rt-node.on text { fill: var(--accent-ink); }
.rt-c1 { font-size: 17px; font-weight: 700; fill: var(--text); }
.rt-c2 { font-size: 13px; fill: var(--muted); }
.rt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; counter-reset: rt; }
.rt-list li { counter-increment: rt; }
.rt-list button { display: block; width: 100%; text-align: left; font: inherit; padding: 0.55rem 0.8rem 0.55rem 2.4rem; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; position: relative; }
.rt-list button::before { content: counter(rt); position: absolute; left: 0.8rem; top: 0.55rem; font-weight: 700; color: var(--accent); }
.rt-list button span { display: none; margin-top: 0.25rem; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.rt-list button[aria-pressed="true"] { border-color: var(--accent); }
.rt-list button[aria-pressed="true"] span { display: block; }

/* facts */
.fx-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.fx-tiles sup { font-size: 0.6em; }
.pf { border: 1px solid var(--border); border-radius: 14px; padding: 0.8rem 0.9rem; background: var(--bg); }
.pf-top { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.pf-top p { margin: 0; flex: 1 1 18rem; line-height: 1.45; }
.pf-bars { margin-top: 0.8rem; display: grid; gap: 0.35rem; }
.pf-row { display: grid; grid-template-columns: 4.2rem 1fr 6.2rem; gap: 0.5rem; align-items: center; font-size: 0.86rem; }
.pf-k { color: var(--muted); }
.pf-bar { display: block; height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.pf-bar em { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; transition: width 0.4s; }
.pf-v { text-align: right; font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); }
.pf-axis, .pf-note { font-size: 0.8rem; color: var(--muted); margin: 0.4rem 0 0; }

/* phone */
@media (max-width: 760px) {
  .hv { padding: 0.75rem; }
  .lp, .pz, .op-train, .mob-body, .plan, .kpk, .rt, .daily-grid { grid-template-columns: minmax(0, 1fr); }
  .fx-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mt-row { grid-template-columns: 8.5rem 2.4rem 1fr; font-size: 0.8rem; }
  .rt-pic { max-width: 260px; margin: 0 auto; }
  .lp-moves { max-height: 9rem; }
  .tile b { font-size: 1.3rem; }
  .pf-row { grid-template-columns: 3.6rem 1fr 5.4rem; }
}
