/* ============================================================
   Sidebar — modern glass floating nav
   ============================================================ */

/* ---- Theme variables ---- */
:root {
  /* Panel backgrounds */
  --panel-bg: rgba(10, 12, 20, 0.88);
  --panel-bg-strong: rgba(10, 12, 20, 0.94);
  --panel-bg-medium: rgba(10, 12, 20, 0.55);
  --panel-bg-mobile: rgba(10, 12, 20, 0.9);
  --loading-bg: rgba(5, 7, 15, 0.88);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.12);

  /* Text */
  --text-primary: #e8eaf0;
  --text-heading: #ffffff;
  --text-secondary: rgba(232, 234, 240, 0.65);
  --text-muted: rgba(232, 234, 240, 0.4);
  --text-meta: rgba(232, 234, 240, 0.5);
  --text-body: rgba(232, 234, 240, 0.75);
  --text-info: rgba(232, 234, 240, 0.8);
  --text-dim: rgba(232, 234, 240, 0.7);

  /* Interactive */
  --hover-bg: rgba(255, 255, 255, 0.06);
  --hover-bg-strong: rgba(255, 255, 255, 0.14);
  --active-bg-subtle: rgba(255, 255, 255, 0.05);
  --badge-bg: rgba(255, 255, 255, 0.12);
  --badge-text: rgba(255, 255, 255, 0.45);
  --close-btn-bg: rgba(255, 255, 255, 0.07);

  /* Accents */
  --accent-teal: #4ecdc4;
  --accent-teal-bg: rgba(78, 205, 196, 0.08);
  --accent-teal-glow: rgba(78, 205, 196, 0.5);
  --accent-teal-hover: #7eddd8;
  --accent-teal-muted: rgba(78, 205, 196, 0.7);
  --accent-teal-contact: rgba(78, 205, 196, 0.1);
  --accent-teal-contact-border: rgba(78, 205, 196, 0.3);
  --accent-yellow: #ffd93d;
  --accent-yellow-bg: rgba(255, 217, 61, 0.08);
  --accent-yellow-glow: rgba(255, 217, 61, 0.45);

  /* Timeline */
  --track-line: rgba(255, 255, 255, 0.12);
  --dot-bg: rgba(255, 255, 255, 0.15);
  --dot-border: rgba(255, 255, 255, 0.28);
  --dot-hover-bg: rgba(255, 255, 255, 0.5);
  --dot-hover-border: rgba(255, 255, 255, 0.75);
  --year-label-color: rgba(255, 255, 255, 0.38);
  --year-label-hover: rgba(255, 255, 255, 0.8);
  --year-header-color: rgba(255, 255, 255, 0.28);
  --year-heading-color: rgba(255, 255, 255, 0.45);
  --arrow-color: rgba(255, 255, 255, 0.35);
  --arrow-hover: rgba(255, 255, 255, 0.75);

  /* Scrollbar */
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);

  /* Shadows */
  --panel-shadow: rgba(0, 0, 0, 0.5);
  --text-shadow-strong: rgba(0, 0, 0, 0.7);
  --text-shadow-medium: rgba(0, 0, 0, 0.5);

  /* Zoom controls */
  --zoom-bg: rgba(10, 12, 20, 0.88);
  --zoom-text: rgba(232, 234, 240, 0.8);
  --zoom-hover-bg: rgba(255, 255, 255, 0.1);
  --zoom-hover-text: #ffffff;

  /* Attribution */
  --attr-bg: rgba(10, 12, 20, 0.75);
  --attr-text: rgba(232, 234, 240, 0.45);

  /* Tooltip */
  --tooltip-bg: rgba(10, 12, 20, 0.92);

  /* Loading */
  --loading-spinner: rgba(255, 255, 255, 0.5);
}

