@import url("../assets/fonts/ibm-plex.css");

:root {
  --k9-space: #121212;
  --k9-panel: #1a1a1a;
  --k9-panel-hover: #242424;
  --k9-card: #1e1e1e;
  --k9-text: #e0e0e0;
  --k9-muted: #b8b8b8;
  --k9-orange: #ffb020;
  --k9-orange-hover: #e09a18;
  --k9-cyan: #5eb3ff;
  --k9-border: #2c2c2c;
  --k9-green: #2ecc71;
  --k9-code: #7dffb3;
  --k9-ui: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --k9-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  --k9-max: 68.75rem;
}

html {
  /* Scale page type with window (wide ~120%, narrow desktop ~95%) */
  font-size: clamp(95%, 1.45vw, 120%);
  color-scheme: dark;
}

/* Light mode: same palette family, WCAG-friendlier contrast on white */
html[data-theme="light"] {
  color-scheme: light;
  --k9-space: #dde2ea;
  --k9-panel: #f3f5f8;
  --k9-panel-hover: #e8ecf2;
  --k9-card: #ffffff;
  --k9-text: #0f172a;
  --k9-muted: #334155;
  --k9-orange: #9a3412;
  --k9-orange-hover: #7c2d12;
  /* Darker teal-cyan for ~AAA link contrast on white */
  --k9-cyan: #005f73;
  --k9-border: #8b95a5;
  --k9-green: #14532d;
  --k9-code: #0f3d24;
}

html[data-theme="light"] body::before {
  opacity: 1;
  border-color: #7b8698;
}

html[data-theme="light"] .page-main .readme a,
html[data-theme="light"] .page-main a:not(.btn) {
  color: var(--k9-cyan);
}

html[data-theme="light"] .page-main .readme a {
  text-decoration: underline;
  text-decoration-color: rgba(0, 95, 115, 0.4);
  text-underline-offset: 0.12em;
}

html[data-theme="light"] .page-main .readme a:hover {
  color: #005f7a;
  text-decoration-color: rgba(0, 95, 122, 0.6);
}

html[data-theme="light"] .page-main .readme strong {
  color: var(--k9-text);
  font-weight: 700;
}

html[data-theme="light"] .page-main .readme h2 {
  color: var(--k9-orange);
}

html[data-theme="light"] .page-main.home .home-featured h1 {
  color: var(--k9-orange);
}

html[data-theme="light"] .page-main.home .home-also h2,
html[data-theme="light"] .page-main.home .home-lead,
html[data-theme="light"] .page-main p {
  color: var(--k9-muted);
}

html[data-theme="light"] .k9-crumbs a {
  color: var(--k9-cyan);
}

html[data-theme="light"] .page-main a.btn {
  background: #ffffff;
  border-color: #64748b;
  color: var(--k9-orange);
  font-weight: 600;
}

html[data-theme="light"] .page-main a.btn:hover {
  background: var(--k9-panel-hover);
  border-color: var(--k9-orange);
  color: var(--k9-orange-hover);
}

html[data-theme="light"] .page-main a.btn.btn-live {
  color: var(--k9-green);
  border-color: rgba(20, 83, 45, 0.5);
  background: rgba(20, 83, 45, 0.07);
}

html[data-theme="light"] .page-main.home .home-list a {
  color: var(--k9-orange);
  font-weight: 700;
}

html[data-theme="light"] .page-main.home .home-list li {
  color: var(--k9-muted);
}

/* Cards: visible edge + soft depth so white panels do not blend */
html[data-theme="light"] .k9-card,
html[data-theme="light"] .k9-section-card,
html[data-theme="light"] .sw-fpga-card,
html[data-theme="light"] .sw-fpga-section-card,
html[data-theme="light"] .readme-collapse,
html[data-theme="light"] .page-main .readme,
html[data-theme="light"] .page-main .board-photo,
html[data-theme="light"] .page-main.home .home-hero,
html[data-theme="light"] .page-main.home .home-lead,
html[data-theme="light"] .page-main.home .home-featured,
html[data-theme="light"] .page-main.home .home-also {
  border-color: #7b8698;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 4px 14px rgba(15, 23, 42, 0.07);
}

html[data-theme="light"] .page-main.home .home-list li:hover {
  background: var(--k9-panel-hover);
  border-color: #7b8698;
}

/* Code: light editor surface, dark ink (not neon on white) */
html[data-theme="light"] .page-main .readme code {
  color: var(--k9-code);
  background: #eef2f6;
  border-color: #94a3b8;
}

