/* ==========================================================================
   Chess Anywhere — homepage
   The hero board and the six sections beneath it. Shared chrome (theme,
   header, mobile nav, footer, touch rules) is in css/base.css.

   The design was authored in Claude Design with most styling inline on the
   elements. Anything that repeats, and anything an inline style physically
   cannot express — :hover, :focus-visible, media queries, keyframes — lives
   here instead. Rendered result is the same; the markup is readable.
   ========================================================================== */

/* ---------------------------------------------------------------------- */
/* Board colours                                                          */
/* ---------------------------------------------------------------------- */
/* Tokens rather than values computed in JS, so board-ui.js never has to know
   which theme is on. */

:root {
  --sq-light: #f2f2f3;
  --sq-dark: #b7b7ba;
  --piece-white: #f5f5f8;
  --piece-black: #1d1f20;
  --piece-white-edge: -1px -1px 0 #1d1f20, 1px -1px 0 #1d1f20,
                      -1px 1px 0 #1d1f20, 1px 1px 0 #1d1f20;
  --piece-black-edge: 0 1px 1px rgba(0, 0, 0, 0.2);
}

[data-theme='dark'] {
  --sq-light: #3a3d3f;
  --sq-dark: #17181a;
  --piece-white: #f5f5f8;
  --piece-black: #e7e7ea;
  --piece-black-edge: -1px -1px 0 #0b0c0d, 1px -1px 0 #0b0c0d,
                      -1px 1px 0 #0b0c0d, 1px 1px 0 #0b0c0d;
}

/* ---------------------------------------------------------------------- */
/* Hero                                                                    */
/* ---------------------------------------------------------------------- */

.hero { padding: clamp(40px, 7vw, 88px) 0 clamp(48px, 8vw, 80px); }

.hero__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
  gap: 40px;
}

.hero__copy { max-width: 640px; }

.hero__title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.05;
  margin: 0 0 20px;
}

.hero__sub {
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 28px;
  max-width: 56ch;
  color: color-mix(in srgb, var(--color-text) 85%, transparent);
}

.hero__ctas {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.hero__note {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
}

.hero__panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  max-width: 520px;
  align-content: start;
}

.hero__claim {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-accent-700);
  margin: 0;
}

/* ---------------------------------------------------------------------- */
/* Board                                                                   */
/* ---------------------------------------------------------------------- */

.board {
  border: 1px solid var(--color-divider);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

.sq {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: clamp(22px, 6vw, 38px);
  line-height: 1;
  background: var(--sq-dark);
  color: inherit;
}
.sq--light { background: var(--sq-light); }
.sq--last { background: color-mix(in srgb, var(--color-accent) 16%, transparent); }
.sq--selected { background: color-mix(in srgb, var(--color-accent) 40%, transparent); }
.sq:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; z-index: 1; }

.sq--w { color: var(--piece-white); text-shadow: var(--piece-white-edge); }
.sq--b { color: var(--piece-black); text-shadow: var(--piece-black-edge); }

/* Move hints: a dot on an empty square, a ring around a capturable piece. */
.dot {
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-accent) 60%, transparent);
  pointer-events: none;
}
.dot--capture {
  width: 86%;
  height: 86%;
  background: transparent;
  border: 3px solid color-mix(in srgb, var(--color-accent) 75%, transparent);
}

.board-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.board-status p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

.promotion {
  display: flex;
  gap: 8px;
  border: 1px solid var(--color-divider);
  padding: 10px;
}
.promotion[hidden] { display: none; }

