/*
 * Styles for the introduction site.
 *
 * One file, no preprocessor. The accent is the application's own brand colour
 * (#36ab60, see the `--dm-accent` pair in frontend/src/styles/global.css), the
 * dark palette follows `prefers-color-scheme` rather than a switch, and every
 * colour is a variable so there are exactly two places to look.
 */

:root {
  --accent: #36ab60;
  --accent-strong: #1f7a3f;
  --accent-soft: #eaf6ee;
  --btn-bg: #1f7a3f;
  --btn-bg-hover: #17632f;
  --btn-fg: #ffffff;
  --bg: #ffffff;
  --bg-soft: #f5f8f6;
  --surface: #ffffff;
  --surface-2: #f2f5f3;
  --line: #e3e8e4;
  --line-strong: #cfd8d2;
  --text: #171d19;
  --muted: #5b6862;
  --shadow: 0 1px 2px rgba(20, 40, 30, 0.06), 0 8px 24px rgba(20, 40, 30, 0.06);
  --shadow-lg: 0 24px 70px rgba(12, 24, 18, 0.35);
  --radius: 14px;
  --radius-sm: 9px;
  --max: 1160px;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #45c47a;
    --accent-strong: #6ad598;
    --accent-soft: #16291d;
    --btn-bg: #45c47a;
    --btn-bg-hover: #6ad598;
    --btn-fg: #08150e;
    --bg: #0e1210;
    --bg-soft: #131816;
    --surface: #161c19;
    --surface-2: #1c2320;
    --line: #262e2a;
    --line-strong: #37423c;
    --text: #e9eeeb;
    --muted: #9daba4;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.7);
  }
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

img {
  max-width: 100%;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.3rem);
}

h2 {
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
}

h3 {
  font-size: 1.06rem;
}

p {
  margin: 0 0 1em;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  white-space: nowrap;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ top -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px max(20px, calc((100% - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  overflow: hidden;
}

.brand-mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-mark .fallback {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
}

/* The letter only shows when the artwork could not be loaded. */
.brand-mark:not(.no-icon) .fallback,
.engine-icon:not(.no-icon) .fallback {
  visibility: hidden;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.brand-text strong {
  font-size: 1.02rem;
}

.brand-version {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.92rem;
}

.topnav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.langs {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.langs button {
  min-width: 34px;
  padding: 3px 8px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.langs button:hover {
  color: var(--text);
}

.langs button.is-active {
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
}

/* ----------------------------------------------------------------- hero -- */

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(48px, 8vw, 96px) 20px 8px;
}

.hero .eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.hero h1 {
  max-width: 22ch;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent-strong);
}

.hero .lead {
  max-width: 68ch;
  font-size: clamp(1rem, 1.3vw, 1.12rem);
  color: var(--muted);
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.btn.primary {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}

.btn.primary:hover {
  background: var(--btn-bg-hover);
  border-color: var(--btn-bg-hover);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.btn.ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.pills li {
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  background: var(--bg-soft);
}

/* ------------------------------------------------------------- sections -- */

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(56px, 7vw, 88px) 20px 0;
}

.section-head {
  max-width: 72ch;
  margin-bottom: 28px;
}

.section-head p {
  color: var(--muted);
  margin: 0;
}

.subhead {
  margin: 40px 0 14px;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ------------------------------------------------------------- carousel -- */

.carousel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.slides {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  transition: transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}

html[data-reduced-motion] .slides {
  transition: none;
}

.slide {
  flex: 0 0 100%;
  min-width: 100%;
}

.slide figure {
  margin: 0;
}

.zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.zoom img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-2);
}

.slide figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 16px;
  min-height: 8.5rem;
}

.slide figcaption h3 {
  margin: 0;
  font-size: 1.05rem;
}

.slide figcaption p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  max-width: 90ch;
}

.slide figcaption .chips {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: auto;
  padding-top: 6px;
}

.arrow {
  position: absolute;
  top: 41%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: opacity 0.2s;
}

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

.arrow.prev {
  left: 14px;
}

.arrow.next {
  right: 14px;
}

.carousel-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 2px;
}

.playpause {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}

.playpause::before,
.playpause::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  border-radius: 1px;
}

/* Two bars while it auto-advances, one triangle once it is stopped. */
.playpause::before {
  left: 11px;
  width: 3px;
  height: 10px;
}

.playpause::after {
  left: 17px;
  width: 3px;
  height: 10px;
}

