/* === Reset === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sidebar-width: 280px;
  --footer-height: 10dvh;
  --bg-color: #f5f5f0;
  --sidebar-bg: #d4d0c8;
  --text-color: #000000;
  --border-color: #808080;
  --muted-color: #555;
  --active-color: #6b9bd1;
  --transition-speed: 0.3s;
}

html, body {
  font-family: Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
  overflow: hidden;
  height: 100%;
  width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

/* === Layout === */
body {
  display: flex;
}

/* === Sidebar === */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  border-right: 1px solid var(--border-color);
  background-color: var(--sidebar-bg);
  overflow: hidden;
}

/* Project navigation (top of sidebar, grows to fill) */
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.project-link {
  text-align: left;
  font-size: 1rem;
  text-decoration: none;
  transition: color var(--transition-speed), font-weight var(--transition-speed);
  position: relative;
  padding-left: 1.5rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.project-link.active {
  color: var(--active-color);
  font-weight: bold;
  text-decoration: none;
}

.project-link:hover {
  text-decoration: underline;
}

.project-link.active:hover {
  text-decoration: none;
}

.project-group-gap {
  height: 0.5rem;
  min-height: 0.5rem;
  flex: 0 0 0.5rem;
  pointer-events: none;
  user-select: none;
}

/* Sidebar toggle – hidden on desktop */
.sidebar-toggle {
  display: none;
}

/* Arrow indicator: positioned absolutely inside .sidebar-nav */
.nav-indicator {
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 7px;
  border-color: transparent transparent transparent var(--active-color);
  transition: top 0.35s ease;
  pointer-events: none;
}

/* Sidebar controls (bottom: ← cat/en →) */
.sidebar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  margin-top: 0;
}

/* Language switch (cat / en) */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.lang-btn, .lang-btn-mobile {
  font-size: 0.875rem;
  text-decoration: none;
  transition: all var(--transition-speed);
}

.lang-btn.active, .lang-btn-mobile.active {
  font-weight: bold;
}

.lang-btn:hover, .lang-btn-mobile:hover {
  opacity: 0.6;
}

.lang-sep {
  font-size: 0.875rem;
  user-select: none;
}

/* Navigation arrows */
.nav-arrow {
  font-size: 1.2rem;
  padding: 0.25rem;
  transition: color 0.2s ease;
  font-weight: 300;
  line-height: 1;
  color: var(--muted-color);
}

.nav-arrow:hover {
  color: var(--text-color);
}

/* Mobile footer (hidden on desktop) */
#mobile-footer {
  display: none;
}

/* === Main content === */
#slide-container {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
  background-color: var(--bg-color);
  overflow-y: auto;
}

#slide-container.centered {
  justify-content: center;
}

.slide-content {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2rem;
  padding: 3rem;
  opacity: 1;
  transition: opacity var(--transition-speed) ease-in-out;
}

.slide-content.transitioning {
  opacity: 0;
}

/* Slide image */
.slide-image-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  max-width: 800px;
  cursor: pointer;
}

#slide-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease;
}

#slide-image:hover {
  transform: scale(1.02);
}

/* Slide text */
.slide-text-wrapper {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

#slide-text {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  white-space: pre-line;
  transition: opacity var(--transition-speed) ease-in-out;
}

#slide-text p {
  margin: 0 0 1rem;
}

#slide-text p:last-child {
  margin-bottom: 0;
}

/* About thumbnails grid */
#slide-thumbs {
  display: none;
  width: 100%;
  gap: 0.75rem;
  grid-template-columns: repeat(var(--thumb-columns, 5), minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  margin-bottom: 1.25rem;
}

.slide-thumb {
  width: 100%;
  aspect-ratio: 14 / 9;
  padding: 0;
  border: 1px solid var(--border-color);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slide-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-thumb:hover {
  border-color: var(--text-color);
}

/* Slide links */
.slide-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 1rem;
  transition: opacity var(--transition-speed) ease-in-out;
}

.slide-links a {
  font-size: inherit;
}

/* Image zoom modal */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-speed) ease-in-out;
}

.image-modal.open {
  display: flex;
  opacity: 1;
}

.image-modal img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

/* Text-only slides (no image): text takes full width */
.slide-image-wrapper[style*="display: none"] + .slide-text-wrapper {
  width: 100%;
}

/* Hide empty wrappers */
.slide-text-wrapper:empty,
#slide-text:empty,
.slide-links:empty {
  display: none;
}

/* === Responsive: Mobile === */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  /* Sidebar becomes scrollable project list */
  #sidebar {
    position: relative;
    width: 100%;
    height: auto;
    max-height: 20dvh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    flex: 0 0 auto;
    overflow: hidden;
    transition: max-height 0.35s ease;
  }

  /* Expanded sidebar: simple blind animation */
  #sidebar.expanded {
    max-height: 100dvh;
  }

  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 1rem;
    padding-bottom: 1.5rem;
    height: 100%;
  }

  /* Hide desktop controls in sidebar on mobile */
  .sidebar-controls {
    display: none;
  }

  /* Sidebar toggle chevron */
  .sidebar-toggle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0 0.3rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    color: var(--muted-color);
    z-index: 1;
  }

  .sidebar-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
  }

  #sidebar.expanded .sidebar-toggle .toggle-icon {
    transform: rotate(180deg);
  }

  .project-link {
    flex-shrink: 0;
    white-space: normal;
    font-size: 0.875rem;
  }

  /* Main content fills between sidebar and footer */
  #slide-container {
    height: auto;
    min-height: 0;
    flex: 1;
  }

  .slide-content {
    padding: 1.5rem 1rem;
  }

  .slide-image-wrapper {
    max-width: 100%;
    width: 100%;
    margin-bottom: 1rem;
  }

  #slide-image {
    max-height: 35dvh;
  }

  .slide-text-wrapper {
    width: 100%;
    max-width: 100%;
    font-size: 0.875rem;
  }

  #slide-text {
    font-size: 0.875rem;
    margin-bottom: 1rem;
  }

  #slide-thumbs {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .slide-links {
    font-size: 0.875rem;
  }

  /* Mobile footer: ← cat/en → */
  #mobile-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--footer-height);
    min-height: var(--footer-height);
    padding: 0 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--sidebar-bg);
    flex-shrink: 0;
  }
}
