@import './css/stylesheet.css';

/* =========================
   Core layout
========================= */

#file-select { display: none; }

.slide {
  position: absolute;
  z-index: 0;
  width: 100%;
  padding: 5px;
  display: flex;
  gap: 5px;
  justify-content: center;
  background: var(--background);
  height: fit-content;
  max-height: calc(100vh - 180px);
}

.togglebox {
  flex: 0 0 60px; /* width when inactive */
  height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  border-radius: 10px;
  background: var(--background);
  filter: brightness(90%);
  transition: flex 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.togglebox:hover { background: var(--content); }

.togglebox.active {
  flex-grow: 1000; /* expand when active */
  filter: none;
  overflow: hidden;
  justify-content: unset;
  align-items: unset;
}

.togglebox.active:hover { background: inherit; }

/* =========================
   Slide content visibility
========================= */

#slide_content {
  display: grid;
  align-items: center;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s, opacity 0.8s linear;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge */
}
#slide_content::-webkit-scrollbar { display: none; }

.togglebox.active #slide_content {
  visibility: visible;
  opacity: 1;
}

.togglebox p { visibility: hidden; opacity: 0; }
.togglebox.active p {
  visibility: visible;
  opacity: 1;
  animation: 2s ease 0s forwards fadein;
}

@keyframes fadein { 0%,33%{opacity:0;} 100%{opacity:1;} }

/* =========================
   Slide title (tab label)
========================= */

.slide_title { height: inherit; border-radius: 10px; }

/* Base color (inactive default) */
.slide_title h1 a {
  color: var(--content);
  text-decoration: none;
}

/* Active tab color */
.togglebox.active .slide_title h1 a { color: var(--background); }

/* Hover color only on inactive tabs */
.togglebox:not(.active):hover .slide_title h1 a { color: var(--background); }

/* When active, you also change the title bg if desired */
.togglebox.active .slide_title { background: var(--theme-color); }

/* =========================
   Canvas (Three.js)
========================= */

.togglebox .canvas {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: calc(100vh - 120px);
  overflow: hidden;

  visibility: hidden;
  opacity: 0;
}

.togglebox.active .canvas {
  visibility: visible;
  opacity: 1;
  animation: 2s ease 0s forwards fadein;
}

/* Make the WebGL <canvas> fill the container */
.canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* =========================
   Image wrapper
========================= */

.img_wrapper {
  display: grid;
  grid-template-columns: auto;
  grid-template-rows: auto;
  align-items: center;
  align-content: center;
  left: 0;
}
.img_wrapper img { height: 90vh; align-content: center; }

/* =========================
   Responsive: titles
========================= */

@media screen and (min-width: 749px) {
  .slide_title h1 {
    padding: 10px;
    line-height: 0;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-weight: 500;
  }
}

@media screen and (max-width: 749px) {
  .slide {
    width: 100%;
    min-height: calc(100% - 80px);
    flex-direction: column;
  }

  .togglebox {
    width: inherit;
    height: 60px;
    display: grid;
    place-items: center;
    background: var(--background);
  }

  .slide_title h1 { font-weight: 500; text-align: center; }
  .slide_title { font-weight: 500; }

  .togglebox.active .slide_title { visibility: hidden; opacity: 0; display: none; }
}

/* =========================
   Project sheet
========================= */

.line {
  border-top: 3px solid var(--content);
  padding: 10px 0;
  text-align: justify;
  text-justify: inter-word;
}

.c .p { left: 0; padding: 0; margin: 0; top: 0; }

.line img { width: 100%; border-radius: var(--spacing-l); }

.wrapper {
  display: grid;
  grid-template-columns: 50% 5% 50%;
  width: 85%;
  margin: 50px auto;
  color: var(--content);
}

.title { font-size: 3em; color: var(--content); }

.b ul {
  list-style: none;
  line-height: 100%;
  margin: 0;
  padding-left: 0;
}