html[data-theme="light"] .page-main .readme pre {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

html[data-theme="light"] .page-main .readme pre code {
  color: inherit;
  background: transparent;
  border: none;
}

html[data-theme="light"] .theme-chip-trigger .menu-chip-label,
html[data-theme="light"] .menu-chip-trigger .menu-chip-label {
  color: #1e293b;
  font-weight: 600;
}

/* Kill leftover #00d4ff glow paints in banner chrome when light */
html[data-theme="light"] .site-menu a[aria-current="page"],
html[data-theme="light"] .site-menu .menu-parent.is-active,
html[data-theme="light"] .site-menu .menu-has-kids.is-active > .menu-parent,
html[data-theme="light"] .site-menu .menu-drop-label.is-active,
html[data-theme="light"] .site-menu .menu-nested.is-active > .menu-drop-label,
html[data-theme="light"] .site-footer .footer-home[aria-current="page"] {
  color: var(--k9-cyan);
  border-color: var(--k9-cyan);
  background: transparent;
  box-shadow: none;
}

/* Mobile open-menu: traces sit on a dark overlay -- dark teal is invisible there */
html[data-theme="light"] .menu-trace-path {
  stroke: #5eb3ff;
  stroke-width: 2;
  opacity: 1;
}

/* Group headers (Projects, Space Wars, Workbench, DDS) use --k9-cyan/#005f73 in light
   theme; that is unreadable on the dark menu overlay. Force bright labels. */
html[data-theme="light"] .menu-trace-group {
  color: #7dd3fc;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.85);
}

html[data-theme="light"] .menu-trace-subgroup,
html[data-theme="light"] .menu-trace-soon {
  color: #cbd5e1;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* Selected pill stays transparent over the dark overlay.
   White label + bright cyan outline (dark teal was invisible there). */
html[data-theme="light"] .menu-trace-link[aria-current="page"] {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 2.5px solid #38bdf8 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  font-weight: 700 !important;
  text-shadow: 0 0 3px rgba(0, 0, 0, 1), 0 1px 2px rgba(0, 0, 0, 1);
  opacity: 1 !important;
}

html[data-theme="light"] .menu-chip-trigger.is-open .menu-chip-icon {
  filter: none;
}

html[data-theme="light"] .menu-chip-trigger.is-open .menu-chip-label {
  color: var(--k9-cyan);
}

/* Theme switch: ~250ms ease (skip if user prefers reduced motion) */
body,
body::before,
.site-chrome,
.site-banner,
.site-menu,
.site-menu a,
.site-footer,
.site-footer .footer-home,
.site-footer .copy,
.site-footer .footer-email,
.page-main,
.page-main a.btn,
.page-main .readme,
.page-main .readme h2,
.page-main .readme code,
.page-main .board-photo,
.page-main.home .home-hero,
.page-main.home .home-lead,
.page-main.home .home-featured,
.page-main.home .home-also,
.page-main.home .home-list li,
.page-main.home .home-list a,
.k9-card,
.k9-section-card,
.sw-fpga-card,
.sw-fpga-section-card,
.readme-collapse,
.readme-collapse summary,
.theme-chip-trigger .menu-chip-label,
.menu-chip-trigger .menu-chip-label {
  transition:
    background-color 250ms ease,
    color 250ms ease,
    border-color 250ms ease,
    box-shadow 250ms ease,
    opacity 250ms ease,
    filter 250ms ease;
}

@media (prefers-reduced-motion: reduce) {
  body,
  body::before,
  .site-chrome,
  .site-banner,
  .site-menu,
  .site-menu a,
  .site-footer,
  .site-footer .footer-home,
  .site-footer .copy,
  .site-footer .footer-email,
  .page-main,
  .page-main a.btn,
  .page-main .readme,
  .page-main .readme h2,
  .page-main .readme code,
  .page-main .board-photo,
  .page-main.home .home-hero,
  .page-main.home .home-lead,
  .page-main.home .home-featured,
  .page-main.home .home-also,
  .page-main.home .home-list li,
  .page-main.home .home-list a,
  .k9-card,
  .k9-section-card,
  .sw-fpga-card,
  .sw-fpga-section-card,
  .readme-collapse,
  .readme-collapse summary,
  .theme-chip-trigger .menu-chip-label,
  .menu-chip-trigger .menu-chip-label {
    transition: none;
  }
}

/* Theme chip: mirror mobile menu IC chip, left of logo (home only) */
.theme-chip-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: auto;
  min-width: 44px;
  margin: 0;
  padding: 0;
  gap: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  z-index: 1003;
  -webkit-tap-highlight-color: transparent;
}

.theme-chip-trigger .menu-chip-icon {
  width: 3.18381525rem;
  height: 3.18381525rem;
  display: block;
  flex-shrink: 0;
}

.theme-chip-trigger .menu-chip-label {
  position: absolute;
  top: calc(100% + 0.08rem);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.22em;
  font-family: var(--k9-ui);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--k9-muted);
  line-height: 1;
  white-space: nowrap;
}

