/* Almasu
   The team's logo sets the colours: night navy, signal blue, red-orange for the have/want
   swap, and white. (--tile is the blue, --saffron the red-orange: names kept from the first palette.)
   The perforated plate in the header is the one decorative element; the rest stays plain. */

:root {
  color-scheme: light;
  --plate: #e7ecf6;
  --plate-hole: #c3cde0;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #0a1633;
  --ink-2: #4b5876;
  --line: #d3dbea;
  --tile: #0062e8;
  --tile-ink: #ffffff;
  --tile-soft: #e1ecff;
  --saffron: #ff5a3c;
  --saffron-ink: #0a1633;
  --free: #2e7a3c;
  --free-soft: #ddefe0;
  --focus: #0062e8;
  --backdrop: rgb(2 13 43 / 0.55);

  --font-body: 'Exo 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Michroma', 'Exo 2', system-ui, sans-serif;
  --display-weight: 400;
  /* Michroma for Latin-only marks (the wordmark, FTC/FLL tags, big numbers) in every language. */
  --font-latin: 'Michroma', 'Exo 2', system-ui, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --page: 1240px;
  --gutter: 16px;
}

/* Dark palette: follows the OS setting unless the viewer explicitly picked light,
   and also applies when a host sets data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --plate: #0b1a3d;
    --plate-hole: #04102b;
    --bg: #020d2b;
    --surface: #0c1938;
    --ink: #eef2fa;
    --ink-2: #a6b2cc;
    --line: #1e2f58;
    --tile: #4c9dff;
    --tile-ink: #021033;
    --tile-soft: #0c2a5c;
    --free: #6cc27a;
    --free-soft: #173022;
    --focus: #4c9dff;
    --backdrop: rgb(0 0 0 / 0.7);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --plate: #0b1a3d;
  --plate-hole: #04102b;
  --bg: #020d2b;
  --surface: #0c1938;
  --ink: #eef2fa;
  --ink-2: #a6b2cc;
  --line: #1e2f58;
  --tile: #4c9dff;
  --tile-ink: #021033;
  --tile-soft: #0c2a5c;
  --free: #6cc27a;
  --free-soft: #173022;
  --focus: #4c9dff;
  --backdrop: rgb(0 0 0 / 0.7);
}

@media (min-width: 720px) {
  :root { --gutter: 24px; }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }

a { color: var(--tile); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-s);
}
.skip-link:focus { top: 8px; }

.icon { flex: none; }

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

.plate {
  position: relative;
  background: var(--plate);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

/* Hole grid like a build plate: 6px holes on a 24px pitch. It fades out toward the
   text so the headline and search box sit on solid metal. */
.plate::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--plate-hole) 0 3px, transparent 3.6px);
  background-size: 24px 24px;
  background-position: 12px 12px;
  -webkit-mask-image: linear-gradient(to left, #000 0%, #000 22%, transparent 62%);
  mask-image: linear-gradient(to left, #000 0%, #000 22%, transparent 62%);
  pointer-events: none;
}

@media (max-width: 719px) {
  .plate::before {
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 40px, transparent 96px);
    mask-image: linear-gradient(to bottom, #000 0, #000 40px, transparent 96px);
  }
}

.plate-inner {
  position: relative;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 16px 0;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-latin);
  font-weight: 400;
  font-size: var(--step-1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 0;
}
/* The team's logo on its own navy tile, so it reads on the light plate and the dark one. */
.wordmark-logo {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-s);
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.nav-links a:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nav-links a[aria-current='page'] {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.hero {
  max-width: 44rem;
  padding: 24px 0 40px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: calc(var(--step-3) * 0.8);
  line-height: 1.25;
  letter-spacing: 0;
  max-width: 20ch;
  text-wrap: balance;
}

.plate-short .hero { padding-bottom: 32px; }

/* Hero with the intro video beside it on wide screens. */
.hero-row { display: grid; gap: 32px; align-items: center; }
@media (min-width: 1040px) {
  .hero-row:has(.intro:not([hidden])) { grid-template-columns: minmax(0, 1fr) 280px; }
}

/* The intro sits in a phone-shaped frame, like a clip someone is showing you. */
.intro {
  position: relative;
  display: none;
  margin: 24px 0 40px;
  width: 280px;
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  overflow: hidden;
  background: var(--ink);
  border: 6px solid var(--ink);
  box-shadow: 0 30px 60px rgb(0 0 0 / 0.3);
}
.intro:not([hidden]) { display: block; }
/* Phones and tablets: the clip sits under the hero text, centred. */
@media (max-width: 1039.98px) {
  .intro { width: min(260px, 72vw); margin: 0 auto 40px; }
}
.intro-video { display: block; width: 100%; height: 100%; object-fit: cover; }

.intro-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
}
.intro-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: rgb(2 13 43 / 0.72);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.intro-btn:hover { background: rgb(2 13 43 / 0.9); }

/* Narrow screens: a button under the search opens the intro in a dialog. */
.intro-open {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 16px;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--tile);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.intro-open[hidden] { display: none; }
/* The clip now shows inline at every width, with its own sound button. */
.intro-open { display: none !important; }
.intro-open-icon {
  width: 0;
  height: 0;
  border-left: 11px solid currentColor;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

.intro-dialog {
  width: min(360px, calc(100% - 2 * var(--gutter)));
  aspect-ratio: 9 / 16;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  overflow: hidden;
  background: var(--ink);
}
.intro-dialog::backdrop { background: var(--backdrop); }

.hero-sub {
  margin-top: 14px;
  max-width: 52ch;
  color: var(--ink-2);
  font-size: 1.0625rem;
}

.search { margin-top: 28px; }
.search label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.9375rem;
}

.search-field { position: relative; }
.search-field .icon {
  position: absolute;
  left: 16px;
  top: 50%;
  translate: 0 -50%;
  color: var(--ink-2);
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px 0 48px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-m);
  font-size: 1.0625rem;
}
.search input::placeholder { color: var(--ink-2); opacity: 1; }
.search input:focus-visible { outline-offset: 3px; }

