/* FPGA Paint - project showcase. No external fonts or libraries: works offline. */

:root {
  --bg: #0e1014;
  --bg-alt: #12151b;
  --panel: #171b22;
  --panel-2: #1d222b;
  --line: #2a303b;
  --line-strong: #3a4250;
  --text: #e7e9ee;
  --muted: #98a1b0;
  --accent: #ffd23f;          /* pencil yellow */
  --accent-ink: #1a1400;
  --link: #7cc4ff;
  --hot: #ff7a59;
  --f-r: #ff5555;
  --f-g: #55dd55;
  --f-b: #5599ff;
  --f-size: #c08cff;
  --f-tool: #ffd23f;
  --f-btn: #4fd1c5;
  --f-none: #3a4250;
  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.35em; }
kbd { background: var(--panel-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0.05em 0.4em; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.85rem; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: 0.01em; }
.project-brand { margin-right: auto; white-space: nowrap; }
@media (max-width: 680px) {
  .header-row { height: auto; flex-wrap: wrap; gap: 4px 16px; padding-block: 8px; }
  .header-row .nav { width: 100%; }
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 4px;
  background:
    linear-gradient(90deg, var(--f-r) 0 33%, var(--f-g) 33% 66%, var(--f-b) 66%) top / 100% 50% no-repeat,
    linear-gradient(90deg, #ffaa00 0 33%, #ffffff 33% 66%, #aa55ff 66%) bottom / 100% 50% no-repeat;
  image-rendering: pixelated;
  box-shadow: 0 0 0 1px var(--line-strong);
}
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; font-size: 0.93rem; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }

/* ---------- hero ---------- */
.hero { padding: 64px 0 48px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--accent); font: 600 0.82rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 16px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -0.02em; max-width: 18ch; }
.lede { color: var(--muted); font-size: 1.12rem; max-width: 62ch; margin: 18px 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 26px; }
.chips li { font: 500 0.82rem/1 var(--mono); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 36px; }
.palette-strip { display: grid; grid-template-columns: repeat(32, 1fr); height: 28px; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); max-width: 760px; }
.palette-strip span { display: block; }
@media (max-width: 600px) { .palette-strip { grid-template-columns: repeat(16, 1fr); height: 40px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 0.95rem/1 var(--sans); color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 11px 16px; cursor: pointer;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 7px 11px; font-size: 0.84rem; }
.btn:focus-visible, .tab:focus-visible, .tb-item:focus-visible, .tree button:focus-visible, .blk.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- sections ---------- */
.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { margin-bottom: 26px; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -0.01em; }
.section-head p { color: var(--muted); max-width: 75ch; margin: 10px 0 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel h3 { font-size: 0.95rem; margin-bottom: 12px; letter-spacing: 0.01em; }

/* ---------- demo ---------- */
.demo-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .demo-grid { grid-template-columns: minmax(0, 1fr); } }

.monitor { background: #05070a; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px -20px rgba(0,0,0,0.7); }
.monitor-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 0.82rem; flex-wrap: wrap; }
.monitor-bar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.monitor-title { font-family: var(--mono); color: var(--muted); margin-left: 6px; margin-right: auto; }
.badge { font: 600 0.75rem/1 var(--mono); background: var(--hot); color: #200800; padding: 5px 8px; border-radius: 999px; }

.screen { position: relative; overflow: hidden; aspect-ratio: 470 / 450; background: #000; touch-action: none; }
.screen canvas { position: absolute; left: 0; top: 0; width: calc(100% * 640 / 470); height: auto; image-rendering: pixelated; cursor: none; display: block; }
.nudge {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: var(--accent); color: var(--accent-ink); font-size: 0.88rem; padding: 8px 12px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5); pointer-events: none;
}

.howto { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; color: var(--muted); font-size: 0.88rem; margin-top: 12px; }
.howto .btn { margin-left: auto; }

.demo-side .panel { padding: 12px; }
.toolbar-list { display: grid; grid-template-columns: 1fr; gap: 2px; max-height: 640px; overflow-y: auto; }
@media (max-width: 900px) { .toolbar-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: none; } }
.tb-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text);
  padding: 3px 6px; font: 0.86rem/1.2 var(--sans); text-align: left; cursor: pointer;
}
.tb-item:hover { background: var(--panel-2); }
.tb-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* Wide layout: the toolbar panel spans the full height of the monitor column and
   its rows stretch to fill it, scrolling only if all 25 bands can't fit. */
