/* ==========================================================================
   APP SIDEBAR
   - Icon-only navigation rail that docks to the left edge of the
     calculator card, vertically centered on it, and slides in from
     that side when the hamburger is toggled. No full-screen
     backdrop/dim — it's a small floating panel, not a mobile drawer.
   - Built entirely from the shared tokens in main.css, so it follows
     whatever theme (light/dark) and accent color is active.
   ========================================================================== */

.app-sidebar {
  position: fixed;
  z-index: 40;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  width: 52px;
  padding: var(--space-4) 0;

  background: var(--color-btn-function);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);

  opacity: 0;
  transform: translateX(-24px) scale(0.96);
  transform-origin: right center;
  pointer-events: none;
  transition: opacity var(--duration-normal) ease,
              transform var(--duration-normal) ease;
}

.app-sidebar.is-open {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.app-sidebar__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-secondary);
  box-shadow: none;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-press),
              box-shadow var(--duration-fast) var(--ease-press),
              background var(--duration-fast) ease,
              color var(--duration-fast) ease;
}

/* Divider between the calculator tools and the Settings entry,
   mirroring the grouped-icon-rail look. */
.app-sidebar__item[data-page="settings"] {
  margin-top: var(--space-4);
}
.app-sidebar__item[data-page="settings"]::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--space-4) + -6px);
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 1px;
  background: var(--color-text-muted);
  opacity: 0.35;
}

.app-sidebar__item svg {
  width: 18px;
  height: 18px;
}

.app-sidebar__item:hover {
  color: var(--color-text-primary);
}

.app-sidebar__item:active {
  transform: scale(0.92);
}

.app-sidebar__item.is-active {
  background: var(--color-card);
  color: var(--color-btn-operator);
  box-shadow: var(--shadow-btn-soft);
}

/* "fx" glyph for the Scientific entry, matching the mark used in History */
.app-sidebar__glyph {
  font-size: 0.85rem;
  font-style: italic;
  font-weight: var(--fw-semibold);
  line-height: 1;
}
.app-sidebar__glyph sub {
  font-size: 0.65em;
}

/* ---- Hover tooltip, name appears to the right of the rail ---- */
.app-sidebar__item::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 50%;
  left: calc(100% + var(--space-3));
  transform: translateY(-50%) translateX(-4px);
  white-space: nowrap;
  background: var(--color-card);
  color: var(--color-btn-operator);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-btn-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.app-sidebar__item:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ---- Hamburger <-> arrow icon morph on #menuToggle ---- */
#menuToggle {
  position: relative;
}

.menu-toggle__icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transform: rotate(0deg) scale(1);
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.menu-toggle__icon svg {
  width: 18px;
  height: 18px;
}

.menu-toggle__icon--arrow {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

#menuToggle.is-open .menu-toggle__icon--menu {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

#menuToggle.is-open .menu-toggle__icon--arrow {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}