.theme-chip-trigger .theme-toggle-glyph {
  font-size: 0.85em;
  line-height: 1;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.theme-chip-trigger:focus {
  outline: none;
}

.theme-chip-trigger:focus:not(:focus-visible) {
  outline: none;
}

.theme-chip-trigger:focus-visible {
  outline: 2px solid var(--k9-cyan);
  outline-offset: 3px;
}

/* No hover/sticky glow on the theme chip (touch leaves :hover on some browsers). */

@media (min-width: 768px) {
  .site-banner:has(.theme-chip-trigger) {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-content: unset;
  }

  .site-banner:has(.theme-chip-trigger) .mark {
    grid-column: 2;
    justify-self: center;
  }

  .theme-chip-trigger {
    grid-column: 1;
    justify-self: center;
    align-self: center;
  }
}

@media (max-width: 767px) {
  .theme-chip-trigger {
    grid-column: 1;
    justify-self: center;
    align-self: center;
  }

  /* Dim under menu overlay (menu chip stays above at 1003; theme chip must not). */
  body.menu-trace-open .theme-chip-trigger {
    z-index: 1000;
    pointer-events: none;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--k9-space);
  color: var(--k9-text);
  font-family: var(--k9-ui);
  font-size: clamp(0.95rem, 0.7rem + 0.55vw, 1.05rem);
  line-height: 1.65;
}

/* Thin frame around the viewport; colors stay --k9-* */
body::before {
  content: "";
  position: fixed;
  inset: 0.5rem;
  border: 1px solid var(--k9-border);
  border-radius: 0.5rem;
  pointer-events: none;
  z-index: 3000;
  box-sizing: border-box;
  opacity: 0.65;
}

.page-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-sizing: border-box;
  width: min(100% - clamp(1rem, 4vw, 2.5rem), var(--k9-max));
  max-width: var(--k9-max);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(0.75rem, 2.5vw, 1.5rem)
    clamp(2.5rem, 6vw, 4rem);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.page-main h1 {
  margin: 0 0 0.85rem;
  font-family: var(--k9-mono);
  font-size: clamp(1.35rem, 1rem + 1.2vw, 1.85rem);
  color: var(--k9-text);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  border-left: 3px solid var(--k9-orange);
  padding-left: 0.75rem;
}

.page-main p {
  margin: 0 0 1.15rem;
  color: var(--k9-muted);
  line-height: 1.65;
}

.page-main .project-badges {
  margin: 0 0 1rem;
  line-height: 0;
}

.page-main .project-badges a {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
}

.page-main .project-badges img {
  display: block;
  height: 20px;
  width: auto;
  border: 0;
}

.page-main .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1.25rem;
}

.page-main a.btn {
  display: inline-block;
  padding: 0.48em 0.9em;
  border: 1px solid var(--k9-border);
  border-radius: 0.55rem;
  background: var(--k9-panel);
  color: var(--k9-orange);
  text-decoration: none;
  font-family: var(--k9-ui);
  font-weight: 500;
  letter-spacing: -0.01em;
  font-size: 0.92rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.page-main a.btn:hover {
  color: var(--k9-orange-hover);
  text-decoration: none;
  background: var(--k9-panel-hover);
  border-color: rgba(255, 176, 32, 0.45);
  box-shadow: 0 0 10px rgba(255, 176, 32, 0.12);
}

.page-main a.btn.btn-live {
  color: var(--k9-green);
  border-color: rgba(46, 204, 113, 0.45);
  background: rgba(46, 204, 113, 0.08);
}

.page-main a.btn.btn-live:hover {
  color: #47df88;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.15);
}

.stub-note {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--k9-border);
  border-left: 3px solid var(--k9-orange);
  background: var(--k9-panel);
  color: var(--k9-muted);
  font-size: 0.95rem;
  border-radius: 0.35rem;
}

.page-main.page-wide {
  width: min(100% - clamp(1rem, 4vw, 2.5rem), var(--k9-max));
  max-width: var(--k9-max);
}

/* Sitewide cards (charcoal dashboard sections) */
.k9-card,
.sw-fpga-card {
  background: var(--k9-card);
  border: 1px solid var(--k9-border);
  border-radius: 0.65rem;
  padding: clamp(1rem, 2.5vw, 1.75rem);
  box-sizing: border-box;
}

.k9-card-intro > p,
.sw-fpga-card-intro > p {
  margin: 0 0 1.25rem;
  max-width: 65ch;
}

.k9-card-intro .actions,
.sw-fpga-card-intro .actions {
  margin-top: 0;
}

.k9-section-card,
.sw-fpga-section-card {
  margin: 0 0 1.35rem;
  padding: clamp(1rem, 2vw, 1.35rem);
  background: var(--k9-panel);
  border: 1px solid var(--k9-border);
  border-radius: 0.55rem;
}

.k9-section-card:last-child,
.sw-fpga-section-card:last-child {
  margin-bottom: 0;
}

.k9-section-card .table-wrap,
.sw-fpga-section-card .table-wrap {
  margin-bottom: 0;
}

.k9-card-media,
.sw-fpga-card-media {
  margin: 0 0 1.35rem;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  text-align: center;
}

.readme-collapse.k9-card,
.readme-collapse.sw-fpga-card {
  margin-top: 0;
  padding: 0;
  overflow: hidden;
}

.page-main .board-photo.k9-card,
.page-main .board-photo.sw-fpga-card {
  margin: 0;
  max-width: none;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  overflow: visible;
}