/* ---- Demo note ---------------------------------------------------------- */

.demo-note {
  max-width: var(--page);
  margin: 16px auto 0;
  padding: 0 var(--gutter);
}
.demo-note p {
  padding: 12px 16px;
  border-left: 4px solid var(--saffron);
  background: var(--surface);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  color: var(--ink-2);
  font-size: var(--step--1);
}

/* ---- Browse layout ------------------------------------------------------ */

.browse {
  max-width: var(--page);
  margin: 0 auto;
  padding: 24px var(--gutter) 56px;
}

@media (min-width: 1040px) {
  .browse {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }
}

/* Filters: a panel the toggle opens on small screens, a sticky column on wide ones. */
.filters {
  display: none;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.filters-close,
.filters-foot { display: none; }

/* Phones and tablets: an open filter panel is a sheet that slides up from the bottom. */
@media (max-width: 1039.98px) {
  .filters.is-open {
    display: block;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    max-height: 85dvh;
    margin: 0;
    padding: 8px 16px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    border-bottom: 0;
    box-shadow: 0 -12px 32px rgb(0 0 0 / 0.18);
    animation: sheet-up 0.22s ease-out;
  }
  .filters.is-open::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto 8px;
    border-radius: 2px;
    background: var(--line);
  }
  .filters.is-open .filters-head {
    position: sticky;
    top: -8px;
    z-index: 1;
    padding: 8px 0;
    background: var(--surface);
  }
  .filters.is-open .filters-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: 8px;
    background: none;
    border: 0;
    border-radius: var(--radius-s);
    color: var(--ink);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }
  .filters.is-open .filters-head h2 { margin-right: auto; }
  .filters.is-open .filters-foot {
    display: block;
    position: sticky;
    bottom: 0;
    margin: 16px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .filters-done { width: 100%; min-height: 48px; justify-content: center; }
  .filters-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 29;
    background: var(--backdrop);
    animation: fade-in 0.22s ease-out;
  }
  body.sheet-open { overflow: hidden; }
}
.filters-backdrop[hidden] { display: none; }

@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }

@media (min-width: 1040px) {
  .filters {
    display: block;
    position: sticky;
    top: 16px;
    margin: 0;
  }
  .filters-toggle { display: none !important; }
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.filters-head h2 { font-size: var(--step-0); font-weight: 600; }

.filter-group {
  margin: 0;
  padding: 12px 0 0;
  border: 0;
  min-inline-size: 0;
}
.filter-group legend,
.filter-group label {
  display: block;
  padding: 0;
  margin-bottom: 6px;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink-2);
}

select {
  width: 100%;
  min-height: 44px;
  padding: 0 36px 0 12px;
  background-color: var(--bg);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  appearance: none;
  cursor: pointer;
}

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

