/* ===== Colours: an Altium-style 3D render of a black board. EDIT here to restyle. ===== */
:root {
  --view-top: #f2f2f2;     /* 3D viewport background */
  --view-bottom: #dcdcdc;
  --mask: #111111;         /* solder mask */
  --edge: #3a3833;         /* FR-4 board edge */
  --copper: #4a4a4a;       /* copper under the mask */
  --gold: #d4a73a;         /* exposed pads */
  --silk: #f4f4f4;         /* silkscreen */
  --silk-dim: #c4c4c4;
  --pulse: #fff3a0;        /* electricity */
  --chrome: #1b1b1b;       /* toolbar / status bar */
  --chrome-text: #d6d6d6;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 64px; overflow-x: hidden; overflow-x: clip; } /* hidden = fallback for older Safari */
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  overflow-x: clip; /* parts dragged in from off the board never widen the page */
  background: linear-gradient(var(--view-top), var(--view-bottom)) fixed;
  color: var(--silk);
  font: 400 15px/1.6 "JetBrains Mono", Consolas, Menlo, monospace;
  padding-bottom: 28px;
}

a { color: var(--silk); }
:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }

/* Silkscreen text: printed on the board. */
.silk { color: var(--silk); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin: 0; }

/* ===== Toolbar ===== */
.toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: 52px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--chrome); border-bottom: 1px solid #000;
}
.logo svg { display: block; width: 120px; height: 40px; }
.toolbar nav { display: flex; gap: 4px; }
.tab {
  padding: 4px 10px; font-size: 13px; color: var(--chrome-text); text-decoration: none;
  border: 1px solid #3a3a3a; background: #242424;
}
.tab:hover { border-color: var(--silk); color: #fff; }

/* ===== The board ===== */
.board {
  position: relative;
  max-width: 1100px;
  margin: 76px auto 48px;
  background: var(--mask);
  border: 4px solid var(--edge);
  border-radius: 16px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, .35), 0 2px 0 rgba(255, 255, 255, .25) inset;
}
.board > section, .board > footer { position: relative; z-index: 1; }

.section { padding: 32px 48px; }
.section > h2 { font-size: 1.25rem; margin-bottom: 14px; }
.ref { color: var(--silk-dim); font-weight: 400; font-size: .8em; letter-spacing: .04em; margin-right: .6em; }
.hint { color: var(--silk-dim); margin: 0 0 8px; }

