/* ============================================================
   About: a red dev board with a TFT screen and tactile buttons,
   dropped onto the desk as a popup over whatever view is open.
   ============================================================ */

.about-modal {
  position: fixed;
  inset: 0;
  z-index: 65; /* under the lamp layers (70) so the board is lit like the desk */
  display: grid;
  place-items: center;
  padding: 20px;
}
.about-modal[hidden] { display: none; }
.about-scrim { position: absolute; inset: 0; background: rgba(26, 15, 4, .44); }

body[data-modal="about"] .work-badge { visibility: hidden; }

.board {
  --pcb: #b3231b;
  --pcb-hi: #c8382c;
  --silk: rgba(250, 246, 236, .92);
  --gold: #d8ad55;
  position: relative;
  width: min(920px, 94vw, calc((100vh - 48px) * 1.78));
  font-family: "Courier Prime", ui-monospace, monospace;
  /* the shadow is cast by the tilted board, so it follows its real outline */
  filter:
    drop-shadow(2px 4px 2px rgba(32, 20, 6, .42))
    drop-shadow(14px 26px 22px rgba(32, 20, 6, .34));
}

/* ---------- the PCB ---------- */
.pcb {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(20px, 3.6%, 38px);
  align-items: center;
  padding: clamp(46px, 7.5%, 64px) clamp(26px, 4.5%, 44px) clamp(40px, 6.5%, 56px);
  border-radius: 10px;
  background-color: var(--pcb);
  background-image:
    radial-gradient(120% 90% at 18% 8%, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .2  0 0 0 0 0  0 0 0 0 0  0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  /* 1.6mm board: a lit top edge, the darker side edge, and light falling off away from the lamp */
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 210, .35),
    inset -40px -50px 80px rgba(60, 8, 4, .28),
    0 3px 0 #6e120d,
    0 4px 0 #4c0d09;
  /* seen at a slight angle, not square to the camera (JS animates this; these are the resting values) */
  --rx: 11deg;
  --ry: -7deg;
  --rz: -1.4deg;
  transform: perspective(1500px) rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(var(--rz));
  transition: transform .7s cubic-bezier(.2, .7, .2, 1);
}
/* glossy solder mask: a soft warm highlight from the lamp that slides as the board turns */
.pcb::after {
  content: "";
  transition: background-position .7s ease;
  position: absolute;
  inset: 0;
  z-index: 6;
  border-radius: inherit;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(55% 45% at var(--gx, 28%) var(--gy, 18%), rgba(255, 228, 190, .30), rgba(255, 228, 190, 0) 70%),
    linear-gradient(112deg, rgba(255, 240, 215, 0) 38%, rgba(255, 240, 215, .10) 47%, rgba(255, 240, 215, 0) 56%);
}

/* traces and silkscreen outlines, drawn behind everything */
.pcb-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pcb-art .trace { fill: none; stroke: var(--pcb-hi); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: .9; }
.pcb-art .via { fill: var(--gold); opacity: .8; }

.hole {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1d1a16;
  box-shadow: 0 0 0 4px var(--gold), inset 1px 1px 2px rgba(0, 0, 0, .6);
}
.hole.tl { top: 12px; left: 12px; } .hole.tr { top: 12px; right: 12px; }
.hole.bl { bottom: 12px; left: 12px; } .hole.br { bottom: 12px; right: 12px; }

.silk {
  position: absolute;
  color: var(--silk);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.2;
  white-space: nowrap;
  text-transform: uppercase;
  pointer-events: none;
}
.silk.name { top: 16px; right: 44px; font-size: 13px; letter-spacing: .14em; }
.silk.rev { top: 33px; right: 44px; font-size: 9px; opacity: .8; }
.silk.spec { bottom: 16px; left: 44px; font-size: 10px; }
.silk.made { bottom: 16px; right: 44px; font-size: 10px; }

