/* ================================================================= header */

.site-header-host {
  position: sticky;
  z-index: 50;
  top: 0;
  min-height: var(--header-height);
  /* Only ever transformed, so hiding the bar on a phone stays off the main
     thread and cannot reflow the document beneath it. */
  transition: transform var(--duration-normal) var(--ease-out);
}

.site-header {
  position: relative;
  border-bottom: 1px solid var(--color-line);
  background: color-mix(in srgb, var(--color-surface) 86%, transparent);
  transition: border-color var(--duration-normal) ease, background-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

@supports (backdrop-filter: blur(1rem)) {
  .site-header {
    backdrop-filter: saturate(160%) blur(1.25rem);
  }
}

html.is-scrolled .site-header {
  box-shadow: 0 10px 30px -18px rgb(0 0 0 / 0.35);
}

@media (prefers-reduced-transparency: reduce) {
  .site-header {
    background: var(--color-surface);
    backdrop-filter: none;
  }
}

/*
 * Three columns: the wordmark, the sections centred, the controls. The bar is
 * quiet — plain text links, no pills — so the page below it leads.
 */
.site-header__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: var(--space-2);
  align-items: stretch;
  width: min(100% - (2 * var(--gutter)), var(--shell-wide));
  min-height: var(--header-height);
  margin-inline: auto;
  transition: transform var(--duration-normal) var(--ease-out);
}

html.motion-none .site-header-host,
html.motion-none .site-header {
  transition: none;
}

/* The wordmark is typographic (docs/brand-guidelines.md): no mark beside it. */
.wordmark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-self: start;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: stretch;
}

/*
 * Plain text links. The motion is lazer's: colour comes in fast and leaves
 * slowly (100ms / 600ms), and the page you are on is marked by a line along
 * the foot that draws out over 500ms OutQuint.
 */
.site-nav a {
  position: relative;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding-inline: 0.9rem;
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: color 600ms var(--ease-out-quint);
}

.site-nav a > * {
  position: relative;
}

.site-nav a::after {
  content: "";
  position: absolute;
  right: 0.9rem;
  bottom: -1px;
  left: 0.9rem;
  height: 2px;
  background: var(--color-accent);
  transform: scaleX(0);
  transition: transform 500ms var(--ease-out-quint);
}

.site-nav a:hover {
  color: var(--color-text);
  transition-duration: 100ms;
}

.site-nav a[aria-current="page"] {
  color: var(--color-text);
  font-weight: 600;
}

.site-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

/* The markup carries icons for the phone sheet; the bar shows words only. */
.site-nav__icon {
  display: none;
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
}

.site-header__actions {
  display: flex;
  grid-column: 3;
  gap: var(--space-1);
  align-items: center;
  justify-self: end;
}

/* Round icon controls in the header: settings, theme and sound. */
.icon-button {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-soft);
  text-decoration: none;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.icon-button:hover {
  background: color-mix(in srgb, var(--color-text) 8%, transparent);
  color: var(--color-text);
}

.icon-button[aria-current="page"] {
  color: var(--color-accent);
}

.icon-button__icon {
  grid-area: 1 / 1;
  width: 1.125rem;
  height: 1.125rem;
  display: none;
}

.icon-button__icon--static {
  display: block;
}

/* The visible state of the sound control follows the stored preference. */
html[data-sound="off"] .sound-toggle__off,
html[data-sound="on"] .sound-toggle__on {
  display: block;
}

html[data-sound="on"] .sound-toggle {
  color: var(--color-accent);
}

html[data-theme="system"] .theme-toggle__icon--auto,
html[data-theme="light"] .theme-toggle__icon--light,
html[data-theme="dark"] .theme-toggle__icon--dark {
  display: block;
}

.account-link {
  display: inline-flex;
  align-items: center;
  max-width: 12rem;
  min-height: 2.25rem;
  margin-left: var(--space-2);
  padding-inline: var(--space-2);
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 600ms var(--ease-out-quint);
}

