/* =====================================================================
   HL GLOW — "Lab" layer (graph paper, HUD, terminal, tiles, X-ray mode…)
   RULES: no new fonts, no new colours. Everything is drawn with the site's
   existing tokens (--ink, --white, --black, --g100…--g700) and "Inter".
   Tints use color-mix() on --ink, with an rgba() fallback just above it.
   All effects are decorative: pointer-events:none unless it is a control.
   ===================================================================== */

/* ---------- 1. graph-paper background ---------- */
body::before { display: none !important;
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(17, 17, 17, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, .045) 1px, transparent 1px),
    linear-gradient(rgba(17, 17, 17, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, .09) 1px, transparent 1px);
  background-image:
    linear-gradient(color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}

/* ---------- 2. background canvas (oscilloscope + DNA) & cursor canvas ---------- */
.lab-bg, .lab-fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lab-bg { z-index: -1; }
.lab-fx { z-index: 95; }

/* ---------- 3. HUD: crosshair corners + readouts ---------- */
.lab-hud { position: fixed; inset: 0; z-index: 94; pointer-events: none; font-variant-numeric: tabular-nums; color: var(--ink); }
.lab-hud .ch { position: absolute; width: 18px; height: 18px; opacity: .55; }
.lab-hud .ch.tl { left: 10px;  top: calc(var(--hh, 64px) + 6px); }
.lab-hud .ch.tr { right: 10px; top: calc(var(--hh, 64px) + 6px); transform: scaleX(-1); }
.lab-hud .ch.bl { left: 10px;  bottom: 10px; transform: scaleY(-1); }
.lab-hud .ch.br { right: 10px; bottom: 10px; transform: scale(-1, -1); }
.lab-hud .ro { position: absolute; top: calc(var(--hh, 64px) + 8px); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; opacity: .6; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.lab-hud .ro.l { left: 34px; }
.lab-hud .ro.r { right: 34px; }
.lab-hud .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); animation: labBlink 1.6s steps(2, jump-none) infinite; }
.lab-hud .ro.r { display: none; }
@media (min-width: 700px) { .lab-hud .ro.r { display: flex; } }
@media (max-width: 420px) { .lab-hud .ro .tm { display: none; } }
@keyframes labBlink { 50% { opacity: .15; } }

/* ---------- 4. figure labels + hand-drawn annotations ---------- */
.lab-rel { position: relative; }
.lab-tag { position: absolute; top: 10px; right: var(--gut, 20px); z-index: 2; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--g600); border: 1px solid var(--g300); border-radius: 4px; padding: 3px 7px; background: var(--white); pointer-events: none; white-space: nowrap; }
.hero .lab-tag { top: calc(var(--hh, 64px) + 40px); }
.lab-note { position: absolute; pointer-events: none; color: var(--ink); display: flex; align-items: flex-start; gap: 4px; font-size: 13px; font-style: italic; letter-spacing: .01em; white-space: nowrap; opacity: .8; transform: rotate(-3deg); z-index: 2; }
.lab-note svg { width: 56px; height: 44px; flex: none; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lab-note path { stroke-dasharray: var(--len, 120); stroke-dashoffset: var(--len, 120); transition: stroke-dashoffset 1.1s cubic-bezier(.2,.7,.2,1) .2s; }
.lab-note.in path { stroke-dashoffset: 0; }
.lab-note.hero-note { left: 6px; top: calc(100% + 10px); }
.lab-note.head-note { left: calc(100% + 12px); top: -2px; }
.lab-note.bb-note { right: 8px; top: 4px; display: none; }
@media (min-width: 900px) { .lab-note.bb-note { display: flex; } }
@media (max-width: 520px) { .lab-note.head-note { display: none; } }

/* ---------- 5. typing terminal ---------- */
.lab-term { position: relative; padding-top: clamp(40px, 7vw, 88px); padding-bottom: 0; }
.lab-term .win { border: 1.5px solid var(--ink); border-radius: var(--r-lg, 18px); background: var(--white); overflow: hidden; max-width: 860px; }
.lab-term .bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--g200); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--g600); }
.lab-term .bar i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; }
.lab-term .bar span { margin-left: auto; }
.lab-term .log { padding: 16px 16px 6px; min-height: 168px; max-height: 300px; overflow-y: auto; font-size: 14px; line-height: 1.6; overscroll-behavior: contain; }
.lab-term .log p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.lab-term .log .u { color: var(--g600); }
.lab-term .log a { text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.lab-term .cur { display: inline-block; width: .55em; height: 1.05em; background: var(--ink); vertical-align: -2px; animation: labBlink 1s steps(2, jump-none) infinite; margin-left: 2px; }
.lab-term form { display: flex; align-items: center; gap: 8px; padding: 6px 16px 14px; font-size: 14px; }
.lab-term form .ps { color: var(--g600); white-space: nowrap; }
.lab-term input { flex: 1; min-width: 0; min-height: 44px; border: 0; border-bottom: 1px dashed var(--g300); background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 0 2px; border-radius: 0; }
.lab-term input:focus { outline: none; border-bottom-color: var(--ink); }
.lab-term .chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.lab-term .chips button { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--g300); background: var(--white); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; }
.lab-term .chips button:hover { border-color: var(--ink); }

