/* ==========================================================================
   Emotion Wheel – style.css
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #222;
  overflow: hidden;
  touch-action: none;
}

/* ---- Layout ---- */

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#canvas-container {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

#wheel {
  display: block;
}

/* ---- Floating Top Bar ---- */

#floating-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
  pointer-events: none;
}

#floating-top > * {
  pointer-events: auto;
}

.floating-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.92);
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  border: 1px solid #ddd;
}

.floating-lang label {
  font-size: 1rem;
}

.floating-lang select {
  border: none;
  background: transparent;
  font-size: 0.85rem;
  padding: 4px 2px;
  outline: none;
  cursor: pointer;
}

.floating-actions {
  display: flex;
  gap: 6px;
}

.floating-btn {
  width: 40px;
  height: 40px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  color: #333;
  line-height: 1;
  transition: background 0.15s;
}

.floating-btn:hover {
  background: #eee;
}

.floating-btn:active {
  background: #ddd;
}

/* ---- Export dropdown ---- */

#export-menu {
  position: absolute;
  top: 58px;
  right: 10px;
  z-index: 25;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#export-menu.hidden {
  display: none;
}

#export-menu button {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}

#export-menu button:hover {
  background: #f0f0f0;
}

#export-menu button + button {
  border-top: 1px solid #eee;
}

/* ---- Zoom Controls ---- */

#zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

#zoom-controls button {
  width: 40px;
  height: 40px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  color: #333;
  line-height: 1;
}

#zoom-controls button:hover { background: #eee; }
#zoom-controls button:active { background: #ddd; }

/* ---- Sidebar ---- */

#sidebar {
  width: 280px;
  min-width: 220px;
  background: #fff;
  border-left: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-handle {
  display: none; /* only visible on mobile */
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

/* ---- Author bar ---- */

.sidebar-author {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #999;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.sidebar-author span {
  margin-right: auto;
}

.sidebar-author strong {
  color: #666;
}

.sidebar-author a {
  color: #888;
  font-size: 1.1rem;
  transition: color 0.15s;
  text-decoration: none;
}

.sidebar-author a:hover {
  color: #333;
}

#sidebar h1 {
  font-size: 1.15rem;
  margin: 0 0 6px;
  color: #333;
  line-height: 1.3;
}

.app-description {
  font-size: 0.82rem;
  color: #888;
  margin: 0 0 20px;
  line-height: 1.45;
}

#sidebar h2 {
  font-size: 0.95rem;
  margin: 0 0 10px;
  color: #555;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

/* ---- Selected List ---- */

#selected-list {
  list-style: none;
  flex: 1 1 auto;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 0.92rem;
}

/* Percentage distribution bar */
.percentage-bar-wrapper {
  padding: 4px 8px 0 !important;
}

.percentage-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}

.percentage-bar > div {
  min-width: 2px;
  transition: width 0.3s ease;
}

#selected-list li {
  padding: 3px 8px;
  border-radius: 4px;
}

#selected-list li.empty {
  color: #999;
  font-style: italic;
  padding: 8px;
}

#selected-list li.group-header {
  font-weight: 700;
  margin-top: 12px;
  padding: 6px 8px 4px;
  color: #444;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f7f7f7;
  border-radius: 4px;
}

#selected-list li.group-header:first-child {
  margin-top: 0;
}

#selected-list li:not(.group-header):not(.empty) {
  padding-left: 16px;
  color: #555;
}

/* ---- Desktop: hide floating top (sidebar has its own controls) ---- */
/* We keep the floating top ALWAYS visible for consistency */

/* ---- Toast ---- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 999;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================================================================
   RESPONSIVE: MOBILE (< 700px)
   - Sidebar becomes a collapsible bottom sheet
   - Canvas fills the viewport
   - Floating controls on top of the wheel
   ================================================================ */

@media (max-width: 700px) {
  html, body {
    overflow: hidden;
  }

  #app {
    flex-direction: column;
    position: relative;
  }

  #canvas-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  /* Floating top adjustments */
  #floating-top {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .floating-lang select {
    font-size: 0.8rem;
    max-width: 110px;
  }

  .floating-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  #export-menu {
    top: 52px;
    right: 8px;
  }

  /* Sidebar → bottom sheet */
  #sidebar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: unset;
    border-left: none;
    border-top: 1px solid #ddd;
    border-radius: 16px 16px 0 0;
    max-height: 55vh;
    z-index: 30;
    transition: transform 0.3s ease;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
  }

  #sidebar.collapsed {
    transform: translateY(calc(100% - 46px));
  }

  #sidebar-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 6px;
    cursor: pointer;
    touch-action: none;
    flex-shrink: 0;
  }

  .handle-bar {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
  }

  #sidebar-content {
    padding: 4px 14px 16px;
  }

  #sidebar h1 {
    font-size: 1rem;
    margin: 0 0 2px;
  }

  .app-description {
    font-size: 0.75rem;
    margin: 0 0 10px;
  }

  #sidebar h2 {
    font-size: 0.88rem;
    margin: 0 0 6px;
  }

  #selected-list {
    max-height: 30vh;
    overflow-y: auto;
    margin-bottom: 8px;
  }

  #zoom-controls {
    bottom: 55px; /* above the collapsed sidebar handle */
    right: 10px;
  }

  #zoom-controls button {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  #toast {
    bottom: 60px;
  }
}