.account-link:hover {
  color: var(--color-accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition-duration: 100ms;
}

.nav-toggle {
  display: none;
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  place-items: center;
  transition: background-color var(--duration-fast) ease;
}

.nav-toggle:hover {
  background: color-mix(in srgb, var(--color-text) 8%, transparent);
}

/*
 * All three bars sit at the exact centre and are separated only by transform.
 * Animating `top` (an earlier version did) snapped the outer bars inward
 * before the rotation eased in, which made the X land lopsided.
 */
.nav-toggle__line {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 1.0625rem;
  height: 1.5px;
  margin: -0.75px 0 0 -0.53125rem;
  border-radius: 1px;
  background: currentColor;
  transform-origin: center;
  transition: transform var(--duration-normal) var(--ease-out), opacity var(--duration-fast) ease;
}

.nav-toggle__line:nth-child(1) { transform: translateY(-5px); }
.nav-toggle__line:nth-child(2) { transform: translateY(0); }
.nav-toggle__line:nth-child(3) { transform: translateY(5px); }

/* ========================================================= section header */

/*
 * Every inner page opens on a plain grey band holding its title, one line
 * about it and — where a section has more than one page — a row of local
 * links along the foot, the way large product and documentation sites head
 * a page. No colour field, no decoration: the type carries it. What moves
 * is the entrance (motion.css), not the band.
 */
.page-hero {
  position: relative;
  padding-block: clamp(2.75rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem);
  background: var(--color-band);
}

.page-hero--compact {
  padding-block: clamp(2rem, 4vw, 3rem) clamp(1.5rem, 3vw, 2.25rem);
}

.page-hero:has(.page-tabs) {
  padding-bottom: 0;
}

.page-hero__inner {
  position: relative;
  display: block;
}

/*
 * A game page shows its cover beside the title, the way a product page sets
 * its picture beside its name. The text keeps its own column; the picture
 * sits in the right-hand margin it leaves.
 */
.page-hero__inner:has(> .page-hero__art) {
  --art: clamp(12rem, 24vw, 17rem);
  min-height: calc(var(--art) * 0.8);
  padding-right: calc(var(--art) + clamp(1.5rem, 4vw, 3rem));
}

.page-hero__art {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--art);
  height: auto;
  aspect-ratio: 5 / 4;
  border-radius: var(--radius-lg);
  /* The drawing's ground is the band's own grey, so a hairline keeps its edge. */
  box-shadow: 0 0 0 1px var(--color-line), 0 22px 44px -26px rgb(0 0 0 / 0.35);
  object-fit: cover;
}

@media (max-width: 40rem) {
  .page-hero__inner:has(> .page-hero__art) {
    min-height: 0;
    padding-right: 0;
  }

  .page-hero__art {
    display: none;
  }
}

.page-hero h1,
.page-hero p:not(.page-kicker) {
  max-width: 46rem;
}

