/**
 * Simple Kids Mode (WeDo 2.0 Style) Stylesheet
 * Tactile, chunky, icon-first horizontal puzzle blocks and bottom ribbon dock.
 */

/* =========================================================
   1. Chunky Icon Blocks (Horizontal Puzzle Connectors)
   ========================================================= */

/* =========================================================
   1. Chunky Icon Blocks (Horizontal Puzzle Connectors)
   ========================================================= */

.simple-block-element {
  display: inline-flex;
  flex-direction: row;
  align-items: flex-start;
  position: absolute;
  width: max-content;
  height: max-content;
  user-select: none;
  cursor: grab;
  touch-action: none;
  z-index: 10;
  transition: transform 0.08s ease;
}

/* Sub-blocks connected in horizontal chain: flow seamlessly to the right! */
.simple-block-element .simple-block-element {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  margin-left: -2px !important;
  flex-shrink: 0;
  filter: none !important;
}

.workspace-canvas.is-simple-mode {
  padding-bottom: 160px;
}

.simple-block-element:active {
  cursor: grabbing;
}

.simple-block-element.is-palette {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  cursor: grab;
  margin: 0 6px;
  flex-shrink: 0;
}

.simple-block-element.is-palette:hover {
  transform: translateY(-3px) scale(1.04);
}

/* Main Tactile Square Tile (76px × 76px) */
.simple-block-body {
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background-color: var(--simple-color, #ffb800);
  border: 3.5px solid var(--simple-border, #d49700);
  border-radius: 14px;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.16), inset 0 2px 3px rgba(255, 255, 255, 0.45);
  box-sizing: border-box;
  pointer-events: auto;
}

/* Start Block (Rounded / Flat Left Edge) */
.simple-block-body.is-start-body {
  border-top-left-radius: 24px;
  border-bottom-left-radius: 24px;
}

/* Horizontal Right Puzzle Tab */
.simple-tab-right {
  position: absolute;
  right: -13px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 28px;
  background-color: var(--simple-color, #ffb800);
  border: 3.5px solid var(--simple-border, #d49700);
  border-left: none;
  border-radius: 0 8px 8px 0;
  z-index: 5;
  box-shadow: 3px 0 4px rgba(0, 0, 0, 0.08);
}

/* Horizontal Left Notch Indicator */
.simple-notch-left {
  position: absolute;
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 28px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 0 8px 8px 0;
  z-index: 2;
}

.simple-block-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.simple-icon-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15));
}

/* Value Badge (Number / Color / Sound parameter) */
.simple-val-badge {
  position: absolute;
  bottom: -6px;
  right: -4px;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ffffff;
  border: 2px solid #334155;
  color: #1e293b;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 15;
  transition: transform 0.1s ease;
}

.simple-val-badge:hover {
  transform: scale(1.15);
}

