@font-face {
  font-family: Barlow;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/barlow-700.woff2') format('woff2');
}

@font-face {
  font-family: Barlow;
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('./fonts/barlow-800.woff2') format('woff2');
}

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/garamond-400.woff2') format('woff2');
}

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/garamond-500.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --ink: #10140f;
  --leaf: #f4f1ea;
  --yellow: #f5c400;
  --oxide: #e85d04;
  --sienna: #8c4a2f;
  --grass: #3f7d32;
  --teal: #0f7a72;
  --ultra: #2a4fbf;
  --violet: #5b3cc4;
  --rust: #c2410c;
  --pine: #1f6b4a;
  --board: var(--yellow);
  --board-ink: var(--ink);
  font-family: 'EB Garamond', Palatino, Georgia, serif;
}

body[data-section='100'] {
  --board: var(--oxide);
  --board-ink: #fff;
}
body[data-section='200'] {
  --board: var(--sienna);
  --board-ink: #fff;
}
body[data-section='300'] {
  --board: var(--grass);
  --board-ink: #fff;
}
body[data-section='400'] {
  --board: var(--teal);
  --board-ink: #fff;
}
body[data-section='500'] {
  --board: var(--ultra);
  --board-ink: #fff;
}
body[data-section='600'] {
  --board: var(--violet);
  --board-ink: #fff;
}
body[data-section='700'] {
  --board: var(--yellow);
  --board-ink: var(--ink);
}
body[data-section='800'] {
  --board: var(--rust);
  --board-ink: #fff;
}
body[data-section='900'] {
  --board: var(--pine);
  --board-ink: #fff;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--board);
  color: var(--ink);
  line-height: 1.45;
  caret-color: var(--ink);
}

.skip {
  position: absolute;
  left: -999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 2;
  background: var(--leaf);
  padding: 0.5rem 0.75rem;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.75rem;
  min-height: 100vh;
}

.leaf {
  margin: 1.25rem 0.4rem 1.25rem 1.25rem;
  background: var(--leaf);
  padding: 1.15rem 1.45rem 1.6rem;
}

.leaf-head {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: center;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  text-decoration: none;
}

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

.brand:hover .mark {
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.brand:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.logo {
  display: block;
  width: auto;
  height: 1.65rem;
  flex: none;
}

.logo-leaf,
.logo-tab {
  stroke: currentColor;
  stroke-width: 1.75;
}

.logo-leaf {
  fill: #fffdf8;
}

.logo-lines {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
}

.logo-tab {
  fill: var(--yellow);
}

.logo-num {
  fill: currentColor;
  font-family: Barlow, sans-serif;
  font-size: 16px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.mark {
  margin: 0;
  font-family: Barlow, sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.banner {
  margin: 0;
  max-width: 22rem;
  font-size: 1.05rem;
  line-height: 1.2;
  text-align: right;
}

label {
  display: block;
  margin: 0.85rem 0 0.3rem;
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#search {
  width: 100%;
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
  padding: 0.45rem 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
}

#search::placeholder {
  color: #5c5348;
}
#search:disabled {
  opacity: 0.55;
}

#search:focus-visible,
button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.tries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.5rem;
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tries button {
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 0.18rem 0.5rem;
  cursor: pointer;
}

.tries button:hover {
  background: #ffe14a;
}

.tries button:disabled {
  opacity: 0.5;
  cursor: default;
}

#status {
  margin: 0.7rem 0 0;
  font-size: 1rem;
  line-height: 1.25;
  min-height: 1.25rem;
}

.status-error {
  color: #9a1b12;
}

.reading {
  display: grid;
  gap: 0.85rem 2rem;
  align-items: start;
  margin-top: 0.55rem;
  padding-bottom: 1.35rem;
  border-bottom: 3px solid var(--ink);
  scroll-margin-top: 0.75rem;
}

#detail {
  margin-top: 0;
  padding: 0.85rem 1rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: #fffdf8;
}
#detail[hidden] {
  display: none;
}

#detail .rule-id {
  margin: 0;
  font-family: Barlow, sans-serif;
  font-weight: 800;
  font-size: clamp(2.8rem, 6.4vw, 4.6rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 0.86;
}

.wording {
  max-width: 65ch;
  margin: 0.45rem 0 0;
  font-size: 1.2rem;
  line-height: 1.28;
}