.page-hero h1 {
  margin-bottom: var(--space-3);
  color: var(--color-text);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-hero p:not(.page-kicker) {
  margin-bottom: 0;
  color: var(--color-text-soft);
  font-size: var(--text-md);
}

.page-hero a:not(.back-link, .button, .page-tabs a) {
  color: var(--color-accent);
}

/*
 * Breadcrumb: a line of small text above the title, the way a path is set
 * in print. The arrow moves toward where the link goes.
 */
.page-kicker,
.back-link {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: color 300ms var(--ease-out-quint), transform 500ms var(--ease-out-quint);
}

.back-link:hover {
  color: var(--color-accent);
  text-decoration: none;
  transform: translateX(-3px);
}

.page-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.chip {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 1.75rem;
  padding-inline: 0.7rem;
  border-radius: 999px;
  background: var(--color-accent-wash);
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.chip--quiet {
  background: color-mix(in srgb, var(--color-text) 7%, transparent);
  color: var(--color-text-soft);
}

/*
 * In a section header the facts read as one line of text divided by short
 * rules, not as a row of pills. The first is the page's own kind, in the
 * section colour; the rest are quiet, and links among them underline only
 * under the pointer.
 */
.page-hero .page-hero__meta {
  align-items: center;
  gap: 0.4rem 0;
  font-size: var(--text-sm);
}

.page-hero .page-hero__meta > * {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}

.page-hero .page-hero__meta > * + *::before {
  content: "";
  width: 1px;
  height: 0.85em;
  margin-inline: 0.85rem;
  background: var(--color-rule);
}

.page-hero .page-hero__meta > :first-child {
  color: var(--color-accent);
}

.page-hero .page-hero__meta > a:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/*
 * Local navigation between the pages of one section, along the foot of the
 * header band; the current page is underlined. Colour and underline move on
 * OutQuint over 500ms, lazer's tab timing (OsuTabControl.TRANSITION_LENGTH).
 */
.page-tabs {
  position: relative;
  display: flex;
  gap: var(--space-1);
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  overflow-x: auto;
  scrollbar-width: none;
}

.page-tabs::-webkit-scrollbar {
  display: none;
}

.page-tabs a {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: 0.9rem;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: color 500ms var(--ease-out-quint);
}

.page-tabs a::after {
  content: "";
  position: absolute;
  right: 0.9rem;
  bottom: 0;
  left: 0.9rem;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--color-accent);
  opacity: 0;
  transform: scaleX(0.4);
  transition: opacity 500ms var(--ease-out-quint), transform 500ms var(--ease-out-quint);
}

.page-tabs a:hover {
  color: var(--color-text);
}

.page-tabs a:hover::after {
  opacity: 0.35;
  transform: scaleX(1);
}

.page-tabs a[aria-current="page"] {
  color: var(--color-text);
}

.page-tabs a[aria-current="page"]::after {
  opacity: 1;
  transform: scaleX(1);
}

.page-body {
  padding-block: clamp(1.75rem, 3.5vw, 2.75rem) var(--section-space);
}

/* =============================================================== controls */

.button {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--button-height);
  padding: 0 var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.button:active {
  opacity: 0.82;
}

.button--primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.button--primary:hover {
  background: var(--color-accent-strong);
  color: var(--color-on-accent);
  text-decoration: none;
}

.button--secondary {
  border-color: var(--color-rule);
  background: transparent;
  color: var(--color-text);
}

.button--secondary:hover {
  border-color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
  text-decoration: none;
}

.button--quiet {
  border-color: color-mix(in srgb, currentColor 40%, transparent);
  background: transparent;
  color: currentColor;
}

.button--quiet:hover {
  border-color: currentColor;
  text-decoration: none;
}

.button--danger {
  border-color: color-mix(in srgb, var(--color-error) 45%, var(--color-line));
  background: transparent;
  color: var(--color-error);
}

.button--danger:hover {
  border-color: var(--color-error);
  text-decoration: none;
}

.button-row,
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  color: var(--color-accent);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

/* ================================================================== cards */

/*
 * One card pattern serves the home page, the product index and every
 * catalogue: a white surface that lifts slightly on hover. Nothing else on
 * the site is allowed to float.
 */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(1.35rem, 2.2vw, 1.85rem);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: inherit;
  text-decoration: none;
  transition: transform var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out);
}

a.card:hover,
a.card:focus-visible {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
}

.card__icon {
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: var(--space-5);
  color: var(--color-accent);
}

