@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #e4e8f0;
  --border: #d3d9e3;
  --text: #10131a;
  --text-dim: #565f70;
  --accent: #2f6fed;
  --accent-dim: #e4ecff;
  --ok: #17a673;
  --ok-bg: #e2f6ee;
  --warn: #d98c12;
  --warn-bg: #fbeed8;
  --radius: 14px;
  --max-width: 880px;
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

header.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  max-width: 1080px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
  display: inline-block;
}

nav.site-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  margin-left: 22px;
}

nav.site-nav a:hover { color: var(--text); }

main { flex: 1; }

.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 44px 20px 8px;
  text-align: center;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.5vw, 2.5rem);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--text-dim);
  font-size: 1.02rem;
  max-width: 640px;
  margin: 0 auto;
}

.os-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* --- Device tab switcher --- */
.device-tabs {
  max-width: 1080px;
  margin: 26px auto 0;
  padding: 0 20px;
  display: flex;
  justify-content: center;
}

.device-tabs .tab-track {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}

.device-tab {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.device-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(16, 19, 26, 0.12);
}

.ad-slot {
  max-width: 1080px;
  margin: 18px auto;
  padding: 0 20px;
  min-height: 12px;
}

.test-panel { display: none; }
.test-panel.active { display: block; }

.test-wrap {
  max-width: 1080px;
  margin: 8px auto 0;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

@media (max-width: 820px) {
  .test-wrap { grid-template-columns: 1fr; }
}

.canvas-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.canvas-toolbar h2 {
  font-size: 0.95rem;
  margin: 0;
  color: var(--text-dim);
  font-weight: 600;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

select.layout-select {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

button.reset-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  cursor: pointer;
}

button.reset-btn:hover { background: var(--border); }

#test-canvas {
  display: block;
  width: 100%;
  height: 420px;
  touch-action: none;
  cursor: crosshair;
  background:
    linear-gradient(var(--surface-2) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--surface-2) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--surface);
}

.hint-bar {
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 76px;
}

.results-panel h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

.check-item .label { display: flex; align-items: center; gap: 8px; }

.check-item .status {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.check-item.detected {
  background: var(--ok-bg);
}

.check-item.detected .status { color: var(--ok); }

.check-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex: none;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.check-item.detected .check-icon {
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-bg), 0 0 8px rgba(23, 166, 115, 0.6);
}

.live-readout {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.8;
}

.live-readout code {
  color: var(--text);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* --- Keyboard test --- */
.keyboard-wrap {
  padding: 22px 16px;
  overflow-x: auto;
}

.keyboard {
  --key-size: 44px;
  --key-gap: 6px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
  width: max-content;
  margin: 0 auto;
}

/* Full-size (16" laptop / external board with numpad) packs three blocks
   side by side, so the keys shrink to keep the whole thing on screen. */
.keyboard.size-full {
  --key-size: 36px;
  --key-gap: 5px;
}

/* Full size needs the whole content width — drop the sidebar below it. */
#panel-keyboard.kb-full .test-wrap { grid-template-columns: 1fr; }

.kb-section {
  display: flex;
  flex-direction: column;
  gap: var(--key-gap);
}

.kb-main   { width: calc(15 * var(--key-size) + 14 * var(--key-gap)); }
.kb-nav    { width: calc(3  * var(--key-size) + 2  * var(--key-gap)); }
.kb-numpad { width: calc(4  * var(--key-size) + 3  * var(--key-gap)); }

.kb-row {
  display: flex;
  gap: var(--key-gap);
}

/* vertical breathing room between key clusters (e.g. above the arrows) */
.kb-rowgap { height: calc(var(--key-size) * 0.6); }

.kb-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: var(--key-size);
  gap: var(--key-gap);
}