#detail h2 {
  max-width: 65ch;
  margin: 0.35rem 0 0;
  font-weight: 500;
  font-size: 1.45rem;
  line-height: 1.15;
}

#detail h3 {
  margin: 0.85rem 0 0.15rem;
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.examples {
  max-width: 65ch;
  margin: 0;
  padding-left: 1.1rem;
  font-size: 1.05rem;
  line-height: 1.28;
}

.examples li + li {
  margin-top: 0.28rem;
}

#results {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 16rem;
  overflow: auto;
}

#results:empty {
  display: none;
}

#results button {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: baseline;
  width: 100%;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
  border-radius: 0;
  padding: 0.32rem 0.15rem 0.28rem;
  cursor: pointer;
}

#results button:hover {
  background: color-mix(in srgb, var(--yellow) 55%, transparent);
}

.hit-id {
  font-family: Barlow, sans-serif;
  font-weight: 800;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.hit-text {
  font-size: 1.02rem;
  line-height: 1.22;
}

footer {
  margin-top: 1.15rem;
  padding-top: 0.15rem;
}

footer h2 {
  margin: 0 0 0.15rem;
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

footer section {
  display: grid;
  grid-template-columns: 6.4rem minmax(0, 1fr);
  gap: 0.15rem 0.85rem;
  align-items: start;
  padding: 0.55rem 0 0.6rem;
  border-top: 1px solid color-mix(in srgb, var(--ink) 28%, transparent);
}

footer h3,
footer dt {
  margin: 0.12rem 0 0;
  font-family: Barlow, sans-serif;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

footer p,
footer dd {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
}

footer p + p {
  margin-top: 0.4rem;
}

footer dl {
  margin: 0;
}

footer dl div {
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 1fr);
  gap: 0.45rem;
  align-items: baseline;
}

footer dl div + div {
  margin-top: 0.28rem;
}

footer dt {
  margin: 0;
}

a {
  color: var(--ultra);
  overflow-wrap: anywhere;
}
a:hover {
  color: var(--ink);
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem 0 1.25rem 0;
}

.tabs button {
  flex: 1;
  min-height: 3.2rem;
  border: 0;
  background: color-mix(in srgb, var(--leaf) 18%, var(--board));
  color: var(--board-ink);
  font-family: Barlow, sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.tabs button[data-section='100'] {
  background: var(--oxide);
  color: #fff;
}
.tabs button[data-section='200'] {
  background: var(--sienna);
  color: #fff;
}
.tabs button[data-section='300'] {
  background: var(--grass);
  color: #fff;
}
.tabs button[data-section='400'] {
  background: var(--teal);
  color: #fff;
}
.tabs button[data-section='500'] {
  background: var(--ultra);
  color: #fff;
}
.tabs button[data-section='600'] {
  background: var(--violet);
  color: #fff;
}
.tabs button[data-section='700'] {
  background: var(--yellow);
  color: var(--ink);
}
.tabs button[data-section='800'] {
  background: var(--rust);
  color: #fff;
}
.tabs button[data-section='900'] {
  background: var(--pine);
  color: #fff;
}

.tabs button.is-open {
  outline: 3px solid var(--ink);
  outline-offset: -3px;
  margin-left: -0.7rem;
}

.tabs button:disabled {
  cursor: default;
}

@media (min-width: 880px) {
  .reading {
    grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.9fr);
  }
  .reading:has(#detail[hidden]) {
    grid-template-columns: 1fr;
  }
  #results {
    max-height: min(70vh, 36rem);
  }
}

@media (max-width: 720px) {
  .board {
    grid-template-columns: 1fr;
  }
  .leaf {
    margin: 0.6rem;
  }
  .leaf-head {
    flex-direction: column;
    align-items: start;
    gap: 0.2rem;
  }
  .banner {
    text-align: left;
  }
  .tabs {
    flex-direction: row;
    order: -1;
    padding: 0.6rem 0.6rem 0;
    overflow-x: auto;
  }
  .tabs button {
    writing-mode: horizontal-tb;
    transform: none;
    min-width: 3.4rem;
    min-height: 2.6rem;
  }
  .tabs button.is-open {
    margin-left: 0;
  }
}

@media (max-width: 520px) {
  footer section,
  footer dl div {
    grid-template-columns: 1fr;
    gap: 0.12rem;
  }
}