.movelist {
  border: 1px solid var(--color-divider);
  padding: 10px 14px;
}
.movelist summary {
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.movelist__scroll {
  font-family: var(--font-mono);
  font-size: 13px;
  max-height: 160px;
  overflow: auto;
  margin-top: 10px;
}
.movelist__row {
  display: grid;
  grid-template-columns: 2em 1fr 1fr;
  gap: 6px;
  padding: 2px 0;
}
.movelist__num { color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* ---------------------------------------------------------------------- */
/* Segmented option rows (computer levels, clock presets)                   */
/* ---------------------------------------------------------------------- */

.opts {
  display: flex;
  gap: 2px;
}

.opt {
  flex: 1;
  padding: 10px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--color-divider);
  background: transparent;
  color: var(--color-text);
}
.opt:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.opt[aria-pressed='true'] {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

.opt--level {
  padding: 10px 4px;
  font-size: 12px;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------- */
/* Three ways to play                                                      */
/* ---------------------------------------------------------------------- */

.ways-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 32px;
}

.way { padding: 28px; }

.way__title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  text-transform: uppercase;
  font-size: 20px;
  margin: 0 0 12px;
}

.way__stage {
  height: 120px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Bluetooth — two handsets, each pulsing a ring toward the other. */
.ble-stage {
  position: relative;
  justify-content: space-between;
  padding: 0 20px;
}
.handset {
  position: relative;
  width: 34px;
  height: 60px;
  border: 2px solid var(--color-text);
  border-radius: 6px;
}
.ble-ring {
  position: absolute;
  top: 50%;
  width: 60px;
  height: 60px;
  margin-top: -30px;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  animation: blePulse 2.4s ease-out infinite;
}
.ble-ring--l { left: 100%; }
.ble-ring--r { right: 100%; animation-delay: 1.2s; }

@keyframes blePulse {
  0% { transform: scale(0.3); opacity: 0.75; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Pass & Play — a quartered board that turns to face the other player. */
.pass-board {
  width: 80px;
  height: 80px;
  border: 2px solid var(--color-text);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  transition: transform 260ms linear;
}
.pass-board.is-flipped { transform: rotate(180deg); }
.pass-board i:nth-child(1),
.pass-board i:nth-child(4) { background: var(--color-bg); }
.pass-board i:nth-child(2),
.pass-board i:nth-child(3) { background: var(--color-neutral-400); }

/* ---------------------------------------------------------------------- */
/* Real chess, proven                                                      */
/* ---------------------------------------------------------------------- */

.proven-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 32px;
}

/* Drawing-sheet title block above the rule-coverage table. */
.dochead {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-divider);
}
.dochead__title {
  flex: 1;
  min-width: 16ch;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
.dochead__cell {
  border-left: 1px solid var(--color-divider);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
  white-space: nowrap;
}

.table--mono {
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 0;
}

.aside-note {
  border: 1px solid var(--color-divider);
  padding: 20px;
}
.aside-note__label,
.callout__label {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent-700);
}
.aside-note p:last-child,
.callout p:last-child {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: color-mix(in srgb, var(--color-text) 82%, transparent);
}

/* Rubber-stamp verification mark, set slightly off-square. */
.stamp {
  border: 2px solid var(--color-accent-700);
  padding: 14px 18px;
  transform: rotate(-1.2deg);
  align-self: flex-start;
}
.stamp p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-700);
}

.proven-aside {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------------------------------------------------------------------- */
/* Clocks                                                                  */
/* ---------------------------------------------------------------------- */

.clocks-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
}

.callout {
  border: 1px solid var(--color-accent-700);
  padding: 18px 20px;
}

.clock-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clock-face {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--color-divider);
  padding: 18px 22px;
  cursor: pointer;
  background: var(--color-bg);
  color: var(--color-text);
}
.clock-face.is-active {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}
.clock-face__label {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.clock-face__time {
  font-family: var(--font-mono);
  font-size: clamp(40px, 6vw, 64px);
  font-variant-numeric: tabular-nums;
}
.clock-face.is-running .clock-face__time {
  animation: flagTick 1s steps(1) infinite;
}

@keyframes flagTick {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.35; }
}

/* ---------------------------------------------------------------------- */
/* The rest                                                                */
/* ---------------------------------------------------------------------- */

/* The 1px gap is the divider — cells sit on a divider-coloured grid. */
.rest-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--color-divider);
}

.rest-cell {
  background: var(--color-bg);
  padding: 22px;
}
.rest-cell h3 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 17px;
  text-transform: uppercase;
  margin: 0 0 8px;
}

/* ---------------------------------------------------------------------- */
/* What it doesn't do                                                      */
/* ---------------------------------------------------------------------- */

.doesnt {
  padding: clamp(56px, 9vw, 100px) 0;
  background: var(--color-accent-900);
  color: #f2f2f3;
}

.doesnt__title {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: clamp(32px, 6vw, 54px);
  margin: 0 0 40px;
}

.doesnt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 1px;
  background: color-mix(in srgb, #f2f2f3 20%, transparent);
}

.doesnt-cell {
  background: var(--color-accent-900);
  padding: 24px;
}
.doesnt-cell p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* ---------------------------------------------------------------------- */
/* Responsive — homepage                                                  */
/* ---------------------------------------------------------------------- */

@media (max-width: 700px) {
  .proven-grid,
  .clocks-grid,
  .rest-grid { grid-template-columns: 1fr; }

  /* The board is the argument the page is making, so on a phone it gets the
     full width — 8 squares out of 342px is a 43px square, out of 390px it is
     a 48px one, and that difference is the difference between playable and
     fiddly. */
  .board {
    width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
    border-left: 0;
    border-right: 0;
  }

  /* The glyph is sized off the square, not the viewport: a full-bleed board
     puts a square at 12.5vw, and a piece wants roughly 60% of that. */
  .sq { font-size: 7.5vw; }

  .hero__panel { gap: 16px; }

  /* Long rule text in a narrow mono column needs the room. */
  .table--mono { font-size: 12px; }

  .stamp { transform: none; }
}

@media (max-width: 380px) {
  /* Four segmented options stop fitting side by side before the phone runs
     out of width — two rows of two beats four columns of clipped text. */
  .opts { flex-wrap: wrap; }
  .opts .opt { flex: 1 0 calc(50% - 1px); }
}

@media (prefers-reduced-motion: reduce) {
  .ble-ring,
  .pass-board,
  .clock-face.is-running .clock-face__time {
    animation: none !important;
    transition: none !important;
  }
}
