/* gambit.ad — ink on paper, one vermilion accent.
   The I-beam marks of the logo are the recurring motif: wordmark, caret, product card. */

@font-face {
  font-family: 'Jost';
  src: url('/assets/fonts/jost-latin-wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DM Mono';
  src: url('/assets/fonts/dm-mono-latin-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3f1ec;
  --ink: #121211;
  --ink-soft: #5c5952;
  --line: rgba(18, 18, 17, 0.16);
  --accent: #e03d1a;
  --on-ink-soft: rgba(243, 241, 236, 0.64);
  --sans: 'Jost', 'Futura', 'Century Gothic', 'Avenir Next', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --gutter: clamp(20px, 4.4vw, 64px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* Share of the board SVG taken by the rank labels: captions align with the frame. */
  --board-inset: 7.27%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.125rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Paper grain. Black noise at low alpha: visible on paper, invisible on ink. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .075 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,
h2,
h3,
p,
ol,
ul,
figure,
address {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

address {
  font-style: normal;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

.wrap {
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.label {
  font: 400 0.75rem/1.4 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.arrow {
  display: inline-block;
  margin-left: 0.55em;
  transition: transform 0.3s var(--ease);
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
}

.skip:focus {
  top: 12px;
}

/* ---------- Wordmark ---------- */

.wordmark {
  position: relative;
  display: inline-block;
  /* Room for the I-beams above and below the word. */
  padding-block: 0.22em 0.44em;
  font-size: 1.875rem;
  line-height: 1;
}

.wm-word {
  display: block;
  font: 400 1em/1 var(--sans);
  letter-spacing: -0.012em;
}

.wm-a {
  position: relative;
  display: inline-block;
}

.wm-ticks {
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 100%;
  height: 1.6em;
  transform: translateY(-50%);
  overflow: visible;
  pointer-events: none;
}

.wm-ticks path {
  fill: none;
  stroke: currentColor;
  stroke-width: max(1px, 0.02em);
  vector-effect: non-scaling-stroke;
}

.wm-sub {
  display: none;
}

.wordmark-large {
  font-size: clamp(4.5rem, 21vw, 17rem);
}

.wordmark-large .wm-sub {
  display: block;
  position: absolute;
  left: 45%;
  /* In its own (small) em: sits level with the lower I-beams, as in the logo. */
  top: 10em;
  font: 400 0.14em/1 var(--sans);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Header ---------- */

.top {
  padding-block: clamp(14px, 2.2vw, 26px);
}

.top-row {
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 56px);
}

.top-row .wordmark {
  margin-right: auto;
}

.top-nav {
  display: flex;
  gap: clamp(18px, 2.6vw, 40px);
  font-size: 1rem;
}

.top-nav a {
  position: relative;
  padding-block: 4px;
}

.top-nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}

.top-nav a:hover::after,
.top-nav a:focus-visible::after {
  transform: scaleX(1);
}

.langs {
  display: flex;
  gap: 2px;
  font: 400 0.75rem/1 var(--mono);
  letter-spacing: 0.08em;
}

.langs a {
  padding: 8px;
  color: var(--ink-soft);
  transition: color 0.2s;
}

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

.langs a[aria-current] {
  color: var(--ink);
  box-shadow: inset 0 -1px 0 var(--ink);
}

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

.hero {
  padding-block: clamp(28px, 5vw, 72px) clamp(56px, 8vw, 120px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7.5fr) minmax(0, 4.5fr);
  gap: clamp(32px, 5vw, 88px);
  align-items: end;
}

h1 {
  margin-top: 0.42em;
  font: 300 clamp(2.75rem, 5.8vw, 5.5rem)/0.98 var(--sans);
  letter-spacing: -0.035em;
  text-wrap: balance;
}

/* The first clause gets its own line where there is room for it. */
.h1-a {
  display: block;
}

/* An I-beam text cursor, same shape as the marks in the logo. */
.caret {
  position: relative;
  display: inline-block;
  width: 0.04em;
  height: 0.78em;
  margin-left: 0.14em;
  vertical-align: -0.07em;
  background: var(--accent);
  animation: blink 1.15s steps(1) 4.6s infinite;
}

.caret::before,
.caret::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 0.2em;
  height: 0.04em;
  background: var(--accent);
  transform: translateX(-50%);
}

.caret::before {
  top: 0;
}

.caret::after {
  bottom: 0;
}

.lead {
  max-width: 31em;
  margin-top: 1.7em;
  font-size: clamp(1.125rem, 1.5vw, 1.375rem);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 32px;
  margin-top: 2.3em;
}

.button {
  display: inline-flex;
  align-items: center;
  padding: 0.95em 1.5em;
  background: var(--ink);
  color: var(--paper);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.25s;
}

.button:hover {
  background: var(--accent);
}

.button:hover .arrow {
  transform: translateX(5px);
}

.text-link {
  padding-bottom: 2px;
  border-bottom: 1px solid currentColor;
  font-size: 1rem;
  font-weight: 500;
  transition: color 0.2s;
}

.text-link:hover {
  color: var(--accent);
}

.text-link:hover .arrow {
  transform: translateY(3px);
}

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

.board {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.board-dark rect {
  fill: var(--ink);
  opacity: 0.055;
}

.board-grid line {
  stroke: var(--ink);
  stroke-opacity: 0.15;
  vector-effect: non-scaling-stroke;
}

.board-frame {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.board-labels text {
  font: 400 21px var(--mono);
  fill: var(--ink-soft);
}

.pawn {
  stroke: var(--ink);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.pawn-white {
  fill: var(--paper);
}

.pawn-black {
  fill: var(--ink);
}

.origin {
  fill: none;
  stroke: var(--ink);
  stroke-opacity: 0.4;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

.threat {
  stroke: var(--accent);
  stroke-width: 1.5px;
  stroke-dasharray: 5 5;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

/* The opening plays once on load: 1. d4 d5 2. c4. One square is 100 user units. */
.move-d4 {
  animation: advance 0.8s var(--ease) 1s both;
}

.move-d5 {
  animation: reply 0.8s var(--ease) 2s both;
}

.move-c4 {
  animation:
    advance 0.8s var(--ease) 3s both,
    offer 0.5s ease 3.7s both;
}

.origin-move-d4 {
  animation: appear 0.4s ease 1.3s both;
}

.origin-move-d5 {
  animation: appear 0.4s ease 2.3s both;
}

.origin-move-c4 {
  animation: appear 0.4s ease 3.3s both;
}

.threat {
  animation: appear 0.6s ease 4.1s both;
}

.notation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1.1em;
  margin-top: 16px;
  padding-left: var(--board-inset);
  font: 400 0.875rem/1.6 var(--mono);
}

.ply {
  opacity: 0.28;
}

.ply i {
  font-style: normal;
  color: var(--ink-soft);
}

.ply-1 {
  animation: appear 0.4s ease 1.2s both;
}

.ply-2 {
  animation: appear 0.4s ease 2.2s both;
}

.ply-3 {
  color: var(--accent);
  animation: appear 0.4s ease 3.2s both;
}

.ply-3 i {
  color: inherit;
}

.notation-name {
  margin-left: auto;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.definition {
  margin-top: 10px;
  margin-left: var(--board-inset);
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.definition dfn {
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
}

.definition abbr {
  font: 400 0.75rem var(--mono);
  text-decoration: none;
}

/* Staggered entrance for the hero. */
.hero-place,
.hero h1,
.lead,
.actions,
.opening {
  animation: rise 0.9s var(--ease) both;
}

.hero h1 {
  animation-delay: 0.08s;
}

.lead {
  animation-delay: 0.18s;
}

.actions {
  animation-delay: 0.28s;
}

.opening {
  animation-delay: 0.2s;
}

/* ---------- Bands ---------- */

.band {
  padding-block: clamp(56px, 8vw, 128px);
  border-top: 1px solid var(--line);
}

.band-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: clamp(24px, 4vw, 64px);
}

.band-label {
  display: flex;
  align-items: baseline;
  gap: 1.2em;
  padding-top: 0.9em;
}

.index {
  color: var(--ink);
}

h2 {
  font: 300 clamp(2rem, 4.2vw, 3.75rem)/1.04 var(--sans);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.crafts {
  margin-top: clamp(32px, 4.5vw, 64px);
  border-top: 1px solid var(--ink);
}

.crafts li {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 5fr) minmax(0, 6fr);
  align-items: baseline;
  gap: 8px clamp(16px, 3vw, 48px);
  padding-block: clamp(20px, 2.4vw, 32px);
  border-bottom: 1px solid var(--line);
  transition: padding-left 0.35s var(--ease);
}

.crafts li:hover {
  padding-left: 14px;
}

.craft-n {
  font: 400 0.8125rem var(--mono);
  color: var(--ink-soft);
  transition: color 0.25s;
}

.crafts li:hover .craft-n {
  color: var(--accent);
}

.crafts h3 {
  font: 400 clamp(1.375rem, 2.2vw, 2rem)/1.15 var(--sans);
  letter-spacing: -0.02em;
}

.crafts p {
  max-width: 34em;
  color: var(--ink-soft);
}

/* ---------- Product ---------- */

.product {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  align-items: end;
  gap: clamp(24px, 4vw, 64px);
  /* The I-beams stick out above and below the card. */
  margin-block: 34px;
  padding: clamp(28px, 4.5vw, 64px);
  border: 1px solid var(--ink);
  transition:
    background 0.4s var(--ease),
    color 0.4s var(--ease);
}

.product:hover {
  background: var(--ink);
  color: var(--paper);
}

.tick {
  position: absolute;
  width: 1px;
  height: 24px;
  background: var(--ink);
}

.tick::before {
  content: '';
  position: absolute;
  left: -6px;
  width: 13px;
  height: 1px;
  background: var(--ink);
}

.tick-tl,
.tick-tr {
  bottom: calc(100% + 9px);
}

.tick-bl,
.tick-br {
  top: calc(100% + 9px);
}

.tick-tl,
.tick-bl {
  left: -1px;
}

.tick-tr,
.tick-br {
  right: -1px;
}

.tick-tl::before,
.tick-tr::before {
  top: 0;
}

.tick-bl::before,
.tick-br::before {
  bottom: 0;
}

.product-name {
  font: 300 clamp(3rem, 9vw, 8.5rem)/0.9 var(--sans);
  letter-spacing: -0.045em;
}

.dot {
  color: var(--accent);
}

.product-side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.product-text {
  font-size: clamp(1.0625rem, 1.4vw, 1.25rem);
  line-height: 1.45;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags span {
  padding: 0.5em 0.75em;
  border: 1px solid currentColor;
  font: 400 0.6875rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.product-link {
  padding-bottom: 2px;
  border-bottom: 1px solid currentColor;
  font-size: 1rem;
  font-weight: 500;
}

.product:hover .product-link .arrow {
  transform: translate(3px, -3px);
}

/* ---------- Principles ---------- */

.principles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(24px, 3.5vw, 56px);
}

.principles li {
  padding-top: 20px;
  border-top: 1px solid var(--ink);
}

.principles h3 {
  font: 400 clamp(1.375rem, 2vw, 1.75rem)/1.15 var(--sans);
  letter-spacing: -0.02em;
}

.principles p {
  margin-top: 12px;
  color: var(--ink-soft);
}

/* ---------- Contact ---------- */

.contact {
  padding-block: clamp(64px, 9vw, 144px);
  background: var(--ink);
  color: var(--paper);
}

.contact .label {
  color: var(--on-ink-soft);
}

.contact .index {
  color: var(--paper);
}

.contact-text {
  max-width: 28em;
  margin-top: 1.1em;
  font-size: clamp(1.125rem, 1.5vw, 1.375rem);
  line-height: 1.5;
  color: var(--on-ink-soft);
}

.mail {
  display: inline-block;
  margin-top: clamp(28px, 4vw, 56px);
  padding-bottom: 0.08em;
  border-bottom: 1px solid rgba(243, 241, 236, 0.35);
  font: 300 clamp(2rem, 6.4vw, 6rem)/1.05 var(--sans);
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
  transition:
    color 0.25s,
    border-color 0.25s;
}

.mail:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.contact address {
  margin-top: clamp(28px, 4vw, 48px);
  font: 400 0.8125rem/1.75 var(--mono);
  letter-spacing: 0.04em;
  color: var(--on-ink-soft);
}

/* ---------- Footer ---------- */

.foot {
  padding-block: clamp(40px, 6vw, 88px) 28px;
}

.foot-mark {
  /* Optical alignment: the G has a little left side bearing. */
  margin-left: -0.04em;
  overflow: hidden;
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 32px;
  margin-top: clamp(24px, 4vw, 56px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font: 400 0.6875rem/1.6 var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

/* ---------- 404 ---------- */

.lost main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  min-height: 100vh;
  min-height: 100svh;
}

.lost h1 {
  margin: 0;
}

/* ---------- Motion ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

@keyframes advance {
  to {
    transform: translateY(-200px);
  }
}

@keyframes reply {
  to {
    transform: translateY(200px);
  }
}

@keyframes offer {
  to {
    fill: var(--accent);
    stroke: var(--accent);
  }
}

@keyframes appear {
  to {
    opacity: 1;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
}

/* Scroll reveal where the browser supports it; everything is simply visible elsewhere. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .band-body > h2,
    .crafts li,
    .product,
    .principles li,
    .contact .band-body > * {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 36%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  /* Jump straight to the final position: the opening is shown already played. */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .top-nav {
    display: none;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .opening {
    max-width: 520px;
    /* Pull the rank labels into the gutter so the frame lines up with the text. */
    margin-left: calc(var(--board-inset) * -0.5);
  }

  .band-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .band-label {
    padding-top: 0;
  }

  .crafts li {
    grid-template-columns: 2.25rem minmax(0, 1fr);
  }

  .crafts p {
    grid-column: 2;
  }

  .product {
    grid-template-columns: minmax(0, 1fr);
  }

  .principles {
    grid-template-columns: minmax(0, 1fr);
  }
}