.simple-val-badge.badge-color_picker,
.simple-val-badge.badge-message_picker,
.simple-val-badge.badge-color_cycle,
.simple-val-badge.badge-distance_picker {
  width: 24px;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

/* =========================================================
   2. Horizontal Loop Bracket
   ========================================================= */

.simple-loop-container {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  margin-left: 2px;
  flex-shrink: 0;
}

.simple-loop-inner-slot {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  min-width: 80px;
  min-height: 80px;
  background-color: rgba(0, 0, 0, 0.06);
  border: 2.5px dashed var(--simple-border, #ea580c);
  border-radius: 14px;
  padding: 2px 6px;
  box-sizing: border-box;
}

.simple-loop-inner-slot > .simple-block-element {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  margin-left: 0 !important;
}

.simple-loop-right-bar {
  width: 14px;
  height: 76px;
  background-color: var(--simple-border, #ea580c);
  border-radius: 0 10px 10px 0;
  margin-left: 2px;
  flex-shrink: 0;
}

/* =========================================================
   3. Dragging & Active Execution Glow
   ========================================================= */

.simple-block-element.block-dragging {
  z-index: 1000 !important;
  opacity: 0.95;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
  transform: scale(1.04);
}

.simple-block-element.block-executing > .simple-block-body {
  animation: simpleExecutingPulse 0.8s infinite ease-in-out !important;
  z-index: 50 !important;
}

@keyframes simpleExecutingPulse {
  0% {
    box-shadow: 0 0 0 4px #ffe600, 0 0 20px 6px rgba(255, 230, 0, 0.9), inset 0 0 6px rgba(255, 255, 255, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px #fff566, 0 0 32px 10px rgba(255, 230, 0, 1), inset 0 0 10px rgba(255, 255, 255, 0.9);
  }
  100% {
    box-shadow: 0 0 0 4px #ffe600, 0 0 20px 6px rgba(255, 230, 0, 0.9), inset 0 0 6px rgba(255, 255, 255, 0.7);
  }
}

/* =========================================================
   4. Bottom Ribbon Palette Dock
   ========================================================= */

.simple-palette-dock {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 146px;
  background: #ffffff;
  border-top: 3.5px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 150;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
}

.simple-palette-tabs {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  overflow-x: auto;
  overflow-y: hidden;
}

.simple-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 2px solid var(--btn-border, #cbd5e1);
  background: var(--btn-color, #475569);
  color: #ffffff !important;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: all 0.16s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  opacity: 0.88;
}

.simple-tab-btn:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.simple-tab-btn.is-active {
  opacity: 1 !important;
  transform: scale(1.06);
  box-shadow: 0 0 0 3px #ffffff, 0 4px 14px rgba(0, 0, 0, 0.28);
  border-color: #ffffff;
  z-index: 2;
}

.simple-tab-btn .tab-cat-icon {
  font-size: 15px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.simple-tab-btn .tab-cat-name {
  color: #ffffff !important;
}

/* 5. Continuous Horizontal Tray (All Blocks in One Scrolling Menu) */
.simple-palette-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  padding: 0 6px;
}

.simple-palette-nav-btn {
  width: 28px;
  height: 80px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.16s ease;
  user-select: none;
  touch-action: manipulation;
  z-index: 5;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  margin: 0 3px;
}

.simple-palette-nav-btn:hover:not(:disabled) {
  background: #3b82f6;
  border-color: #2563eb;
  color: #ffffff;
  transform: scale(1.06);
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.35);
}

.simple-palette-nav-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.simple-palette-nav-btn:disabled,
.simple-palette-nav-btn.is-disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
  border-color: #e2e8f0;
}

.nav-arrow-svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.simple-palette-nav-btn.btn-nav-left:hover:not(:disabled) .nav-arrow-svg {
  transform: translateX(-2px);
}

.simple-palette-nav-btn.btn-nav-right:hover:not(:disabled) .nav-arrow-svg {
  transform: translateX(2px);
}

.simple-palette-tray {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  flex: 1;
  scroll-behavior: smooth;
}

.simple-palette-group {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.simple-group-items {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.simple-palette-divider {
  width: 2px;
  height: 64px;
  background: #e2e8f0;
  border-radius: 1px;
  margin: 0 4px;
  flex-shrink: 0;
}

.simple-palette-tray::-webkit-scrollbar {
  height: 7px;
}

.simple-palette-tray::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.simple-palette-tray::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================================================
   5. Interactive Popovers (Keypad, Colors, Sounds)
   ========================================================= */

.simple-popover {
  position: fixed;
  z-index: 3000;
  width: max-content;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  border: 3px solid #334155;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  animation: popoverFadeIn 0.12s ease-out;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.stepper-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.btn-step-minus,
.btn-step-plus {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s ease;
}

.btn-step-minus:hover,
.btn-step-plus:hover {
  background: #e2e8f0;
}

.stepper-display {
  font-size: 26px;
  font-weight: 900;
  min-width: 48px;
  text-align: center;
  color: #0f172a;
}

.stepper-quick-presets {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.btn-quick-val {
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-quick-val:hover {
  background: #3b82f6;
  border-color: #2563eb;
  color: #ffffff;
}

.color-palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 38px);
  gap: 8px;
}

.color-palette-grid.color-palette-10 {
  grid-template-columns: repeat(5, 36px);
  gap: 8px;
}

.message-palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 40px);
  gap: 8px;
}

.btn-palette-color {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.12s ease, outline 0.12s ease;
}

.btn-palette-msg {
  width: 40px;
  height: 40px;
}

.btn-palette-color:hover {
  transform: scale(1.18);
}

.btn-palette-color.is-selected {
  outline: 3px solid #0f172a;
  outline-offset: 2px;
  transform: scale(1.12);
}

.btn-palette-color[data-hex="#ffffff"] {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 0 0 1.5px rgba(0, 0, 0, 0.35);
}

.btn-palette-color[data-hex="#000000"] {
  border-color: #64748b;
}

.sound-palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 46px);
  gap: 8px;
}

.btn-palette-sound {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background 0.1s ease;
}

.btn-palette-sound:hover {
  background: #f3e8ff;
  border-color: #a855f7;
  transform: scale(1.1);
}

/* Badges for distance, tilt, key pickers */
.simple-val-badge.badge-tilt_picker {
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #94a3b8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  width: 24px;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.simple-val-badge.badge-tilt_picker:hover {
  border-color: #0284c7;
  transform: scale(1.15);
}

.simple-val-badge.badge-key_picker {
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #94a3b8;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
}

/* 4-Range Visual Distance Ruler Popover */
.simple-dist-picker {
  min-width: 140px;
}

.dist-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.btn-dist-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-dist-card:hover {
  background: #f1f5f9;
  border-color: #0284c7;
  transform: scale(1.02);
}

.btn-dist-card.is-selected {
  background: #e0f2fe;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px #0284c7;
}

.dist-ruler-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
}

