/* Rust Build website - self-contained (no external fonts / CDNs) */
:root {
  --bg: #121519;
  --bg2: #171b21;
  --panel: #1d222a;
  --panel2: #232a33;
  --line: #2f3844;
  --text: #dfe5ec;
  --muted: #9aa6b4;
  --accent: #cd412b;      /* Rust red */
  --accent2: #e8643f;
  --gold: #ffd479;        /* editor shortcut colour */
  --blue: #8fd1ff;        /* editor heading colour */
  --green: #6fcf8a;
  --warn: #f0b44c;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-w: 290px;
  color-scheme: dark;
}
/* dark by default, like the editor and its splash; Light is the button in the top bar */
:root[data-theme="light"] {
  --bg: #f4f5f7; --bg2: #eceef2; --panel: #ffffff; --panel2: #f5f7fa; --line: #d8dde4;
  --text: #1d232b; --muted: #5b6673; --gold: #8a5a00; --blue: #145f9a; --green: #217a3c; --warn: #9a6200;
  --shadow: 0 6px 20px rgba(20, 30, 40, .10); color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15.5px/1.6 var(--sans); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--panel2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
kbd {
  display: inline-block; min-width: 1.6em; text-align: center; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--line); border-bottom-width: 3px; background: var(--panel2); color: var(--gold); font-weight: 600; line-height: 1.4;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.22rem; }