.page-main .readme {
  margin-top: 1.5rem;
  padding: clamp(1.1rem, 2.5vw, 1.75rem);
  border: 1px solid var(--k9-border);
  border-radius: 0.5rem;
  background: var(--k9-card);
  color: var(--k9-text);
  font-family: var(--k9-ui);
  font-size: 1rem;
  line-height: 1.65;
  box-shadow: none;
}

.page-main .readme p {
  margin: 0 0 1rem;
  color: var(--k9-muted);
}

.page-main .readme a {
  color: var(--k9-cyan);
  text-decoration: none;
}

.page-main .readme a:hover {
  color: #8ecaff;
  text-decoration: underline;
}

.page-main .readme strong {
  font-weight: 600;
  color: var(--k9-text);
}

.page-main .readme em {
  font-style: italic;
}

.page-main .readme h2 {
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--k9-border);
  font-family: var(--k9-mono);
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.35rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.03em;
  color: var(--k9-orange);
}

.page-main .readme h3 {
  margin: 1.25rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--k9-text);
}

.page-main .readme code {
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 85%;
  font-family: var(--k9-mono);
  background: rgba(125, 255, 179, 0.08);
  border: 1px solid rgba(125, 255, 179, 0.22);
  border-radius: 6px;
  color: var(--k9-code);
}

.page-main .readme pre {
  margin: 0 0 1rem;
  padding: 12px 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  font-family: var(--k9-mono);
  background: var(--k9-space);
  border: 1px solid var(--k9-border);
  border-radius: 6px;
  color: var(--k9-text);
}

.page-main .readme pre code {
  padding: 0;
  margin: 0;
  font-size: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  color: inherit;
}

.page-main .readme .table-wrap {
  margin: 0 0 1rem;
  overflow-x: auto;
}

.page-main .readme table {
  width: max-content;
  max-width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.page-main .readme th,
.page-main .readme td {
  padding: 6px 13px;
  border: 1px solid var(--k9-border);
  color: var(--k9-text);
  text-align: left;
}

.page-main .readme th {
  font-family: var(--k9-mono);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--k9-card);
}

.page-main .readme tr:nth-child(2n) {
  background: rgba(255, 255, 255, 0.03);
}

.page-main .readme .center {
  text-align: center;
}

.page-main .readme .center img,
.page-main .readme > p > img {
  display: block;
  width: auto;
  max-width: min(100%, clamp(11rem, 46vw, 28rem));
  height: auto;
  margin-left: auto;
  margin-right: auto;
  object-fit: contain;
}

.page-main .project-hero {
  margin: 0 0 1.25rem;
  text-align: center;
  line-height: 0;
}

.page-main .project-hero.k9-card {
  margin: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
}

.page-main .project-hero img {
  display: block;
  width: auto;
  max-width: min(100%, clamp(10rem, 40vw, 22rem));
  max-height: min(50vh, clamp(12rem, 42vw, 28rem));
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.page-main .readme .important-box,
.page-main .readme .center img.important-box,
.page-main .readme > p > img.important-box {
  display: block;
  width: auto;
  max-width: min(100%, clamp(27rem, 81vw, 45.3515625rem));
  height: auto;
  margin: 0 auto 1.25rem;
  object-fit: contain;
}

.page-main .readme .ships-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0 0 1rem;
}

.page-main .readme .ships-row img {
  width: clamp(4.5rem, 12vw, 8.75rem);
  height: auto;
  background: var(--k9-space);
  border: 1px solid var(--k9-border);
  border-radius: 0.35rem;
}

.page-main .readme .ui-theme-shot {
  margin: 0.75rem 0 1rem;
}

.page-main .readme .ui-theme-shot img {
  display: block;
  width: min(100%, 48rem);
  height: auto;
  margin: 0 auto;
  background: var(--k9-space);
  border: 1px solid var(--k9-border);
  border-radius: 0.45rem;
}
/* MiniMe: first two shots +25% vs shared readme defaults */
#minime-readme .readme > p.center:not(.ui-theme-shot) > img {
  max-width: min(100%, clamp(16.5rem, 69vw, 42rem));
}

#minime-readme .readme .ui-theme-shot img {
  width: auto;
  max-width: min(100%, clamp(16.5rem, 69vw, 42rem));
}

.page-main .readme .ui-theme-shot .ui-theme-shot-light {
  display: none;
}

html[data-theme="light"] .page-main .readme .ui-theme-shot .ui-theme-shot-dark {
  display: none;
}

html[data-theme="light"] .page-main .readme .ui-theme-shot .ui-theme-shot-light {
  display: block;
}

.page-main .readme video {
  display: block;
  width: clamp(12rem, 48vw, 36rem);
  max-width: 100%;
  margin: 0 auto 1rem;
  background: var(--k9-space);
  border: 1px solid var(--k9-border);
  border-radius: 0.35rem;
}

/* Home â€” project-first layout */
.page-main.home .home-hero {
  margin: 0;
  padding: 0;
  max-width: none;
  border: 1px solid var(--k9-border);
  border-radius: 0.65rem;
  background: var(--k9-card);
  box-shadow: none;
}

.page-main.home .home-hero-link {
  display: block;
  line-height: 0;
  text-decoration: none;
  border-radius: 0.45rem;
}

