:root {
  color-scheme: light;
  --paper: #f4f1e8;
  --paper-soft: #ebe6d9;
  --ink: #151515;
  --muted: #6d695f;
  --line: #1f1f1f;
  --line-soft: rgba(31, 31, 31, 0.16);
  --tile: rgba(255, 253, 247, 0.9);
  --tile-muted: rgba(235, 230, 217, 0.78);
  --accent: #236d62;
  --accent-2: #a05a32;
  --shadow-line: rgba(31, 31, 31, 0.14);
  --radius: 6px;
  --container: 1060px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #111111;
    --paper-soft: #181818;
    --ink: #f2efe7;
    --muted: #aaa59b;
    --line: #f2efe7;
    --line-soft: rgba(242, 239, 231, 0.16);
    --tile: rgba(24, 24, 24, 0.9);
    --tile-muted: rgba(32, 32, 32, 0.82);
    --accent: #80cbc0;
    --accent-2: #e5a06d;
    --shadow-line: rgba(242, 239, 231, 0.12);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111111;
  --paper-soft: #181818;
  --ink: #f2efe7;
  --muted: #aaa59b;
  --line: #f2efe7;
  --line-soft: rgba(242, 239, 231, 0.16);
  --tile: rgba(24, 24, 24, 0.9);
  --tile-muted: rgba(32, 32, 32, 0.82);
  --accent: #80cbc0;
  --accent-2: #e5a06d;
  --shadow-line: rgba(242, 239, 231, 0.12);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  touch-action: pan-x pan-y;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: var(--font-sans);
  line-height: 1.55;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

p,
h1,
h2 {
  margin: 0;
}

h1,
h2 {
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.05;
}

h1 {
  max-width: 780px;
  font-size: 4.45rem;
}

h2 {
  font-size: 2rem;
}

button {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  transform: translateY(-160%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 0.65rem 0.9rem;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

.section {
  padding: 5.5rem 0;
}

.section-tight {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(16px);
}

.header-inner {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
}

.brand:hover {
  color: var(--ink);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-link,
.theme-toggle,
.language-toggle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0.48rem 0.76rem;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.nav-link {
  min-width: 82px;
}

.nav-link:hover,
.theme-toggle:hover,
.language-toggle:hover {
  color: var(--ink);
  border-color: var(--line-soft);
  background: var(--tile);
}

.theme-toggle {
  min-width: 68px;
}

.language-toggle {
  min-width: 48px;
}

.intro {
  min-height: auto;
  display: grid;
  align-items: start;
  padding-top: 2.25rem;
  padding-bottom: 1.15rem;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 2rem;
}

.hsv-strip {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.95rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.intro-copy .hsv-strip p {
  margin: 0;
  color: inherit;
  font-size: inherit;
  line-height: 1;
}

.hsv-logo {
  width: auto;
  height: 1em;
  display: block;
  flex: 0 0 auto;
}

.eyebrow {
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(110px, 0.25fr) minmax(0, 1fr);
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.9rem;
}

.section-heading .eyebrow {
  margin-bottom: 0;
}

.section-heading-compact {
  grid-template-columns: 1fr;
  margin-bottom: 0.75rem;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  padding-top: 0.25rem;
  padding-bottom: 0;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.tile {
  min-height: 132px;
  display: grid;
  align-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile);
  padding: 1rem;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.tile:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--paper-soft);
  color: var(--ink);
}

.tile span {
  color: var(--accent-2);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 900;
}

.tile strong {
  align-self: end;
  font-size: 1.2rem;
}

.tile small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.tile-muted {
  background: var(--tile-muted);
  color: var(--muted);
}

.puzzle-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 1rem;
  align-items: start;
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile);
  padding: 1rem;
}

.puzzle-head {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  padding-right: 1rem;
}

.puzzle-head .eyebrow {
  color: var(--accent-2);
  margin-bottom: 0;
}

.puzzle-head h2 {
  max-width: 280px;
  margin-block: auto;
}

.puzzle-status {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.puzzle-play {
  display: grid;
  gap: 0.75rem;
}

.chessground-board {
  box-sizing: border-box;
  width: min(100%, 400px);
  height: auto;
  aspect-ratio: 1;
  justify-self: end;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
  background: #b8ced9;
  touch-action: none;
}

.chessground-board cg-container,
.chessground-board cg-board {
  inset: 0;
  width: 100%;
  height: 100%;
}

.chessground-board cg-board {
  background-color: #b8ced9;
  background-image: url("../img/board-blue2.jpg");
  background-size: 100% 100%;
}

.chessground-board square.move-dest {
  background: radial-gradient(rgba(20, 85, 30, 0.5) 22%, #208530 0, rgba(0, 0, 0, 0.3) 0, transparent 0);
}

.chessground-board square.move-dest.oc {
  background: radial-gradient(transparent 0%, transparent 80%, rgba(20, 85, 30, 0.5) 80%);
}

.chessground-board square.move-dest:hover,
.chessground-board square.selected {
  background-color: rgba(20, 85, 30, 0.5);
}

.chessground-board square.last-move {
  background-color: rgba(155, 199, 0, 0.41);
}

.chessground-board square.check {
  background: radial-gradient(
    ellipse at center,
    rgba(255, 0, 0, 1) 0%,
    rgba(231, 0, 0, 1) 25%,
    rgba(169, 0, 0, 0) 89%,
    rgba(158, 0, 0, 0) 100%
  );
}

.chessground-board piece {
  cursor: grab;
}

.chessground-board piece.dragging {
  cursor: grabbing;
}

.puzzle-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--tile);
  color: var(--ink);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.about-strip {
  padding: 0.85rem 0;
}

.about-copy {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile);
  padding: 1rem;
}

.about-copy p {
  max-width: 740px;
  color: var(--muted);
  font-size: 1.03rem;
}

.article-hero {
  padding-top: 3rem;
  padding-bottom: 1.25rem;
}

.article-hero-copy {
  display: grid;
  gap: 0.85rem;
}

.article-hero-copy h1 {
  font-size: 3.3rem;
}

.article-hero-copy p {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.05rem;
}

.article-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.article-card {
  min-height: 132px;
  display: grid;
  align-content: space-between;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile);
  padding: 1rem;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.article-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--paper-soft);
  color: var(--ink);
}