@media (min-width: 901px) {
  .demo-side { align-self: stretch; position: relative; }
  .demo-side .panel { position: absolute; inset: 0; display: flex; flex-direction: column; }
  .demo-side .toolbar-list { flex: 1; min-height: 0; max-height: none; grid-auto-rows: minmax(31px, 1fr); }
  .demo-side .tb-item { padding-top: 2px; padding-bottom: 2px; }
}
.tb-item canvas { width: 30px; height: 27px; image-rendering: pixelated; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px var(--line); }
.tb-item .y { margin-left: auto; color: var(--muted); font: 0.72rem var(--mono); }

.inspect-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 1000px) { .inspect-grid { grid-template-columns: 1fr 1fr; } .inspect-grid > :first-child { grid-column: 1 / -1; } }
@media (max-width: 640px) { .inspect-grid { grid-template-columns: 1fr; } }

.regbits { display: grid; grid-template-columns: repeat(32, 1fr); gap: 1px; margin-bottom: 14px; font-family: var(--mono); }
.regbits .bit { text-align: center; font-size: 0.7rem; padding: 4px 0; background: var(--panel-2); color: var(--muted); border-top: 3px solid var(--fc, var(--f-none)); }
.regbits .bit.on { color: var(--text); background: color-mix(in srgb, var(--fc, var(--f-none)) 28%, var(--panel-2)); }
.regbits .lbl { grid-row: 2; font-size: 0.62rem; color: var(--muted); text-align: center; padding-top: 4px; white-space: nowrap; overflow: hidden; }
@media (max-width: 520px) { .regbits .bit { font-size: 0.55rem; } .regbits .lbl { font-size: 0.5rem; } }