.page-main.home .home-hero-link:focus-visible {
  outline: 2px solid var(--k9-cyan);
  outline-offset: 3px;
}

.page-main.home .home-hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.45rem;
  vertical-align: top;
  opacity: 0.88;
  filter: saturate(0.82) contrast(1.05) brightness(0.92);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.page-main.home .home-hero-link:hover img,
.page-main.home .home-hero-link:focus-visible img {
  opacity: 1;
  filter: saturate(0.95) contrast(1.06) brightness(0.98);
}

.page-main.home .home-hero:has(figcaption) img {
  border-radius: 0.45rem 0.45rem 0 0;
}

.page-main.home .home-hero figcaption {
  margin: 0;
  padding: 0.65rem 0.85rem 0.75rem;
  border-top: 1px solid var(--k9-border);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--k9-muted);
  text-align: center;
}

.page-main.home.home-empty {
  min-height: calc(100vh - var(--k9-chrome-top-h) - var(--k9-footer-h, 3rem));
}

.page-main .board-photo {
  margin: 2rem auto 0;
  padding: 0;
  max-width: clamp(14rem, 50vw, 40rem);
  border: 1px solid var(--k9-border);
  border-radius: 0.5rem;
  background: var(--k9-panel);
  overflow: hidden;
}

.page-main .board-photo-link {
  display: block;
  line-height: 0;
  text-decoration: none;
}

.page-main .board-photo-link:focus-visible {
  outline: 2px solid var(--k9-cyan);
  outline-offset: 3px;
}

.page-main .board-photo img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  opacity: 0.92;
  filter: saturate(0.9) contrast(1.03) brightness(0.94);
  cursor: pointer;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.page-main .board-photo-link:hover img,
.page-main .board-photo-link:focus-visible img {
  opacity: 1;
  filter: saturate(1) contrast(1.05) brightness(1);
}

.page-main .board-photo figcaption {
  margin: 0;
  padding: 0.65rem 0.85rem 0.75rem;
  border-top: 1px solid var(--k9-border);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--k9-muted);
  text-align: center;
}

.page-main.home .home-lead {
  margin: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  color: var(--k9-muted);
  background: var(--k9-card);
  border: 1px solid var(--k9-border);
  border-radius: 0.65rem;
  line-height: 1.65;
}

.k9-crumbs {
  margin: 0 0 0.85rem;
  padding: 0;
  font-family: var(--k9-ui);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--k9-muted);
}

.k9-crumbs a {
  color: var(--k9-cyan);
  text-decoration: none;
}

.k9-crumbs a:hover {
  color: var(--k9-orange-hover);
  text-decoration: underline;
}

.page-main.home .workbench-title {
  margin: 0 0 0.85rem;
  padding-left: 0;
  border-left: none;
  font-family: var(--k9-mono);
  font-size: clamp(1.55rem, 4.2vw, 2.05rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--k9-orange);
  text-align: center;
}

.page-main.home .home-featured {
  margin: 0;
  padding: clamp(1.15rem, 2.5vw, 1.55rem);
  border: 1px solid var(--k9-border);
  border-radius: 0.65rem;
  background: var(--k9-card);
}

.page-main.home .home-featured h1 {
  margin: 0 0 0.65rem;
  border-left: none;
  padding-left: 0;
  color: var(--k9-orange);
}

.page-main.home .home-featured p {
  margin: 0 0 0.35rem;
}

.page-main.home .home-featured strong {
  color: var(--k9-green);
  font-weight: 600;
}

.page-main.home .home-also {
  padding: clamp(1.15rem, 2.5vw, 1.55rem);
  border: 1px solid var(--k9-border);
  border-radius: 0.65rem;
  background: var(--k9-card);
}

.page-main.home .home-also h2 {
  margin: 0 0 0.75rem;
  font-family: var(--k9-mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--k9-muted);
  border-left: none;
  padding-left: 0;
}

.page-main.home .home-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-main.home .home-list li {
  margin: 0 0 0.5rem;
  padding: 0.45rem 0.55rem;
  color: var(--k9-muted);
  line-height: 1.45;
  border: 1px solid transparent;
  border-radius: 0.35rem;
}

.page-main.home .home-list li:hover {
  background: var(--k9-panel-hover);
  border-color: var(--k9-border);
}

.page-main.home .home-list a {
  color: var(--k9-orange);
  text-decoration: none;
  font-weight: 600;
}

.page-main.home .home-list a:hover {
  color: var(--k9-orange-hover);
}

.page-main.home .home-list li.home-stub {
  font-size: 0.95rem;
  opacity: 0.88;
}

.page-main.home .home-list li.home-stub a {
  color: var(--k9-muted);
  font-weight: 500;
}

.page-main.home .home-list li.home-stub a:hover {
  color: var(--k9-text);
}

.readme-collapse {
  margin-top: 1.25rem;
  border: 1px solid var(--k9-border);
  border-radius: 0.5rem;
  background: var(--k9-panel);
}

