/* ==========================================================
   Coder Stats Card: one stylesheet for the whole site
   ========================================================== */

:root {
  /* A soft lavender page, white surfaces, and an indigo to violet to cyan accent
     that matches the logo ring. */
  --bg: #f6f5fc;
  --bg-2: #efedfa;
  --surface: #ffffff;
  --ink: #17152e;
  --muted: #625f7c;
  --line: #e3e0f1;
  --accent: #5a45f0;
  --accent-2: #b847f2;
  --accent-3: #0eadc4;
  --accent-ink: #ffffff;
  --accent-soft: #ece9ff;
  --danger: #d0263f;
  --code-bg: #f1effa;
  --grid: #e5e2f3;
  --star: #e0a400;
  --shadow: 0 1px 2px rgb(23 21 46 / 0.05), 0 18px 40px -26px rgb(62 44 160 / 0.35);
  --header-bg: linear-gradient(90deg, rgb(255 255 255 / 0.86), rgb(244 241 255 / 0.86));
  --header-line: linear-gradient(90deg, transparent, rgb(90 69 240 / 0.45) 25%, rgb(184 71 242 / 0.45) 60%, rgb(14 173 196 / 0.35) 85%, transparent);
  --header-shadow: 0 10px 30px -22px rgb(62 44 160 / 0.45);
  /* Buttons keep strong, saturated colors in both modes so white text stays readable. */
  --btn-grad: linear-gradient(115deg, #5a45f0 0%, #8b3ff0 55%, #b847f2 100%);
  --btn-glow: rgb(90 69 240 / 0.55);

  /* Codeforces rank colors, tuned per mode for contrast */
  --r-newbie: #808080;
  --r-pupil: #008000;
  --r-specialist: #03a89e;
  --r-expert: #0000ff;
  --r-cm: #aa00aa;
  --r-master: #ff8c00;
  --r-gm: #ff0000;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 12px;
  --grad: linear-gradient(115deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-3) 100%);
  color-scheme: light;
}

/* Dark colors. The page script sets data-theme to "light" or "dark" before the
   first paint (from the visitor's choice or their device setting). Without
   JavaScript the device setting still applies through the media query. */
