/* ===== Shared interactive layer: dark mode, palette, chat, contact form, bug hunt ===== */

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --bg: #0D1520;
  --card: #141F2B;
  --ink: #E6EDF3;
  --navy: #8AB8E8;
  --muted: #8AA0B4;
  --line: #243342;
}
:root[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
:root[data-theme="dark"] .btn.primary { background: #1B4A75; border-color: #1B4A75; color: #fff; }
:root[data-theme="dark"] .contact-card { background: #10263C; }
:root[data-theme="dark"] .job::before { background: var(--bg); }
:root[data-theme="dark"] .testrun, :root[data-theme="dark"] .chip, :root[data-theme="dark"] .postcard { box-shadow: none; }
:root[data-theme="dark"] .job li { color: #B9C9D6; }
:root[data-theme="dark"] h1, :root[data-theme="dark"] .job-head h3 { color: #F2F7FB; }

/* ---------- Top control cluster ---------- */
.topctl { position: absolute; top: 26px; display: flex; gap: 8px; z-index: 40; }
html[dir="ltr"] .topctl { right: 24px; }
html[dir="rtl"] .topctl { left: 24px; }
.topctl .lang-switch { position: static; }
.ctl-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 13.5px; font-weight: 500;
  color: var(--navy);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.ctl-btn:hover { border-color: var(--navy); }

/* ---------- Command palette ---------- */
.pal-overlay {
  position: fixed; inset: 0; background: rgba(13, 21, 32, 0.55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 14vh 20px 0; z-index: 100; backdrop-filter: blur(2px);
}
.pal-overlay.open { display: flex; }
.pal {
  width: 100%; max-width: 520px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.35); overflow: hidden;
  font-family: "JetBrains Mono", monospace; direction: ltr; text-align: left;
}
.pal input {
  width: 100%; border: 0; outline: none; background: transparent;
  color: var(--ink); font: inherit; font-size: 15px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.pal input::placeholder { color: var(--muted); }
.pal ul { list-style: none; margin: 0; padding: 8px; max-height: 320px; overflow-y: auto; }
.pal li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 8px; font-size: 14px;
  color: var(--ink); cursor: pointer;
}
.pal li .k { color: var(--muted); font-size: 12px; }
.pal li.sel, .pal li:hover { background: rgba(11, 58, 102, 0.09); color: var(--navy); }
:root[data-theme="dark"] .pal li.sel, :root[data-theme="dark"] .pal li:hover { background: rgba(138, 184, 232, 0.12); }
.pal li .cmd-ico { color: var(--pass); margin-right: 10px; }

/* ---------- Chat widget ---------- */
.chat-fab {
  position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 90;
  font-family: "JetBrains Mono", monospace; font-size: 13.5px; font-weight: 600;
  background: var(--navy); color: #fff; border: 0; border-radius: 999px;
  padding: 13px 20px; cursor: pointer; box-shadow: 0 8px 24px rgba(11,58,102,0.35);
}
:root[data-theme="dark"] .chat-fab { background: #1B4A75; }
.chat-panel {
  position: fixed; bottom: 84px; inset-inline-end: 22px; z-index: 95;
  width: min(360px, calc(100vw - 32px)); height: min(480px, 70vh);
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.chat-head .dot-live { color: var(--pass); }
.chat-head button { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.chat-msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
:root[data-theme="dark"] .chat-msg.user { background: #1B4A75; }
.chat-msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.bot.typing { color: var(--muted); font-family: "JetBrains Mono", monospace; }
.chat-note { font-size: 11px; color: var(--muted); text-align: center; padding: 0 14px 6px; }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-input input {
  flex: 1; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 10px; padding: 10px 13px; font: inherit; font-size: 14px; outline: none;
}
.chat-input input:focus { border-color: var(--navy); }
.chat-input button {
  border: 0; background: var(--navy); color: #fff; border-radius: 10px;
  padding: 0 16px; font-weight: 600; cursor: pointer; font-size: 14px;
}
:root[data-theme="dark"] .chat-input button { background: #1B4A75; }

/* ---------- Contact form ---------- */
.cform { max-width: 460px; margin: 0 auto 26px; text-align: start; display: grid; gap: 10px; }
.cform input, .cform textarea {
  width: 100%; border: 1px solid rgba(232, 239, 246, 0.3); background: rgba(255,255,255,0.06);
  color: #fff; border-radius: 10px; padding: 11px 14px; font: inherit; font-size: 14.5px; outline: none;
}
.cform input::placeholder, .cform textarea::placeholder { color: #9FB4C6; }
.cform input:focus, .cform textarea:focus { border-color: #4ADE80; }
.cform textarea { min-height: 96px; resize: vertical; }
.cform .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cform button[type="submit"] {
  border: 0; background: #1A9E5C; color: #fff; font-weight: 700; font-size: 15px;
  border-radius: 10px; padding: 12px; cursor: pointer;
}
.cform button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }
.cform .cf-status { font-family: "JetBrains Mono", monospace; font-size: 13px; min-height: 18px; }
.cform .cf-status.ok { color: #4ADE80; }
.cform .cf-status.err { color: #FF9B9B; }
.cform-divider { color: #9FB4C6; font-size: 13px; margin-bottom: 18px; font-family: "JetBrains Mono", monospace; }

/* ---------- Bug hunt ---------- */
.bug { all: unset; cursor: inherit; }
.chip.bug-rot { display: inline-block; transform: rotate(180deg); }
.bug:focus-visible { outline: 2px dashed var(--pass); outline-offset: 2px; }
.bug.found { text-decoration: line-through; text-decoration-color: var(--pass); opacity: 0.75; }
.lights .bug-light { width: 10px; height: 10px; background: var(--line); display: inline-block; }
.lights .bug-light.sq { border-radius: 2px; }
.lights .bug-light.found { background: var(--pass); border-radius: 50%; }
.bug-toast {
  position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 90;
  background: var(--card); border: 1px solid var(--pass); border-radius: 12px;
  font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--ink);
  padding: 12px 16px; max-width: 320px; box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.bug-toast.show { opacity: 1; transform: none; }
.bug-toast .t1 { color: var(--pass); font-weight: 600; }
.bug-modal {
  position: fixed; inset: 0; z-index: 110; display: none;
  align-items: center; justify-content: center; background: rgba(13,21,32,0.6); padding: 20px;
}
.bug-modal.open { display: flex; }
.bug-modal .box {
  background: var(--card); border: 1px solid var(--pass); border-radius: 16px;
  max-width: 440px; padding: 30px 28px; text-align: center;
  font-family: "JetBrains Mono", monospace;
}
.bug-modal .box h3 { color: var(--pass); font-size: 17px; margin-bottom: 12px; font-family: "JetBrains Mono", monospace; }
.bug-modal .box p { font-size: 14px; color: var(--ink); line-height: 1.6; margin-bottom: 18px; }
.bug-modal .box a.hire {
  display: inline-block; background: var(--pass); color: #fff; text-decoration: none;
  font-weight: 700; border-radius: 10px; padding: 11px 20px; font-size: 14px;
}
.bug-modal .box button { background: none; border: 0; color: var(--muted); margin-top: 12px; cursor: pointer; font: inherit; font-size: 12.5px; display: block; width: 100%; }
.bug-hint { font-size: 12px; opacity: 0.85; }

@media (prefers-reduced-motion: reduce) {
  .bug-toast { transition: none; }
}
@media (max-width: 560px) {
  .topctl { top: 18px; }
  .chat-panel { bottom: 78px; }
}