.readme-collapse summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-family: var(--k9-mono);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--k9-text);
  background: var(--k9-panel);
  user-select: none;
}

.readme-collapse summary::-webkit-details-marker {
  display: none;
}

.readme-collapse summary::after {
  content: "+";
  float: right;
  color: var(--k9-muted);
  font-weight: 400;
}

.readme-collapse[open] summary::after {
  content: "\2212";
}

.readme-collapse .readme {
  margin-top: 0;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--k9-border);
}

.page-main .readme .arch-flow {
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 0.75rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--k9-border);
  border-radius: 0.45rem;
  background: #0b0d12;
}

/* Bright variant for light mode. Dark keeps .arch-flow defaults above. */
html[data-theme="light"] .page-main .readme .arch-flow,
.page-main .readme .arch-flow.arch-flow-bright,
html[data-theme="light"] .page-main .readme .flow-wrap,
.page-main .readme .flow-wrap.flow-wrap-bright {
  background: var(--k9-panel);
}

html[data-theme="light"] .page-main .readme .arch-flow .arch-group-cloud,
html[data-theme="light"] .page-main .readme .arch-flow .arch-group-board,
.page-main .readme .arch-flow.arch-flow-bright .arch-group-cloud,
.page-main .readme .arch-flow.arch-flow-bright .arch-group-board {
  background: rgba(255, 255, 255, 0.85);
}

html[data-theme="light"] .page-main .readme .arch-flow .arch-node,
.page-main .readme .arch-flow.arch-flow-bright .arch-node {
  background: var(--k9-card);
  color: var(--k9-text);
  border-color: var(--k9-border);
}

html[data-theme="light"] .page-main .readme .arch-flow .arch-label,
.page-main .readme .arch-flow.arch-flow-bright .arch-label {
  color: var(--k9-muted);
}

html[data-theme="light"] .page-main .readme .arch-flow .arch-link em,
.page-main .readme .arch-flow.arch-flow-bright .arch-link em {
  color: var(--k9-cyan);
}

.page-main .readme .arch-label {
  margin: 0.35rem 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--k9-muted);
}

.page-main .readme .arch-group-cloud {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.35rem;
  padding: 0.55rem;
  border: 1px solid var(--k9-border);
  border-radius: 0.45rem;
  background: rgba(20, 24, 32, 0.55);
  box-sizing: border-box;
}

.page-main .readme .arch-group-board {
  width: fit-content;
  max-width: 100%;
  margin: 0.35rem auto 0;
  padding: 0.55rem;
  border: 1px solid var(--k9-border);
  border-radius: 0.45rem;
  background: rgba(20, 24, 32, 0.55);
  box-sizing: border-box;
}

.page-main .readme .arch-label-cloud {
  margin: 0 0 0.45rem;
  text-align: center;
  /* Center over middle cloud box (Discord HTTPS REST) */
  width: 12.5rem;
  margin-left: auto;
  margin-right: auto;
}

.page-main .readme .arch-label-board {
  flex: 0 1 12.5rem;
  width: 12.5rem;
  max-width: 12.5rem;
  margin: 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.6rem;
  box-sizing: border-box;
}

.page-main .readme .arch-hline-ghost {
  visibility: hidden;
}

.page-main .readme .arch-foot-spacer {
  flex: 0 1 12.5rem;
  width: 12.5rem;
  max-width: 12.5rem;
  visibility: hidden;
  min-height: 3.6rem;
}

.page-main .readme .arch-board-foot {
  align-items: center;
}

.page-main .readme .arch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.page-main .readme .arch-row-3 .arch-node {
  flex: 0 1 12.5rem;
  width: 12.5rem;
  max-width: 12.5rem;
}

.page-main .readme .arch-hline {
  display: block;
  flex: 0 0 1.1rem;
  width: 1.1rem;
  height: 2px;
  margin: 0 0.15rem;
  background: var(--k9-cyan);
  align-self: center;
}

.page-main .readme .arch-node {
  margin: 0;
  padding: 0.5rem 0.55rem;
  min-height: 3.6rem;
  box-sizing: border-box;
  border: 1px solid var(--k9-border);
  border-radius: 0.4rem;
  background: #141820;
  color: var(--k9-text);
  font-size: 0.74rem;
  line-height: 1.3;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-main .readme .arch-links {
  display: grid;
  margin: 0.1rem 0;
  align-items: center;
  justify-items: center;
}

.page-main .readme .arch-links-3 {
  grid-template-columns: repeat(3, minmax(0, 12.5rem));
  justify-content: center;
  column-gap: 1.4rem;
}

.page-main .readme .arch-links-1 {
  grid-template-columns: 1fr;
  max-width: 12.5rem;
  margin-left: auto;
  margin-right: auto;
}

.page-main .readme .arch-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 1.2rem;
  text-align: center;
}

.page-main .readme .arch-link i {
  display: block;
  width: 2px;
  height: 0.55rem;
  background: var(--k9-cyan);
  flex-shrink: 0;
}

.page-main .readme .arch-link em {
  display: block;
  margin: 0.1rem 0;
  padding: 0;
  font-style: normal;
  font-size: 0.62rem;
  line-height: 1.2;
  color: var(--k9-cyan);
}