.type-toggle {
  min-height: 40px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 500;
  cursor: pointer;
  /* 40px pill plus the 8px gap keeps each target at 44px+ with spacing. */
}
.type-toggle:hover { border-color: var(--ink-2); }
.type-toggle[aria-pressed='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.type-toggle[aria-pressed='true']::before { content: '✓\00a0'; }

.link-button {
  min-height: 44px;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--tile);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

/* ---- Results ------------------------------------------------------------ */

.results:focus { outline: none; }

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.results-count { font-weight: 600; }

.results-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  font-weight: 500;
  cursor: pointer;
}

.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--step--1);
  color: var(--ink-2);
}
.sort select { width: auto; color: var(--ink); background-color: var(--surface); }

.active-part {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
  padding: 8px 8px 8px 16px;
  background: var(--tile-soft);
  border-radius: var(--radius-m);
}
.active-part[hidden] { display: none; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.card:hover { border-color: var(--ink-2); }
.card:has(.card-open:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.card-media,
.detail-media {
  position: relative;
  aspect-ratio: 3 / 2;
  background: var(--plate);
}
.team-photo,
.catalog-photo {
  height: 100%;
  margin: 0;
}
.team-photo img,
.catalog-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Vendor photos are product shots on white: show the whole part, on white in both
   themes, and label them so nobody takes them for the actual item. */
.catalog-photo {
  position: relative;
  background: #fff;
}
.catalog-photo img {
  object-fit: contain;
  padding: 8%;
}
.catalog-photo figcaption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(10 22 51 / 0.72);
  color: #fff;
  font-size: 0.75rem;
}

.glyph {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--ink-2);
  background-image: radial-gradient(circle, var(--plate-hole) 0 2px, transparent 2.6px);
  background-size: 16px 16px;
  background-position: 8px 8px;
}
.glyph .icon {
  padding: 14px;
  box-sizing: content-box;
  background: var(--plate);
  border-radius: 50%;
}

/* The chip sits over the photo: card chips are placed against the card's top-left
   corner (the photo is at the top), dialog chips against the dialog photo. */
.chip {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
}
.chip.type-trade { background: var(--tile-soft); color: var(--tile); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tile) 35%, transparent); }
.chip.type-sell { background: var(--ink); color: var(--bg); }
.chip.type-wanted { background: var(--saffron); color: var(--saffron-ink); }
.chip.type-giveaway { background: var(--free-soft); color: var(--free); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--free) 35%, transparent); }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 12px;
}

.card-title { font-size: var(--step-0); font-weight: 500; }
.card-title .card-open {
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-price {
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-giveaway .card-price { color: var(--free); }
.card-cond {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: var(--radius-s);
  background: var(--plate);
  font-size: 0.8125rem;
  font-weight: 500;
}

.card-open {
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}
/* The title button covers the whole card, so any tap opens the details. */
.card-open::after {
  content: '';
  position: absolute;
  inset: 0;
}
.card-open:focus-visible { outline: none; }

.exchange { margin: 0; }
.ex-row dt {
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.ex-row dd {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.card-kicker {
  font-size: 0.8125rem;
  color: var(--ink-2);
}

/* The ask under the card title, marked with the saffron swap arrows. */
.card-ask {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--saffron) 14%, var(--surface));
  border-radius: var(--radius-s);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.card-ask .icon { margin-top: 3px; color: color-mix(in srgb, var(--saffron) 70%, var(--ink)); }
.ask-label { font-weight: 400; color: var(--ink-2); }

.card-meta {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  font-size: var(--step--1);
  line-height: 1.4;
  color: var(--ink-2);
}
.card-meta .team { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-foot { padding: 0 16px 16px; }

/* Phones: two columns of classifieds-style cards. The whole card opens the details,
   which hold the Message button, so the card itself stays photo, title and price. */
@media (max-width: 559px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-media { aspect-ratio: 1; }
  .card-media .glyph .icon { width: 40px; height: 40px; padding: 8px; }
  .card-media .catalog-photo img { padding: 6%; }
  .card-media .catalog-photo figcaption { display: none; }
  .card .chip { top: 8px; left: 8px; padding: 2px 8px; font-size: 0.75rem; }
  .card-body { gap: 6px; padding: 10px 10px 12px; }
  .card-title { font-size: 0.9375rem; }
  .card-price { font-size: var(--step-0); }
  .card-foot { display: none; }
}

.contact {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--tile);
  color: var(--tile-ink);
  border-radius: var(--radius-s);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.contact:hover { background: color-mix(in srgb, var(--tile) 86%, var(--ink)); }
.contact.is-disabled {
  background: var(--plate);
  color: var(--ink-2);
  font-weight: 500;
}

.empty,
.error {
  padding: 32px 24px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  max-width: 40rem;
}
.empty h2 { font-size: var(--step-1); margin-bottom: 8px; }
.empty p { color: var(--ink-2); margin-bottom: 16px; }
.error { border-style: solid; border-color: var(--saffron); }
.empty[hidden], .error[hidden] { display: none; }

.button {
  min-height: 44px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: var(--radius-s);
  font-weight: 600;
  cursor: pointer;
}

/* ---- Detail dialog ------------------------------------------------------ */

.detail {
  width: min(640px, calc(100% - 2 * var(--gutter)));
  max-height: calc(100dvh - 32px);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-l);
  overflow: auto;
}
.detail::backdrop { background: var(--backdrop); }
.detail[open] { animation: rise 180ms ease-out; }

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

.detail-inner { position: relative; }
.detail-media { aspect-ratio: 16 / 9; max-height: 40dvh; }

.detail-thumbs {
  display: flex;
  gap: 8px;
  padding: 8px 16px 0;
  overflow-x: auto;
}
.detail-thumbs img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-s);
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 20px 24px;
}
.detail-body h2 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: var(--step-1);
  line-height: 1.25;
}

