:root {
  --light: rgba(0,0,0,0.1);
  --light2: rgba(0,0,0,0.5);
  --main: rgba(0,0,0,0.7);
  --ubcblue: rgb(0, 33, 70);
  --ubcwhite: rgb(255, 255, 255);
  
  /* Responsive breakpoints */
  --mobile-max: 767px;
  --tablet-min: 768px;
  --tablet-max: 1023px;
  --desktop-min: 1024px;
}

body,html {
  margin: 0px;
  font-family: 'Open Sans', sans-serif;
  font-size: 11pt;
  color: var(--main);
  overflow-x: hidden;
  max-width: 100vw;
}

a {
  text-decoration: none;
  color: var(--main);
  font-weight: bold;
}

a:hover {
  color: var(--light2);
}

ul {
  padding-left: 2em;
}

h3, h4 {
  margin: 0px;
}

/* Hamburger Menu Button */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 28px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1001;
}

.hamburger span {
  width: 28px;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger.active span {
  opacity: 0;
}

.hamburger.active::after {
  content: '×';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  color: var(--main);
  line-height: 1;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Legend Toggle Button */
.legend-toggle-btn {
  position: absolute;
  top: 70px;
  right: 20px;
  padding: 10px 16px;
  background: white;
  border: 2px solid var(--light);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--main);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 100;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.legend-toggle-btn:hover {
  background: var(--light);
  border-color: var(--light2);
}

.legend-toggle-btn:active {
  transform: scale(0.95);
  background: var(--light2);
}

/* Legend Panel */
.legend-panel {
  position: absolute;
  top: 0;
  right: -350px;
  width: 320px;
  height: 100%;
  background: white;
  border-left: 2px solid var(--light);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
  transition: right 0.3s ease;
  z-index: 150;
  overflow-y: auto;
}

.legend-panel.active {
  right: 0;
}

.legend-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 28px;
  font-weight: 300;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 151;
}

.legend-close-btn:hover {
  color: var(--main);
  background: var(--light);
  border-radius: 4px;
}

#legend-content {
  padding: 50px 20px 20px 20px;
}

/* Hide the SVG legend on mobile/tablet, show on desktop */
svg .legend {
  display: none;
}

/* Prevent text selection during touch interactions */
#course-map svg {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#header {
  grid-row: 1;
  grid-column-start: 1;
  grid-column-end: 3;
  background-color: var(--ubcblue);
  color: white;
  position: relative;
}

#header h2 {
  margin: 0px;
  padding-left: 10px;
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  transition: left 0.3s ease;
}

.dept-toggle {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.dept-toggle:hover {
  opacity: 0.8;
}

.dept-toggle.active {
  opacity: 1;
}

.dept-separator {
  margin: 0 10px;
  opacity: 0.5;
}

#disclaimer-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #f8f9fa;
  border-top: 1px solid #dee2e6;
  padding: 10px 16px;
  min-height: 35px;
  font-size: 14px;
  line-height: 1.5;
  color: #6c757d;
  text-align: center;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

#disclaimer-footer p {
  margin: 0;
  padding: 0;
  max-width: 90%;
  text-align: center;
  word-wrap: break-word;
  hyphens: auto;
}

#disclaimer-footer a {
  color: #0066cc;
  text-decoration: underline;
  font-weight: 600;
}

#disclaimer-footer a:hover {
  color: #004499;
}

#dashboard {
  display: grid;
  grid-template-columns: 35% 65%;
  grid-template-rows: 5vh max(275px,38vh) 57vh;
  column-gap: 0px;
  row-gap: 0px;
  width: 100%;
  min-width: 320px;
  max-width: 100vw;
  height: calc(100vh - 35px);
  background-color: white;
  overflow: hidden;
}

#dashboard > div {
  background-color: white;
}

#program-track-nav {
  grid-row: 2;
  grid-column: 1;
  margin: 10px;
  padding: 10px;
  border: 1px solid var(--light);
  border-radius: 2px;
  overflow: auto;
}

#program-track-nav div {
  padding: 2px 8px 3px 8px;
  border: 1px solid white;
  border-radius: 2px;
}

#program-track-nav div.track {
  margin-left: 12px;
}

#program-track-nav div:hover {
  cursor: default;
  background-color: var(--light);
}

#program-track-nav div.highlight {
  border-color: var(--light2);
}

#course-info {
  grid-row: 3;
  grid-column: 1;
  margin: 0px 10px 10px 10px;
  padding: 15px 15px 10px 15px;
  overflow: auto;
  border: 1px solid var(--light);
  border-radius: 2px;
  opacity: 1;
}

/* Styling for track requirement tables */
#course-info table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  table-layout: fixed;
}

#course-info table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--light);
}

#course-info table td:nth-child(2) {
  width: 60px;
  text-align: right;
}

#course-info table tr:last-child td {
  border-bottom: none;
}

#course-info table strong {
  color: var(--ubcblue);
}

