/* ============================================================================
 * Opening pages (docs/seo) — visual layer on top of theme.css tokens.
 * "Scoresheet on an analysis board": board-grid hero, a material bar that reads
 * as the board's own colors, and chess notation set in mono. All classes are
 * `op-` prefixed so they never collide with Bootstrap or the games UI.
 * ========================================================================== */

.op {
  --op-white: var(--sc-cream); /* White wins — light squares */
  --op-draw: #7f8896; /* Draws — neutral slate */
  --op-black: #3b4250; /* Black wins — dark squares */
  max-width: 1100px;
}

/* ---- Breadcrumb --------------------------------------------------------- */
.op-crumbs {
  font-family: var(--sc-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--sc-faint);
  margin-bottom: 1rem;
}
.op-crumbs a {
  color: var(--sc-muted);
  text-decoration: none;
}
.op-crumbs a:hover {
  color: var(--sc-accent-hi);
}
.op-crumbs .op-sep {
  margin: 0 0.5rem;
  color: var(--sc-border);
}

/* ---- Hero --------------------------------------------------------------- */
.op-hero {
  position: relative;
  overflow: hidden;
  background: var(--sc-surface-1);
  border: 1px solid var(--sc-border);
  border-radius: var(--bs-border-radius-lg);
  padding: clamp(1.5rem, 4vw, 2.75rem);
  box-shadow: var(--sc-shadow-1);
}
/* Faint 8×8 board motif — the subject's own material, barely there. */
.op-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      45deg,
      var(--sc-cream) 25%,
      transparent 25% 75%,
      var(--sc-cream) 75%
    ),
    linear-gradient(45deg, var(--sc-cream) 25%, transparent 25% 75%, var(--sc-cream) 75%);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  opacity: 0.022;
  pointer-events: none;
}
.op-hero > * {
  position: relative;
}
.op-eyebrow {
  font-family: var(--sc-font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sc-accent-hi);
  margin: 0 0 0.6rem;
}
.op-title {
  font-family: var(--sc-font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--sc-text);
  margin: 0;
}
.op-lead {
  color: var(--sc-muted);
  font-size: 1.02rem;
  max-width: 60ch;
  margin: 0.9rem 0 0;
}
.op-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.op-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--sc-font-mono);
  font-size: 0.8rem;
  color: var(--sc-text);
  background: var(--sc-surface-2);
  border: 1px solid var(--sc-border);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
}
.op-chip b {
  color: var(--sc-accent-hi);
  font-weight: 600;
}

/* ---- Section scaffolding ------------------------------------------------ */
.op-section {
  margin-top: 2.5rem;
}
.op-section-title {
  font-family: var(--sc-font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--sc-text);
  margin: 0 0 1rem;
  padding-left: 0.7rem;
  border-left: 3px solid var(--sc-accent);
}

/* ---- Signature: the material bar --------------------------------------- */
.op-results {
  background: var(--sc-surface-1);
  border: 1px solid var(--sc-border);
  border-radius: var(--bs-border-radius-lg);
  padding: clamp(1.25rem, 3vw, 1.75rem);
}
.op-bar {
  display: flex;
  height: 2.75rem;
  border-radius: var(--bs-border-radius-sm);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.op-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sc-font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: flex-basis 0.2s ease;
}
.op-seg--white {
  background: var(--op-white);
  color: #23262c;
}
.op-seg--draw {
  background: var(--op-draw);
  color: #12151a;
}
.op-seg--black {
  background: var(--op-black);
  color: var(--sc-text);
}
.op-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
}
.op-legend-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.op-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  flex: none;
}
.op-swatch--white {
  background: var(--op-white);
}
.op-swatch--draw {
  background: var(--op-draw);
}
.op-swatch--black {
  background: var(--op-black);
}
.op-legend-label {
  color: var(--sc-muted);
  font-size: 0.85rem;
}
.op-legend-val {
  font-family: var(--sc-font-mono);
  font-weight: 600;
  color: var(--sc-text);
}

/* ---- Variations — a scoresheet of lines -------------------------------- */
.op-variations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}
.op-variation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--sc-surface-1);
  border: 1px solid var(--sc-border);
  border-radius: var(--bs-border-radius);
  padding: 0.7rem 0.85rem;
  color: var(--sc-text);
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease,
    background 0.15s ease;
}
a.op-variation:hover {
  border-color: var(--sc-accent);
  background: var(--sc-surface-2);
  transform: translateY(-2px);
}
.op-variation-name {
  font-family: var(--sc-font-mono);
  font-size: 0.82rem;
  line-height: 1.35;
  min-width: 0;
}
.op-variation-count {
  font-family: var(--sc-font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sc-accent-hi);
  background: color-mix(in srgb, var(--sc-accent) 14%, transparent);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  flex: none;
}
.op-variation--static {
  color: var(--sc-muted);
}
.op-more {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--sc-faint);
}

