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

/* ---- CSS Custom Properties (Light theme) ---- */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-alt: #f7f7f7;
  --border: #ddd;
  --border-light: #eee;
  --text: #222;
  --text-muted: #555;
  --text-dim: #888;
  --text-faint: #999;
  --btn-bg: rgba(255,255,255,0.92);
  --btn-hover: #eee;
  --btn-active: #ddd;
  --btn-border: #ccc;
  --btn-text: #333;
  --export-hover: #f0f0f0;
  --sidebar-shadow: rgba(0,0,0,0.1);
  --handle-bar: #ccc;
  --toast-bg: #333;
  --toast-text: #fff;
  --lang-bg: rgba(255,255,255,0.92);
}

/* ---- Dark theme overrides ---- */
body.dark {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-alt: #0f3460;
  --border: #3a3a5c;
  --border-light: #2a2a4a;
  --text: #e0e0e0;
  --text-muted: #b0b0c0;
  --text-dim: #8888aa;
  --text-faint: #6666888;
  --btn-bg: rgba(22,33,62,0.95);
  --btn-hover: #0f3460;
  --btn-active: #1a1a4e;
  --btn-border: #3a3a5c;
  --btn-text: #d0d0e8;
  --export-hover: #0f3460;
  --sidebar-shadow: rgba(0,0,0,0.4);
  --handle-bar: #4a4a6a;
  --toast-bg: #e0e0e0;
  --toast-text: #111;
  --lang-bg: rgba(22,33,62,0.95);
}

*, *::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: var(--bg);
  color: var(--text);
  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: var(--lang-bg);
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  border: 1px solid var(--border);
  color: var(--text);
}

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

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

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

.floating-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  background: var(--btn-bg);
  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: var(--btn-text);
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.floating-btn:hover {
  background: var(--btn-hover);
}

.floating-btn:active {
  background: var(--btn-active);
}

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

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

#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;
  color: var(--text);
}

#export-menu button:hover {
  background: var(--export-hover);
}

#export-menu button + button {
  border-top: 1px solid var(--border-light);
}

/* ---- 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 var(--btn-border);
  border-radius: 8px;
  background: var(--btn-bg);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  color: var(--btn-text);
  line-height: 1;
}

#zoom-controls button:hover { background: var(--btn-hover); }
#zoom-controls button:active { background: var(--btn-active); }

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

#sidebar {
  width: 280px;
  min-width: 220px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  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: var(--text-faint);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

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

.sidebar-author strong {
  color: var(--text-dim);
}

.sidebar-author a {
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: color 0.15s;
  text-decoration: none;
}

.sidebar-author a:hover {
  color: var(--text);
}

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

.app-description {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0 0 20px;
  line-height: 1.45;
}

#sidebar h2 {
  font-size: 0.95rem;
  margin: 0 0 10px;
  color: var(--text-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* ---- 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: var(--text-faint);
  font-style: italic;
  padding: 8px;
}

#selected-list li.group-header {
  font-weight: 700;
  margin-top: 12px;
  padding: 6px 8px 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-alt);
  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: var(--text-muted);
}

/* ---- 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: var(--toast-bg);
  color: var(--toast-text);
  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 var(--border);
    border-radius: 16px 16px 0 0;
    max-height: 55vh;
    z-index: 30;
    transition: transform 0.3s ease;
    box-shadow: 0 -2px 12px var(--sidebar-shadow);
  }

  #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: var(--handle-bar);
    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;
  }
}
