/* Commander Coder – site styles */

/* Machine screen fonts (CC BY-SA 3.0, see /credits/). Each font lives in its own folder
   in static/fonts/ together with the readme.txt and license.txt from its download,
   which the licence requires. If a file is missing the normal monospace font is used. */
@font-face {
  font-family: "Ensjo MC6847";
  src: url("/fonts/ensjo-mc6847/ensjo-mc6847.otf.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "ZX81 VDU";
  src: url("/fonts/zx81-vdu/zx81-vdu.otf.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Sharp MZ";
  src: url("/fonts/sharp-mz/MZ80B.ttf") format("truetype");
  font-display: swap;
}
:root {
  --bg: #fbfaf6;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --ink: #1c2229;
  --ink-2: #4a5360;
  --line: #ddd9cf;
  --accent: #0b7a4b;
  --accent-ink: #ffffff;
  --amber: #a85a06;
  --screen: #0d1512;
  --phosphor: #5fe39a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Dark theme: light is the default; dark only when the visitor picks it with the toggle */
:root[data-theme="dark"] {
  --bg: #101416;
  --surface: #171c1f;
  --surface-2: #1e2428;
  --ink: #e4e9e6;
  --ink-2: #a7b0ab;
  --line: #2c3438;
  --accent: #48c983;
  --accent-ink: #08110c;
  --amber: #f0a64a;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.65 var(--sans);
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, pre, kbd { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--screen); color: var(--phosphor); padding: 16px; border-radius: var(--radius); overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; color: inherit; }
/* Listings shown the way each machine displayed them. These machines had no lower case. */
pre.screen-atom, pre.screen-zx81, pre.screen-mz { text-transform: uppercase; font-size: 16px; line-height: 1.3; }
pre.screen-atom code { font-family: "Ensjo MC6847", var(--mono); font-size: inherit; }
pre.screen-zx81 { background: #f4f4f0; color: #111; border: 1px solid var(--line); }
pre.screen-zx81 code { font-family: "ZX81 VDU", var(--mono); font-size: inherit; color: inherit; }
pre.screen-mz code { font-family: "Sharp MZ", var(--mono); font-size: inherit; }
.screen-caption { font-size: .85rem; color: var(--ink-2); margin-top: -.6em; }

/* ZX81 character chart. --zx-ink / --zx-paper swap for the inverse set. */
.zx-chart { --zx-ink: #111; --zx-paper: #f4f4f0; list-style: none; margin: 0 0 1.5em; padding: 10px; display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; background: #f4f4f0; border: 1px solid var(--line); border-radius: var(--radius); }
.zx-chart.inverse { --zx-ink: #f4f4f0; --zx-paper: #111; }
@media (max-width: 700px) { .zx-chart { grid-template-columns: repeat(8, 1fr); } }
.zx-chart li { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.zx-chart small { font-family: var(--mono); font-size: 10px; color: #666; }
.zx-glyph { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--zx-paper); color: var(--zx-ink); font-family: "ZX81 VDU", var(--mono); font-size: 26px; line-height: 1; outline: 1px dotted #bbb; }
.zx-quad { width: 100%; height: 100%; display: grid; grid-template-columns: 1fr 1fr; }
.zx-quad .on { background: var(--zx-ink); }
.zx-grey, .zx-grey-lower, .zx-grey-upper { width: 100%; height: 100%; background-image: repeating-conic-gradient(var(--zx-ink) 0 25%, transparent 0 50%); background-size: 4px 4px; }
.zx-grey-lower, .zx-grey-upper { box-sizing: border-box; background-clip: content-box; }
.zx-grey-lower { padding-top: 16px; }
.zx-grey-upper { padding-bottom: 16px; }
.zx-chart-label { margin-bottom: .4em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95em; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); }
.table-wrap { overflow-x: auto; margin: 1em 0; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---------- header & nav ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { font-family: var(--mono); font-weight: 700; background: var(--screen); color: var(--phosphor); padding: 4px 8px; border-radius: 6px; font-size: 15px; }
.brand-text { font-family: var(--mono); font-weight: 700; letter-spacing: -.02em; font-size: 18px; }
.site-nav > ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; align-items: center; }
.site-nav a { color: var(--ink); text-decoration: none; display: block; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--accent); }
.has-sub { position: relative; }
.sub-head { display: flex; align-items: center; }
.sub-head > a { padding-right: 4px; }
.sub-toggle { background: none; border: 0; color: var(--ink-2); padding: 8px 6px; cursor: pointer; border-radius: 6px; display: flex; }
.sub-toggle:hover { background: var(--surface-2); }
.sub-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.sub { list-style: none; margin: 0; padding: 6px; position: absolute; top: 100%; left: 0; min-width: 250px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.12); display: none; }
.sub.open { display: block; }
@media (hover: hover) and (min-width: 861px) { .has-sub:hover .sub { display: block; } }
.header-actions { display: flex; align-items: center; gap: 8px; order: 3; }
.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; width: 44px; height: 44px; cursor: pointer; color: var(--ink); display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme-active="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme-active="dark"] .theme-toggle .icon-moon { display: none; }
.site-nav { order: 2; margin-left: auto; }
.menu-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; width: 44px; height: 44px; cursor: pointer; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
.menu-toggle span { display: block; width: 20px; height: 2px; background: var(--ink); transition: transform .2s, opacity .2s; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 860px) {
  .menu-toggle { display: flex; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--line); max-height: calc(100vh - 64px); overflow-y: auto; }
  .site-nav.open { display: block; }
  .site-nav > ul { flex-direction: column; align-items: stretch; padding: 8px 16px 16px; gap: 0; }
  .site-nav a { padding: 12px; }
  .sub-head { justify-content: space-between; }
  .sub-head > a { flex: 1; }
  .sub-toggle { padding: 12px 14px; }
  .sub { position: static; box-shadow: none; border: 0; border-left: 2px solid var(--line); border-radius: 0; margin-left: 12px; padding: 0 0 0 4px; min-width: 0; }
}

/* ---------- page ---------- */
.crumbs { font-size: .875rem; color: var(--ink-2); margin-top: 20px; }
.crumbs a { color: var(--ink-2); }
.page { max-width: 760px; margin: 0 auto; padding: 8px 0 32px; }
.page.wide { max-width: none; }
.page-head { margin: 24px 0 8px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
[id] { scroll-margin-top: 80px; } /* keep anchor targets clear of the sticky header */
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0 0 8px; }
h2 { font-size: 1.5rem; margin: 2em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
.lede { font-size: 1.2rem; color: var(--ink-2); margin: 0 0 8px; }
.meta { font-size: .85rem; color: var(--ink-2); margin: 0; }
.callout { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.5em 0; }
.callout.amber { border-color: var(--amber); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; border: 0; cursor: pointer; font-size: 1rem; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.2em 0; }

/* screenshots (with graceful placeholder until local images are added) */
.shot { margin: 1.5em 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--screen); }
.shot img { width: 100%; }
.shot figcaption { background: var(--surface); color: var(--ink-2); font-size: .85rem; padding: 8px 12px; border-top: 1px solid var(--line); }
.shot.noimg::before { content: attr(data-label); display: flex; align-items: center; justify-content: center; aspect-ratio: 16/9; font-family: var(--mono); color: var(--phosphor); font-size: clamp(1rem, 3vw, 1.6rem); text-align: center; padding: 16px; background: radial-gradient(ellipse at center, #173226 0%, var(--screen) 70%); text-shadow: 0 0 8px rgba(95,227,154,.6); }
.shot.noimg.small::before { aspect-ratio: 16/10; font-size: 1rem; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; padding: 40px 0 24px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.hero .lede { font-size: 1.25rem; }
.terminal { background: var(--screen); color: var(--phosphor); font-family: "Ensjo MC6847", var(--mono); border-radius: 14px; padding: 20px 22px; font-size: 14.5px; line-height: 1.6; box-shadow: 0 10px 40px rgba(0,0,0,.18); border: 8px solid #2a2f2b; min-height: 240px; white-space: pre-wrap; overflow: hidden; }
.terminal .cursor { display: inline-block; width: .6em; background: var(--phosphor); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .terminal .cursor { animation: none; } }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 24px; } }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 2.5em; }
.section-head h2 { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin: 1em 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card .shot { margin: 0; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.card .shot img { aspect-ratio: 16 / 10; object-fit: cover; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 1.1rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.card p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.card .tag { font-family: var(--mono); font-size: .75rem; color: var(--amber); text-transform: uppercase; letter-spacing: .05em; }
.card .more { margin-top: auto; padding-top: 8px; font-weight: 600; font-size: .95rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .split { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel h3 { margin-top: 0; }
.updates-list { list-style: none; padding: 0; margin: 0; }
.updates-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.updates-list li:last-child { border-bottom: 0; }
.updates-list time { font-family: var(--mono); font-size: .8rem; color: var(--amber); display: block; }

.update { border-left: 3px solid var(--line); padding-left: 18px; margin: 28px 0; }
.update time { font-family: var(--mono); font-size: .85rem; color: var(--amber); }
.update h2 { margin: 4px 0 8px; font-size: 1.3rem; }

/* ---------- comments ---------- */
.feedback { max-width: 760px; margin: 0 auto 48px; border-top: 1px solid var(--line); padding-top: 8px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 24px; }
.comment-list > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.comment-list .who { font-weight: 600; }
.comment-list .when { color: var(--ink-2); font-size: .8rem; margin-left: 6px; }
.comment-list .stars { color: var(--amber); margin-left: 6px; letter-spacing: 1px; }
.comment-list .body { white-space: pre-wrap; margin: 6px 0 0; }
.comment-list .owner-reply { margin: 10px 0 0; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: .95rem; }
.comment-form, .contact-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 12px; }
.comment-form h3 { margin: 0; }
.comment-form p { margin: 0; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
input, textarea, select { font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; }
.comment-form button, .contact-form button { justify-self: start; }
.comment-form button, .contact-form button { background: var(--accent); color: var(--accent-ink); border: 0; padding: 10px 18px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.comment-form button:disabled, .contact-form button:disabled { opacity: .6; cursor: wait; }
.form-status { font-weight: 600; }
.form-status.err { color: #c0392b; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.rating { border: 0; padding: 0; margin: 0; display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.rating legend { font-weight: 600; font-size: .95rem; margin-bottom: 4px; padding: 0; float: left; width: 100%; }
.rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating label { font-size: 1.8rem; color: var(--line); cursor: pointer; line-height: 1; display: inline; }
.rating input:checked ~ label, .rating label:hover, .rating label:hover ~ label { color: var(--amber); }
.rating input:focus-visible + label { outline: 3px solid var(--amber); }
.summary { font-weight: 600; }
.summary .stars { color: var(--amber); }

/* ---------- footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 28px 0 16px; margin-top: 32px; }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-inner p { margin: 0 0 4px; }
.footer-inner ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, auto); gap: 4px 28px; }
.footer-inner a { color: var(--ink-2); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); text-decoration: underline; }
.copyright { margin-top: 16px; }