.card__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.card__text {
  max-width: 32ch;
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.card__spacer {
  flex: 1;
  min-height: var(--space-5);
}

.card__cue {
  display: inline-flex;
  align-items: center;
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 500;
}

.card__cue::after {
  content: "\203A";
  display: inline-block;
  margin-left: 0.35em;
  font-size: 1.15em;
  line-height: 1;
  transition: transform var(--duration-fast) var(--ease-out);
}

a.card:hover .card__cue::after {
  transform: translateX(0.2rem);
}

/* ================================================================== forms */

.form-field {
  display: grid;
  gap: var(--space-2);
}

.form-field label,
.field-label {
  font-size: var(--text-sm);
  font-weight: 500;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.form-field input,
.form-field select {
  min-height: 2.875rem;
  padding: 0 var(--space-4);
}

.form-field textarea {
  min-height: 11rem;
  padding: var(--space-4);
  line-height: 1.6;
  resize: vertical;
}

.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover {
  border-color: var(--color-rule);
}

.field-help {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.form-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.form-status[data-state="error"] {
  color: var(--color-error);
}

.form-status[data-state="success"] {
  color: var(--color-success);
}

/* ================================================================= footer */

.site-footer-host {
  min-height: 0;
}

.site-footer {
  position: relative;
  margin-top: clamp(4rem, 8vw, 6rem);
  overflow: hidden;
  border-top: 1px solid var(--color-line);
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.site-footer__shell {
  position: relative;
  width: min(100% - (2 * var(--gutter)), var(--shell-wide));
  margin-inline: auto;
}

.site-footer__main {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr));
  gap: clamp(2rem, 4vw, 3rem);
  padding-block: clamp(2.75rem, 5vw, 4rem);
}

.site-footer__brand .wordmark {
  margin-right: 0;
}

.site-footer__brand p {
  max-width: 22rem;
  margin: var(--space-4) 0 0;
  color: var(--color-text-muted);
}

.site-footer__brand .site-footer__motto {
  margin-top: var(--space-2);
  color: var(--color-accent);
  font-weight: 600;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.footer-nav h2 {
  margin: 0 0 var(--space-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0;
}

.footer-nav a {
  position: relative;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

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

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-5);
  border-top: 1px solid var(--color-line);
  font-size: var(--text-xs);
}

.site-footer__bottom p {
  margin: 0;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}

.site-footer__bottom a {
  color: inherit;
  text-decoration: none;
}

.site-footer__bottom a:hover {
  color: var(--color-text);
}

/* ======================================================== floating layers */

.toast-region {
  position: fixed;
  z-index: 200;
  right: var(--gutter);
  bottom: var(--space-5);
  display: grid;
  justify-items: end;
  width: min(24rem, calc(100vw - 2 * var(--gutter)));
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  max-width: 100%;
  padding: 0.8rem 1.1rem 0.8rem 0.9rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.5;
  pointer-events: auto;
  cursor: default;
}

.toast__icon {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast--success .toast__icon {
  color: var(--color-success);
}

.toast--error {
  border-color: color-mix(in srgb, var(--color-error) 35%, var(--color-line));
}

.toast--error .toast__icon {
  color: var(--color-error);
}

.toast--info .toast__icon {
  color: var(--color-accent);
}

@media (max-width: 40rem) {
  .toast-region {
    right: 50%;
    justify-items: center;
    transform: translateX(50%);
  }
}

.yz-dialog {
  width: min(32rem, calc(100vw - 2 * var(--gutter)));
  padding: 0;
  border: 0;
  border-radius: var(--dialog-radius);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-float);
}

.yz-dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
  backdrop-filter: blur(0.25rem);
}

.yz-dialog__inner {
  padding: var(--space-6);
}

.yz-dialog__header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-5);
}

.yz-dialog__header h2 {
  margin-bottom: 0;
  font-size: var(--text-xl);
}

.yz-dialog__close {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--color-surface-sunken);
}

/* ============================================================ error pages */

.error-page {
  position: relative;
  isolation: isolate;
  display: grid;
  place-content: center;
  justify-items: center;
  min-height: calc(100vh - var(--header-height) - 14rem);
  padding-block: clamp(3rem, 9vw, 6rem);
  text-align: center;
}