/* ---------- 6. sensor dashboard ---------- */
.lab-sensors { position: relative; padding-bottom: 0; }
.lab-sensors .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
@media (min-width: 760px) { .lab-sensors .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.lab-sensors .rd { border: 1.5px solid var(--g200); border-radius: var(--r-lg, 18px); background: var(--white); padding: 16px 16px 14px; position: relative; overflow: hidden; }
.lab-sensors .rd small { display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--g600); }
.lab-sensors .rd b { display: block; font-size: clamp(24px, 4.4vw, 34px); letter-spacing: -.03em; line-height: 1.15; margin-top: 8px; font-variant-numeric: tabular-nums; }
.lab-sensors .rd b u { text-decoration: none; font-size: .5em; font-weight: 500; color: var(--g600); margin-left: 3px; letter-spacing: 0; }
.lab-sensors .rd em { display: block; font-style: normal; font-size: 12px; color: var(--g600); margin-top: 4px; min-height: 1.3em; }
.lab-sensors .rd.date b { font-size: clamp(18px, 3vw, 24px); }
.lab-sensors .rd::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--ink) var(--p, 0%), transparent 0); opacity: .75; transition: --p .6s; }
.lab-sensors .stat { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--g600); margin-top: 14px; display: flex; gap: 8px; align-items: center; }
.lab-sensors .stat i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); display: inline-block; }
.lab-sensors .stat.off i { background: transparent; border: 1.5px solid var(--g600); }

/* ---------- 7. periodic-table navigation ---------- */
.nav a.el { position: relative; width: 62px; height: 54px; padding: 0; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--white); color: var(--ink); display: block; overflow: hidden; transition: background .2s, color .2s; }
.nav a.el:hover { background: var(--white); color: var(--ink); }
.nav { gap: 8px; align-items: center; }
.nav .el-front, .nav .el-back { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .28s cubic-bezier(.4, 0, .2, 1); }
.nav .el-front sup { position: absolute; left: 6px; top: 4px; font-size: 9px; font-weight: 600; opacity: .65; line-height: 1; }
.nav .el-front b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.nav .el-back { font-size: 11.5px; font-weight: 700; letter-spacing: .02em; transform: scaleX(0); }
.nav a.el:hover .el-front, .nav a.el:focus-visible .el-front { transform: scaleX(0); }
.nav a.el:hover .el-back, .nav a.el:focus-visible .el-back { transform: scaleX(1); transition-delay: .14s; }
.nav a.el[aria-current="page"] { background: var(--black); color: var(--white); font-weight: inherit; }
.nav a.el[aria-current="page"]:hover { background: var(--black); color: var(--white); }
#menu nav a .el-badge { display: inline-grid; place-items: center; width: 40px; height: 40px; margin-right: 14px; border: 1.5px solid var(--ink); border-radius: 8px; font-size: 15px; font-weight: 700; letter-spacing: -.02em; vertical-align: middle; position: relative; top: -3px; }