.detail-notes { color: var(--ink-2); white-space: pre-line; }
.photo-credit { font-size: var(--step--1); color: var(--ink-2); }
.part-name a { color: var(--ink); text-decoration-color: var(--line); }
.part-name a:hover { color: var(--tile); text-decoration-color: currentColor; }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 16px;
  margin: 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.facts dt { font-size: 0.8125rem; color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 500; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

/* ---- How it works ------------------------------------------------------- */

.how {
  max-width: var(--page);
  margin: 0 auto;
  padding: 48px var(--gutter) 56px;
  border-top: 1px solid var(--line);
}
.how h2 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: var(--step-2);
}

.steps {
  display: grid;
  gap: 24px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
@media (min-width: 800px) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: 32px; }
}

.steps li {
  counter-increment: step;
  padding-top: 16px;
  border-top: 3px solid var(--ink);
}
.steps li::before {
  content: counter(step);
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-latin);
  font-weight: 400;
  font-size: var(--step-2);
  color: var(--tile);
}
.steps h3 { font-size: var(--step-1); font-weight: 600; margin-bottom: 8px; }
.steps p { color: var(--ink-2); max-width: 46ch; }

.bot-cta { margin-top: 28px; font-weight: 500; }

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

.footer {
  padding: 24px var(--gutter) 32px;
  background: var(--plate);
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--step--1);
}
.footer p { max-width: var(--page); margin: 0 auto; }
.footer p + p { margin-top: 6px; }
/* The team credit, made to stand out in Quattuor's colours: a pill with a
   pink-to-violet border and glow, their Qt mark, and the line in the gradient. */
.quattuor { max-width: var(--page); margin: 28px auto 4px; }
.quattuor-inner {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px 12px 14px;
  border: 2px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(100deg, #f57ef9, #7b80ff) border-box;
  box-shadow: 0 0 28px rgb(245 126 249 / 0.35), 0 0 60px rgb(123 128 255 / 0.25);
}
.quattuor-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1b1b1d;
}
.quattuor-mark img { width: 24px; height: auto; }
.footer .quattuor .footer-credit {
  margin: 0;
  font-family: var(--font-latin, var(--font-display));
  font-size: var(--step-1);
  letter-spacing: 0.04em;
  background: linear-gradient(100deg, #e45bf0, #6d72ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (max-width: 480px) {
  .quattuor-inner { gap: 10px; padding: 10px 16px 10px 10px; }
  .footer .quattuor .footer-credit { font-size: var(--step-0); }
}

/* ---- Catalog page ------------------------------------------------------- */

.catalog {
  max-width: var(--page);
  margin: 0 auto;
  padding: 24px var(--gutter) 56px;
}
.catalog:focus { outline: none; }

.brand-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.brand-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.brand-nav a:hover { border-color: var(--ink-2); }

.brand {
  margin-top: 32px;
  scroll-margin-top: 16px;
}
.brand h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: var(--step-2);
}
.brand-count {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink-2);
}

.cat-group { margin-top: 20px; }
.cat-group h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: var(--step-0);
  font-weight: 600;
  color: var(--ink-2);
}

.part-rows {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}