.ruler-num {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 900;
  color: #0f172a;
  min-width: 16px;
  text-align: center;
}

.ruler-bar {
  display: flex;
  align-items: center;
}

.ruler-cap {
  font-family: monospace, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
  user-select: none;
}

.ruler-fill {
  height: 6px;
  border-radius: 3px;
  display: inline-block;
  margin: 0 1px;
}

.bar-very_close .ruler-fill {
  width: 16px;
  background: #ef4444;
}

.bar-near .ruler-fill {
  width: 33px;
  background: #f97316;
}

.bar-mid .ruler-fill {
  width: 50px;
  background: #22c55e;
}

.bar-clear .ruler-fill {
  width: 64px;
  background: #94a3b8;
}

/* Tilt D-Pad Compass Popover */
.simple-tilt-picker {
  min-width: 156px;
}

.tilt-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tilt-dpad-middle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tilt-dpad {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.btn-tilt-dpad:hover {
  background: #f0f9ff;
  border-color: #0284c7;
  transform: scale(1.08);
}

.btn-tilt-dpad.is-selected {
  background: #0284c7;
  border-color: #0369a1;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.4);
}

.tilt-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Tactile Keycap Popover */
.simple-key-picker {
  min-width: 250px;
}

.key-picker-grid {
  display: flex;
  align-items: center;
  gap: 12px;
}

.key-picker-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.key-picker-divider {
  width: 2px;
  height: 90px;
  background: #e2e8f0;
}

.key-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.btn-keycap {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 2px solid #94a3b8;
  background: #ffffff;
  color: #1e293b;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #94a3b8, 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.08s ease;
  user-select: none;
}

.btn-keycap:hover {
  background: #f1f5f9;
  border-color: #3b82f6;
  box-shadow: 0 3px 0 #3b82f6, 0 4px 8px rgba(59, 130, 246, 0.25);
}

.btn-keycap:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #94a3b8;
}

.btn-keycap.is-selected {
  background: #3b82f6;
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 3px 0 #1d4ed8;
}

.btn-keycap.btn-keycap-space {
  width: 126px;
  font-size: 12px;
}

/* =========================================================
   6. Mode Switcher Toolbar Button & Dialog
   ========================================================= */

.mode-switcher-toggle {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: 20px;
  padding: 2px;
  margin-left: 12px;
}

.btn-mode-pill {
  padding: 4px 12px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-mode-pill.is-active {
  background: #3b82f6;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.btn-mode-pill.is-active.mode-simple {
  background: #ffb800;
  color: #78350f;
  box-shadow: 0 2px 6px rgba(255, 184, 0, 0.4);
}

/* Warning Modal Overlay */
.mode-warning-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  animation: fadeIn 0.15s ease;
}

.mode-warning-dialog {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border: 3px solid #f59e0b;
}

.mode-warning-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mode-warning-icon {
  font-size: 32px;
}

.mode-warning-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
}

.mode-warning-text {
  font-size: 14px;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 12px;
}

.mode-warning-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px 0;
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 12px;
  padding: 10px 14px;
}

.mode-warning-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
}

.mode-warning-hint {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 20px;
}

.mode-warning-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-mode-cancel {
  padding: 8px 16px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-weight: 700;
  cursor: pointer;
}

.btn-mode-confirm {
  padding: 8px 18px;
  border-radius: 10px;
  border: none;
  background: #f59e0b;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(245, 158, 11, 0.4);
}

.btn-mode-confirm:hover {
  background: #d97706;
}