.key {
  flex-basis: 0;
  flex-shrink: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 7px;
  height: var(--key-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: calc(var(--key-size) * 0.30);
  font-weight: 600;
  color: var(--text);
  user-select: none;
  overflow: hidden;
  transition: transform 0.05s ease, background 0.1s ease, box-shadow 0.1s ease;
}

/* grid cells size from the grid track, not from flex */
.kb-grid .key { height: auto; flex-basis: auto; }

.key.wide-label { font-size: calc(var(--key-size) * 0.22); }

/* keys the OS swallows before the browser sees them (fn) */
.key.dead { opacity: 0.4; border-bottom-width: 1px; }

.kb-gap { flex-basis: 0; flex-shrink: 1; min-width: 0; }

/* stays on once a key has been pressed, so you can see what's been covered */
.key.tested {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

/* held down right now — wins over .tested, so a re-press still reads as a press */
.key.pressed {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  transform: translateY(2px);
  box-shadow: 0 0 10px rgba(23, 166, 115, 0.45);
}

/* --- "What you've typed" readout --- */
.type-output {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
}

.type-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.type-output-head span {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
}

.typed-text {
  min-height: 66px;
  max-height: 150px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.typed-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  vertical-align: -0.15em;
  animation: caret-blink 1.1s step-end infinite;
}

.typed-text.is-empty { color: var(--text-dim); }
.typed-text.is-empty::after { display: none; }

@keyframes caret-blink { 50% { opacity: 0; } }

.keyboard-readout {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kv {
  display: flex;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

.kv .k { color: var(--text-dim); }
.kv .v { font-family: var(--font-mono); font-weight: 600; }

.mod-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.mod-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: uppercase;
}

.mod-pill.active {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

/* --- Mouse test --- */
.mouse-surface {
  padding: 30px 16px 10px;
  display: flex;
  justify-content: center;
  touch-action: none;
  cursor: pointer;
}

.mouse-diagram {
  position: relative;
  width: 180px;
  height: 260px;
  flex: none;
}

.mouse-body {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 90px 90px 46px 46px;
  pointer-events: none;
}

.mouse-divider {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 1px;
  height: 42%;
  background: var(--border);
  pointer-events: none;
}

.mouse-zone {
  position: absolute;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  border-radius: 80px 80px 10px 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: background 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
}

.mouse-zone.active {
  background: var(--ok-bg);
  color: var(--ok);
  box-shadow: inset 0 0 0 2px var(--ok), 0 0 14px rgba(23, 166, 115, 0.4);
}

.zone-left { top: 6px; left: 6px; width: calc(50% - 10px); height: 42%; border-radius: 80px 8px 8px 8px; }
.zone-right { top: 6px; right: 6px; width: calc(50% - 10px); height: 42%; border-radius: 8px 80px 8px 8px; }

.zone-wheel {
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 30%;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  align-items: center;
  padding: 0;
}

.zone-side {
  left: -14px;
  width: 22px;
  height: 15%;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-items: center;
  padding: 0;
  writing-mode: vertical-rl;
}

.zone-back { top: 52%; }
.zone-forward { top: 70%; }

.mouse-hint {
  align-self: center;
  max-width: 300px;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.6;
  padding-left: 30px;
}

@media (max-width: 560px) {
  .mouse-surface { flex-direction: column; align-items: center; gap: 18px; }
  .mouse-hint { padding-left: 0; text-align: center; }
}

.help-section {
  max-width: 1080px;
  margin: 40px auto 0;
  padding: 0 20px 10px;
}

.help-section h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 14px;
}

.help-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.help-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--text);
}

.help-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-family: var(--font-display);
}

.help-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

footer.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 50px;
  padding: 24px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
}

footer.site-footer a {
  color: var(--text-dim);
  margin: 0 8px;
}

/* --- Blog / static page layout --- */
.article {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.article .kicker {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin: 8px 0 6px;
  letter-spacing: -0.01em;
}

.article .meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 30px;
  font-family: var(--font-mono);
}

.article h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 34px 0 10px;
}

.article p, .article li {
  line-height: 1.75;
  font-size: 1rem;
  color: var(--text);
}

.article ol, .article ul {
  padding-left: 22px;
}

.cta-box {
  margin: 26px 0;
  padding: 18px 20px;
  background: var(--accent-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cta-box p { margin: 0; font-weight: 600; color: var(--text); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}