.part-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 2px 14px;
  align-items: center;
  padding: 8px 16px 8px 8px;
  min-height: 72px;
}
.part-row + .part-row { border-top: 1px solid var(--line); }

.part-thumb {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.part-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.part-thumb.is-glyph { background: var(--plate); color: var(--ink-2); }

.part-name { grid-column: 2 / -1; font-weight: 500; }
.part-sku { color: var(--ink-2); font-size: var(--step--1); }
.part-count { justify-self: end; font-size: var(--step--1); font-weight: 500; white-space: nowrap; }
a.part-count { display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; }
.part-count.is-zero { color: var(--ink-2); font-weight: 400; }

@media (min-width: 720px) {
  .part-row { grid-template-columns: 56px minmax(0, 1fr) 11rem 7rem; }
  .part-thumb { grid-row: auto; }
  .part-name { grid-column: auto; }
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---- FTC / FLL switch ---------------------------------------------------- */

/* A segmented control: one program at a time, or All. */
.program-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.program-btn {
  min-height: 40px;
  padding: 0 18px;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
}
.program-btn:hover { color: var(--ink); }
.program-btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), inset 0 0 0 1px var(--line);
}
.catalog .program-switch { margin-bottom: 20px; }

/* ---- Landing page ------------------------------------------------------- */

.landing-hero { max-width: 46rem; padding: 40px 0 56px; }
.eyebrow {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  color: var(--tile);
}
.landing-hero h1 {
  font-size: clamp(2rem, 1.2rem + 3.6vw, 3.6rem);
  line-height: 1.12;
  max-width: 14ch;
}
.landing-hero .hero-sub { font-size: var(--step-1); max-width: 40ch; }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 32px; }
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 22px;
  border-radius: var(--radius-s);
  font-weight: 600;
  text-decoration: none;
}
.cta-primary { background: var(--tile); color: var(--tile-ink); }
.cta-primary:hover { background: color-mix(in srgb, var(--tile) 85%, var(--ink)); }
.cta-ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.cta-ghost:hover { box-shadow: inset 0 0 0 2px var(--ink); }
@media (max-width: 480px) { .cta { flex: 1 1 100%; } }
.landing-search { max-width: 34rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
  transform: translateY(-28px);
}
@media (min-width: 800px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin: 0 -1px -1px 0;
}
.stat:first-child { border-radius: var(--radius-m) 0 0 0; }
.stat:last-child { border-radius: 0 0 var(--radius-m) 0; }
.stat-num { font-family: var(--font-latin); font-size: var(--step-2); color: var(--tile); }
.stat-label { color: var(--ink-2); font-size: var(--step--1); }

.band { max-width: var(--page); margin: 0 auto; padding: 32px var(--gutter) 48px; }
.band h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-2); line-height: 1.25; }
.band-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.band-link { color: var(--tile); font-weight: 600; text-decoration: none; }
a.band-link:hover { text-decoration: underline; }
.band-sub { color: var(--ink-2); max-width: 60ch; margin-top: 8px; }

.latest-list { display: grid; gap: 12px; margin: 20px 0 0; padding: 0; list-style: none; }
@media (min-width: 800px) { .latest-list { grid-template-columns: repeat(3, 1fr); } }
.latest-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  height: 100%;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--ink);
  text-decoration: none;
}
.latest-card:hover { border-color: var(--ink); }
.latest-title { font-weight: 600; font-size: var(--step-1); line-height: 1.3; }
.latest-want { color: var(--ink-2); }
.latest-meta { margin-top: auto; padding-top: 6px; color: var(--ink-2); font-size: var(--step--1); }
.latest-empty { margin-top: 16px; color: var(--ink-2); }

.programs { display: grid; gap: 16px; }
@media (min-width: 800px) { .programs { grid-template-columns: 1fr 1fr; } }
.program-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  color: var(--ink);
  text-decoration: none;
}
.program-card:hover { border-color: var(--ink); }
.program-card p { color: var(--ink-2); max-width: 48ch; }
.program-card .band-link { margin-top: auto; padding-top: 6px; }
.program-tag {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-latin);
  font-size: var(--step--1);
  letter-spacing: 0.12em;
}
.program-tag-fll { background: var(--saffron); color: var(--saffron-ink); }

.teaser-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 20px 0 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .teaser-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1040px) { .teaser-grid { grid-template-columns: repeat(6, 1fr); } }
.teaser-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--ink);
  text-decoration: none;
}
.teaser-card:hover { border-color: var(--ink); }
.teaser-img, .teaser-glyph {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: var(--radius-s);
  background: #fff;
  overflow: hidden;
}
.teaser-glyph { background: var(--plate); color: var(--ink-2); }
.teaser-img img { width: 100%; height: 100%; object-fit: contain; }
.teaser-name { font-size: var(--step--1); line-height: 1.35; }
.latest-card .chip { position: static; }

