﻿/* TerraTrend - sidebar.css
   Variable selector sidebar and pills */

/* ---------- Variable sidebar (left panel) ---------- */
.var-sidebar {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
  width: 230px;
  max-height: calc(100vh - var(--appbar-h) - 90px);
  overflow-y: auto;
  scrollbar-width: none;
  background:
    linear-gradient(90deg, transparent 15%, rgba(140, 150, 255, 0.35) 50%, transparent 85%) top / 100% 1px no-repeat,
    rgba(8, 9, 22, 0.94);
  border: 1px solid rgba(140, 150, 255, 0.16);
  border-radius: 18px;
  padding: 20px 14px 18px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(139, 124, 255, 0.07) inset,
    0 0 50px -20px rgba(139, 124, 255, 0.4);
  pointer-events: auto;
  animation: sidebarIn 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes sidebarIn {
  from { opacity: 0; transform: translateY(-50%) translateX(-10px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
.var-sidebar-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 0 6px;
  display: block;
  opacity: 0.85;
}
.var-selector-pills {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.var-pill {
  display: grid;
  grid-template-columns: 28px 1fr 20px;
  column-gap: 8px;
  align-items: center;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
  width: 100%;
  text-align: left;
}
.var-pill:hover {
  background: rgba(139, 124, 255, 0.09);
  border-color: rgba(139, 124, 255, 0.22);
  color: var(--text);
}
.var-pill.active {
  background: color-mix(in srgb, var(--pill-col, var(--accent)) 8%, rgba(4, 5, 14, 0.85));
  border-color: color-mix(in srgb, var(--pill-col, var(--accent)) 55%, transparent);
  color: #fff;
  box-shadow:
    inset 2px 0 0 var(--pill-col, var(--accent)),
    0 0 0 1px color-mix(in srgb, var(--pill-col, var(--accent)) 20%, transparent) inset,
    0 6px 20px -6px color-mix(in srgb, var(--pill-col, var(--accent)) 45%, transparent);
}
.pill-icon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.var-pill.active .pill-icon {
  background: color-mix(in srgb, var(--pill-col, var(--accent)) 14%, transparent);
}
.pill-name {
  font-size: 0.78rem;
  line-height: 1.3;
  min-width: 0;
  padding-right: 8px;
}
.pill-rate {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  transition: max-height 0.2s ease, opacity 0.2s ease, margin-top 0.2s ease;
}
.var-pill:hover .pill-rate,
.var-pill.active .pill-rate {
  max-height: 20px;
  opacity: 0.8;
  margin-top: 3px;
}
.pill-spark { display: none; }
.pill-arrow {
  grid-column: 3;
  font-size: 0.6rem;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
}
.pill-arrow.up    { color: var(--signal-warm); text-shadow: 0 0 8px rgba(255, 138, 92, 0.6); }
.pill-arrow.down  { color: var(--accent-2);    text-shadow: 0 0 8px rgba(34, 224, 238, 0.6); }
.pill-arrow.mixed { color: var(--accent);      text-shadow: 0 0 8px rgba(139, 124, 255, 0.6); }

/* ---------- Explore tracker ---------- */
.explore-tracker {
  margin-top: 14px;
  padding: 10px 10px 9px;
  background: rgba(34, 224, 238, 0.05);
  border: 1px solid rgba(34, 224, 238, 0.14);
  border-radius: 10px;
}
.explore-counter {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--accent-2);
  display: block;
  text-align: center;
  margin-bottom: 7px;
  opacity: 0.9;
  transition: color 0.4s, text-shadow 0.4s;
}
.explore-counter.all-explored {
  text-shadow: 0 0 14px rgba(34, 224, 238, 0.6);
}
.explore-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}
.explore-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-2);
  border-radius: 99px;
  box-shadow: 0 0 8px rgba(34, 224, 238, 0.7);
  transition: width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Viewed pill indicator */
.var-pill.viewed .pill-icon {
  box-shadow: 0 0 0 1.5px rgba(34, 224, 238, 0.45);
}

/* Mobile variable strip: hidden on desktop */
.mobile-var-strip { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .var-sidebar {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    width: 100%;
    max-height: none;
    overflow-y: visible;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(140, 150, 255, 0.18);
    border-left: none;
    border-right: none;
    border-bottom: none;
    background: rgba(4, 5, 16, 0.98);
    box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(139, 124, 255, 0.07) inset;
    animation: none;
  }
  /* No drag handle: this is a dock, not a sheet */
  .var-sidebar::before { display: none; }

  /* Top border tints to match the active variable, linking dock to the floating panel */
  .var-sidebar {
    border-top: 1px solid color-mix(in srgb, var(--spot-col, rgba(140, 150, 255, 0.18)) 60%, rgba(140, 150, 255, 0.18));
  }

  /* Active variable name strip: shows full name in the variable's own color */
  .mobile-var-strip {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 44px 6px 44px;
    min-height: 18px;
    opacity: 0.9;
    transition: color 0.3s ease;
  }

  .var-selector-pills {
    flex-direction: row;
    gap: 4px;
    overflow: visible;
    padding-bottom: 0;
  }

  /* Equal-width icon tiles */
  .var-pill {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 3px;
    height: 52px;
    border-radius: 13px;
    border: 1px solid transparent;
    background: transparent;
    transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  }
  .var-pill:active { transform: scale(0.93); }

  .var-pill.active {
    background: color-mix(in srgb, var(--pill-col, var(--accent)) 16%, rgba(3, 4, 14, 0.95));
    border-color: color-mix(in srgb, var(--pill-col, var(--accent)) 55%, transparent);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--pill-col, var(--accent)) 22%, transparent) inset,
      0 4px 18px -4px color-mix(in srgb, var(--pill-col, var(--accent)) 55%, transparent);
  }

  .pill-icon {
    font-size: 1.25rem;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.18s, box-shadow 0.18s;
  }
  .var-pill.active .pill-icon {
    background: color-mix(in srgb, var(--pill-col, var(--accent)) 22%, rgba(0, 0, 0, 0.5));
    box-shadow: 0 0 10px color-mix(in srgb, var(--pill-col, var(--accent)) 65%, transparent);
  }

  .pill-name,
  .var-sidebar-label,
  .pill-spark,
  .pill-arrow,
  .pill-rate { display: none; }

  /* Counter floats in the top-right corner so it doesn't add to dock height */
  .explore-tracker {
    position: absolute;
    top: 10px;
    right: 12px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
  }
  .explore-bar { display: none; }
  .explore-counter {
    font-size: 0.48rem;
    letter-spacing: 0.16em;
    margin: 0;
    opacity: 0.85;
    text-align: right;
  }

  /* Tighten pills on very narrow phones (< 360px) */
  @media (max-width: 360px) {
    .var-pill { height: 44px; border-radius: 10px; }
    .pill-icon { font-size: 1.1rem; width: 28px; height: 28px; border-radius: 8px; }
  }
}
