/* Light theme. Dark stays the default; html[data-theme="light"] is set before paint by the inline script in <head>.
   Hardware pieces (homepage 3D hero, LED counters, chips, story band) stay dark on purpose: they are objects, not page. */
html[data-theme="light"] {
  color-scheme: light;
  --hx-night: #f6f3ee; --hx-surface: #fffdf9; --hx-ink: #22201c; --hx-mute: #5c554b; --hx-soft: #3a362f;
  --hx-line: #e2d9cb; --hx-accent: #0f766e; --cu: #c98a52; --cu-hi: #8f5420;
}
html[data-theme="light"] a:hover { color: #115e59; }
html[data-theme="light"] .inner .site-top.mh { border-bottom-color: var(--hx-line); }
html[data-theme="light"] .inner .site-top.mh::before { background: rgba(246, 243, 238, .86); }
html[data-theme="light"] .codebg { color: #6b5a44; opacity: .10; }
html[data-theme="light"] .codebg .k { color: #9a5a22; } html[data-theme="light"] .codebg .s { color: #0f766e; }
html[data-theme="light"] .crumbs li + li::before { color: #a99c88; }
html[data-theme="light"] :is(strong, .tl b, .flow b, .svc h3, .proof h3, .contact-ways a, .nda-k, .sites a, .sites span, .phases b, .prep h3, .foot-k, .toc a:hover, .pin h3) { color: var(--hx-ink); }
html[data-theme="light"] :is(.btn-ghost, .links a, .chips li, .status, .form input, .form select, .form textarea, .foot .btn-ghost) { border-color: #cfc6b8; }
html[data-theme="light"] :is(.btn-ghost:hover, .foot .btn-ghost:hover, .tl li:hover) { background: rgba(0, 0, 0, .04); }
html[data-theme="light"] .stats-band { background: rgba(255, 255, 255, .6); }
html[data-theme="light"] :is(.svc a:hover, .toc a:hover, .pin:hover .pl, .pin:focus-visible .pl) { background: #fff; }
html[data-theme="light"] .svc-ic { background: linear-gradient(145deg, #fff, #ece5d9); }
html[data-theme="light"] .nda { background: repeating-linear-gradient(135deg, rgba(154, 90, 34, .06) 0 12px, transparent 12px 24px), #ece5d9; }
html[data-theme="light"] .foot { background: linear-gradient(#ece5d9, #e8e1d5); }
html[data-theme="light"] .flow, html[data-theme="light"] .toc { background: rgba(255, 255, 255, .9); box-shadow: 0 20px 40px rgba(60, 40, 10, .08); }
html[data-theme="light"] .portrait img { box-shadow: 0 20px 40px rgba(60, 40, 10, .15); }
/* the 3D cube faces on About keep their dark plate, so their white text stays readable */
html[data-theme="light"] .face b { color: #fff; }

/* homepage: hero follows the light palette; hardware bands (LEDs, chip, story) turn warm graphite, no navy */
html[data-theme="light"] .hx-shade { background: linear-gradient(90deg, rgba(246, 243, 238, .92) 0%, rgba(246, 243, 238, .55) 34%, transparent 52%); }
html[data-theme="light"] .hx-dock { background: rgba(246, 243, 238, .8); }
html[data-theme="light"] .srv { background: #fff; }
html[data-theme="light"] :is(.led-band, .ic, .story) {
  color-scheme: dark; --hx-night: #24211d; --hx-surface: #2e2a25; --hx-ink: #f3eee6; --hx-mute: #b3a998; --hx-soft: #ddd4c6;
  --hx-line: #3d3830; --hx-accent: #2dd4bf; --cu-hi: #f0b27a; color: var(--hx-ink);
}
html[data-theme="light"] .led-band { background: radial-gradient(120% 140% at 50% 0, #34302a 0, #1f1c18 70%); }
html[data-theme="light"] .led li { background: #171512; border-color: #3d3830; box-shadow: inset 0 0 0 4px #24211d, inset 0 10px 30px rgba(0,0,0,.6); }
html[data-theme="light"] .ic { background: linear-gradient(160deg, #3a352e, #1c1a16 60%); border-color: #4a443a; }
html[data-theme="light"] .story { background: radial-gradient(120% 140% at 85% 50%, #34302a 0, #161410 70%); }
html[data-theme="light"] :is(.story-h, .story strong) { color: #fff; }
html[data-theme="light"] .pin .pl { background: #fff; }

/* switch: a DIP toggle with a status LED, same box as the fullscreen button, in the top-right tool group */
.mh-tools { display: flex; align-items: flex-start; gap: 8px; }
.theme-sw { position: relative; z-index: 2; margin-top: 39px; display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  background: rgba(11, 11, 11, .72); border: 1px solid rgba(201, 138, 82, .45); border-radius: 4px; cursor: pointer; color: #c98a52;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: border-color .2s, color .2s; }
.theme-sw:hover, .theme-sw:focus-visible { border-color: #c98a52; color: #f0b27a; }
.theme-sw:focus-visible { outline: 2px solid #f0b27a; outline-offset: 3px; }
.theme-sw svg { width: 22px; height: 22px; }
.ts-slot { fill: #121212; stroke: currentColor; stroke-width: 1.2; }
.ts-knob { fill: currentColor; transition: transform .18s cubic-bezier(.5, 1.6, .5, 1); }
.ts-led { fill: #3a2a1c; transition: fill .2s, filter .2s; }
.theme-sw text { font: 700 5px/1 ui-monospace, monospace; fill: currentColor; opacity: .7; }
html[data-theme="light"] .ts-knob { transform: translateY(-8px); }
html[data-theme="light"] .ts-led { fill: #ffd27a; filter: drop-shadow(0 0 2px #ffb347); }
.mh.hot .theme-sw { opacity: .3; } .pn-open .theme-sw { visibility: hidden; }
@media (max-width: 860px) { .theme-sw { margin-top: 26px; } }
.inner .mh .theme-sw { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .theme-sw, .ts-knob { transition: none; } }

/* menu button: original size, fully visible, with a small electric spark every few seconds */
html .mh .pn-btn { opacity: 1; }
html .mh .pn-btn::before, html .mh .pn-btn::after { content: ""; position: absolute; pointer-events: none; width: 14px; height: 18px;
  background: #e8fffb; clip-path: polygon(55% 0, 15% 55%, 45% 55%, 30% 100%, 85% 40%, 55% 40%, 75% 0);
  filter: drop-shadow(0 0 4px #2dd4bf) drop-shadow(0 0 8px #2dd4bf); opacity: 0; }
html .mh .pn-btn::before { top: -12px; right: -8px; animation: pn-spark 4.2s steps(1) infinite; }
html .mh .pn-btn::after { bottom: -12px; left: -6px; transform: rotate(160deg); animation: pn-spark 4.2s steps(1) 1.9s infinite; }
@keyframes pn-spark { 0%, 88%, 100% { opacity: 0; } 90% { opacity: 1; } 92% { opacity: .2; } 94% { opacity: 1; } 96% { opacity: 0; } }
html[data-theme="light"] .inner .mh .pn-btn { background: #22201c; }
@media (prefers-reduced-motion: reduce) { html .mh .pn-btn, html .mh .pn-btn::before, html .mh .pn-btn::after { animation: none; } }

/* homepage hero text and Jumper menu on the light background */
html[data-theme="light"] .hx-h1, html[data-theme="light"] :is(.hx-tab:hover, .hx-tab.on) { color: #22201c; }
html[data-theme="light"] .mh { --cream: #22201c; }
html[data-theme="light"] .jp-lb small { color: rgba(34, 32, 28, .6); }
html[data-theme="light"] :is(.jp, .jp-wire) { opacity: .75; }
html[data-theme="light"] .led-band { background: #f6f3ee; border-bottom-color: #e2d9cb; }
/* Viva Vola band stays dark green, so its text stays light */
html[data-theme="light"] .vv-star, html[data-theme="light"] .vv-star :is(p, h2, .k, .more) { color: #fff; }
html[data-theme="light"] .hx .hx-dock .hx-tab:is(:hover, .on) { color: #22201c; }

/* light only: a faint PCB grid on every other section, full width behind the content */
html[data-theme="light"] body { overflow-x: clip; }
html[data-theme="light"] main .sec:nth-of-type(even) { position: relative; isolation: isolate; }
html[data-theme="light"] main .sec:nth-of-type(even)::before { content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%); pointer-events: none;
  background:
    radial-gradient(circle at 24px 24px, rgba(154, 90, 34, .16) 2px, transparent 2.5px) 0 0 / 48px 48px,
    repeating-linear-gradient(0deg, rgba(34, 32, 28, .045) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(90deg, rgba(34, 32, 28, .045) 0 1px, transparent 1px 48px),
    #ece5d9; }

/* top-right tool group: 15% bigger, lifted to line up with the logo chip */
html .mh :is(.theme-sw, .fs-btn) { width: 44px; height: 44px; }
html .mh .pn-btn { width: 64px; height: 44px; }
html .mh .pn-btn .pn-ico { width: 44px; height: 23px; }
html .mh .fs-btn svg { width: 21px; height: 21px; }
html .mh .theme-sw svg { width: 25px; height: 25px; }
html body:not(.inner) .mh :is(.theme-sw, .fs-btn, .pn-btn) { margin-top: 20px; }
@media (max-width: 860px) { html body:not(.inner) .mh :is(.theme-sw, .fs-btn, .pn-btn) { margin-top: 14px; } }
@media (max-width: 420px) { html .mh :is(.theme-sw, .fs-btn) { width: 40px; height: 40px; } html .mh .pn-btn { width: 56px; height: 40px; } html .mh .mh-tools { gap: 6px; } }
html body.inner .mh :is(.theme-sw, .fs-btn, .pn-btn) { margin-top: 0; } html body.inner .mh .mh-tools { align-items: center; }

/* light accent: one warm copper. --hx-hot drives the stage label (.hx-k "01 · HTML") and the active-stage underline (.hx-tab::after) in hero.css;
   #a4561c = 5.0:1 on #f6f3ee, 4.4:1 on #ece5d9 (label sits on the hero, not on the grid sections) */
html[data-theme="light"] { --hx-hot: #a4561c; --lt-cu: #b8661f; --lt-cu-tx: #8f5420; }
html[data-theme="light"] ::selection { background: #f0c89a; color: #22201c; }
html[data-theme="light"] a:hover { color: var(--lt-cu-tx); }
html[data-theme="light"] .hx .hx-dock .hx-tab.on b { color: var(--hx-hot); opacity: 1; }
html[data-theme="light"] :is(.theme-sw, .fs-btn, .lang-tg) { border-color: var(--lt-cu); }
html[data-theme="light"] :is(.btn-ghost:hover, .foot .btn-ghost:hover) { border-color: var(--lt-cu); color: var(--lt-cu-tx); }

/* homepage EN/عربي toggle: same row and box as the theme / fullscreen / menu buttons */
html body:not(.inner) .mh .lang-tg { margin-top: 20px; margin-inline: 0; height: 44px; min-width: 44px; box-sizing: border-box;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@media (max-width: 860px) { html body:not(.inner) .mh .lang-tg { margin-top: 14px; } }
@media (max-width: 420px) { html body:not(.inner) .mh .lang-tg { height: 40px; min-width: 40px; } }

/* pinout overlay keeps its dark plate in light mode, so its pin titles keep the light cream (light .mh sets --cream to graphite) */
html[data-theme="light"] .pn { --cream: #f3e9d8; }

/* all cards (service .svc a, numbered .cards li): a PCB pattern (copper pads + traces) fades in and drifts on hover, both themes */
:is(.svc a, .cards li) { position: relative; isolation: isolate; overflow: hidden; }
:is(.svc a, .cards li)::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
  background:
    radial-gradient(circle, rgba(201, 138, 82, .55) 1.6px, transparent 2.2px) 0 0 / 32px 32px,
    linear-gradient(90deg, transparent 15px, rgba(201, 138, 82, .22) 15px 16px, transparent 16px) 0 0 / 32px 32px,
    linear-gradient(0deg, transparent 15px, rgba(45, 212, 191, .12) 15px 16px, transparent 16px) 0 0 / 64px 64px;
  -webkit-mask: linear-gradient(135deg, transparent 20%, #000 75%); mask: linear-gradient(135deg, transparent 20%, #000 75%);
  transition: opacity .35s; }
:is(.svc a, .cards li):is(:hover, :focus-visible, :focus-within)::after { opacity: .5; animation: card-pcb 6s linear infinite; }
@keyframes card-pcb { to { background-position: 32px 32px, 32px 0, 0 64px; } }
html[data-theme="light"] :is(.svc a, .cards li)::after { filter: saturate(1.2) brightness(.85); }
@media (prefers-reduced-motion: reduce) { :is(.svc a, .cards li)::after { transition: none; } :is(.svc a, .cards li):is(:hover, :focus-visible, :focus-within)::after { animation: none; } }

/* hero diagram box (.flow): the trace runs exactly from the first pad to the last one, drawn per row (row heights vary) */
.flow::before { display: none; }
.flow li::after { content: ""; position: absolute; left: -24px; top: 0; bottom: 0; width: 2px; z-index: -1;
  background: linear-gradient(var(--cu), var(--hx-accent)); opacity: .5; }
.flow li:first-child::after { top: 50%; } .flow li:last-child::after { bottom: 50%; }
.flow li:only-child::after { display: none; }
.flow li { isolation: auto; } .flow { isolation: isolate; }
html[dir="rtl"] .flow li::after { left: auto; right: -24px; }
.flow::after { left: 27px; } html[dir="rtl"] .flow::after { left: auto; right: 27px; } /* pad, line and packet share one centre: 23px outside the row */
/* no pad squares: one clean trace (row segments join into a continuous line), packet rides on it */
.flow li::before { display: none; }
.flow li + li::after { top: -1px; }
/* round dots on the trace: hollow rings, js/theme.js slides the packet to each one and fills it, then pauses */
.flow li::before { display: block; content: ""; position: absolute; left: -28px; top: 50%; width: 10px; height: 10px; margin-top: -5px; box-sizing: border-box;
  border-radius: 50%; border: 2px solid var(--cu-hi); background: var(--hx-surface); transition: background .3s, border-color .3s, box-shadow .3s; }
html[dir="rtl"] .flow li::before { left: auto; right: -28px; }
.flow li.on::before { background: var(--hx-accent); border-color: var(--hx-accent); box-shadow: 0 0 10px var(--hx-accent); }
.flow.trace-js::after { animation: none; opacity: 1; top: var(--pk, 0px); margin-top: -5px; transition: top .7s cubic-bezier(.6, 0, .4, 1), opacity .3s; }
.flow.trace-js.reset::after { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .flow li::before { background: var(--hx-accent); border-color: var(--hx-accent); transition: none; } }