#course-info sup {
  font-size: 0.8em;
}

#course-info .responsive-figure-table {
  margin: 10px 0;
  margin-inline-start: 0;
  margin-inline-end: 0;
}

#course-map {
  grid-column: 2;
  grid-row-start: 2;
  grid-row-end: 4;
  border: 1px solid var(--light);
  border-radius: 2px;
  margin: 10px 10px 10px 0px;
  padding: 10px;
  overflow-x: hidden;
}

.degree-note {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 1em;
}

/* ============================================
   RESPONSIVE MEDIA QUERIES
   ============================================ */

/* Tablet and Mobile: Collapsible Sidebar + Bottom Info Pane */
@media screen and (max-width: 1023px) {
  .hamburger {
    display: flex;
  }
  
  #header h2 {
    left: 50px;
    font-size: clamp(16px, 4vw, 20px);
  }
  
  .dept-toggle {
    font-size: clamp(14px, 3.5vw, 18px);
  }
  
  #program-track-nav {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    z-index: 999;
    background: white;
    transition: left 0.3s ease;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    padding-top: 60px;
  }
  
  #program-track-nav.active {
    left: 0;
  }
  
  #course-info {
    grid-column: 1 / -1;
    grid-row: 3;
    margin: 0 10px 10px 10px;
    padding: 12px;
    max-height: 100%;
    min-height: 150px;
    overflow-y: auto;
    font-size: 14px;
    border-top: 2px solid var(--light);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    background: white;
  }
  
  #course-info h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  #course-info h4 {
    font-size: 14px;
    margin-top: 12px;
    margin-bottom: 6px;
  }
  
  #course-info p {
    font-size: 13px;
    line-height: 1.4;
    margin: 6px 0;
  }
  
  #course-info ul {
    font-size: 13px;
    margin: 6px 0;
  }
  
  #course-map {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 10px;
  }
}

/* Mobile Only: 320px - 767px */
@media screen and (max-width: 767px) {
  #dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 50px 1.2fr 1fr;
    height: calc(100vh - 35px);
  }
  
  #header {
    height: 50px;
  }
  
  #header h2 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
  }
  
  .dept-toggle {
    font-size: 14px;
    padding: 4px 8px;
  }
  
  .dept-separator {
    margin: 0 5px;
  }
  
  #program-track-nav {
    width: 260px;
  }
  
  #course-info {
    margin: 0 5px 5px 5px;
    padding: 10px;
    max-height: 100%;
    min-height: 120px;
    font-size: 13px;
    border-top: 2px solid var(--light);
  }
  
  #course-info h3 {
    font-size: 15px;
  }
  
  #course-info h4 {
    font-size: 13px;
  }
  
  #course-info p, #course-info ul {
    font-size: 12px;
  }
  
  #course-map {
    margin: 5px;
    padding: 5px;
  }
  
  .legend-toggle-btn {
    top: 60px;
    right: 15px;
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .legend-panel {
    position: fixed;
    width: 85vw;
    max-width: 320px;
    right: -100vw;
    height: 100vh;
    top: 0;
    z-index: 200;
  }
  
  #disclaimer-footer {
    padding: 8px 10px;
    font-size: 9px;
    line-height: 1.3;
  }
  
  #disclaimer-footer p {
    max-width: 95%;
  }
}

/* Tablet: 768px - 1023px */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  #dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 5vh 1.2fr 1fr;
    height: calc(100vh - 35px);
  }
  
  #program-track-nav {
    width: 320px;
    top: 0;
    height: 100vh;
  }
  
  #course-info {
    margin: 0 15px 15px 15px;
    max-height: 30vh;
    min-height: 180px;
    border-top: 2px solid var(--light);
  }
  
  #course-map {
    margin: 15px;
    padding: 10px;
  }
  
  .legend-toggle-btn {
    top: 65px;
    right: 15px;
    padding: 10px 14px;
    font-size: 13px;
  }
  
  .legend-panel {
    position: fixed;
    width: 300px;
    right: -320px;
    height: 100vh;
    top: 0;
    z-index: 200;
  }
  
  #disclaimer-footer {
    font-size: 10px;
  }
}

/* Desktop: 1024px+ */
@media screen and (min-width: 1024px) {
  #dashboard {
    min-width: 1024px;
  }
  
  .legend-toggle-btn {
    display: none;
  }
  
  .legend-panel {
    display: none;
  }
  
  svg .legend {
    display: block;
  }
}

/* Landscape mobile phones */
@media screen and (max-width: 767px) and (orientation: landscape) {
  #course-info {
    max-height: 40vh;
    min-height: 100px;
  }
}

/* Support for very small screens (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
  #header h2 {
    font-size: 14px;
    left: 45px;
  }
  
  .dept-toggle {
    font-size: 12px;
    padding: 3px 6px;
  }
  
  #program-track-nav {
    width: 240px;
  }
}