/* ===== Board header ===== */
.hero { padding: 64px 48px 32px; }
.board-name { color: var(--silk-dim); font-size: 13px; margin: 0 0 10px; }
.hero h1 { font-size: clamp(2rem, 6vw, 4rem); line-height: 1.1; }
.subtitle { font-size: clamp(1rem, 2.4vw, 1.25rem); margin: 10px 0 28px; }
.switches { display: flex; flex-wrap: wrap; gap: 18px 40px; }
.sw {
  display: inline-flex; align-items: center; gap: 12px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em; text-decoration: none;
}
.sw-ref { color: var(--silk-dim); font-weight: 400; font-size: 12px; }
/* An SMD tact switch: metal frame, black round plunger, gold legs. */
.sw-cap {
  position: relative; width: 42px; height: 42px; border-radius: 4px; flex: none;
  background: linear-gradient(145deg, #e6e6e6, #8c8c8c);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, .35);
}
.sw-cap::after {
  content: ""; position: absolute; inset: 10px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #5a5a5a, #0e0e0e 70%);
}
.sw-cap::before {
  content: ""; position: absolute; left: -6px; right: -6px; top: 6px; bottom: 6px; z-index: -1;
  background:
    linear-gradient(var(--gold), var(--gold)) left top / 6px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 6px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 6px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 6px 6px no-repeat;
}
.sw:hover .sw-cap, .sw:active .sw-cap { transform: translateY(1px); box-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }

/* ===== Notes (About) ===== */
.note { max-width: 72ch; }
.note p { margin: 0 0 10px; }

/* ===== Project blocks =====
   Without JS: normal flow. With JS (.board.live): script.js positions each block on the board. */
.blocks { position: relative; }
.pkg { display: none; } /* data only: script.js reads the package name from it */
.part { margin: 0 0 28px; padding: 16px; outline: 1px solid rgba(244, 244, 244, .5); }
.board.live .part { position: absolute; margin: 0; padding: 0; outline: none; }
.open { display: none; }
.board.live .open {
  display: block; position: absolute; z-index: 2;
  background: none; border: 0; border-radius: 6px; cursor: pointer;
}
.board.live .open:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
.silk-block { min-width: 0; }
.silk-block h3 { font-size: 1.05rem; margin: 2px 0 4px; }
.tags { color: var(--silk-dim); font-size: 12px; margin: 0 0 8px; }
.desc { margin: 0; }
.links { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.links a { position: relative; z-index: 2; display: inline-block; padding: 3px 10px; border: 1px solid var(--silk); text-decoration: none; font-size: 13px; }
.links a:hover { background: var(--silk); color: var(--mask); }

/* ===== Contact: connector J1 (white housing, gold pins) ===== */
.j1 { position: relative; display: inline-grid; gap: 16px; padding: 4px 0 4px 66px; max-width: 100%; }
.j1::before {
  content: ""; position: absolute; left: 0; top: -8px; bottom: -8px; width: 46px; border-radius: 3px;
  background: linear-gradient(90deg, #fbf7ec, #d9cfb8);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, .35);
}
.pin { position: relative; display: flex; align-items: center; gap: 12px; text-decoration: none; overflow-wrap: anywhere; }
.pin::before {
  content: ""; position: absolute; left: -52px; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  background: #2b2b2b; border: 4px solid var(--gold); border-radius: 50%;
}
.pin[data-pin="1"]::before { border-radius: 2px; }
.pin-label { font-weight: 700; min-width: 7ch; }
.pin:hover .pin-label { text-decoration: underline; }

footer { text-align: center; color: var(--silk-dim); font-size: 13px; padding: 24px 16px 36px; }
footer p { margin: 0; }

.credit { font-size: 11px; margin-top: 6px; }

/* ===== Live board: KiCad renders + HTML placed on the board's text zones (script.js) =====
   All positions come from script.js in px (board mm x --s). */
.board.live { font-size: max(12px, calc(var(--s) * 1.45px)); overflow: visible; }
.board.live > section, .board.live > footer, .board.live .blocks { position: static; padding: 0; }
.board.live .zoned { position: absolute; z-index: 2; margin: 0; }
.board.live .hero h1 { font-size: 3.4em; }
.board.live .subtitle { font-size: 1.25em; margin: .4em 0 0; }
.board.live .switches { display: contents; }
.board.live .sw { position: absolute; z-index: 2; }
.board.live .sw-cap, .board.live .sw-ref { display: none; } /* the real switch is in the render underneath */
.board.live .part:focus-within { opacity: 1 !important; }
.board.live #projects > h2, .board.live .hint {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); /* visually hidden */
}
.board.live .j1 { display: contents; }
.board.live .j1::before, .board.live .pin::before { display: none; }
.board.live .pin { position: absolute; z-index: 2; font-size: .9em; }
.board.live .part { position: absolute; z-index: 2; margin: 0; outline: none;
  background: rgba(8, 8, 8, .86); border: 1px solid rgba(244, 244, 244, .7); padding: .8em 1em; }
.board.live footer { text-align: left; }
.board.live .part .links { margin-top: .6em; gap: .4em; }
.board.live .part .links a { font-size: .82em; padding: .15em .55em; }
.board.live .part .tags { margin-bottom: .4em; }

.layers, .layers > * { position: absolute; left: 0; top: 0; }
.layers { width: 100%; height: 100%; z-index: 0; }
.tile { width: 100%; display: block; }
.grp, #overlay { overflow: visible; pointer-events: none; }
.spr { background-repeat: no-repeat; will-change: transform; }
#overlay { width: 100%; height: 100%; z-index: 3; }
.pulse { fill: none; stroke: var(--pulse); stroke-linecap: round; }
.data { fill: none; stroke: var(--pulse); stroke-linecap: square; }
.rats { stroke: #ffffff; stroke-dasharray: .4 .5; opacity: .85; }
.ic-sel { fill: none; stroke: #ffffff; display: none; }
.ic-sel.on { display: inline; }
.leader { fill: none; stroke: var(--silk); }
.leader-head { fill: var(--silk); }

/* ===== Project details panel ===== */
#panel {
  position: fixed; margin: 0; inset: 52px 0 28px auto;
  width: min(420px, 100%); height: auto; max-width: none; max-height: none;
  background: #141414; color: #ededed;
  border: 0; border-left: 2px solid var(--silk); padding: 28px 24px;
  overflow-y: auto;
}
#panel::backdrop { background: rgba(0, 0, 0, .3); }
#panel .close {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px;
  background: none; color: var(--silk); border: 1px solid var(--silk); font: inherit; font-size: 20px; cursor: pointer;
}
.panel-pkg { color: #a9a9a9; font-size: 13px; margin: 0 0 4px; }
#panel h3 { font-size: 1.2rem; }
#panel .tags { color: #a9a9a9; }
#panel .links a:hover { color: #141414; }

/* ===== Status bar ===== */
.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: 28px; padding: 0 12px;
  display: flex; align-items: center; gap: 18px;
  background: var(--chrome); border-top: 1px solid #000; font-size: 12px; color: #a9a9a9;
}
.sb-contact { margin-left: auto; font-weight: 700; text-decoration: none; color: #ffffff; }

/* ===== Phone ===== */
@media (max-width: 899px) {
  .toolbar { padding: 0 10px; }
  .logo svg { width: 96px; }
  .tab { padding: 4px 7px; font-size: 12px; }
  /* The narrow board, capped so tablets and narrow windows don't blow it up to double size. */
  .board { width: calc(100% - 8px); max-width: 480px; margin: 60px auto 40px; border-width: 3px; border-radius: 12px; }
  .hero { padding: 48px 20px 24px; }
  .section { padding: 24px 16px; }
  #sb-x, #sb-layer { display: none; }
  #panel { inset: auto 0 28px 0; width: 100%; max-height: 70vh; border-left: 0; border-top: 2px solid var(--silk); }
}
