/* Custom styles for Projects: The Cooper Union static site */

/* Prevent images from causing horizontal scroll */
.mw-parser-output img:not(.thumbimage),
.embedded-email img:not(.thumbimage) {
  max-width: 100%;
  height: auto;
}

/* Thumbimages have their own width constraints */
.thumbimage {
  max-width: 100%;
  height: auto;
}

/* Ensure image links show pointer cursor (hand) */
.mw-parser-output a:has(img),
.fullImageLink a,
.embedded-email a:has(img) {
  cursor: pointer !important;
}

/* Gallery-style image lists */
/* These are created from MediaWiki <gallery> tags that get converted to markdown bullet lists */
.mw-parser-output > ul:has(> li > a > img),
.mw-parser-output > ul:has(> li > p > a > img) {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px;
  padding: 2px;
}

.mw-parser-output > ul:has(> li > a > img) > li,
.mw-parser-output > ul:has(> li > p > a > img) > li {
  display: inline-block;
  vertical-align: top;
  margin: 0;
  padding: 0;
  width: 180px;
}

.mw-parser-output > ul:has(> li > a > img) > li > a,
.mw-parser-output > ul:has(> li > p > a > img) > li > p > a {
  display: block;
  text-align: center;
  margin: 2px;
}

.mw-parser-output > ul:has(> li > a > img) > li img,
.mw-parser-output > ul:has(> li > p > a > img) > li img {
  max-width: 180px;
  max-height: 240px;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid #c8ccd1;
  background-color: #f8f9fa;
  padding: 3px;
}

/* Caption text below images */
.mw-parser-output > ul:has(> li > a > img) > li,
.mw-parser-output > ul:has(> li > p > a > img) > li {
  font-size: 94%;
  text-align: center;
  overflow: hidden;
  word-wrap: break-word;
}

/* Mobile hamburger menu */
#mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: #fff;
  border: 1px solid #a2a9b1;
  border-radius: 3px;
  width: 44px;
  height: 44px;
  text-align: center;
  align-items: center;
  justify-content: center;
  padding: 10px;
  line-height: 1;
  appearance: none;
  cursor: pointer;
}

#mobile-menu-toggle .mobile-menu-lines {
  width: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

#mobile-menu-toggle .mobile-menu-line {
  width: 100%;
  height: 2px;
  background-color: #000;
  border-radius: 2px;
}

/* Mobile responsive styles */
@media screen and (max-width: 982px) {
  /* Show hamburger menu on mobile */
  #mobile-menu-toggle {
    display: flex;
  }

  /* Position sidebar off-screen by default */
  #mw-panel {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    height: 100vh;
    background: #f6f6f6;
    overflow-y: auto;
    transition: left 0.3s ease;
    z-index: 999;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  }

  /* Make sidebar navigation text bigger for easier tapping */
  #mw-panel .portal .body li {
    font-size: 1.1em !important;
    padding: 0.3em 0 !important;
    line-height: 1.4 !important;
  }

  #mw-panel .portal .body li a {
    display: block;
    padding: 0.2em 0;
  }

  /* Bigger portal headings */
  #mw-panel .portal h3 {
    font-size: 1em !important;
    padding: 0.4em 0 !important;
  }

  /* Show sidebar when toggled */
  #mw-panel.mobile-nav-open {
    left: 0;
  }

  /* Overlay when menu is open */
  body:has(#mw-panel.mobile-nav-open)::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
  }

  /* Remove left margin since sidebar is hidden by default */
  .mw-body,
  #mw-head-base,
  #left-navigation,
  #mw-data-after-content,
  .mw-footer {
    margin-left: 0 !important;
  }

  /* Make content full width */
  .mw-body {
    padding: 1em !important;
    border: 0 !important;
  }

  /* Show logo at top of sidebar */
  #mw-panel #p-logo {
    display: block !important;
    position: static !important;
    width: 100% !important;
    text-align: center;
    margin-bottom: 1em;
  }

  #mw-panel #p-logo a {
    width: 120px !important;
    height: 120px !important;
    margin: 0 auto;
    background-size: contain !important;
  }

  /* Hide Read tab and search on mobile */
  #p-views,
  #p-search {
    display: none !important;
  }

  /* Hide the giant gray header sections */
  #mw-head-base,
  #mw-page-base {
    display: none !important;
  }

  /* Hide entire navigation header on mobile */
  #mw-head {
    display: none !important;
  }

  /* Reduce top margin on content */
  .mw-body {
    margin-top: 0 !important;
  }

  /* Adjust footer */
  .mw-footer {
    margin-left: 0 !important;
    padding: 1em !important;
  }

  /* Make tables scrollable on mobile */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Homepage icon table - stack vertically on mobile */
  .mw-parser-output > center table {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mw-parser-output > center table td {
    display: block !important;
    width: 100% !important;
    padding: 15px 0 !important;
    border-bottom: 1px solid #eee;
  }

  .mw-parser-output > center table td:last-child {
    border-bottom: none;
  }

  /* PDF thumbnail - stack on mobile (remove float) */
  .thumb.tright {
    float: none !important;
    margin: 1em auto !important;
    clear: both !important;
  }

  .thumb .thumbinner {
    width: 100% !important;
    max-width: 302px;
    margin: 0 auto;
  }

  .thumb .thumbimage {
    width: 100% !important;
    height: auto !important;
  }

}