.error-page__mark {
  margin-bottom: var(--space-5);
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: clamp(4rem, 12vw, 7.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.error-page__copy h1 {
  margin-bottom: var(--space-4);
  font-size: var(--text-3xl);
}

.error-page__copy p {
  max-width: 34rem;
  margin: 0 auto var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-md);
}

.error-page .hero__actions {
  justify-content: center;
}

/* ============================================================= responsive */

/*
 * Below the tablet break the three nav links move into a full-width sheet
 * that drops from the header — the pattern every large site uses on phones.
 * Theme and account stay in the bar, so the sheet holds navigation only.
 */
/* Only in the phone sheet, where the header has no room for it (below). */
.site-nav a.site-nav__extra {
  display: none;
}

@media (max-width: 48rem) {
  .nav-toggle {
    display: grid;
  }

  .site-nav {
    position: absolute;
    grid-column: 1 / -1;
    justify-self: stretch;
    top: 100%;
    right: 0;
    left: 0;
    display: block;
    box-sizing: border-box;
    width: auto;
    min-width: 0;
    max-width: none;
    margin-top: var(--space-3);
    padding-block: var(--space-2) var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    /* The panel already has a hairline boundary. A floating shadow is painted
     * from the rectangular transform layer in some mobile browsers, leaving
     * a grey slab visible outside the rounded corners. */
    box-shadow: none;
    transform: translateY(-0.5rem);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) ease, transform var(--duration-normal) var(--ease-out), visibility 0s linear var(--duration-normal);
  }

  .site-nav a {
    display: flex;
    width: min(100% - (2 * var(--gutter)), var(--shell));
    min-height: 3.25rem;
    margin-inline: auto;
    padding-inline: var(--space-3);
    box-sizing: border-box;
    justify-content: flex-start;
    color: var(--color-text);
    font-size: var(--text-md);
    white-space: nowrap;
  }

  .site-nav a + a {
    border-top: 1px solid var(--color-line);
  }

  .site-nav a::before {
    inset: 0.3rem 0;
  }

  /* In the sheet the current-page bar runs down the leading edge instead. */
  .site-nav a::after {
    top: 0.85rem;
    right: auto;
    bottom: 0.85rem;
    left: 0;
    width: 3px;
    height: auto;
    border-radius: 0 3px 3px 0;
    transform: scaleY(0);
  }

  .site-nav a[aria-current="page"]::after {
    transform: scaleY(1);
  }

  .site-nav a[aria-current="page"] {
    color: var(--color-accent);
  }

  .nav-open .site-nav {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }

  .nav-open .nav-toggle {
    background: color-mix(in srgb, var(--color-text) 8%, transparent);
  }

  .nav-open .nav-toggle__line:nth-child(1) {
    transform: translateY(0) rotate(45deg);
  }

  .nav-open .nav-toggle__line:nth-child(2) {
    opacity: 0;
    transform: translateY(0) scaleX(0.3);
  }

  .nav-open .nav-toggle__line:nth-child(3) {
    transform: translateY(0) rotate(-45deg);
  }

  .site-footer__main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer__brand {
    grid-column: 1 / -1;
  }
}

/*
 * Where the viewport is short, a permanently parked bar is a real cost: on a
 * landscape phone it can be a tenth of everything visible. So it yields —
 * scrolling down retracts it, scrolling up brings it straight back, and it is
 * always restored at the top of the page. `motion.js` sets the flag; only a
 * transform moves, so nothing below it reflows.
 *
 * It never retracts while the menu is open or while focus is inside it, or a
 * keyboard user would be dragged to an element they cannot see.
 */
@media (max-width: 48rem), (max-height: 34rem) {
  html.header-retracted .site-header-host {
    transform: translateY(calc(-100% - 1rem));
  }

  html.header-retracted body.nav-open .site-header-host,
  .site-header-host:focus-within {
    transform: none;
  }
}

@media (max-width: 36rem) {
  .account-link {
    max-width: 6.5rem;
    padding-inline: var(--space-3);
  }

  /* Three icon buttons plus the account pill overflow a 375px bar. Settings
     moves into the navigation sheet, and sound with it — the settings page
     holds the sound switch. */
  .site-header__inner {
    gap: var(--space-2);
  }

  .site-header__actions > .settings-link,
  .site-header__actions > .sound-toggle {
    display: none;
  }

  .site-nav a.site-nav__extra {
    display: flex;
  }

  .site-footer__main {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
}

/* ============================================================ scroll back */

/* OverlayScrollContainer's scroll-back button: a round control at the foot of
 * long pages that rises in once the top is well out of sight. */
.scroll-back {
  position: fixed;
  z-index: 60;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: max(var(--space-6), env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-soft);
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translateY(0.75rem) scale(0.9);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-in-quint), color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.scroll-back svg {
  width: 1.15rem;
  height: 1.15rem;
}

.scroll-back[data-state="in"] {
  opacity: 1;
  transform: none;
  transition: opacity 400ms var(--ease-out-quint), transform 600ms var(--ease-out-elastic-half), color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

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

html:is(.motion-minimal, .motion-none) .scroll-back {
  transform: none;
}

/* ============================================================ game shelf */

/*
 * Games shelved the way a store shelves products: the picture, then the name
 * and one quiet line under it — no frame around the pair. The picture is a
 * drawing of the game mid-play (assets/img/games): pale ground, white
 * pieces, ink, and the one accent. Each has a dark twin for the dark theme.
 */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: clamp(1.5rem, 3vw, 2rem) clamp(1rem, 2vw, 1.5rem);
}

.game-grid--compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.game-card {
  display: grid;
  align-content: start;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
}

.game-card:focus-visible {
  outline: none;
}

.game-card__cover {
  position: relative;
  display: block;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-band);
  transition: box-shadow 600ms var(--ease-out-quint);
}

