/* Ferrite website: one stylesheet, one dark theme (the brand). */

:root {
  --bg: #07080a;
  --panel: #0c0e12;
  --panel-2: #10131800;
  --line: #1a1f26;
  --rim: #121519;
  --text: #e6e8eb;
  --sub: #9aa3ae;
  --dim: #6b7480;
  --faint: #3a414a;
  --blue: #4da3ff;
  --blue-dim: #1d2733;
  --amber: #f0b44c;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Barlow", system-ui, sans-serif;
  --measure: 65ch;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 2px; }
::selection { background: #1f3b5c; }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--blue); color: #000; padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 720px) { :root { --gutter: 32px; } }

/* Header */
.site-head { border-bottom: 1px solid var(--line); background: rgba(7, 8, 10, 0.92); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand .logo { width: 30px; height: 30px; flex: none; }
.brand span { font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: 0.04em; line-height: 1; }
.site-head nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 36px; }
.site-head nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-head nav a { color: var(--sub); text-decoration: none; font-size: 13px; padding: 4px 0; border-bottom: 1px solid transparent; }
.site-head nav a:hover { color: var(--text); }
.site-head nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--blue); }
@media (max-width: 560px) {
  .head-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .site-head nav { flex-direction: column; align-items: flex-start; gap: 2px; }
  .site-head nav ul { gap: 2px 16px; }
}

/* Footer */
.site-foot { margin-top: 80px; border-top: 1px solid var(--line); padding: 36px 0 32px; color: var(--dim); font-size: 13px; }
.foot-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .foot-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 48px; } }
.site-foot p { margin: 12px 0 0; max-width: var(--measure); }
.site-foot a { color: var(--sub); }
.brand-small .logo { width: 22px; height: 22px; }
.brand-small span { font-size: 18px; }
.foot-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fine { font-size: 12px; color: var(--faint); margin-top: 28px; }
.fine p { margin: 0; max-width: none; }
.ca { white-space: nowrap; }
.ca .flag { width: 32px; height: 16px; vertical-align: -3px; margin-right: 6px; border-radius: 1px; }