/* ---------- 8. microscope lens ---------- */
.lab-lens { position: fixed; z-index: 96; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%; border: 2px solid var(--ink); background-color: var(--white); background-repeat: no-repeat; pointer-events: none; opacity: 0; transform: scale(.8); transition: opacity .15s, transform .15s; box-shadow: 0 8px 30px rgba(0, 0, 0, .18), inset 0 0 0 4px rgba(255, 255, 255, .6); }
.lab-lens.on { opacity: 1; transform: none; }
.lab-lens::before, .lab-lens::after { content: ""; position: absolute; background: var(--ink); opacity: .35; }
.lab-lens::before { left: 50%; top: 14px; bottom: 14px; width: 1px; }
.lab-lens::after { top: 50%; left: 14px; right: 14px; height: 1px; }

/* ---------- 9. loader (test tube) ---------- */
.lab-loader { position: fixed; inset: 0; z-index: 500; background: var(--white); display: grid; place-items: center; align-content: center; gap: 18px; transition: opacity .55s ease, visibility 0s linear .55s; animation: labFailsafe 0s linear 6s forwards; }
.lab-loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.lab-loader svg { width: 70px; height: 170px; overflow: visible; }
.lab-loader .cap { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--g600); text-align: center; }
.lab-loader .pc { font-size: 36px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.lab-noload .lab-loader { display: none; }
@keyframes labFailsafe { to { visibility: hidden; opacity: 0; } }

/* ---------- 10. dock: lab-mode + sound buttons ---------- */
.lab-dock { position: fixed; left: 14px; bottom: 16px; z-index: 125; display: flex; gap: 8px; }
.lab-dock button { min-height: 44px; padding: 0 14px 0 12px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink); display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; cursor: pointer; }
.lab-dock button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.lab-dock button[aria-pressed="true"] { background: var(--black); color: var(--white); }
body:has(.sticky-bar.show) .lab-dock { bottom: 88px; }
@media (max-width: 480px) { .lab-dock button .lbl { display: none; } .lab-dock button.snd .lbl { display: inline; } }

/* ---------- 11. easter-egg game ---------- */
.lab-game { position: fixed; inset: 0; z-index: 600; background: rgba(255, 255, 255, .94); display: none; place-items: center; padding: 16px; }
.lab-game.open { display: grid; }
.lab-game .box { width: min(420px, 100%); border: 1.5px solid var(--ink); border-radius: var(--r-lg, 18px); background: var(--white); padding: 14px; }
.lab-game .hd { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 10px; }
.lab-game .hd b { font-size: 13px; letter-spacing: .08em; }
.lab-game canvas { width: 100%; aspect-ratio: 3 / 4; display: block; border: 1px solid var(--g300); border-radius: 12px; touch-action: none; background: var(--white); }
.lab-game .x { min-width: 44px; min-height: 44px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--white); font-size: 18px; cursor: pointer; }
.lab-game p { font-size: 12px; color: var(--g600); margin-top: 10px; text-align: center; }

/* ---------- 12. LAB MODE: X-ray / wireframe view (outlines only) ---------- */
html.lab-xray body { background: var(--white); }
html.lab-xray body *:not(.lab-keep):not(.lab-keep *) {
  background: transparent !important; background-image: none !important; box-shadow: none !important; text-shadow: none !important;
  color: var(--ink) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  outline: 1px solid rgba(17, 17, 17, .4); outline: 1px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: -1px;
}
html.lab-xray svg *:not(.lab-keep *) { fill: none !important; stroke: var(--ink) !important; outline: none !important; }
html.lab-xray img { filter: grayscale(1) contrast(1.8) brightness(1.25); opacity: .5; mix-blend-mode: multiply; }
html.lab-xray .layer .drawer-panel, html.lab-xray .layer .modal-panel, html.lab-xray .search-panel, html.lab-xray #menu,
html.lab-xray .sticky-bar, html.lab-xray .cookie, html.lab-xray #toasts > *, html.lab-xray .filters.open,
html.lab-xray input, html.lab-xray select, html.lab-xray textarea { background: var(--white) !important; }
html.lab-xray .lab-tag, html.lab-xray .lab-note { background: var(--white) !important; }

/* ---------- Lenis (smooth scroll) housekeeping ---------- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

/* ---------- print + reduced motion ---------- */
@media print { .lab-bg, .lab-fx, .lab-hud, .lab-dock, .lab-loader, .lab-lens, .lab-game, body::before { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  .lab-hud .dot, .lab-term .cur { animation: none; }
  .lab-note path { transition: none; stroke-dashoffset: 0; }
  .nav .el-front, .nav .el-back, .lab-lens { transition: none; }
}