/* ---- Phones: a compact header and a tighter first screen ---------------- */
@media (max-width: 719px) {
  .topbar { flex-wrap: nowrap; flex-direction: column; align-items: stretch; gap: 4px; padding: 12px 0 8px; }
  /* The three links share the row in equal thirds, so none hides off the edge;
     long Russian and Kazakh names wrap onto a second line inside their tab. */
  .nav-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(min-content, 1fr));
    gap: 4px;
  }
  .nav-links a {
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 4px 6px;
    text-align: center;
    line-height: 1.2;
    font-size: 0.9375rem;
  }
  .landing-hero { padding: 20px 0 32px; }
  .eyebrow { margin-bottom: 12px; font-size: 0.75rem; }
  .landing-hero .hero-sub { font-size: var(--step-0); }
  .cta-row { margin: 22px 0 24px; gap: 10px; }
  .stats { transform: translateY(-20px); }
  .stat { padding: 16px; }
}

/* The ✓ next to a team an admin has verified. */
.verified {
  display: inline-grid;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  background: var(--tile);
  color: var(--tile-ink);
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  vertical-align: 0.05em;
}

/* ---- Languages ---------------------------------------------------------- */

/* Michroma has no Cyrillic. In Russian and Kazakh the display headings switch to
   Exo 2 Bold (already loaded), tightened a little so they keep the wide-set,
   engineered feel; the ALMASU wordmark, FTC/FLL tags and numbers stay in Michroma. */
:root:lang(ru), :root:lang(kk) {
  --font-display: 'Exo 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display-weight: 700;
}
:root:lang(ru) .hero h1, :root:lang(kk) .hero h1 { letter-spacing: -0.005em; line-height: 1.15; }
:root:lang(ru) .eyebrow, :root:lang(kk) .eyebrow { font-weight: 600; letter-spacing: 0.14em; }

/* KZ / RU / EN in the top bar. */
.lang-switch {
  display: inline-flex;
  flex: none;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-s);
  /* Opaque, so the plate's hole pattern doesn't show through. */
  background: color-mix(in srgb, var(--ink) 7%, var(--plate));
}
.lang-btn {
  min-width: 36px;
  min-height: 32px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-2);
  font-family: var(--font-latin);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.lang-btn:hover { color: var(--ink); }
.lang-btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), inset 0 0 0 1px var(--line);
}

/* Wide screens: wordmark, links, then the switch at the far right. */
@media (min-width: 720px) {
  .topbar .nav-links { margin-left: auto; }
}

/* Phones: the switch shares the wordmark row, aligned right; the links scroll below. */
@media (max-width: 719px) {
  .topbar { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .topbar .nav-links { order: 3; flex: 1 0 100%; }
  .lang-switch { order: 2; }
}
:root:lang(ru) .footer .quattuor .footer-credit,
:root:lang(kk) .footer .quattuor .footer-credit { font-family: var(--font-body); font-weight: 700; letter-spacing: 0; }

/* ---- Phones and tablets: touch sizes ------------------------------------ */

/* Fingers, not a mouse: language buttons, the bot link and the "all listings"
   links get a full tap height. */
@media (pointer: coarse) {
  .lang-btn { min-width: 40px; min-height: 40px; }
  .band-link { display: inline-flex; align-items: center; min-height: 44px; }
  .part-name a { display: inline-block; padding: 6px 0; }
}

/* iPhone and iPad zoom the page into any field under 16px when it's tapped. */
@media (max-width: 719px), (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}

@media (max-width: 719px) {
  /* Long team names wrap instead of pushing the check mark off the card. */
  .card-meta .team { white-space: normal; overflow-wrap: anywhere; }
  .part-sku { overflow-wrap: anywhere; }
  .part-count { white-space: normal; text-align: end; }
}

/* The narrowest phones (320 px): a smaller wordmark keeps KZ / RU / EN on its row. */
@media (max-width: 359px) {
  .wordmark { gap: 8px; font-size: 1.0625rem; letter-spacing: 0.08em; }
  .wordmark-logo { width: 32px; height: 32px; border-radius: 8px; }
  .nav-links a { padding: 4px 3px; font-size: 0.875rem; }
}