.regs { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.regs div { min-width: 0; }
.regs dt { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.regs dd { margin: 0; font: 600 0.98rem var(--mono); overflow-wrap: anywhere; }
.console { margin: 0; height: 176px; overflow: auto; background: #07090c; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: 0.8rem/1.45 var(--mono); color: #a8f0a0; white-space: pre-wrap; }

.notes { margin-top: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.notes summary { cursor: pointer; font-weight: 600; }
.notes ul { margin: 12px 0 4px; padding-left: 20px; color: var(--muted); }
.notes li { margin: 6px 0; }
.notes b { color: var(--text); }

/* ---------- architecture ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { font: 600 0.9rem var(--sans); color: var(--muted); background: transparent; border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.diagram { margin: 0 0 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 720px; height: auto; font-family: var(--sans); }
.diagram .boundary { fill: none; stroke: var(--line-strong); stroke-dasharray: 6 5; }
.diagram .boundary-label { fill: var(--muted); font: 600 12px var(--mono); letter-spacing: 0.05em; text-transform: uppercase; }
.diagram .blk rect { fill: var(--panel-2); stroke: var(--line-strong); stroke-width: 1.2; }
.diagram .blk .t { fill: var(--text); font-size: 14px; font-weight: 700; text-anchor: middle; }
.diagram .blk .s { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.diagram .blk .s.accent { fill: var(--accent); font-weight: 600; }
.diagram .blk .reg { fill: var(--text); font: 12px var(--mono); }
.diagram .blk .reg.ro { fill: var(--muted); }
.diagram .blk.dim rect { fill: transparent; stroke-dasharray: 4 3; }
.diagram .blk.dim .t { fill: var(--muted); }
.diagram .blk.custom rect { stroke: var(--accent); stroke-width: 2; fill: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.diagram .blk.cpu rect { stroke: var(--link); stroke-width: 2; }
.diagram .blk.mem rect { stroke: var(--f-size); stroke-width: 2; }
.diagram .blk.ext rect { fill: transparent; }
.diagram .blk.link { cursor: pointer; }
.diagram .blk.link:hover rect { fill: var(--line); }
.diagram .blk.link .t::after { content: ""; }
.diagram .bus { fill: color-mix(in srgb, var(--link) 14%, var(--panel-2)); stroke: var(--link); }
.diagram .bus-label { fill: var(--text); font-size: 13px; font-weight: 600; text-anchor: middle; }
.diagram .wire { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.diagram .wire.hot { stroke: var(--accent); stroke-width: 2; }
.diagram .arrowhead { fill: var(--muted); }
.diagram .wl { fill: var(--muted); font: 11px var(--mono); text-anchor: middle; }
.diagram .wl[text-anchor="start"] { text-anchor: start; }
.diagram .wl[text-anchor="end"] { text-anchor: end; }

.arch-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
@media (max-width: 900px) { .arch-grid { grid-template-columns: 1fr; } }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { margin: 8px 0; }
.steps b { color: var(--text); }
.bitmap { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.bitmap th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 8px 8px 0; }
.bitmap td { padding: 7px 8px 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.bitmap td:first-child { font-family: var(--mono); white-space: nowrap; }
.bitmap td:nth-child(2) { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.f-r { background: var(--f-r); } .f-g { background: var(--f-g); } .f-b { background: var(--f-b); }
.f-size { background: var(--f-size); } .f-tool { background: var(--f-tool); } .f-btn { background: var(--f-btn); } .f-none { background: var(--f-none); }

/* ---------- source browser ---------- */
.browser { display: grid; grid-template-columns: 290px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); height: min(78vh, 820px); }
@media (max-width: 820px) { .browser { grid-template-columns: 1fr; height: auto; } }
.tree-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 820px) { .tree-pane { border-right: 0; border-bottom: 1px solid var(--line); max-height: 320px; } }
.tree-pane input { margin: 12px; padding: 9px 11px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font: 0.9rem var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 0 12px 10px; font-size: 0.72rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.tree { overflow-y: auto; padding: 0 6px 12px; font-size: 0.88rem; flex: 1; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }
.tree button { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 4px 6px; border-radius: 5px; cursor: pointer; font: inherit; }
.tree button:hover { background: var(--panel-2); }
.tree button.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.tree .folder > button { color: var(--muted); font-weight: 600; }
.tree .folder > button .chev { display: inline-block; width: 10px; transition: transform 0.15s; }
.tree .folder.collapsed > button .chev { transform: rotate(-90deg); }
.tree .folder.collapsed > ul { display: none; }
.tree .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.o-project { background: var(--accent); }
.o-modified { background: var(--f-btn); }
.o-provided { background: var(--link); }
.o-generated { background: var(--f-size); }
.o-vendor { background: #8a94a6; }
.o-unused { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

.code-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.code-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 14px 16px 6px; flex-wrap: wrap; }
.code-path { font: 600 0.95rem var(--mono); overflow-wrap: anywhere; }
.code-title { color: var(--muted); font-size: 0.85rem; margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-actions { display: flex; gap: 6px; }
.code-desc { margin: 0; padding: 0 16px 12px; color: var(--muted); font-size: 0.9rem; max-width: 95ch; border-bottom: 1px solid var(--line); }
.code-scroll { overflow: auto; flex: 1; background: #0b0d11; min-height: 300px; max-height: 70vh; }
@media (min-width: 821px) { .code-scroll { max-height: none; } }
.code { margin: 0; padding: 12px 0; font: 0.82rem/1.55 var(--mono); tab-size: 4; counter-reset: ln; min-width: max-content; }
.code .ln { display: block; padding-right: 20px; }
.code .ln::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 4.2em; padding-right: 1.2em; text-align: right; color: #4a5262; user-select: none; }
.code .ln:target, .code .ln.hl { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tok-c { color: #6b7689; font-style: italic; }
.tok-k { color: #ff8fa3; }
.tok-t { color: #7cc4ff; }
.tok-s { color: #b5e48c; }
.tok-n { color: #ffb86b; }
.tok-d { color: #c08cff; }
.tok-f { color: #ffd23f; }

/* ---------- about ---------- */
.about p { max-width: 68ch; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Files listed by name only (not written by us). */
.tree li.withheld .name { opacity: .6; }
.code.withheld { white-space: normal; }
.code.withheld .withheld-note, .code.withheld .withheld-note * { display: block; padding: 28px 24px; color: var(--muted); font-family: var(--sans); font-size: 0.95rem; }
.code-actions [hidden] { display: none; }
