﻿/* ============================================================
   GearNas Keyboard Simulator -- Keyboard Layout & Animations
   Dark / Purple Glass-Morphism
   ============================================================ */

/* -- Stage & Scaler ------------------------------------------ */
.keyboard-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0 16px;
  overflow-x: auto;
  padding-bottom: var(--kb-bottom-pad, 0px);
}

.keyboard-scaler {
  transform: scale(var(--kb-scale, 1));
  transform-origin: top center;
  transition: transform 200ms ease;
}

/* -- Keyboard Case ------------------------------------------- */
.keyboard-case {
  display: inline-flex;
  flex-direction: column;
  padding: 16px 18px 20px;
  user-select: none;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 0 60px rgba(80,20,180,0.18),
    0 20px 60px rgba(0,0,0,0.7),
    0 4px 0 rgba(255,255,255,0.04) inset;
}

/* -- LED Bar -------------------------------------------------- */
.led-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 4px 10px;
}

.led-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
}

.led-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-faint);
  border: 1px solid rgba(255,255,255,0.1);
  transition: background 150ms ease, box-shadow 150ms ease;
}

.led-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--color-text-faint);
  text-transform: uppercase;
}

.led-indicator.active .led-dot {
  background: var(--color-accent-light);
  box-shadow: 0 0 6px var(--color-accent-light), 0 0 12px var(--color-accent-glow);
}

.led-indicator.active .led-label {
  color: var(--color-accent-light);
}

/* -- Keyboard Body ------------------------------------------- */
.keyboard-body {
  display: flex;
  flex-direction: column;
  gap: var(--key-gap);
}

/* -- Section Layout: 4 sections side by side ---------------- */
.kb-sections-wrapper {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: calc(var(--key-unit) * 0.65);
}

/* Each section is a column of rows */
.kb-section {
  display: flex;
  flex-direction: column;
  gap: var(--key-gap);
}

/* -- Rows ---------------------------------------------------- */
.kb-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: var(--key-gap);
}

/* Empty row spacer: same height as one key */
.kb-row-spacer {
  height: var(--key-height);
}

/* Gap between PrtSc row and Ins/Del rows */
.kb-section-nav-arrow .kb-row:first-child {
  margin-bottom: calc(var(--key-height) * 0.32);
}

/* Numpad: CSS Grid with 4 columns, auto rows */
.kb-section-numpad {
  display: grid;
  grid-template-columns: repeat(4, var(--key-unit));
  grid-auto-rows: var(--key-height);
  gap: var(--key-gap);
  /* Align NumLock row with the Num/Number row of the main block */
  margin-top: calc(var(--key-height) * 1.32 + var(--key-gap));
}

.kb-section-numpad .key {
  width: 100%;
  height: 100%;
  min-width: 0;
}

/* -- Gap Spacer (non-interactive, fills space inside a row) -- */
.kb-gap-spacer {
  width: calc(var(--key-unit) * var(--w, 0.5));
  flex-shrink: 0;
  pointer-events: none;
}

/* -- Base Key ------------------------------------------------ */
.key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--key-unit);
  height: var(--key-height);
  flex-shrink: 0;

  font-family: var(--font-key);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: 0.2px;

  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-top: 1px solid var(--key-border-top);
  border-radius: var(--key-radius);
  box-shadow: var(--key-shadow);

  cursor: pointer;
  transition:
    background var(--transition-key),
    box-shadow var(--transition-key),
    transform var(--transition-key),
    border-color var(--transition-key);

  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Width multiplier: JS writes style="--w: X" on the element */
.key[style*="--w"] {
  width: calc(var(--key-unit) * var(--w) + var(--key-gap) * (var(--w) - 1));
}

/* Subtle top-face gloss */
.key::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--key-radius);
  background: linear-gradient(160deg, rgba(255,255,255,0.07) 0%, transparent 55%);
  pointer-events: none;
}

/* -- Key Hover ---------------------------------------------- */
.key:hover {
  background: var(--key-bg-hover);
  border-color: rgba(255,255,255,0.18);
  box-shadow: var(--key-shadow), 0 0 8px rgba(124,58,237,0.12);
}

/* -- Key Active (pressed) ----------------------------------- */
.key.active,
.key:active {
  background: var(--key-bg-active);
  transform: translateY(2px);
  box-shadow: var(--key-shadow-active);
  border-color: var(--color-accent);
  color: var(--color-accent-light);
}

.key.active::before {
  background: linear-gradient(160deg, rgba(167,139,250,0.12) 0%, transparent 55%);
}

/* -- Tall Key (numpad + and Enter, span 2 rows) ------------- */
.key.key-tall {
  height: calc(var(--key-height) * 2 + var(--key-gap));
}

/* -- Key Legends -------------------------------------------- */
.key-main {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
}

.key-shift {
  font-size: 9px;
  font-weight: 400;
  color: var(--color-text-muted);
  line-height: 1;
  pointer-events: none;
  margin-bottom: 2px;
}

.key.dual-label {
  justify-content: space-between;
  padding: 5px 5px 4px;
  align-items: flex-start;
}

.key.dual-label .key-shift { align-self: flex-start; }
.key.dual-label .key-main  { align-self: flex-start; }

/* -- Special Key Types -------------------------------------- */
.key.fn-key  { font-size: 10px; color: var(--color-text-muted); }
.key.mod-key { font-size: 10px; color: var(--color-text-muted); }
.key.numpad-key { font-size: 11px; }
.key.arrow-key  { font-size: 13px; }

.key.space-key .key-main {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

/* Caps Lock: persistent accent border when toggled on */
.key.caps-active {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 8px var(--color-accent-dim) !important;
}

/* -- Bootstrap overrides ------------------------------------ */
.spinner-border.text-accent {
  color: var(--color-accent-light) !important;
}