/* pin header along the top, like the real module */
.pins {
  position: absolute;
  top: 12px;
  left: 44px;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #151412;
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}
.pins i { width: 9px; height: 9px; border-radius: 1px; background: linear-gradient(135deg, #f3d589, #b98a2e); }
.pin-labels {
  position: absolute;
  top: 29px;
  left: 44px;
  display: flex;
  gap: 2px;
  font-size: 6.5px;
  letter-spacing: 0;
}
.pin-labels span { width: 11px; text-align: center; writing-mode: vertical-rl; transform: rotate(180deg); height: 22px; }

/* little surface-mount parts */
.smd { position: absolute; display: block; background: #23201c; border-radius: 1px; box-shadow: 0 .5px 0 rgba(0, 0, 0, .4); }
.smd::before, .smd::after { content: ""; position: absolute; top: 0; bottom: 0; width: 28%; background: linear-gradient(#e7e3da, #a9a49a); }
.smd::before { left: 0; } .smd::after { right: 0; }
.smd.r { width: 14px; height: 7px; }
.smd.c { width: 12px; height: 7px; background: #a98a62; }
.ic {
  position: absolute;
  width: 30px;
  height: 30px;
  background: #1d1b19;
  border-radius: 2px;
  box-shadow: 0 0 0 3px transparent, 0 .5px 0 rgba(0,0,0,.5);
  outline: 2px dotted #cfcac0;
  outline-offset: 1px;
}
.ic::after { content: ""; position: absolute; top: 4px; left: 4px; width: 4px; height: 4px; border-radius: 50%; background: #3a3632; }

/* ---------- the TFT ---------- */
.bezel {
  position: relative;
  padding: 8px 8px 12px;
  background: #131313;
  border-radius: 3px;
  box-shadow:
    0 0 0 3px #b9b8b3,              /* metal frame of the module */
    0 0 0 4px #7b7a76,
    1px 2px 2px 4px rgba(0, 0, 0, .3);
}
.bezel::after { /* ribbon flex peeking out under the glass */
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 30%;
  height: 7px;
  translate: -50% 0;
  background: linear-gradient(#d29a3c, #a8741f);
  border-radius: 0 0 2px 2px;
}
.screen {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #04060a;
  container-type: size;
  border-radius: 1px;
}
/* scanlines + a little backlight bleed at the edges */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    repeating-linear-gradient(rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px),
    radial-gradient(130% 120% at 50% 50%, transparent 62%, rgba(140, 170, 255, .07) 100%);
}
/* the glass: the lamp's hotspot, a hard-edged window-style reflection band, and a lit top edge */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(38% 30% at var(--sx, 20%) var(--sy, 10%), rgba(255, 238, 210, .42), rgba(255, 238, 210, .08) 55%, rgba(255, 238, 210, 0) 75%),
    linear-gradient(116deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .07) var(--band, 31%), rgba(255, 255, 255, 0) calc(var(--band, 31%) + .4%)),
    linear-gradient(116deg, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, .05) 62%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(rgba(255, 255, 255, .07), rgba(255, 255, 255, 0) 18%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 0 0 1px rgba(255, 255, 255, .05);
}
.screen.is-off .scr { opacity: 0; }

.scr {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 3.4cqh 4cqw 2.6cqh;
  font-family: "VT323", ui-monospace, monospace;
  font-size: 7.4cqh;
  line-height: 1.12;
  color: #eef3ff;
  text-shadow: 0 0 .35em rgba(170, 200, 255, .35);
  transition: opacity .12s linear;
}
.scr a { color: inherit; text-decoration: none; }
.scr-top, .scr-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2cqw;
  font-size: 6cqh;
  color: #6be3ff;
}
.scr-top { padding-bottom: 1.6cqh; border-bottom: 1px dashed rgba(107, 227, 255, .35); }
.scr-bottom { padding-top: 1.4cqh; border-top: 1px dashed rgba(107, 227, 255, .25); color: #8ea2c8; }
.scr-tabs { display: flex; gap: 1.6cqw; }
.scr-tabs span { opacity: .4; }
.scr-tabs span.on { opacity: 1; color: #ffe14a; }
.scr-body {
  overflow-y: auto;
  scrollbar-width: none;
  padding: 2.4cqh .5cqw 1cqh 0;
}
.scr-body::-webkit-scrollbar { display: none; }

.t-title {
  margin: 0 0 1.6cqh;
  font-family: "Silkscreen", "VT323", monospace;
  font-size: 9cqh;
  font-weight: 400;
  line-height: 1;
}
.scr p { margin: 0 0 1.4cqh; }
.scr ul { margin: 0; padding: 0; list-style: none; }
.scr li { padding: .3cqh 0; }
.lbl { color: #8ea2c8; font-size: 6cqh; letter-spacing: .06em; }
.c-y { color: #ffe14a; } .c-r { color: #ff5a52; } .c-g { color: #57f287; }
.c-b { color: #62b0ff; } .c-m { color: #ff7ad9; } .c-c { color: #6be3ff; } .c-w { color: #f4f6ff; }

.fact { font-size: 10.5cqh; line-height: 1.1; margin-top: 3cqh !important; }
.fact-n { color: #8ea2c8; }

/* selectable rows (books, films) */
.item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2.2cqw;
  align-items: center;
  padding: .8cqh 1cqw;
  border-radius: 1px;
}
.item.is-sel { background: #eef3ff; color: #04060a; text-shadow: none; }
.item.is-sel .lbl, .item.is-sel .stars { color: #04060a; }
.item canvas {
  width: 7cqh;
  height: 10.5cqh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}
.item .ttl { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { display: flex; gap: 2cqw; font-size: 5.8cqh; color: #8ea2c8; }
.stars { color: #ffe14a; letter-spacing: .05em; }
.group + .group { margin-top: 2cqh; }

.boot { color: #9ab0d6; }
.boot .ok { color: #57f287; }
.cursor::after { content: "_"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- controls: tactile switches soldered to the board ---------- */
.controls {
  display: grid;
  justify-items: center;
  gap: 18px;
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, var(--sw));
  grid-template-rows: repeat(3, var(--sw));
  gap: 10px;
  --sw: clamp(46px, 5.4vw, 58px);
}
.dpad [data-act="up"] { grid-area: 1 / 2; }
.dpad [data-act="prev"] { grid-area: 2 / 1; }
.dpad [data-act="ok"] { grid-area: 2 / 2; }
.dpad [data-act="next"] { grid-area: 2 / 3; }
.dpad [data-act="down"] { grid-area: 3 / 2; }
.aux { display: flex; gap: 22px; align-items: flex-start; --sw: clamp(40px, 4.4vw, 48px); }

.tact {
  position: relative;
  width: var(--sw);
  height: var(--sw);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* black body + steel top plate + round cap */
.tact .body {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: #1f1e1c;
  box-shadow: .5px 1.2px 1px rgba(32, 20, 6, .55), inset 0 0 0 1px #2e2c29;
}
.tact .body::before { /* the four solder legs */
  content: "";
  position: absolute;
  inset: -4px 18%;
  background:
    linear-gradient(#c9c6bf, #c9c6bf) left top / 4px 5px no-repeat,
    linear-gradient(#c9c6bf, #c9c6bf) right top / 4px 5px no-repeat,
    linear-gradient(#c9c6bf, #c9c6bf) left bottom / 4px 5px no-repeat,
    linear-gradient(#c9c6bf, #c9c6bf) right bottom / 4px 5px no-repeat;
  z-index: -1;
}
.tact .plate {
  position: absolute;
  inset: 12%;
  border-radius: 2px;
  background: linear-gradient(135deg, #e9e8e4, #a9a7a1 55%, #d4d2cc);
}
.tact .plate::before, .tact .plate::after { /* rivet dots on the plate */
  content: "";
  position: absolute;
  width: 9%;
  height: 9%;
  border-radius: 50%;
  background: #6f6d68;
}
.tact .plate::before { top: 8%; left: 8%; } .tact .plate::after { bottom: 8%; right: 8%; }
.tact .cap {
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 236, 205, .55) 0 6%, rgba(255, 236, 205, 0) 18%),
    radial-gradient(circle at 35% 30%, #4a4844, #161514 70%);
  box-shadow: 0 2.5px 0 #0b0a09, 0 3px 2px rgba(0, 0, 0, .45);
  transition: transform .06s ease, box-shadow .06s ease;
}
.tact.is-down .cap, .tact:active .cap { transform: translateY(2px) scale(.97); box-shadow: 0 .5px 0 #0b0a09, 0 1px 1px rgba(0, 0, 0, .4); }
.tact:focus-visible { outline: 2px dashed var(--silk); outline-offset: 5px; border-radius: 4px; }
.tact .lab {
  position: absolute;
  left: 50%;
  top: calc(100% + 5px);
  translate: -50% 0;
  color: var(--silk);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  white-space: nowrap;
}
.dpad .tact .lab { top: auto; bottom: calc(100% + 3px); font-size: 11px; }
.dpad [data-act="down"] .lab { bottom: auto; top: calc(100% + 3px); }
.dpad [data-act="prev"] .lab { left: auto; right: calc(100% + 4px); bottom: 50%; translate: 0 50%; }
.dpad [data-act="next"] .lab { left: calc(100% + 4px); bottom: 50%; translate: 0 50%; }
.dpad [data-act="ok"] .lab { display: none; }

/* SMD LED next to the sound switch */
.led {
  position: absolute;
  top: -12px;
  right: -14px;
  width: 8px;
  height: 5px;
  border-radius: 1px;
  background: #2b4a2f;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.tact[aria-pressed="true"] .led { background: #6dff8a; box-shadow: 0 0 6px 2px rgba(109, 255, 138, .55); }

/* ---------- phones: portrait board, like the real module ---------- */
@media (max-width: 700px) {
  .board { width: min(420px, 96vw); }
  .pcb { --rx: 7deg; --ry: -3deg; --rz: -.8deg; }
  .pcb { grid-template-columns: minmax(0, 1fr); padding: 50px 16px 44px; gap: 30px; }
  .screen { aspect-ratio: 4 / 5; }
  .scr { font-size: 5.4cqh; }
  .t-title { font-size: 6.6cqh; }
  .fact { font-size: 7.6cqh; }
  .scr-top, .scr-bottom, .lbl, .item .sub { font-size: 4.4cqh; }
  .item canvas { width: 5.4cqh; height: 8cqh; }
  .controls { grid-template-columns: auto auto; align-items: center; gap: 34px; }
  .aux { flex-direction: column; gap: 26px; }
  .silk.name { right: 36px; font-size: 11px; }
  .silk.rev { display: none; }
  .pins { left: 36px; } .pin-labels { display: none; }
  .silk.spec { left: 36px; } .silk.made { right: 36px; }
  .smd, .ic { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor::after { animation: none; }
}