.article-card strong {
  font-size: 1.18rem;
  line-height: 1.25;
}

.article-card small,
.article-meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.article-tag {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--accent);
  padding: 0.22rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.article-empty {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile);
  color: var(--muted);
  padding: 1rem;
}

.ai-news-note {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.25rem;
}

.ai-news-note p:not(.eyebrow) {
  max-width: 820px;
  color: var(--muted);
  font-size: 0.95rem;
}

.digest-article {
  max-width: 820px;
}

.digest-article h1 {
  margin-bottom: 0.8rem;
  font-size: 3rem;
}

.digest-meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.digest-section {
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.digest-section h2 {
  margin-bottom: 1rem;
}

.digest-item {
  display: grid;
  gap: 0.45rem;
  padding: 1rem 0;
}

.digest-item + .digest-item {
  border-top: 1px solid var(--line-soft);
}

.digest-item h3 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

.digest-item p {
  color: var(--muted);
}

.digest-item a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.site-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.footer-inner a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink);
  padding: 0.42rem 0.72rem;
  line-height: 1;
}

.footer-inner a:hover {
  border-color: var(--line-soft);
  background: var(--tile);
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .tile {
    transition: none;
  }

  .tile:hover {
    transform: none;
  }
}

@media (max-width: 820px) {
  .site-nav {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    border: 0;
    background: transparent;
    padding: 0;
  }

  .nav-link,
  .theme-toggle,
  .language-toggle {
    justify-content: center;
    padding: 0.85rem 0.9rem;
  }

  .intro-grid,
  .puzzle-block,
  .section-heading {
    grid-template-columns: 1fr;
  }

  .puzzle-head {
    min-height: auto;
    border-bottom: 1px solid var(--line-soft);
    padding-right: 0;
    padding-bottom: 1rem;
  }

  .puzzle-head h2 {
    margin-block: 0;
  }

  .chessground-board {
    justify-self: center;
  }

  .tile-grid {
    grid-template-columns: 1fr;
  }

  .article-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .container {
    width: min(100% - 1.1rem, var(--container));
  }

  .section {
    padding: 4rem 0;
  }

  .section-tight {
    padding-top: 1rem;
    padding-bottom: 0.75rem;
  }

  .about-strip {
    padding: 1rem 0 0.75rem;
  }

  .intro {
    padding-top: 2rem;
  }

  .intro {
    padding-bottom: 1rem;
  }

  h2 {
    font-size: 1.65rem;
  }

  .article-hero-copy h1,
  .digest-article h1 {
    font-size: 2.35rem;
  }

  .hsv-strip {
    gap: 0.55rem;
    font-size: 0.86rem;
  }

  .tile {
    min-height: 112px;
  }

  .puzzle-block {
    padding: 0.75rem;
  }

  .footer-inner {
    padding: 0.75rem 0;
  }
}
