@font-face {
  font-family: 'DGM Saffron';
  src: url('fonts/DGMSaffron-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DGM Saffron';
  src: url('fonts/DGMSaffron-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'DGM Saffron Mono';
  src: url('fonts/DGMSaffron-Mono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DGM Saffron Mono';
  src: url('fonts/DGMSaffron-Mono-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

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

a {
  text-decoration: none;
  color: inherit;
}

:root {
  --margin: 12px;
  --gap: 12px;
  --pad: 12px;
  --columns: 6;
  --ui: 1.75rem;
  --edu: 0.65rem;
  /* Width calculation: 4 columns worth of space + 3 gaps */
  --tower-width: calc(((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns) * 4) + 3 * var(--gap));
  --max-image-height: calc(100vh - var(--margin) * 2);
}

body {
  background: #ffffff;
  font-family: 'DGM Saffron', BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
  height: 100vh;
}

body.loading .gallery-container {
  opacity: 0;
}

.gallery-container {
  transition: opacity 0.4s ease;
}

/* ========== HEADER (under the About overlay) ========== */
.topbar {
  position: fixed;
  top: var(--pad);
  left: var(--pad);
  right: var(--pad);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10;
}

.topbar__left {
  line-height: 1.02;
  font-size: var(--ui);
}

.reset-btn {
  cursor: pointer;
  display: inline-block;
}

.reset-btn::after {
  content: ' ↺';
  opacity: 0;
  transition: opacity 0.2s ease;
}

.reset-btn:hover::after {
  opacity: 1;
}

.ui-btn {
  background: none;
  border: none;
  font-size: var(--ui);
  cursor: pointer;
  font-family: inherit;
}

.ui-btn:hover {
  opacity: 0.6;
}

/* ========== NAV ========== */
.nav {
  position: fixed;
  left: var(--pad);
  bottom: var(--pad);
  display: flex;
  gap: 18px;
  align-items: center;
}

.nav__counter {
  font: inherit;
}

.nav .ui-btn {
  min-width: var(--pad);
  min-height: var(--pad);
}

/* ========== ABOUT overlay (ABOVE everything) ========== */
.about {
  position: fixed;
  inset: 0;
  background: #000;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), visibility 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  visibility: hidden;
  z-index: 20;
}

.about.is-open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.95);
  visibility: visible;
}

.about__back {
  position: fixed;
  top: var(--pad);
  right: var(--pad);
  z-index: 21;
  color: rgba(255, 255, 255, 0.55);
}

.about__layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
}

.about__main {
  flex: 1;
  width: 85%;
}

.about__headline {
  font-size: var(--ui);
  line-height: 1.05;
}

.about__education {
  margin-top: 32px;
  font-size: var(--ui);
  line-height: 1.02;
}

.about__edu-label {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.about__year {
  opacity: 0.5;
}

.about__contact {
  font-size: var(--ui);
  line-height: 1.02;
}

.gallery-container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
}

.gallery-track {
  display: flex;
  gap: var(--gap);
  padding: 0 var(--gap) 0 var(--margin);
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--margin);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.gallery-track::-webkit-scrollbar {
  display: none;
}

.gallery-track {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.tower {
  flex: 0 0 var(--tower-width);
  width: var(--tower-width);
  height: 100%;
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
  cursor: default;
}

/* Individual tower width classes (based on column spans) */
.tower.cols-1 { --tower-width: calc((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns)); }
.tower.cols-2 { --tower-width: calc(((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns) * 2) + 1 * var(--gap)); }
.tower.cols-3 { --tower-width: calc(((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns) * 3) + 2 * var(--gap)); }
.tower.cols-4 { --tower-width: calc(((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns) * 4) + 3 * var(--gap)); }
.tower.cols-5 { --tower-width: calc(((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns) * 5) + 4 * var(--gap)); }
.tower.cols-6 { --tower-width: calc(((100vw - (var(--columns) + 1) * var(--gap)) / var(--columns) * 6) + 5 * var(--gap)); }

.tower-inner {
  position: absolute;
  bottom: var(--margin);
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--gap);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.tower-item {
  width: 100%;
  position: relative;
  flex-shrink: 0;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='21' height='35' viewBox='0 0 12.8 20'%3E%3Cpath fill='black' d='M12.8,11.2l-6.3,8.8h0L0,11.2l.4-.5c1.7,1,3.5,1.8,5.5,2.4L3.7,0l2.7,1.1,2.7-1.1-2.3,13.1c2-.6,3.9-1.4,5.6-2.4l.4.5Z'/%3E%3C/svg%3E") 6 10, pointer;
}

.tower-item img,
.tower-item video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  max-height: var(--max-image-height);
}

/* Cover image styles */
.tower-item.cover {
  position: relative;
  overflow: visible;
}

.tower-item.cover img,
.tower-item.cover video {
  width: 100%;
  height: auto;
  max-height: calc(var(--max-image-height) - 2.5rem); /* Leave room for title */
}

/* Title overlay - hidden by default, slides up on hover */
.title-overlay {
  position: relative;
  background: transparent;
  padding: 0.8rem 0;
}

.title-overlay h2 {
  font-size: var(--ui);
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Description slide */
.tower-item.description {
  padding: 0 0 0 0;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  max-height: var(--max-image-height);
  overflow: hidden;
  max-width: 800px;
}

.tower-item.description p {
  font-size: 0.95rem;
  line-height: 1.6;
  font-weight: 300;
}

.tower-item.description p+p {
  margin-top: 12px;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  :root {
    --tower-width: calc(((100vw - 5 * var(--gap)) / 4 * 3) + 2 * var(--gap));
  }
}

@media (max-width: 768px) {
  :root {
    --tower-width: calc(100vw - 2 * var(--gap));
  }
}