[data-theme="light"] {
  /* Panel backgrounds */
  --panel-bg: rgba(232, 220, 200, 0.92);
  --panel-bg-strong: rgba(228, 216, 196, 0.96);
  --panel-bg-medium: rgba(232, 220, 200, 0.7);
  --panel-bg-mobile: rgba(228, 216, 196, 0.95);
  --loading-bg: rgba(242, 234, 222, 0.92);

  /* Borders */
  --border-subtle: rgba(120, 100, 70, 0.12);
  --border-light: rgba(120, 100, 70, 0.15);
  --border-medium: rgba(120, 100, 70, 0.2);
  --border-hover: rgba(120, 100, 70, 0.25);

  /* Text */
  --text-primary: #2c2418;
  --text-heading: #1e1710;
  --text-secondary: rgba(44, 36, 24, 0.8);
  --text-muted: rgba(44, 36, 24, 0.5);
  --text-meta: rgba(44, 36, 24, 0.6);
  --text-body: rgba(44, 36, 24, 0.9);
  --text-info: rgba(44, 36, 24, 0.92);
  --text-dim: rgba(44, 36, 24, 0.8);

  /* Interactive */
  --hover-bg: rgba(120, 100, 70, 0.1);
  --hover-bg-strong: rgba(120, 100, 70, 0.2);
  --active-bg-subtle: rgba(120, 100, 70, 0.08);
  --badge-bg: rgba(120, 100, 70, 0.15);
  --badge-text: rgba(44, 36, 24, 0.6);
  --close-btn-bg: rgba(120, 100, 70, 0.12);

  /* Accents — deep enough for WCAG AA on beige */
  --accent-teal: #1a7268;
  --accent-teal-bg: rgba(26, 114, 104, 0.1);
  --accent-teal-glow: rgba(26, 114, 104, 0.3);
  --accent-teal-hover: #135550;
  --accent-teal-muted: rgba(26, 114, 104, 0.8);
  --accent-teal-contact: rgba(26, 114, 104, 0.1);
  --accent-teal-contact-border: rgba(26, 114, 104, 0.35);
  --accent-yellow: #8a6b08;
  --accent-yellow-bg: rgba(138, 107, 8, 0.1);
  --accent-yellow-glow: rgba(138, 107, 8, 0.3);

  /* Timeline */
  --track-line: rgba(120, 100, 70, 0.25);
  --dot-bg: rgba(120, 100, 70, 0.25);
  --dot-border: rgba(120, 100, 70, 0.45);
  --dot-hover-bg: rgba(120, 100, 70, 0.6);
  --dot-hover-border: rgba(120, 100, 70, 0.8);
  --year-label-color: rgba(44, 36, 24, 0.6);
  --year-label-hover: rgba(44, 36, 24, 0.9);
  --year-header-color: rgba(44, 36, 24, 0.5);
  --year-heading-color: rgba(44, 36, 24, 0.65);
  --arrow-color: rgba(44, 36, 24, 0.5);
  --arrow-hover: rgba(44, 36, 24, 0.85);

  /* Scrollbar */
  --scrollbar-thumb: rgba(120, 100, 70, 0.3);

  /* Shadows — softer on light */
  --panel-shadow: rgba(0, 0, 0, 0.15);
  --text-shadow-strong: rgba(0, 0, 0, 0.15);
  --text-shadow-medium: rgba(0, 0, 0, 0.1);

  /* Zoom controls */
  --zoom-bg: rgba(232, 220, 200, 0.92);
  --zoom-text: rgba(44, 36, 24, 0.85);
  --zoom-hover-bg: rgba(120, 100, 70, 0.15);
  --zoom-hover-text: #1e1710;

  /* Attribution */
  --attr-bg: rgba(232, 220, 200, 0.85);
  --attr-text: rgba(44, 36, 24, 0.6);

  /* Tooltip */
  --tooltip-bg: rgba(232, 220, 200, 0.95);

  /* Loading */
  --loading-spinner: rgba(58, 50, 40, 0.5);
}

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

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

a, a:hover, a:focus {
  color: inherit;
  text-decoration: none;
}

/* Wrapper: full-height column, pointer-events passthrough */
.wrapper {
  position: fixed;
  left: 0;
  top: 0;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
}

/* Sidebar nav */
#sidebar {
  display: flex;
  flex-direction: column;
  width: 52px;
  height: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-primary);
  pointer-events: all;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  will-change: width;
}

#sidebar:hover,
#sidebar.expanded {
  width: 210px;
}

/* ---- Section groups ---- */
.sidebar-section {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-top: auto; /* push bottom links to bottom */
}

/* ---- Section label ---- */
.section-label {
  padding: 0 16px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateX(-4px);
  white-space: nowrap;
  overflow: hidden;
}

#sidebar:hover .section-label,
#sidebar.expanded .section-label {
  opacity: 1;
  transform: translateX(0);
}

/* ---- Individual items ---- */
.sidebar-item {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
  text-align: left;
  width: 100%;
}

.sidebar-item:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.sidebar-item .item-icon {
  font-size: 1rem;
  width: 24px;
  min-width: 24px;
  text-align: center;
  transition: color 0.15s;
}

.sidebar-item .item-label {
  margin-left: 12px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}

#sidebar:hover .item-label,
#sidebar.expanded .item-label {
  opacity: 1;
  transform: translateX(0);
}

/* ---- Active / selected filter states ---- */
#societies-btn.active {
  border-left-color: var(--accent-teal);
  color: var(--accent-teal);
  background: var(--accent-teal-bg);
}

#societies-btn.active .item-icon {
  color: var(--accent-teal);
  filter: drop-shadow(0 0 6px var(--accent-teal-glow));
}

#inventions-btn.active {
  border-left-color: var(--accent-yellow);
  color: var(--accent-yellow);
  background: var(--accent-yellow-bg);
}

#inventions-btn.active .item-icon {
  color: var(--accent-yellow);
  filter: drop-shadow(0 0 6px var(--accent-yellow-glow));
}

/* ---- Disabled / coming-soon ---- */
.sidebar-item.disabled {
  cursor: default;
  opacity: 0.4;
}

.sidebar-item.disabled:hover {
  background: transparent;
  color: var(--text-muted);
}

.coming-soon-badge {
  margin-left: 8px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ---- Mobile toggle ---- */
#sidebarCollapse {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1100;
  background: var(--panel-bg-mobile);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1rem;
  pointer-events: all;
}

@media (max-width: 768px) {
  #sidebarCollapse {
    display: flex;
  }

  #sidebarCollapse.expanded {
    display: none;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    width: 210px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #sidebar.expanded {
    transform: translateX(0);
    width: 210px;
  }

  #sidebar:hover {
    width: 210px;
    transform: translateX(-100%);
  }

  #sidebar.expanded:hover {
    transform: translateX(0);
  }

  #sidebar .item-label {
    opacity: 1;
    transform: translateX(0);
  }

  #sidebar .section-label {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---- Theme toggle ---- */
#theme-toggle {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
  text-align: left;
  width: 100%;
}

#theme-toggle:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

#theme-toggle .item-icon {
  font-size: 1rem;
  width: 24px;
  min-width: 24px;
  text-align: center;
  transition: color 0.15s;
}

#theme-toggle .item-label {
  margin-left: 12px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}

#sidebar:hover #theme-toggle .item-label,
#sidebar.expanded #theme-toggle .item-label {
  opacity: 1;
  transform: translateX(0);
}