/* Type */
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: 0.01em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(34px, 6vw, 52px); }
h2 { font-size: clamp(26px, 4vw, 34px); }
h3 { font-size: 21px; }
p, ul, ol { margin: 0 0 1em; }
.prose { max-width: var(--measure); }
.prose > * + h2 { margin-top: 2.2em; }
.prose > * + h3 { margin-top: 1.8em; }
.prose h2, .prose h3 { margin-bottom: 0.5em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose code, code { font-family: var(--mono); font-size: 0.92em; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.35em; }
pre { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; margin: 0 0 1.2em; }
pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.lead { color: var(--sub); font-size: 17px; line-height: 1.65; max-width: var(--measure); }
.sub { color: var(--sub); }
.note { color: var(--dim); font-size: 13px; }
.kicker { font-size: 12px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--blue); margin: 0 0 14px; }
.kicker span { color: var(--dim); margin-right: 10px; }
kbd { font-family: var(--mono); font-size: 0.85em; color: var(--text); background: #12161c; border: 1px solid #262c35; border-bottom-width: 2px; border-radius: 4px; padding: 0.05em 0.4em; white-space: nowrap; }

/* Page structure */
.page-head { padding: 64px 0 24px; }
.page-head .lead { margin-top: 18px; }
.section { padding: 48px 0; }
.section + .section { border-top: 1px solid var(--line); }
.stack > * + * { margin-top: 24px; }

/* The radio's screen: a real simulator frame, never a drawn radio. */
.screen {
  width: 240px; height: 320px;
  padding: 8px; box-sizing: content-box;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--rim);
  box-shadow: inset 0 1px 0 #191d23, 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(77, 163, 255, 0.04);
  flex: none;
}
.screen img { display: block; width: 240px; height: 320px; border-radius: 3px; image-rendering: pixelated; }
figure { margin: 0; }
figcaption { color: var(--dim); font-size: 12px; margin-top: 12px; text-align: center; max-width: 256px; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.btn { display: inline-block; font-size: 14px; border: 1px solid var(--blue); color: var(--blue); padding: 9px 18px; border-radius: 4px; text-decoration: none; }
.btn:hover { background: rgba(77, 163, 255, 0.08); }
.btn.solid { background: var(--blue); color: #04101e; font-weight: 500; }
.btn.solid:hover { background: #6fb5ff; }

/* Cards and grids */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; }
.card h3 { font-size: 19px; margin-bottom: 8px; }
.card p { color: var(--sub); font-size: 14px; margin: 0; }
.card p + p { margin-top: 8px; }
.card a.more { display: inline-block; margin-top: 12px; font-size: 13px; }

.figures { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin-top: 28px; }
.figure { border-left: 2px solid var(--blue); padding: 4px 0 4px 16px; }
.figure b { display: block; font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1.1; color: var(--text); }
.figure span { color: var(--sub); font-size: 13px; }

/* Feature rows: text beside a screen */
.feature { display: grid; gap: 32px 56px; align-items: center; grid-template-columns: minmax(0, 1fr); padding: 56px 0; }
.feature + .feature { border-top: 1px solid var(--line); }
.feature .shots { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
@media (min-width: 900px) {
  .feature { grid-template-columns: minmax(0, 1fr) auto; }
  .feature.flip { grid-template-columns: auto minmax(0, 1fr); }
  .feature.flip .shots { order: -1; }
}
.feature ul { padding-left: 1.2em; color: var(--sub); }
.feature ul li + li { margin-top: 0.4em; }
.feature ul b { color: var(--text); font-weight: 500; }

/* Tables */
.tablewrap { overflow-x: auto; margin: 16px 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 400; font-size: 12px; }
td.n, th.n { text-align: right; white-space: nowrap; padding-right: 0; padding-left: 12px; }
tr.group th { color: var(--sub); padding-top: 18px; }
tr.sum td { border-bottom: none; font-weight: 700; }
td.em { color: var(--text); font-weight: 500; }

/* Key block (minisign key) */
.keybox { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; font-size: 13px; overflow-wrap: anywhere; word-break: break-all; }
.keybox small { display: block; color: var(--dim); margin-bottom: 4px; word-break: normal; }

.callout { border: 1px solid var(--blue-dim); background: rgba(77, 163, 255, 0.05); border-radius: 8px; padding: 18px 20px; max-width: var(--measure); }
.callout p:last-child { margin-bottom: 0; }
.callout b { color: var(--text); }

.steps { counter-reset: step; list-style: none; padding: 0 !important; }
.steps > li { counter-increment: step; position: relative; padding-left: 40px; }
.steps > li + li { margin-top: 14px !important; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border: 1px solid var(--blue-dim); color: var(--blue); border-radius: 50%; font-size: 12px; display: grid; place-items: center; line-height: 1; }

/* Blog */
.post-list { list-style: none; padding: 0; margin: 0; max-width: var(--measure); }
.post-list li { padding: 24px 0; border-bottom: 1px solid var(--line); }
.post-list h2 { font-size: 24px; }
.post-list h2 a { color: var(--text); text-decoration: none; }
.post-list h2 a:hover { color: var(--blue); }
.post-list p { color: var(--sub); margin: 8px 0 0; }
.meta { color: var(--dim); font-size: 13px; margin: 0 0 6px; }
.draft { display: inline-block; color: var(--amber); border: 1px solid #5a4520; border-radius: 3px; font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; padding: 0 6px; margin-left: 8px; vertical-align: 1px; }
.post { padding-top: 56px; }
.post .prose { margin-top: 28px; }
.post-foot { max-width: var(--measure); margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--dim); }

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

.prose > .kicker + h2, .prose > .kicker + h3 { margin-top: 0; }
@media (max-width: 560px) { .feature .shots .screen + .screen { display: none; } }
.figures.compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
pre.wrapcode { white-space: pre-wrap; word-break: break-all; }

/* Home: the story. One screen stays pinned while the chapters scroll past it. */
.story { display: grid; grid-template-columns: minmax(0, 1fr); }
.story-screen { position: sticky; top: 0; z-index: 1; padding: 12px 0 8px; background: var(--bg); display: flex; justify-content: center; }
.story-screen::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 32px; background: linear-gradient(var(--bg), transparent); pointer-events: none; }
.story-frame { position: relative; width: 168px; height: 224px; padding: 6px; border-radius: 10px; box-shadow: inset 0 1px 0 #191d23, 0 30px 90px rgba(0, 0, 0, 0.7), 0 0 80px rgba(77, 163, 255, 0.05); }
.story-frame .layer { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); border-radius: 3px; object-fit: cover; opacity: 0; transition: opacity 0.5s ease; background: #0a0c0f; }
.story-frame .layer.on { opacity: 1; }
.chapter { min-height: 62vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.chapter h2 { font-size: clamp(26px, 4vw, 40px); }
.chapter p { color: var(--sub); max-width: 34ch; margin: 14px 0 0; font-size: 16px; }
.hero-copy { min-height: 54vh; justify-content: flex-start; padding-top: 24px; }
.hero-copy h1 { font-size: clamp(52px, 10vw, 84px); letter-spacing: 0.03em; line-height: 1; }
.hero-copy .lead { margin-top: 20px; max-width: 30em; }
.hero-copy .actions { margin-top: 30px; }
.ch-poster { display: none; }
@media (min-width: 900px) {
  .story { grid-template-columns: minmax(0, 1fr) auto; column-gap: 64px; }
  .story-screen { order: 2; grid-row: 1; grid-column: 2; align-self: start; top: max(24px, calc(50vh - 340px)); padding: 0; background: none; height: auto; }
  .story-screen::after { display: none; }
  .story-text { grid-row: 1; grid-column: 1; }
  .story-frame { width: min(480px, calc((100vh - 120px) * 0.75)); height: auto; aspect-ratio: 3 / 4; padding: 10px; border-radius: 14px; }
  .story-frame .layer { inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); border-radius: 4px; }
  .chapter { min-height: 80vh; }
  .hero-copy { min-height: calc(100vh - 60px); justify-content: center; padding-top: 0; }
}
/* Without JavaScript: no pinned screen; each chapter shows its own still. */
html:not(.js) .story-screen { display: none; }
html:not(.js) .chapter { min-height: 0; padding: 40px 0; }
html:not(.js) .ch-poster { display: block; width: 240px; height: 320px; border-radius: 8px; margin-bottom: 20px; }
@media (prefers-reduced-motion: reduce) { .story-frame .layer { transition: none; } }

/* Home's end: a closing line and the buttons, in the story's black space. */
.closing { padding: 22vh 0 4vh; text-align: center; }
.closing h2 { font-size: clamp(28px, 4.6vw, 44px); }
.closing .actions { justify-content: center; margin-top: 28px; }
.closing-more { margin: 22px 0 0; font-size: 14px; }
.closing-more a { color: var(--sub); }

/* Watch: one video per row, playing while in view. */
.clips { max-width: 1088px; }
.clip { margin: 0 0 14vh; }
.clip-media { position: relative; }
.clip video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 8px; background: var(--panel); }
.clip-play { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; padding: 0; border-radius: 50%; background: rgba(7, 8, 10, 0.6); border: 1px solid rgba(230, 232, 235, 0.35); cursor: pointer; }
.clip-play::after { content: ""; position: absolute; left: 29px; top: 25px; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent var(--text); }
.clip-play:hover, .clip-play:focus-visible { border-color: var(--blue); background: rgba(7, 8, 10, 0.75); }
.clip-play[hidden] { display: none; }
.clip figcaption { margin-top: 14px; color: var(--sub); font-size: 14px; max-width: var(--measure); text-align: left; }
.tile-title { display: block; margin-bottom: 4px; font-size: 15px; color: var(--text); }
.tile-len { color: var(--dim); }
.nowrap { white-space: nowrap; }

/* Reading pages: one centred column, the page head with it. */
.wrap.column { max-width: calc(var(--measure) + 2 * var(--gutter)); }
.column .prose, .column .lead, .column .callout, .column .post-list, .column .post-foot { max-width: none; }
.column-in { max-width: var(--measure); margin-inline: auto; }
.column-in .prose, .column-in .tablewrap { max-width: none; }
/* Download: short and calm. */
.download .page-head { padding-bottom: 20px; }
.download .prose h3 { font-size: 19px; margin: 32px 0 8px; }
.download .prose p, .download .prose ol { margin-bottom: 0.6em; }
.download .steps > li + li { margin-top: 8px !important; }
.download .keybox { margin: 12px 0 10px; }
.download pre { margin-bottom: 0; }
.column .prose h3 { font-size: 19px; margin: 32px 0 8px; }

/* The developer pages' menu (ferritefw.dev/dev/, docs/tools/mkdev.py). */
.devnav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 28px; padding-bottom: 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.devnav a { color: var(--sub); text-decoration: none; }
.devnav a:hover, .devnav a.on { color: var(--blue); }
.devnav a.on { font-weight: 600; }
.prose p.gen { margin-top: 36px; color: var(--dim); }

/* /s: share codes (Ferrite Pocket): the form, the QR code */
.share-form input, .share-form select, .share-link { font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; width: 100%; box-sizing: border-box; }
.share-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--sub); }
.share-form label small { color: var(--dim); }
.share-form label.check { flex-direction: row; align-items: center; gap: 6px; padding-top: 18px; }
.share-form label.check input { width: auto; }
.share-zone { max-width: 320px; margin-bottom: 16px; }
.share-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 12px; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 0 0 12px; }
.share-row .share-remove { align-self: end; justify-self: start; }
.share-out { display: grid; gap: 24px; align-items: start; margin-top: 24px; }
@media (min-width: 720px) { .share-out { grid-template-columns: 300px 1fr; } }
.share-qr svg { width: 100%; max-width: 300px; height: auto; border-radius: 8px; display: block; }
.share-link { font-family: var(--mono); font-size: 12px; }
.share-out .btn { margin: 0 8px 8px 0; }
.muted { color: var(--dim); }
