/* Chess demo — styled to match erdem6.com (warm ink/bone + vermilion). */
:root {
  --bg: oklch(0.15 0.004 60);
  --surface: oklch(0.186 0.005 60);
  --elevated: oklch(0.224 0.006 60);
  --fg: oklch(0.95 0.01 83);
  --muted: oklch(0.66 0.012 72);
  --faint: oklch(0.5 0.011 66);
  --line: oklch(0.95 0.01 83 / 0.12);
  --line-strong: oklch(0.95 0.01 83 / 0.22);
  --accent: oklch(0.7 0.19 36);

  --sq-light: oklch(0.82 0.035 78);
  --sq-dark: oklch(0.45 0.04 58);
  --piece-white: oklch(0.97 0.012 85);
  --piece-black: oklch(0.2 0.02 52);

  --serif: "Fraunces", "Hoefler Text", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 90% at 50% -10%, oklch(0.7 0.19 36 / 0.1), transparent 55%),
    var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: clamp(1.25rem, 5vw, 3rem) 1.25rem 3rem;
}

.wrap {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--faint);
  text-decoration: none;
  transition: color 0.2s ease;
}
.back:hover {
  color: var(--accent);
}

.head {
  text-align: center;
  margin: clamp(1.5rem, 5vw, 2.75rem) 0 clamp(1.25rem, 4vw, 2rem);
}

.eyebrow {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.6rem, 11vw, 4rem);
  letter-spacing: -0.015em;
  line-height: 1;
}

.lede {
  margin: 1rem auto 0;
  max-width: 34ch;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--muted);
}
.lede span {
  display: block;
  color: var(--faint);
}

/* Board -------------------------------------------------------------- */
.board-frame {
  width: min(88vw, 460px);
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 24px 60px oklch(0 0 0 / 0.45);
}

#chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 2px;
  overflow: hidden;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 8.5vw, 2.6rem);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.square.light {
  background: var(--sq-light);
}
.square.dark {
  background: var(--sq-dark);
}

.white-piece {
  color: var(--piece-white);
  text-shadow: 0 1px 1.5px oklch(0 0 0 / 0.45);
}
.black-piece {
  color: var(--piece-black);
  text-shadow: 0 1px 1px oklch(1 0 0 / 0.12);
}

/* selected origin square */
.square.selected {
  background: var(--accent) !important;
  box-shadow: inset 0 0 0 2px oklch(0.95 0.01 83 / 0.55);
}

/* legal-move markers */
.square.valid-move::after {
  content: "";
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.8;
  pointer-events: none;
}
/* capture target: ring instead of dot */
.square.valid-move.white-piece::after,
.square.valid-move.black-piece::after {
  width: 78%;
  height: 78%;
  background: transparent;
  border: 3px solid var(--accent);
  opacity: 0.9;
}

/* Controls ----------------------------------------------------------- */
.controls {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

#status {
  margin: 0;
  min-height: 1.2em;
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--fg);
}

#resetButton {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.55rem 1.3rem;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
}
#resetButton:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: oklch(0.7 0.19 36 / 0.08);
}
#resetButton:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Footer ------------------------------------------------------------- */
.foot {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--faint);
}
.foot a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}
.foot a:hover {
  color: var(--accent);
}

/* Embed mode (?embed=1): board + controls only, for the inline demo. */
body.embed {
  padding: 0.75rem;
  background: transparent;
}
body.embed .back,
body.embed .head,
body.embed .foot {
  display: none;
}
body.embed .board-frame {
  width: 100%;
  box-shadow: none;
  border: none;
  padding: 0;
  background: transparent;
}
body.embed .controls {
  margin-top: 0.9rem;
  flex-direction: row;
  justify-content: space-between;
  width: 100%;
}
body.embed #status {
  font-size: 0.78rem;
}
body.embed #resetButton {
  padding: 0.4rem 1rem;
  font-size: 0.72rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