:root[data-theme="dark"] {
    --bg: #0d0c1c;
    --bg-2: #121128;
    --surface: #16152c;
    --ink: #eeedf9;
    --muted: #a6a3c4;
    --line: #2a2849;
    --accent: #8f80ff;
    --accent-2: #d685ff;
    --accent-3: #45d6ea;
    --accent-ink: #0d0c1c;
    --accent-soft: #221f45;
    --danger: #ff7a8a;
    --code-bg: #121127;
    --grid: #1a1934;
    --star: #f5c04a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 22px 44px -26px rgb(0 0 0 / 0.7);
    --header-bg: linear-gradient(90deg, rgb(30 27 62 / 0.88), rgb(40 31 78 / 0.88));
    --header-line: linear-gradient(90deg, transparent, rgb(143 128 255 / 0.8) 25%, rgb(214 133 255 / 0.75) 60%, rgb(69 214 234 / 0.6) 85%, transparent);
    --header-shadow: 0 14px 34px -14px rgb(0 0 0 / 0.9);
    --btn-grad: linear-gradient(115deg, #6a54ff 0%, #8f45f2 55%, #c04ee0 100%);
    --btn-glow: rgb(143 110 255 / 0.5);

    --r-newbie: #a8a8a8;
    --r-pupil: #3fbf5a;
    --r-specialist: #2ed3c6;
    --r-expert: #6b8cff;
    --r-cm: #d36bff;
    --r-master: #ffa94d;
    --r-gm: #ff5c5c;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0d0c1c;
    --bg-2: #121128;
    --surface: #16152c;
    --ink: #eeedf9;
    --muted: #a6a3c4;
    --line: #2a2849;
    --accent: #8f80ff;
    --accent-2: #d685ff;
    --accent-3: #45d6ea;
    --accent-ink: #0d0c1c;
    --accent-soft: #221f45;
    --danger: #ff7a8a;
    --code-bg: #121127;
    --grid: #1a1934;
    --star: #f5c04a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 22px 44px -26px rgb(0 0 0 / 0.7);
    --header-bg: linear-gradient(90deg, rgb(30 27 62 / 0.88), rgb(40 31 78 / 0.88));
    --header-line: linear-gradient(90deg, transparent, rgb(143 128 255 / 0.8) 25%, rgb(214 133 255 / 0.75) 60%, rgb(69 214 234 / 0.6) 85%, transparent);
    --header-shadow: 0 14px 34px -14px rgb(0 0 0 / 0.9);
    --btn-grad: linear-gradient(115deg, #6a54ff 0%, #8f45f2 55%, #c04ee0 100%);
    --btn-glow: rgb(143 110 255 / 0.5);

    --r-newbie: #a8a8a8;
    --r-pupil: #3fbf5a;
    --r-specialist: #2ed3c6;
    --r-expert: #6b8cff;
    --r-cm: #d36bff;
    --r-master: #ffa94d;
    --r-gm: #ff5c5c;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

[hidden] {
  display: none !important;
}

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

/* ---------- Layout ---------- */

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 32px;
}

.page {
  position: relative;
  z-index: 1;
}

.hero-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 880px;
  z-index: 0;
  pointer-events: none;
}

/* The header sticks to the top. js/ui/header.js slides it away while scrolling
   down and back while scrolling up, and adds a frosted bar once the page moves. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px 28px;
  padding: 14px 0;
  will-change: transform;
  /* Coming back is a little slower and softer than going away. */
  transition:
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.45s ease;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: -1;
  background: var(--header-line) bottom / 100% 1px no-repeat, var(--header-bg);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: var(--header-shadow);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.site-header.is-scrolled::before {
  opacity: 1;
}

.site-header.is-hidden {
  transform: translateY(-105%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.45s cubic-bezier(0.55, 0, 0.75, 0.2),
    opacity 0.35s ease 0.08s;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  text-decoration: none;
  font-size: 15.5px;
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 22px;
  margin-left: auto;
  font-size: 14.5px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Light and dark switch ---------- */

.theme-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  border-color: color-mix(in srgb, var(--ink) 40%, var(--line));
}

.theme-toggle:active {
  transform: scale(0.92);
}

.theme-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.theme-icon .fill {
  fill: currentColor;
  stroke: none;
}

.theme-icon-light circle {
  fill: var(--star);
  stroke: var(--star);
}

.theme-icon-dark path {
  fill: currentColor;
}

/* The icon for the current choice spins in; the others spin out. */
.theme-toggle[data-choice="light"] .theme-icon-light,
.theme-toggle[data-choice="dark"] .theme-icon-dark,
.theme-toggle[data-choice="system"] .theme-icon-system {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* The circle reveal is drawn by js/ui/theme.js; the browser's default fade is turned off. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Fallback for browsers without view transitions: a short cross fade. */
.theme-fade,
.theme-fade *,
.theme-fade *::before,
.theme-fade *::after {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, fill 0.35s ease !important;
}

/* The repository icon is drawn with a mask so it takes the text color.
   Replace icons/github.svg with any single color SVG to change it. */
.icon-gh {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("../icons/github.svg") center / contain no-repeat;
  mask: url("../icons/github.svg") center / contain no-repeat;
}

.gh-button {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.gh-button:hover {
  transform: translateY(-1px);
}

.gh-button .icon-gh {
  margin: auto 0 auto 14px;
}

.gh-button-text {
  padding: 8px 14px 8px 8px;
}

.gh-button-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.gh-button-count::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--star);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.section {
  padding: 48px 0 64px;
  border-top: 1px solid var(--line);
  /* Room for the header, which slides back in when scrolling up to a section. */
  scroll-margin-top: 76px;
}

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

.h2 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  max-width: 72ch;
}

.small {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  max-width: 50ch;
}

.summary {
  margin-top: 22px;
  max-width: 70ch;
  font-size: 15.5px;
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 28px;
}

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

.site-footer {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  padding: 44px 0 36px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
}

.footer-text {
  margin-top: 10px;
  max-width: 36ch;
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-heading {
  font-weight: 600;
  margin-bottom: 2px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-gh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.footer-gh .icon-gh {
  width: 16px;
  height: 16px;
}

.footer-bottom {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Star band ---------- */

.star-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px 40px;
  flex-wrap: wrap;
  margin: 8px 0 64px;
  padding: 36px 40px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--bg);
}

.star-title {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.star-text {
  margin-top: 8px;
  max-width: 56ch;
  opacity: 0.8;
}

.star-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.star-big {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  transition: transform 0.15s ease;
}

.star-big:hover {
  transform: translateY(-2px);
}

.star-big:hover .star-icon {
  animation: twinkle 0.6s ease;
}

.star-icon {
  color: var(--star);
}

@keyframes twinkle {
  50% {
    transform: scale(1.3) rotate(18deg);
  }
}

.star-count {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.star-meta {
  display: flex;
  gap: 6px 14px;
  flex-wrap: wrap;
  font-size: 14px;
  opacity: 0.8;
}

.star-meta a {
  color: inherit;
  text-underline-offset: 3px;
}

/* ---------- Form controls ---------- */

.input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
}

.input-lg {
  height: 52px;
  padding: 0 16px;
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 108px;
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.button-lg {
  height: 52px;
  padding: 0 22px;
}

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

.button-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.button-ink {
  background: var(--ink);
  color: var(--bg);
}

.button:disabled {
  cursor: progress;
  opacity: 0.85;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.form-error {
  min-height: 1.5em;
  margin-top: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--danger);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14.5px;
  cursor: pointer;
}

.check input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.link-button {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding: 48px 0 64px;
}

.hero-title {
  font-size: clamp(2.4rem, 5vw, 4.1rem);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.03em;
  max-width: 13ch;
}

.hero-lede {
  max-width: 48ch;
  margin-top: 22px;
  font-size: 1.1rem;
  color: var(--muted);
}

.hero-form {
  display: flex;
  gap: 10px;
  max-width: 500px;
  margin-top: 32px;
}

/* Platform picker */
.hero-form {
  max-width: 600px;
}

.platform-select {
  flex: 0 0 184px;
  font-weight: 500;
}

.platform-strip {
  margin-top: 22px;
}

.platform-strip-label {
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--muted);
}

.platform-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 600px;
}

.platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.platform-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip);
}

.platform-chip:hover {
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
  transform: translateY(-1px);
}

.platform-chip[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 600;
}

:root[data-theme="dark"] .platform-chip::before {
  background: var(--chip-dark);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .platform-chip::before {
    background: var(--chip-dark);
  }
}

.hero-stage {
  position: relative;
  min-width: 0;
}

/* The card stack: three real cards dealt onto the table on load. */
.hero-stack {
  position: relative;
  width: 100%;
  aspect-ratio: 520 / 450;
}

.hero-card {
  position: absolute;
  width: 86%;
  height: auto;
  border-radius: 10px;
  box-shadow:
    0 1px 2px color-mix(in srgb, var(--ink) 10%, transparent),
    0 22px 44px -24px color-mix(in srgb, var(--ink) 45%, transparent);
  animation: deal 0.9s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.hero-card-0 {
  top: 0;
  right: 0;
  --to: rotate(3.5deg);
  animation-delay: 0.05s;
}

.hero-card-1 {
  top: 27%;
  left: 0;
  --to: rotate(-4deg);
  animation-delay: 0.2s;
}

.hero-card-2 {
  top: 55%;
  left: 7%;
  --to: rotate(1deg);
  animation-delay: 0.35s;
}

@keyframes deal {
  from {
    opacity: 0;
    transform: translateY(48px) rotate(0deg) scale(0.94);
  }
  to {
    opacity: 1;
    transform: var(--to);
  }
}

/* ---------- Rank ladder ---------- */

.ladder {
  margin: 0;
  width: 100%;
}

.ladder-track {
  position: relative;
  padding-top: 58px;
}

.ladder.two .ladder-track {
  padding-bottom: 50px;
}

.ladder-band {
  position: relative;
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
}

.ladder-segment {
  display: block;
  height: 100%;
}

.ladder-inner-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--bg);
  opacity: 0.55;
}