.game-card:is(:hover, :focus-visible) .game-card__cover {
  box-shadow: 0 14px 32px -18px rgb(0 0 0 / 0.35);
  transition-duration: 300ms;
}

.game-card:focus-visible .game-card__cover {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.game-card__art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card__body {
  display: grid;
  gap: 0.2rem;
  padding-inline: 0.15rem;
}

.game-card__name {
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 600;
  transition: color 600ms var(--ease-out-quint);
}

.game-card:is(:hover, :focus-visible) .game-card__name {
  color: var(--color-accent);
  transition-duration: 100ms;
}

/* The description is for the full catalogue; shelves show name and kind. */
.game-card__desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.game-grid--compact .game-card__desc {
  display: none;
}

.game-card__meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  overflow: hidden;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.game-card__meta > * + *::before {
  content: "·";
  margin-inline: 0.4rem;
}

.game-card .chip {
  display: inline;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  font-weight: 400;
}

/* The whole cover is the control; a separate "start" badge only repeated it. */
.game-card__play {
  display: none;
}

@media (max-width: 40rem) {
  .game-grid,
  .game-grid--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-card__desc,
  .game-card__rule {
    display: none;
  }
}

/* ------------------------------------------------------ light / dark art */

/*
 * Each drawing ships twice. The theme can be chosen by hand, which a media
 * query inside an SVG image cannot see, so the page picks the copy.
 */
.art-dark {
  display: none !important;
}

html[data-theme="dark"] .art-light {
  display: none !important;
}

html[data-theme="dark"] .art-dark:not([hidden]) {
  display: block !important;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .art-light {
    display: none !important;
  }

  html[data-theme="system"] .art-dark:not([hidden]) {
    display: block !important;
  }
}

/* ============================================================ tool index */

/*
 * A handful of tools as an index, not as boxes: two columns of entries on
 * hairlines, name over one line of what it does, the kind set small on the
 * right. The rule above an entry fills with the section colour from the left
 * under the pointer — the only ornament. Used on the home page and at the
 * foot of every tool.
 */
.tool-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--color-line);
}

.tool-tile {
  position: relative;
  display: grid;
  grid-template-areas: "name tag" "desc tag";
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem var(--space-4);
  align-items: baseline;
  padding: 1rem 0 1.05rem;
  border-top: 1px solid var(--color-line);
  color: inherit;
  text-decoration: none;
}

.tool-tile::before {
  content: "";
  position: absolute;
  top: -1px;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 500ms var(--ease-out-quint);
}

.tool-tile:is(:hover, :focus-visible)::before {
  transform: scaleX(1);
}

.tool-tile:focus-visible {
  outline: none;
}

.tool-tile__name {
  grid-area: name;
  color: var(--color-text);
  font-weight: 700;
  transition: color 300ms var(--ease-out-quint);
}

.tool-tile:is(:hover, :focus-visible) .tool-tile__name {
  color: var(--color-accent);
}

.tool-tile__desc {
  grid-area: desc;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-tile__tag {
  grid-area: tag;
  align-self: center;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-weight: 600;
}

.tool-tile__arrow {
  display: none;
}

@media (max-width: 40rem) {
  .tool-tiles {
    grid-template-columns: minmax(0, 1fr);
  }
}

html.motion-none .tool-tile::before {
  transition: none;
}