/* ---- Notable games ------------------------------------------------------ */
.op-games {
  border: 1px solid var(--sc-border);
  border-radius: var(--bs-border-radius-lg);
  overflow: hidden;
}
.op-game {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--sc-border-soft);
  background: var(--sc-surface-1);
  transition: background 0.12s ease;
}
.op-game:first-child {
  border-top: 0;
}
.op-game:hover {
  background: var(--sc-surface-2);
}
/* Player names on ONE line: "White 1232 vs Black 1235" */
.op-players {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
}
.op-player {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}
.op-player-name {
  color: var(--sc-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.op-elo {
  font-family: var(--sc-font-mono);
  font-size: 0.72rem;
  color: var(--sc-faint);
  flex: none;
}
.op-vs {
  font-size: 0.72rem;
  color: var(--sc-faint);
}
.op-game-meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.op-result {
  font-family: var(--sc-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--bs-border-radius-sm);
  white-space: nowrap;
}
.op-result--white {
  background: color-mix(in srgb, var(--op-white) 20%, transparent);
  color: var(--sc-cream);
}
.op-result--black {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sc-muted);
}
.op-result--draw {
  background: color-mix(in srgb, var(--op-draw) 20%, transparent);
  color: #b9c1cd;
}
.op-date {
  font-family: var(--sc-font-mono);
  font-size: 0.75rem;
  color: var(--sc-faint);
}
.op-review {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sc-accent-hi);
  text-decoration: none;
  white-space: nowrap;
}
.op-review:hover {
  color: #86d6a4;
}
.op-review::after {
  content: ' →';
}

/* ---- Related openings + CTA -------------------------------------------- */
.op-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.op-pill {
  font-size: 0.85rem;
  color: var(--sc-text);
  background: var(--sc-surface-1);
  border: 1px solid var(--sc-border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}
.op-pill:hover {
  border-color: var(--sc-accent);
  color: var(--sc-accent-hi);
}
.op-cta {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(
    120deg,
    var(--sc-surface-1),
    color-mix(in srgb, var(--sc-accent) 10%, var(--sc-surface-1))
  );
  border: 1px solid var(--sc-border);
  border-radius: var(--bs-border-radius-lg);
  padding: 1.5rem;
}
.op-cta-text {
  flex: 1 1 240px;
}
.op-cta-text h2 {
  font-family: var(--sc-font-display);
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
}
.op-cta-text p {
  color: var(--sc-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ---- Chessboard (server-rendered position) ----------------------------- */
.op-hero--split {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 340px);
  gap: clamp(1.25rem, 4vw, 2.5rem);
  align-items: center;
}
.op-board {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: var(--bs-border-radius);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: var(--sc-shadow-board);
  justify-self: end;
}
.op-sq {
  display: flex;
  align-items: center;
  justify-content: center;
}
.op-sq--l {
  background: #e9e3d2;
}
.op-sq--d {
  background: #6d9860;
}
.op-pc {
  font-size: clamp(1.05rem, 3.6vw, 1.85rem);
  line-height: 1;
}
.op-pc--w {
  color: #fbfaf6;
  text-shadow:
    0 0 1px rgba(0, 0, 0, 0.9),
    0 1px 1px rgba(0, 0, 0, 0.4);
}
.op-pc--b {
  color: #1a1d23;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.12);
}
@media (max-width: 640px) {
  .op-hero--split {
    grid-template-columns: 1fr;
  }
  .op-board {
    justify-self: start;
  }
}

/* ---- Interactive board (opening-board-app, chessground) ----------------- */
.op-board-mount {
  width: 100%;
}
.op-cg {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.op-cg-holder {
  width: 100%;
  aspect-ratio: 1 / 1;
}
.op-cg-board {
  width: 100%;
  height: 100%;
}
.op-cg-board.cg-wrap {
  border-radius: var(--bs-border-radius);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: var(--sc-shadow-board);
}
/* Controls reuse the games-app buttons (react-bootstrap variant="secondary" + FA icons). */
.op-cg-moves {
  font-family: var(--sc-font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  gap: 0.05rem 0.35rem;
  max-height: 6.4rem;
  overflow-y: auto;
}
.op-cg-row {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
}
.op-cg-no {
  color: var(--sc-faint);
}
.op-cg-move {
  background: none;
  border: 0;
  color: var(--sc-text);
  font: inherit;
  padding: 0 0.2rem;
  border-radius: 3px;
  cursor: pointer;
}
.op-cg-move:hover {
  color: var(--sc-accent-hi);
}
.op-cg-move.is-current {
  background: var(--sc-accent);
  color: #06210f;
  font-weight: 600;
}

/* ---- Hub (/openings) index --------------------------------------------- */
.op-family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.6rem;
}
.op-family {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--sc-surface-1);
  border: 1px solid var(--sc-border);
  border-radius: var(--bs-border-radius);
  padding: 0.75rem 0.9rem;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease,
    background 0.15s ease;
}
.op-family:hover {
  border-color: var(--sc-accent);
  background: var(--sc-surface-2);
  transform: translateY(-2px);
}
.op-family-name {
  font-family: var(--sc-font-display);
  font-weight: 500;
  color: var(--sc-text);
}
.op-family-count {
  font-family: var(--sc-font-mono);
  font-size: 0.75rem;
  color: var(--sc-faint);
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .op-variation,
  .op-family,
  .op-seg {
    transition: none;
  }
  a.op-variation:hover,
  .op-family:hover {
    transform: none;
  }
}