.page-main .readme .arch-link-solo {
  width: 100%;
  margin: 0.05rem 0;
}

.page-main .readme .arch-webstack {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 12.5rem;
  margin-left: auto;
  margin-right: auto;
}

.page-main .readme .arch-webstack .arch-node {
  width: 100%;
  max-width: 12.5rem;
  min-height: 3.6rem;
}

@media (max-width: 720px) {
  .page-main .readme .arch-row-3 {
    flex-direction: column;
  }

  .page-main .readme .arch-hline {
    width: 2px;
    height: 0.55rem;
    flex-basis: 0.55rem;
    margin: 0.15rem 0;
  }

  .page-main .readme .arch-links-3 {
    grid-template-columns: 1fr;
    column-gap: 0;
  }
}

.page-main .readme .flow-wrap {
  margin: 1rem 0 1.25rem;
  padding: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--k9-border);
  border-radius: 0.45rem;
  background: #0b0d12;
}

.page-main .readme pre.mermaid {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  overflow: visible;
  white-space: pre;
  font-size: 0.85rem;
  line-height: 1.35;
}

.page-main .readme pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

@media (min-width: 768px) {
  .readme-collapse {
    border: none;
    background: transparent;
    margin-top: 0;
  }

  .readme-collapse summary {
    display: none;
  }

  .readme-collapse .readme {
    border-top: none;
  }

  .page-main {
    width: min(100% - 3rem, var(--k9-max));
    max-width: var(--k9-max);
    padding: 2rem clamp(1rem, 2.5vw, 1.5rem) 4rem;
    gap: 1.5rem;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .page-main.page-wide {
    width: min(100% - 3rem, var(--k9-max));
    max-width: var(--k9-max);
  }

  .page-main h1 {
    margin: 0 0 0.85rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--k9-orange);
    font-size: clamp(1.25rem, 0.85rem + 1.35vw, 1.85rem);
    letter-spacing: -0.02em;
    line-height: 1.25;
  }

  .page-main p {
    line-height: 1.65;
  }

  .page-main .actions {
    gap: 0.65rem 0.85rem;
    margin-top: 1.5rem;
  }

  .k9-card-intro .actions,
  .sw-fpga-card-intro .actions {
    margin-top: 0;
  }

  .page-main.home .home-hero {
    margin-bottom: 0;
    border-color: var(--k9-border);
    border-top: 1px solid var(--k9-border);
    box-shadow: none;
  }

  .page-main.home .home-hero img {
    opacity: 0.9;
  }

  .page-main.home .home-lead {
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: none;
  }

  .page-main.home .home-featured {
    padding: clamp(1.15rem, 2.5vw, 1.55rem);
    border-color: var(--k9-border);
    border-top: 1px solid var(--k9-border);
    box-shadow: none;
  }

  .page-main.home .home-featured h1 {
    margin: 0 0 0.75rem;
    padding-left: 0;
    border-left: none;
    font-size: clamp(1.2rem, 0.8rem + 1.2vw, 1.8rem);
    color: var(--k9-orange);
    letter-spacing: -0.02em;
  }

  .page-main.home .home-also {
    padding: clamp(1.15rem, 2.5vw, 1.55rem);
  }

  .page-main.home .home-also h2 {
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--k9-muted);
    font-weight: 600;
  }

  .page-main.home .home-list li {
    padding: 0.52rem 0.68rem;
    transition: background 0.15s ease, border-color 0.15s ease;
  }

  .page-main.home .home-list li.home-stub {
    border-style: dashed;
    border-color: rgba(163, 163, 163, 0.25);
  }

  .page-main .readme {
    padding: clamp(1.1rem, 2.5vw, 1.75rem);
    box-shadow: none;
  }

  .page-main .readme h2 {
    letter-spacing: 0.03em;
    color: var(--k9-orange);
  }

  .page-main .readme h3 {
    letter-spacing: 0.02em;
  }
}

.page-main.home .home-contact {
  margin: 1.5rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--k9-border);
  border-radius: 0.35rem;
  background: var(--k9-panel);
  color: var(--k9-muted);
}

.page-main.home .home-contact a {
  color: var(--k9-orange);
  text-decoration: none;
}

.page-main.home .home-contact a:hover {
  color: var(--k9-orange-hover);
  text-decoration: underline;
}