.playpause.is-paused::before {
  left: 12px;
  width: 0;
  height: 0;
  background: none;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--text);
  border-radius: 0;
}

.playpause.is-paused::after {
  display: none;
}

.dots {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dots button {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line-strong);
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

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

.dots button.is-active {
  background: var(--accent);
  transform: scale(1.35);
}

.counter {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.thumbs {
  display: flex;
  gap: 10px;
  margin: 12px 0 0;
  padding: 2px 0 4px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: thin;
}

.thumbs button {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 148px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--muted);
}

.thumbs button:hover {
  border-color: var(--line-strong);
}

.thumbs button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.thumbs img {
  display: block;
  width: 100%;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.thumbs span {
  font-size: 0.75rem;
  line-height: 1.3;
  padding: 0 2px 2px;
}

/* -------------------------------------------------------------- gallery -- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery button {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: zoom-in;
  font: inherit;
  color: var(--text);
  text-align: left;
}

.gallery button:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.gallery img {
  display: block;
  width: 100%;
  border-radius: 6px;
  background: var(--surface-2);
}

.gallery span {
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0 2px 3px;
}

/* --------------------------------------------------------------- cards -- */

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

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 18px;
}

.card h3 {
  margin: 0 0 6px;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 9px;
  margin-bottom: 10px;
}

/* ------------------------------------------------------------- engines -- */

.engines {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.engines li {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 16px;
}

.engines h3 {
  margin: 0;
  align-self: end;
}

.engines p {
  grid-column: 2;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  align-self: start;
}

.engine-icon {
  position: relative;
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.engine-icon img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
}

.engine-icon .fallback {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.planned {
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.92rem;
}

.planned strong {
  color: var(--text);
  margin-right: 8px;
}

/* ----------------------------------------------------------- downloads -- */

.downloads {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.downloads li {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 16px;
}

.dl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.downloads p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.notes article {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  padding: 16px;
}

.notes h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.notes p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.notes p + p {
  margin-top: 8px;
}

.points {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.points li {
  position: relative;
  padding-left: 26px;
  color: var(--muted);
  font-size: 0.94rem;
}

.points li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0.62em;
  width: 6px;
  height: 11px;
  border: solid var(--accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* -------------------------------------------------------------- footer -- */

footer {
  max-width: var(--max);
  margin: clamp(70px, 8vw, 110px) auto 0;
  padding: 28px 20px 46px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

footer p {
  margin: 0;
}

footer strong {
  color: var(--text);
  margin-right: 8px;
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-left: auto;
}

footer a {
  color: var(--muted);
}

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

.fineprint {
  flex-basis: 100%;
  font-size: 0.82rem;
}

.noscript {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 20px;
  color: var(--muted);
}

/* ------------------------------------------------------------ lightbox -- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 14, 11, 0.86);
  backdrop-filter: blur(3px);
}

body.is-locked {
  overflow: hidden;
}

.lightbox figure {
  margin: 0;
  max-width: min(1700px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lightbox img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  background: #fff;
}

.lightbox figcaption {
  color: #e8ece9;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lightbox figcaption strong {
  font-size: 0.98rem;
}

.lightbox figcaption span {
  font-size: 0.86rem;
  opacity: 0.75;
  max-width: 90ch;
  margin: 0 auto;
}

.lb-close,
.lb-arrow {
  position: fixed;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}

.lb-close {
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  font-size: 1.4rem;
}

.lb-arrow {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  font-size: 1.7rem;
}

.lb-arrow.prev {
  left: 18px;
}

.lb-arrow.next {
  right: 18px;
}

.lb-close:hover,
.lb-arrow:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* --------------------------------------------------------------- small -- */

@media (max-width: 820px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .topnav {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .langs {
    margin-left: auto;
  }

  .arrow {
    top: 30%;
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }

  .slide figcaption {
    min-height: 11rem;
  }

  .thumbs button {
    width: 120px;
  }

  .lb-arrow {
    top: auto;
    bottom: 22px;
    transform: none;
  }

  footer nav {
    margin-left: 0;
    flex-basis: 100%;
  }
}

@media (max-width: 520px) {
  .slide figcaption {
    min-height: 13rem;
  }

  .counter {
    display: none;
  }
}

@media print {
  .topbar,
  .carousel-bar,
  .thumbs,
  .arrow,
  .lightbox {
    display: none !important;
  }

  .slides {
    display: block !important;
  }

  .slide {
    break-inside: avoid;
  }
}