.ladder-marker {
  position: absolute;
  top: 52px;
  width: 0;
  height: 26px;
  animation: drop 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.ladder-marker::before {
  content: "";
  position: absolute;
  left: -2px;
  bottom: 0;
  width: 4px;
  height: 26px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--bg);
}

.ladder-flag {
  position: absolute;
  bottom: 30px;
  left: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  white-space: nowrap;
  font-size: 13px;
}

.ladder-marker.below .ladder-flag {
  bottom: auto;
  top: 30px;
}

.ladder-flag-handle {
  opacity: 0.75;
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ladder-flag-rating {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ladder-max {
  position: absolute;
  top: 54px;
  width: 0;
  height: 22px;
}

.ladder-max::before {
  content: "";
  position: absolute;
  left: -1px;
  bottom: 0;
  width: 2px;
  height: 22px;
  background: var(--muted);
  border-radius: 1px;
}

.ladder-max-label {
  position: absolute;
  top: 26px;
  left: 0;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.edge-start .ladder-flag {
  transform: translateX(-12px);
}

.edge-end .ladder-flag {
  transform: translateX(calc(-100% + 12px));
}

.edge-end .ladder-max-label {
  transform: translateX(-100%);
}

.edge-start .ladder-max-label {
  transform: none;
}

.ladder-labels {
  display: flex;
  margin-top: 26px;
}

.ladder-label {
  display: flex;
  flex-direction: column;
  padding: 0 6px;
  font-size: 12.5px;
  line-height: 1.3;
  border-left: 1px solid var(--line);
}

.ladder-label:first-child {
  border-left: 0;
  padding-left: 0;
}

.ladder-label-name {
  font-weight: 500;
}

.ladder-label-from {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Builder ---------- */

.types {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.type-group-label {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.type-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: 8px;
}

.type-row > .type {
  grid-column: span var(--span, 1);
}

@media (max-width: 1000px) {
  .type-row {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .type-row > .type {
    grid-column: auto;
  }
}

.type {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
}

.type:hover {
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
}

.type[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.type-name {
  font-weight: 600;
  font-size: 15px;
}

.type-desc {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}

/* Preview and snippet on the left, controls on the right */
.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  grid-template-areas:
    "preview controls"
    "embed controls";
  gap: 28px 44px;
  align-items: start;
}

.preview-area {
  grid-area: preview;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.params {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.param {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Inputs in a column layout must not shrink to nothing. */
.param > .input:not(.textarea) {
  flex: none;
  height: 42px;
}

/* Many short handle boxes (the all platforms card) sit in two columns. */
.params.params-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.params.params-grid > :first-child {
  grid-column: 1 / -1;
}

.param-label {
  font-size: 14px;
  font-weight: 500;
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

.textarea {
  height: auto;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

/* Selects get their own arrow so they look the same in every browser, and keep
   the height of the size class they're given (the large one in the hero). */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.select:not(.input-lg) {
  height: 42px;
}

.input-number {
  flex: 0 0 104px;
  height: 38px;
}

.figure-typing {
  padding: 18px 0;
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}

.embed-area {
  grid-area: embed;
  min-width: 0;
}

.figure {
  margin: 0;
}

.preview {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}

.preview-badge {
  display: block;
  height: 28px;
  width: auto;
}

.caption {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.waiting {
  display: grid;
  place-items: center;
  aspect-ratio: 495 / 220;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.legend {
  padding: 0;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 15px;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
}

.chip:hover {
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
}

.chip[aria-checked="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 600;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid;
  flex-shrink: 0;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.details summary {
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  width: fit-content;
}

.colors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-top: 12px;
}

.color {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
}

.color input {
  width: 34px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

/* ---------- Snippet box ---------- */

.embed {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.embed-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 6px;
  border-bottom: 1px solid var(--line);
}

.embed-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
}

.embed-tab {
  border: 0;
  background: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

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

.embed-tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--code-bg);
  font-weight: 600;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.copy-button:hover:not(:disabled) {
  border-color: var(--ink);
}

.copy-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.embed-code {
  margin: 0;
  padding: 16px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 92px;
}

.embed-hint {
  padding: 10px 16px 12px;
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- README generator ---------- */

.gen-grid {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.gen-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}

.gen-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gen-extra > .input:not(.textarea) {
  flex: none;
  height: 42px;
}

.gen-extra > .link-button {
  align-self: flex-start;
  margin-top: 2px;
}

.gen-extra {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0 4px 26px;
}

.gen-output {
  min-width: 0;
}

.gen-bar {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.gen-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  border: 0;
  background: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.gen-code {
  max-height: 640px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre;
  word-break: normal;
}

.gen-hint {
  max-width: 70ch;
}

/* A stand in for GitHub's README view, in its own light and dark colors. */
.gh-frame {
  border-radius: 12px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  transition: background 0.2s ease;
}

.gh-light {
  --gh-bg: #ffffff;
  --gh-ink: #1f2328;
  --gh-muted: #59636e;
  --gh-line: #d1d9e0;
  --gh-bar: #f6f8fa;
  --gh-link: #0969da;
}

.gh-dark {
  --gh-bg: #0d1117;
  --gh-ink: #f0f6fc;
  --gh-muted: #9198a1;
  --gh-line: #3d444d;
  --gh-bar: #151b23;
  --gh-link: #4493f8;
}

.gh-frame {
  border: 1px solid var(--gh-line);
  background: var(--gh-bg);
  color: var(--gh-ink);
}

.gh-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gh-line);
  background: var(--gh-bar);
  font-size: 14px;
  font-weight: 600;
}

.gh-file .icon-gh {
  width: 16px;
  height: 16px;
  color: var(--gh-muted);
}

.gh-body {
  padding: 24px 32px 28px;
  max-height: 900px;
  overflow: auto;
}

.gh-body img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* Plain centered blocks rather than flexbox: Safari doesn't shrink the height
   of SVG images inside flex columns, which made them overlap on phones. */
.gh-center {
  margin-bottom: 16px;
  text-align: center;
}

.gh-center img {
  display: block;
  margin: 0 auto 12px;
}

.gh-center img:last-child {
  margin-bottom: 0;
}

.gh-h2 {
  margin: 24px 0 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gh-line);
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.25;
}

.gh-p {
  margin: 0 0 16px;
  line-height: 1.6;
}

.gh-row {
  display: flex;
  justify-content: center;
  gap: 2%;
  margin: 0 0 16px;
}

.gh-credit {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--gh-muted);
}

.gh-credit a {
  color: var(--gh-link);
}

.gh-empty {
  color: var(--gh-muted);
  text-align: center;
  padding: 40px 0;
}

.gh-wait {
  display: grid;
  place-items: center;
  max-width: 100%;
  aspect-ratio: 495 / 220;
  border: 1px dashed var(--gh-line);
  border-radius: 10px;
  color: var(--gh-muted);
  font-size: 14px;
}

/* ---------- Compare ---------- */

.compare-form {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 860px;
  margin-top: 22px;
}

.compare-form .input,
.compare-form .button {
  height: 48px;
}

.cmp-platform {
  flex: 0 0 180px;
}

.cmp-empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.compare-and {
  color: var(--muted);
  font-size: 15px;
}

.cmp-people {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 10px;
}

.cmp-person {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cmp-person-b {
  text-align: right;
}

.cmp-name {
  font-size: 1.35rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmp-rank {
  color: var(--muted);
  font-size: 14px;
}

.cmp-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.cmp-table tr {
  border-top: 1px solid var(--line);
}

.cmp-label {
  width: 190px;
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
}

.cmp-a,
.cmp-b {
  padding: 12px 0;
  font-variant-numeric: tabular-nums;
}

.cmp-a {
  text-align: right;
}

.cmp-a > *,
.cmp-b > * {
  vertical-align: middle;
}

.cmp-value {
  display: inline-block;
  min-width: 64px;
  font-weight: 500;
  font-size: 15px;
}

.cmp-a .cmp-value {
  margin-right: 12px;
}

.cmp-b .cmp-value {
  margin-left: 12px;
}

.win .cmp-value {
  font-weight: 700;
}

.cmp-track {
  display: inline-flex;
  width: calc(100% - 80px);
  height: 8px;
  border-radius: 4px;
  background: var(--code-bg);
  overflow: hidden;
}

.cmp-a .cmp-track {
  justify-content: flex-end;
}

.cmp-bar {
  display: block;
  height: 100%;
  border-radius: 4px;
  opacity: 0.45;
  transform-origin: left;
  animation: fill 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.cmp-a .cmp-bar {
  transform-origin: right;
}

.win .cmp-bar {
  opacity: 1;
}

@keyframes fill {
  from {
    transform: scaleX(0);
  }
}

/* ---------- Options table ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.table th {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
}

.table td:first-child {
  white-space: nowrap;
  width: 1%;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table code {
  overflow-wrap: anywhere;
}

.example {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .hero-card {
    animation: none;
    transform: var(--to);
  }
}

/* ---------- Smaller screens ---------- */


@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 32px 0 48px;
  }
  .hero-title {
    max-width: 16ch;
  }
  .hero-stage {
    max-width: 560px;
  }
  .hero-bg {
    height: 1120px;
  }
}

@media (max-width: 1000px) {
  .gen-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .nav {
    display: none;
  }
  .theme-toggle {
    margin-left: auto;
  }
}

@media (max-width: 900px) {
  .builder-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "preview"
      "controls"
      "embed";
  }
  .preview-area {
    max-width: 495px;
  }
}

@media (max-width: 760px) {
  .ladder-labels {
    display: none;
  }
}

@media (max-width: 700px) {
  .compare-form {
    flex-wrap: wrap;
  }
  .compare-form .input {
    flex: 1 1 40%;
  }
  .compare-and {
    display: none;
  }
  .compare-form .button,
  .compare-form .cmp-platform {
    flex: 1 1 100%;
  }
  .cmp-label {
    width: 104px;
    font-size: 12.5px;
    padding: 10px 4px;
  }
  .cmp-track {
    display: none;
  }
  .cmp-value {
    min-width: 0;
  }
  .cmp-a .cmp-value,
  .cmp-b .cmp-value {
    margin: 0;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 0 16px;
  }
  .panel {
    padding: 18px;
  }
  .gh-button-long {
    display: none;
  }
  .gh-body {
    padding: 16px;
  }
  /* Stacked as plain blocks on phones (see the Safari note on .gh-center). */
  .gh-row {
    display: block;
  }
  .gh-row img {
    display: block;
    width: 100% !important;
    margin: 0 auto 12px;
  }
  .gen-actions {
    margin-left: 0;
  }
  .star-band {
    padding: 28px 22px;
  }
  .site-footer {
    grid-template-columns: 1fr 1fr;
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
  .hero-form {
    flex-direction: column;
  }
  .hero-form .input {
    flex: none;
  }
  .platform-select {
    width: 100%;
  }
  .type-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .type-row > .type:last-child:nth-child(odd) {
    grid-column: span 2;
  }
  .type-desc {
    display: none;
  }
  .fields,
  .colors {
    grid-template-columns: 1fr;
  }
  .table td:first-child {
    white-space: normal;
  }
}

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

.not-found {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 80px 0 120px;
}

.not-found-code {
  font-size: clamp(4rem, 14vw, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--accent);
}

.not-found .button {
  text-decoration: none;
  margin-top: 8px;
}


/* ==========================================================
   Look and feel: gradients, glow, motion
   ========================================================== */

body {
  overflow-x: clip;
  background:
    radial-gradient(900px 560px at 88% -6%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 65%),
    radial-gradient(760px 520px at -8% 4%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 65%),
    var(--bg);
  background-repeat: no-repeat;
}

::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.brand span {
  letter-spacing: -0.01em;
}

/* Nav links get a gradient underline that grows from the left. */
.nav a {
  position: relative;
  padding: 4px 0;
  transition: color 0.2s ease;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav a:hover {
  text-decoration: none;
}

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

/* Gradient text with a slow shimmer. */
.grad-text {
  background: linear-gradient(100deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: grad-move 9s ease-in-out infinite;
}

@keyframes grad-move {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Small pill above the hero title. */
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 6px 14px 6px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.hero-kicker b {
  color: var(--ink);
  font-weight: 600;
}

.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%,
  100% {
    transform: scale(2.6);
    opacity: 0;
  }
}

.hero-title {
  font-weight: 700;
}

/* Soft colored light behind the card stack. */
.hero-stage::before {
  content: "";
  position: absolute;
  inset: 4% 2% 0 6%;
  z-index: -1;
  border-radius: 50%;
  background:
    radial-gradient(closest-side at 35% 40%, color-mix(in srgb, var(--accent) 38%, transparent), transparent),
    radial-gradient(closest-side at 70% 65%, color-mix(in srgb, var(--accent-2) 32%, transparent), transparent),
    radial-gradient(closest-side at 60% 25%, color-mix(in srgb, var(--accent-3) 22%, transparent), transparent);
  filter: blur(28px);
  animation: drift 14s ease-in-out infinite alternate;
}

.hero-stage {
  isolation: isolate;
}

@keyframes drift {
  from {
    transform: translate(-3%, 2%) scale(1);
  }
  to {
    transform: translate(3%, -3%) scale(1.06);
  }
}

/* Buttons */
.button-primary {
  background: var(--btn-grad);
  background-size: 160% 100%;
  background-position: 0% 50%;
  color: #fff;
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.15);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.18),
    0 10px 24px -12px var(--btn-glow);
  transition: background-position 0.5s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.button-primary:hover:not(:disabled) {
  filter: none;
  background-position: 100% 50%;
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.22),
    0 14px 30px -12px var(--btn-glow);
}

.button-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.input {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:hover:not(:focus-visible) {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

/* Platform chips light up in their own color. */
.platform-chip {
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.2s;
}

.platform-chip:hover {
  border-color: var(--chip);
  box-shadow: 0 6px 16px -10px var(--chip);
}

/* Section headings get a short gradient bar above them. */
.section .h2::before {
  content: "";
  display: block;
  width: 34px;
  height: 4px;
  margin-bottom: 14px;
  border-radius: 4px;
  background: var(--grad);
}

.h2 {
  font-weight: 700;
}

.panel {
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* Star on GitHub: every so often a light sweeps across it and it pulses once.
   js/ui/header.js adds .is-shining a few times per visit, not on a loop. */
.gh-button {
  position: relative;
  isolation: isolate;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.gh-button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.55) 48%, transparent 66%);
  transform: translateX(-120%);
}

.gh-button:hover {
  box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}

.gh-button.is-shining {
  animation: star-pulse 1.4s ease-out;
}

.gh-button.is-shining::after {
  animation: shine 1.2s cubic-bezier(0.3, 0, 0.3, 1) 0.1s;
}

.gh-button.is-shining .icon-gh,
.gh-button.is-shining .gh-button-count::before {
  animation: twinkle 0.7s ease 0.35s;
}

@keyframes shine {
  to {
    transform: translateX(120%);
  }
}

@keyframes star-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 60%, transparent);
  }
  70% {
    box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent-2) 0%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* The open source band gets the brand gradient, with a slow light passing over. */
.star-band {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(120deg, #4b36e0, #9a3fe6 55%, #c24fd6);
  color: #fff;
  box-shadow: 0 30px 60px -36px rgb(90 69 240 / 0.8);
}

.star-band::before {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: -1;
  background:
    radial-gradient(closest-side at 30% 40%, rgb(255 255 255 / 0.18), transparent),
    radial-gradient(closest-side at 75% 70%, rgb(69 214 234 / 0.35), transparent);
  animation: drift 12s ease-in-out infinite alternate;
}

.star-band .star-text,
.star-band .star-meta {
  opacity: 0.9;
}

.star-big {
  background: #fff;
  color: #17152e;
  box-shadow: 0 10px 24px -12px rgb(0 0 0 / 0.5);
}

.star-big .star-count {
  border-left-color: #e3e0f1;
}

/* Footer: a thin gradient line on top instead of a plain border. */
.site-footer {
  position: relative;
  border-top: 0;
}

.site-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--grad);
  opacity: 0.55;
}

/* Sections rise in as they scroll into view. js/ui/header.js adds .reveal,
   so without JavaScript everything simply shows. */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.7s ease,
    transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .grad-text,
  .hero-stage::before,
  .star-band::before,
  .live-dot::after,
  .gh-button.is-shining,
  .gh-button.is-shining::after {
    animation: none;
  }
  .site-header {
    transition: none;
  }
}

@media (max-width: 600px) {
  .hero-kicker {
    font-size: 12.5px;
  }
}

/* ---------- README generator: templates, links, wide images ---------- */

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

.preset {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}

.preset:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.preset.is-picked {
  animation: pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes pop {
  40% {
    transform: scale(1.08);
  }
}

.gen-extra > .select {
  flex: none;
}

.gen-link {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
}

.gen-link .input {
  height: 38px;
  font-size: 14.5px;
}

.hint-warn {
  color: color-mix(in srgb, var(--star) 70%, var(--ink));
}

.gh-wide {
  margin: 0 0 16px;
}

.gh-wide img {
  display: block;
  width: 100%;
  height: auto;
}

.gh-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0 0 16px;
}

.gh-links img {
  height: 30px;
}

/* ---------- README generator: folding groups and a preview that stays in view ---------- */

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

.gen-sections {
  gap: 8px;
}

.gen-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
  overflow: hidden;
}

.gen-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.gen-group summary::-webkit-details-marker {
  display: none;
}

.gen-group summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.25s ease;
}

.gen-group[open] summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.gen-group summary:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.gen-count {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.gen-count.is-on {
  background: var(--accent-soft);
  color: var(--accent);
}

.gen-group-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 14px 14px;
  animation: unfold 0.3s ease;
}

.gen-look-body {
  gap: 16px;
}

@keyframes unfold {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* The preview shows the whole README at full size and scrolls with the page.
   No inner scroll area, so the mouse wheel always moves the page itself. */
.gh-body {
  height: auto;
  max-height: none;
  overflow: visible;
}

@media (max-width: 1000px) {
  .gen-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.corners {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
}

.corners .select {
  flex: none;
  width: 150px;
  height: 36px;
  font-size: 14px;
}

/* ---------- Open source band: floating coding icons ---------- */

.star-copy,
.star-actions {
  position: relative;
  z-index: 1;
}

.band-icons {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  /* Fade the icons out near the text on the left so it stays easy to read. */
  -webkit-mask-image: linear-gradient(90deg, rgb(0 0 0 / 0.45), #000 50%);
  mask-image: linear-gradient(90deg, rgb(0 0 0 / 0.45), #000 50%);
}

.band-icon {
  position: absolute;
  left: var(--x);
  bottom: -40px;
  width: var(--s);
  height: var(--s);
  color: #fff;
  opacity: 0;
  animation: band-float var(--t) linear var(--d) infinite;
}

.band-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px rgb(255 255 255 / 0.6));
  animation: band-sway calc(var(--t) / 3) ease-in-out var(--d) infinite alternate;
}

/* Rise from below the band to above it, fading in and out on the way. */
@keyframes band-float {
  0% {
    transform: translateY(0) rotate(-8deg) scale(0.85);
    opacity: 0;
  }
  12% {
    opacity: 0.8;
  }
  80% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-260px) rotate(10deg) scale(1.05);
    opacity: 0;
  }
}

@keyframes band-sway {
  from {
    transform: translateX(-10px);
  }
  to {
    transform: translateX(10px);
  }
}

.band-twinkle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px rgb(255 255 255 / 0.7);
  animation: band-twinkle 3.2s ease-in-out var(--d) infinite;
}

@keyframes band-twinkle {
  0%,
  100% {
    opacity: 0.1;
    transform: scale(0.6);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.3);
  }
}

/* The star on the button glows now and then. */
.star-big .star-icon {
  animation: star-glow 3.6s ease-in-out infinite;
}

@keyframes star-glow {
  0%,
  70%,
  100% {
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 0 rgb(224 164 0 / 0));
  }
  80% {
    transform: scale(1.25) rotate(14deg);
    filter: drop-shadow(0 0 6px rgb(224 164 0 / 0.9));
  }
}

.star-big:hover .star-icon {
  animation: twinkle 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
  .band-icon,
  .band-icon svg,
  .band-twinkle,
  .star-big .star-icon {
    animation: none;
  }
  .band-icon {
    opacity: 0.3;
    bottom: 30%;
  }
}

/* ---------- Glitter on the star buttons (see setupSparkles in js/ui/header.js) ---------- */

.sparkle-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

/* A four point glint. */
.sparkle {
  position: absolute;
  background: currentColor;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 3px currentColor);
}

.sparkle-dot {
  clip-path: circle(32% at 50% 50%);
}

/* The button itself glows once while the glints fly out. */
.is-glitter {
  animation: glitter-glow 0.9s ease-out;
}

.is-glitter .icon-gh,
.is-glitter .star-icon,
.is-glitter .gh-button-count::before {
  animation: twinkle 0.6s ease;
}

@keyframes glitter-glow {
  0% {
    box-shadow: 0 0 0 0 rgb(255 213 74 / 0);
  }
  35% {
    box-shadow:
      0 0 0 4px rgb(255 213 74 / 0.35),
      0 0 22px 4px rgb(184 71 242 / 0.45);
  }
  100% {
    box-shadow: 0 0 0 0 rgb(255 213 74 / 0);
  }
}

/* The footer link has no box, so it glows through its text instead. */
.footer-gh.is-glitter {
  animation: none;
  color: var(--ink);
  text-shadow: 0 0 12px rgb(255 213 74 / 0.8);
  transition: text-shadow 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
  .is-glitter,
  .is-glitter .icon-gh,
  .is-glitter .star-icon {
    animation: none;
  }
}

/* On phones the band's text spans the full width, so the drifting icons stay fainter. */
@media (max-width: 600px) {
  .band-icons {
    opacity: 0.45;
    -webkit-mask-image: none;
    mask-image: none;
  }
}

/* Link to the Profile Studio under the hero form. */
.studio-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin-top: 14px;
  padding: 8px 14px 8px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.studio-cta:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px -16px color-mix(in srgb, var(--accent) 80%, transparent);
  transform: translateY(-1px);
  text-decoration: none;
}

.studio-cta-badge {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--btn-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.studio-cta span[aria-hidden] {
  transition: transform 0.2s ease;
}

.studio-cta:hover span[aria-hidden] {
  transform: translateX(3px);
}

/* ---------- Questions ---------- */

.faq {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 860px;
  margin-top: 22px;
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.faq-item[open] {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  box-shadow: var(--shadow);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  font-size: 16.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.25s ease;
}

.faq-item[open] summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.faq-item p {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
  line-height: 1.65;
}
