* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --page-bg: #ffffff;
  --text-color: #222222;
  --nav-bg: #f7f0fa;
  --link-color: #321b38;
  --hover-bg: #eadcf0;
  --current-bg: #e7c9f2;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #121826;
  --text-color: #e5e7eb;
  --nav-bg: #1f2937;
  --link-color: #f3e8ff;
  --hover-bg: #374151;
  --current-bg: #4b3b59;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background-color: var(--page-bg);
  color: var(--text-color);
  transition: background-color 0.2s ease, color 0.2s ease;
}

main {
  flex: 1;
}

p{
  text-align: center;
}

nav {
  z-index: 100;
  background-color: var(--nav-bg);
}

.button-list {
  display: flex;
  margin: 0;
  padding: 0.75rem;
  list-style: none;
}

.button-list li {
  margin: 0;
}

.button-list a {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  color: var(--link-color);
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.button-list a:hover,
.button-list a:focus-visible {
  background-color: var(--hover-bg);
}

.button-list .current a,
.button-list a[aria-current="page"] {
  background-color: var(--current-bg);
  color: var(--link-color);
  font-weight: 700;
}

.skip-link {
  position: absolute;
  top: -3rem;
  left: 0.5rem;
  z-index: 2000;
  padding: 0.5rem 0.75rem;
  background: #fff;
  color: #000;
}

.skip-link:focus {
  top: 0.5rem;
}

#theme-toggle {
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--link-color);
  font: inherit;
  cursor: pointer;
}

#theme-toggle:hover,
#theme-toggle:focus-visible {
  background-color: var(--hover-bg);
}

#theme-toggle:focus-visible,
.button-list a:focus-visible,
.preview:focus-visible,
.lightbox-trigger:focus-visible {
  outline: 3px solid #0d6efd;
  outline-offset: 3px;
}

#image {
  min-height: 250px;
  margin: 1rem 0;
  padding: 1rem;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  border: 1px solid var(--text-color);
}

.gallery,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.gallery figure,
.gallery-grid figure {
  margin: 0;
}

.preview,
.gallery-thumbnail {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.lightbox-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  margin: 0 auto;
  object-fit: contain;
}

.carousel-item img {
  height: min(65vh, 600px);
  object-fit: contain;
  background: #222;
}

.carousel-caption {
  background: rgb(0 0 0 / 70%);
  border-radius: 0.25rem;
}

.floating-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem;
  margin-top: auto;
}

.floating-footer a {
  display: inline-block;
  padding: 0.75rem 1rem;
  color: #fff;
  background: #333;
  border-radius: 0.5rem;
  text-decoration: none;
}

.floating-footer a:hover,
.floating-footer a:focus-visible {
  background: #555;
  text-decoration: underline;
}

.floating-footer a:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 3px;
}

/* Mobile: compact horizontal navigation at the top */
@media (max-width: 599px) {
  nav {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow-x: auto;
  }

  body {
    padding-top: 4rem;
  }

  .button-list {
    flex: 0 0 auto;
    gap: 0.1rem;
    padding: 0.35rem;
  }

  .button-list a,
  #theme-toggle {
    padding: 0.55rem 0.6rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  #theme-toggle {
    flex: 0 0 auto;
  }
}

/* Tablet: fixed vertical navigation on the left */
@media (min-width: 600px) and (max-width: 1023px) {
  nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 7rem;
  }

  body {
    margin-left: 7rem;
  }

  .button-list {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0.4rem;
  }

  .button-list a,
  #theme-toggle {
    padding: 0.65rem 0.25rem;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
  }
}

/* Desktop: sticky horizontal navigation */
@media (min-width: 1024px) {
  nav {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }

  .button-list {
    flex-direction: row;
    justify-content: center;
    gap: 0.75rem;
  }
}