/* Info title (prevent overlap; keep original sizes) */
.info_title {
  line-height: 1.3;
  display: grid;
  gap: 0.25rem;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.info_title h1 {
  font-size: 3em;
  font-weight: 600;
  line-height: 1.1;
  margin: 0;
}
.info_title br { display: none; }

/* Multi-column text only on desktop */
.f .text_grid { column-count: 1; column-gap: 2rem; column-fill: balance; }
@media only screen and (min-width: 750px) {
  .f .text_grid { column-count: 2; column-gap: 2.2rem; }
  .f .text_grid p {
    break-inside: avoid;
    margin: 0 0 1rem 0;
    hyphens: none;
    overflow-wrap: anywhere;
  }
}

/* Wrapper layout breakpoints */
@media only screen and (max-width: 749px) {
  .wrapper { grid-template-columns: auto; }
  .a { grid-row: 1 / 2; }
  .b { grid-column: 1 / 2; grid-row: 2 / 3; }
  .c { grid-row: 3 / 4; }
  .d { grid-row: 4 / 5; }
  .e { grid-row: 5 / 6; }
  .f { grid-column: 1 / 2; grid-row: 6 / 7; }
  .g { grid-column: 1 / 2; grid-row: 8 / 9; }
  .h { grid-column: 1 / 2; grid-row: 9 / 10; }
}

@media only screen and (min-width: 750px) {
  .wrapper { grid-template-columns: 50% 5% 50%; }
  .a { grid-column: 1 / 2; grid-row: 1 / 2; }
  .b { grid-column: 3 / 4; grid-row: 1 / 2; }
  .c {
    font-weight: bold;
    font-size: 1.7em;
    line-height: 10%;
    grid-column: 1 / 2;
    grid-row: 2 / 3;
  }
  .d {
    font-weight: bold;
    font-size: 1.7em;
    grid-column: 1 / 2;
    grid-row: 3 / 4;
  }
  .e {
    font-weight: bold;
    font-size: 1.7em;
    grid-column: 1 / 2;
    grid-row: 4 / 5;
  }
  .f { grid-column: 3 / 4; grid-row: 2 / 3; }
  .g { grid-column: 3 / 4; grid-row: 3 / 4; }
  .h { grid-column: 3 / 4; grid-row: 4 / 5; }
}

/* =========================
   Footer
========================= */

footer {
  position: fixed;
  bottom: 0;
  width: 100%;
}

/* =========================
   Carousel
========================= */

.carousel-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80%;
  margin: 30px auto;
  position: relative;
  gap: 10px;
}

.carousel-container {
  overflow: hidden;
  width: 100%;
  border-radius: 10px;
  position: relative;
}

.carousel-track {
  display: flex;
  gap: 10px;
  width: 100%;
  max-height: 80vh;
  transition: transform 0.4s ease-in-out;
}

.carousel-track img {
  display: block;
  width: 100%;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
}

.carousel-btn {
  position: absolute;
  background: transparent;
  border: none;
  color: var(--content);
  z-index: 2;
  transition: transform 0.2s ease-in-out;
}
.carousel-btn svg { display: block; width: 50px; height: 50px; }

.prev:hover { transform: translateX(-5px); }
.next:hover { transform: translateX(5px); }

.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }

@media screen and (max-width: 749px) { .carousel-wrapper { width: 95%; } }

/* =========================
   Gallery
========================= */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  width: 80%;
  margin: 0 auto 50px;
}

.gallery img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
  transition: filter 0.3s ease-in-out;
}

.gallery img:hover { filter: blur(0) grayscale(0) opacity(0.9); }

/* =========================
   Fullscreen modal
========================= */

#fullscreen-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 998;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#fullscreen-modal.show { visibility: visible; opacity: 1; }

#fullscreen-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 10px;
  transition: opacity 2s ease;
}

.close-btn {
  position: absolute;
  top: 5px;
  right: 30px;
  font-size: 5rem;
  color: #fff;
  z-index: 1000;
}

/* =========================
   Misc
========================= */

@media screen and (max-width: 749px) {
  .carousel-container, .gallery { width: 95%; }
  .carousel img { max-width: 250px; }
}

/* Ensure IMAGE slide content becomes visible when active */
#i3.active #slide_content {
  visibility: visible;
  opacity: 1;
  animation: 2s ease 0s forwards fadein;
}
