/* ============================================
   DA2026 Slides — Mobile-first CSS
   ============================================ */

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

:root {
  --bar-h: 48px;
  --sidebar-w: 0px;
  --nav-size: 52px;
  --slide-max: 680px;
  --bg: #f8f7f4;
  --sidebar-bg: #2c2c2c;
  --sidebar-text: #e8e8e8;
  --sidebar-hover: #3a3a3a;
  --sidebar-active: #1a56db;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --font-body: 16px/1.6 'Georgia', serif;
  --font-heading: 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  font: var(--font-body);
}

/* ---- Top bar ---- */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-h);
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 300;
  box-shadow: 0 1px 0 rgba(255,255,255,0.08);
}

#topbar-right {
  margin-left: auto;
  color: #aaa;
  font-size: 14px;
  font-family: var(--font-heading);
  white-space: nowrap;
  flex-shrink: 0;
}

#topbar-right .curNum {
  color: #fff;
  font-weight: 600;
}

/* ---- App layout (below topbar) ---- */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--bar-h);
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-subtitle {
  font-size: 12px;
  color: #aaa;
  margin-top: 2px;
}

.sidebar-search {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#searchInput {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  outline: none;
}

#searchInput:focus { border-color: var(--sidebar-active); background: rgba(255,255,255,0.15); }
#searchInput::placeholder { color: #777; }

#indexList {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

#indexList::-webkit-scrollbar { width: 6px; }
#indexList::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.idx-item {
  display: flex;
  flex-direction: column;
  padding: 8px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.idx-item:hover { background: var(--sidebar-hover); }

.idx-item.active {
  background: rgba(26,86,219,0.25);
  border-left-color: var(--sidebar-active);
}

.idx-item .idx-num {
  font-size: 11px;
  color: #666;
  font-family: var(--font-heading);
  margin-bottom: 2px;
}

.idx-item.active .idx-num { color: #93c5fd; }

.idx-item .idx-title {
  font-size: 13px;
  color: var(--sidebar-text);
  line-height: 1.35;
  white-space: nowrap;
  overflow-y: auto;
  text-overflow: ellipsis;
}

.idx-item.active .idx-title { color: #fff; }
.idx-item.hidden { display: none; }

/* ---- Main content ---- */
#content {
  flex: 1;
  position: relative;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#slideContainer {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#slideContainer::-webkit-scrollbar { width: 3px; }
#slideContainer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- Slide ---- */
.slide {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 0 28px;
}

.slide + .slide {
  border-top: 1px solid var(--border);
  padding-top: 28px;
}


.slide-content {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.slide-content .page-ref {
  color: #1a56db;
  text-decoration: underline;
  cursor: pointer;
}

.slide-content .page-ref:active {
  color: #1e40af;
}

.content-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.5;
}

.content-table th {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid #1a56db;
  color: #374151;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.content-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #e5e7eb;
  color: #111827;
}

.content-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

.content-table td .page-ref {
  color: #1a56db;
  text-decoration: none;
  font-weight: 500;
}

.content-table td .page-ref:hover {
  text-decoration: underline;
}

.slide-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 4px;
  cursor: zoom-in;
}

.slide-image-page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.slide-image-page img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 4px;
}


#docSlider {
  width: 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: var(--bar-h) 0 0;
  background: var(--bg);
}

#sliderTrack {
  flex: 1;
  width: 6px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  min-height: 40px;
  margin: 0;
}

#sliderThumb {
  position: absolute;
  left: -3px;
  right: -3px;
  height: 20px;
  background: var(--sidebar-active);
  border-radius: 4px;
  top: 0;
  transition: top 0.08s ease-out;
  pointer-events: none;
}

/* ---- Slide nav bar — arrows + centered page label, sticky top of content ---- */
#slideNav {
  position: sticky;

  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

#slideNav #prevBtn,
#slideNav #nextBtn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#slideNav #prevBtn:hover,
#slideNav #nextBtn:hover { background: rgba(0,0,0,0.06); }

#slideNav #prevBtn:active,
#slideNav #nextBtn:active { opacity: 0.6; }

#slidePageLabel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-family: var(--font-heading);
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
}

.slide-counter {
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font-heading);
  text-align: center;
}

.slide-counter .curNum {
  color: var(--text);
  font-weight: 600;
}
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox.hidden { display: none; }

#lightboxOverlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: zoom-out;
}

#lightboxClose {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  transition: background 0.15s;
}

#lightboxClose:hover { background: rgba(255,255,255,0.25); }

#lightboxImg {
  position: relative;
  z-index: 2;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  object-fit: contain;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#lightboxImg:active { cursor: grabbing; }

/* ---- Topbar buttons ---- */
#menuToggle {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  width: 38px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
  padding: 0;
}

#menuToggle:hover { background: rgba(255,255,255,0.22); }

#pageFullBtn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  height: 34px;
}

#pageFullBtn:hover { background: rgba(255,255,255,0.22); }

#backBtn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 0;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#backBtn:hover { background: rgba(255,255,255,0.22); }

#backBtn.hidden { display: none; }

/* ---- Mobile: portrait ---- */
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; --bar-h: 46px; --nav-size: 46px; }

  #sidebar {
    position: fixed;
  
    left: 0;
    width: 100%;
    height: calc(100vh - var(--bar-h));
    height: calc(100dvh - var(--bar-h));
    max-height: none;
    flex-direction: column;
    transform: translateY(-110%);
    transition: transform 0.3s ease;
    z-index: 200;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }

  #sidebar.open { transform: translateY(0); }

  #sidebar .sidebar-header { padding: 12px 14px 10px; }
  .sidebar-title { font-size: 15px; }
  .sidebar-search { padding: 6px 10px; }
  #indexList { max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); }

  #slideContainer { padding: 14px 12px; }

}


/* ---- Desktop/landscape: sidebar docked to left ---- */
@media (min-width: 641px) {
  #sidebar {
    width: 0;
    min-width: 0;
    height: 100%;
    flex-shrink: 0;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease;
    z-index: 10;
    overflow: hidden;
  }

  #sidebar.open {
    width: 260px;
    min-width: 260px;
  }
}