p { margin: .5em 0 .9em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.15rem; letter-spacing: .3px; }
.brand img { width: 36px; height: 36px; border-radius: 7px; }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 460px; margin-left: auto; position: relative; }
.search input {
  width: 100%; padding: 8px 12px 8px 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit;
}
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; opacity: .6; }
.search .count { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .8rem; }
.topbtn { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; font: inherit; }
.topbtn:hover { border-color: var(--accent); }
.menu-toggle { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); }
nav.side {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 16px 10px 40px 16px;
  border-right: 1px solid var(--line); background: var(--bg2); font-size: .92rem;
}
nav.side .grp { margin: 14px 0 4px; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
nav.side a { display: block; padding: 3px 10px; border-radius: 6px; color: var(--text); border-left: 2px solid transparent; }
nav.side a.sub { padding-left: 22px; color: var(--muted); font-size: .88rem; }
nav.side a:hover { background: var(--panel); text-decoration: none; }
nav.side a.active { border-left-color: var(--accent); background: var(--panel); color: var(--text); }
nav.side a.hidden { display: none; }
main { min-width: 0; padding: 0 clamp(16px, 4vw, 56px) 80px; }
section.cat { padding-top: 30px; margin-top: 10px; border-top: 1px solid var(--line); }
section.cat > header p { color: var(--muted); max-width: 900px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 880px; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 36px; align-items: center; padding: 40px 0 26px; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); margin-bottom: .2em; }
.hero h1 span { color: var(--accent2); }
.hero h1 .hero-logo { width: 1.45em; height: 1.45em; border-radius: 12px; vertical-align: -0.38em; margin-right: .35em; box-shadow: 0 4px 16px rgba(0, 0, 0, .45); }
.hero .tag { font-size: 1.12rem; color: var(--muted); }
.hero h1 .ver { font-size: .42em; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 2px 9px; vertical-align: middle; }
.hero .testbuild { font-size: .92rem; border-left: 3px solid var(--accent2); padding: 4px 10px; margin: 0 0 12px; color: var(--muted); }
.hero-media { position: relative; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); aspect-ratio: 16 / 9; background: #0b0d10; }
.hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.2s ease; }
.hero-media img.on { opacity: 1; }
.hero-media .cap { position: absolute; left: 12px; bottom: 10px; background: rgba(0, 0, 0, .6); color: #fff; padding: 3px 10px; border-radius: 6px; font-size: .85rem; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.stats li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: .9rem; }
.stats b { color: var(--gold); }

/* ---------- downloads ---------- */
.dl-main { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 18px 0 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 10px; font-weight: 700; font-size: 1.02rem;
  background: linear-gradient(180deg, var(--accent2), var(--accent)); color: #fff; border: 0; cursor: pointer; box-shadow: 0 4px 14px rgba(205, 65, 43, .35);
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn svg { width: 20px; height: 20px; }
.btn.off { background: var(--panel2); color: var(--muted); box-shadow: none; border: 1px dashed var(--line); cursor: help; }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.dl-meta { color: var(--muted); font-size: .88rem; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 16px 0; }
.dl-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.dl-card h4 { margin: 0 0 4px; }
.dl-card .meta { color: var(--muted); font-size: .84rem; word-break: break-all; }
.dl-card .for { color: var(--muted); font-size: .84rem; margin: 0 0 6px; }
.dl-card a.get { display: inline-block; margin-top: 8px; font-weight: 600; }
.dl-card .none { color: var(--warn); font-size: .86rem; margin-top: 8px; }

/* ---------- feature cards ---------- */
.feature {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 14px; margin: 18px 0;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 26px;
}
.feature.has-media { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.feature.has-media > .media { grid-column: 2; grid-row: 1 / span 20; }
.feature.wide.has-media { grid-template-columns: minmax(0, 1fr); }
.feature.wide.has-media > .media { grid-column: 1; grid-row: auto; }
.feature h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.feature h3 a.anchor { color: var(--muted); opacity: 0; font-size: .9em; }
.feature:hover h3 a.anchor { opacity: 1; }
.feature .what { color: var(--muted); margin: 2px 0 8px; }
.path { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 6px; font-size: .84rem; }
.path span { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; }
.path span + span::before { content: none; }
.path .sep { border: 0; background: none; padding: 0; color: var(--muted); }
.feature ol, .feature ul { margin: .3em 0 .8em; padding-left: 1.35em; }
.feature li { margin: .18em 0; }
.feature ol.steps { counter-reset: s; list-style: none; padding-left: 0; }
.feature ol.steps > li { counter-increment: s; position: relative; padding-left: 34px; margin: .45em 0; }
.feature ol.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: .1em; width: 23px; height: 23px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
table.ctl { width: 100%; border-collapse: collapse; font-size: .9rem; margin: .4em 0 .9em; }
table.ctl th, table.ctl td { text-align: left; vertical-align: top; padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.ctl th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
table.ctl td:first-child { white-space: nowrap; color: var(--gold); font-weight: 600; }
details.more { margin: .3em 0 .7em; }
details.more summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: .92rem; }
.tip, .note, .warn { border-left: 3px solid var(--blue); background: color-mix(in srgb, var(--blue) 8%, transparent); padding: 8px 12px; border-radius: 0 8px 8px 0; margin: .5em 0 .9em; font-size: .93rem; }
.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.note { border-left-color: var(--muted); background: color-mix(in srgb, var(--muted) 8%, transparent); }
.tip b:first-child, .warn b:first-child, .note b:first-child { margin-right: 4px; }
.pending { border: 2px dashed var(--warn); border-radius: var(--radius); padding: 14px 18px; background: color-mix(in srgb, var(--warn) 6%, transparent); }

/* ---------- media ---------- */
figure { margin: 0; }
.media figure { margin: 0 0 10px; }
.media img, .shot img {
  display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: #0b0d10;
}
figcaption { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.anim { position: relative; }
.media figure.tall { max-width: 300px; margin-left: auto; margin-right: auto; }   /* phone-shaped (portrait) pictures */
.anim::after {
  content: "animation"; position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .62); color: #fff; font-size: .7rem; letter-spacing: .6px;
  text-transform: uppercase; padding: 2px 8px; border-radius: 10px; pointer-events: none;
}
.anim.paused::after { content: "paused, click to play"; }
.anim.paused::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; aspect-ratio: var(--ar, 960 / 508); pointer-events: none; z-index: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='32' r='30' fill='%23000' fill-opacity='.55'/%3E%3Cpath d='M25 19l22 13-22 13z' fill='%23fff'/%3E%3C/svg%3E") center / 64px no-repeat;
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 10px 0; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 7, 10, .92); display: none; align-items: center; justify-content: center; padding: 3vh 3vw; cursor: zoom-out; }
.lightbox.on { display: flex; flex-direction: column; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: 8px; box-shadow: var(--shadow); }
.lightbox .lbcap { color: #ddd; margin-top: 10px; font-size: .95rem; text-align: center; }

/* ---------- explainer diagrams (CSS/SVG animations) ---------- */
.diagram { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0 18px; overflow: hidden; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram svg text { fill: var(--text); font: 600 13px var(--sans); }
.diagram svg .sub { fill: var(--muted); font-weight: 400; font-size: 11.5px; }
.diagram svg .box { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.diagram svg .box.hot { stroke: var(--accent); }
.diagram svg .flow { stroke: var(--accent2); stroke-width: 2.5; fill: none; stroke-dasharray: 7 7; animation: dash 1.2s linear infinite; }
.diagram svg .flow.blue { stroke: var(--blue); }
.diagram svg .dot { fill: var(--gold); }
@keyframes dash { to { stroke-dashoffset: -28; } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.diagram svg .pulse { animation: pulse 2s ease-in-out infinite; }

/* keyboard map */
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.keys .kgroup { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.keys h4 { color: var(--blue); margin-bottom: 6px; }
.keys dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }

.toc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 14px 0; }
.toc-cards a { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; color: var(--text); }
.toc-cards a:hover { border-color: var(--accent); text-decoration: none; }
.toc-cards a small { display: block; color: var(--muted); }

footer { border-top: 1px solid var(--line); color: var(--muted); padding: 24px clamp(16px, 4vw, 56px); font-size: .88rem; }

.no-match { display: none; padding: 30px 0; color: var(--muted); }
body.searching section.cat > header { display: none; }
body.searching .feature.miss, body.searching section.cat.miss, body.searching .hide-on-search { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .feature.has-media { grid-template-columns: minmax(0, 1fr); }
  .feature.has-media > .media { grid-column: 1; grid-row: auto; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  nav.side { position: fixed; z-index: 60; top: 60px; left: 0; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.nav-open nav.side { transform: none; }
  .menu-toggle { display: inline-block; }
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 24px; }
  .brand span { display: none; }
  .topbar { gap: 8px; padding: 0 12px; }
  table.ctl td:first-child { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .diagram svg .flow, .diagram svg .pulse { animation: none; }
  .hero-media img { transition: none; }
}

/* narrow screens: nothing may push the page wider than the viewport */
code { overflow-wrap: anywhere; }
table.ctl td { overflow-wrap: anywhere; }
.keys { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.dl-grid { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.toc-cards, .gallery { grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); }
@media (max-width: 600px) {
  .keys dl { grid-template-columns: minmax(0, 1fr); }
  .keys dt { white-space: normal; margin-top: 6px; }
  table.ctl, table.ctl tbody, table.ctl tr, table.ctl td { display: block; width: 100%; }
  table.ctl thead { display: none; }
  table.ctl td:first-child { border-bottom: 0; padding-bottom: 0; }
  .search { max-width: none; }
}
.dl-meta, .dl-meta .sha, .dl-card .meta { overflow-wrap: anywhere; word-break: break-all; }
.search { min-width: 0; }

/* ---------- Full Feature List (#features) ---------- */
.topbar a.topbtn:hover { text-decoration: none; }
.topbtn.feat { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); font-weight: 600; white-space: nowrap; }
.fl-top {
  border-radius: 14px; padding: clamp(16px, 3vw, 28px); margin: 6px 0 22px; border: 1px solid var(--line);
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%), var(--panel);
}
.fl-lead { font-size: clamp(1.25rem, 2.6vw, 1.75rem); font-weight: 700; line-height: 1.3; margin: 0 0 .4em; max-width: 900px; }
.fl-sub { color: var(--muted); font-size: 1.05rem; max-width: 860px; margin: 0; }
.fl-top .dl-main { margin-top: 16px; }
.fl-h { font-size: 1.3rem; margin: 6px 0 12px; }
.fl-hl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; margin-bottom: 22px; }
.fl-hl a {
  display: block; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius);
  padding: 12px 14px; color: var(--text); transition: transform .15s ease, border-color .15s ease;
}
.fl-hl a:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent2); }
.fl-hl b { display: block; font-size: 1.05rem; margin-bottom: 3px; }
.fl-hl span { color: var(--muted); font-size: .9rem; line-height: 1.45; display: block; }
.fl-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.fl-jump a { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .88rem; color: var(--text); }
.fl-jump a:hover { border-color: var(--accent); text-decoration: none; }
.fl-group {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px 28px; align-items: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 12px; margin: 16px 0;
}
.fl-group:nth-of-type(even) > .media { order: -1; }
.fl-group > .media { position: sticky; top: 76px; }
.fl-group h3 { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.fl-group h3 small { font-size: .72rem; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 8px; }
.fl-group ul { list-style: none; margin: 0; padding: 0; }
.fl-group li { position: relative; padding: 3px 0 3px 18px; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.fl-group li::before { content: ""; position: absolute; left: 2px; top: .72em; width: 7px; height: 7px; border-radius: 2px; background: var(--accent2); }
.fl-group li a { color: var(--text); font-weight: 650; }
.fl-group li a:hover { color: var(--blue); }
.fl-end { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 0; }
@media (max-width: 1000px) {
  .fl-group { grid-template-columns: minmax(0, 1fr); }
  .fl-group:nth-of-type(even) > .media { order: 0; }
  .fl-group > .media { grid-row: 1; position: static; }
}
@media (max-width: 600px) {
  .topbtn.feat { padding: 7px 9px; }
  .fl-top .dl-main .btn { width: 100%; justify-content: center; }
  .fl-hl { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .fl-hl a { padding: 10px; }
  .fl-hl span { font-size: .84rem; }
}
@media (max-width: 380px) { .fl-hl { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .fl-hl a { transition: none; } }