.badge-live {
  display: inline-block;
  margin-left: 0.35em;
  padding: 0.12em 0.45em;
  border: 1px solid rgba(46, 204, 113, 0.45);
  border-radius: 0.25em;
  background: rgba(46, 204, 113, 0.12);
  color: var(--k9-green);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-main.page-404 {
  text-align: center;
}

.page-main.page-404 .page-404-kicker {
  margin: 0 auto 1rem;
  max-width: none;
  white-space: nowrap;
  font-size: clamp(0.95rem, 3.6vw, 1.75rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--k9-text);
}
.page-main.page-404 .page-404-toast {
  margin: -0.25rem auto 1rem;
  padding: 0.35rem 0.75rem;
  max-width: 40rem;
  min-height: 2.1em;
  box-sizing: border-box;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: transparent;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  text-shadow: none;
}

.page-main.page-404 .page-404-toast.is-on {
  color: #33ff33;
  background: rgba(6, 8, 6, 0.85);
  border-color: rgba(51, 255, 51, 0.28);
  text-shadow: 0 0 12px rgba(51, 255, 51, 0.45);
}


.page-main.page-404 .page-404-lead {
  margin: 0 auto 1rem;
  max-width: none;
  white-space: nowrap;
  font-size: clamp(0.72rem, 2.65vw, 1.05rem);
}

.page-main.page-404 .actions {
  justify-content: center;
  margin-top: 1.5rem;
}

.dot-matrix-404 {
  margin: 0 auto 1.75rem;
  padding: 1.5rem 1rem 1.15rem;
  max-width: 100%;
  overflow: visible;
  scroll-margin-top: calc(var(--k9-chrome-top-h, 6rem) + 0.75rem);
  border: 1px solid var(--k9-border);
  border-radius: 0.5rem;
  background: #060806;
  box-shadow:
    inset 0 0 28px rgba(51, 255, 51, 0.05),
    inset 0 0 0 1px rgba(51, 255, 51, 0.06);
}

.dot-matrix-404-art {
  display: block;
  width: min(100%, 24rem);
  height: auto;
  margin: 0 auto;
  overflow: visible;
  filter:
    drop-shadow(0 0 3px rgba(51, 255, 51, 0.95))
    drop-shadow(0 0 10px rgba(51, 255, 51, 0.55))
    drop-shadow(0 0 22px rgba(51, 255, 51, 0.28));
}

.dot-matrix-404 .p31-dot {
  fill: #33ff33;
}

.page-main .board-photo.board-photo-viewer {
  margin-top: 1.25rem;
}

.page-main .board-photo.board-photo-viewer img {
  max-height: calc(100vh - var(--k9-chrome-top-h, 12rem) - 8rem);
  object-fit: contain;
}

body.board-photo-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  padding: 1rem;
  text-align: center;
}

body.board-photo-full .board-photo-full-img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

body.board-photo-full .board-photo-full-img.is-fit {
  max-width: min(calc(100vw - 2rem), 100%);
  max-height: calc(100vh - 5.5rem);
  object-fit: contain;
  cursor: zoom-in;
}

body.board-photo-full .board-photo-full-hint {
  margin: 0;
  max-width: 36rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--k9-muted);
}

body.board-photo-full .board-photo-full-back {
  color: var(--k9-cyan);
  font-size: 0.88rem;
  text-decoration: none;
}

body.board-photo-full .board-photo-full-back:hover {
  color: var(--k9-orange-hover);
  text-decoration: underline;
}

@media (max-width: 767px) {
  body::before {
    inset: 0.35rem;
    border-radius: 0.35rem;
  }

  .page-main {
    gap: 1rem;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }

  .page-main h1 {
    font-size: 1.25rem;
    padding-left: 0.6rem;
  }

  .k9-card,
  .sw-fpga-card {
    padding: 1rem;
  }

  .page-main .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .page-main a.btn {
    text-align: center;
  }

  .page-main .readme .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .page-main .readme table {
    width: 100%;
    min-width: 16rem;
  }

  .page-main .readme video {
    width: 100%;
    max-width: 100%;
  }

  .page-main .readme .ships-row {
    flex-direction: column;
  }

  .page-main .readme .ships-row > div {
    width: 100%;
  }
}

/* About page */
.page-about .about-prose {
  max-width: 42rem;
}

.page-about .about-prose > p {
  margin: 0 0 1.1rem;
  color: var(--k9-muted);
  line-height: 1.7;
}

.page-about .about-prose > p:last-child {
  margin-bottom: 0;
}

.page-about .about-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 0 0 1.35rem;
}

.page-about .about-photo-grid figure {
  margin: 0;
  background: var(--k9-panel);
  border: 1px solid var(--k9-border);
  border-radius: 0.55rem;
  overflow: hidden;
}

.page-about .about-photo-grid img {
  display: block;
  width: 100%;
  height: 12.5rem;
  object-fit: cover;
}

.page-about .about-photo-grid figcaption {
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  color: var(--k9-muted);
  border-top: 1px solid var(--k9-border);
}

.page-about .about-now {
  border-left: 3px solid var(--k9-orange);
}

.page-about .about-now h3 {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--k9-orange);
}

.page-about .about-now ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-about .about-now li {
  position: relative;
  margin: 0;
  padding: 0.3rem 0 0.3rem 1.15rem;
  color: var(--k9-muted);
}

.page-about .about-now li::before {
  content: ">";
  position: absolute;
  left: 0;
  color: var(--k9-cyan);
  font-weight: 700;
}

.page-about .about-closing {
  margin: 0;
  font-style: italic;
  color: var(--k9-muted);
}

@media (max-width: 600px) {
  .page-about .about-photo-grid {
    grid-template-columns: 1fr;
  }
}

