/* ==========================================================================
   MATTHEW SIU — PORTFOLIO
   Exact CSS & Typography from portfoliokinda.html
   Font: Arial, Helvetica, sans-serif
   Weight: 400 with text-shadow: 0 0 .35px currentColor, 0 0 .55px currentColor
   ========================================================================== */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: #fff;
  color: #191919;
  overflow-x: hidden;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 400;
  letter-spacing: -0.015em;
  text-shadow: 0 0 0.35px currentColor, 0 0 0.55px currentColor;
}

button, input, textarea, select {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 400;
  letter-spacing: -0.015em;
  text-shadow: 0 0 0.35px currentColor, 0 0 0.55px currentColor;
}

/* ==========================================================================
   SITE GRID LAYOUT (portfoliokinda.html)
   ========================================================================== */
#site {
  display: grid;
  grid-template-columns: minmax(170px, max-content) 1fr;
  min-height: 100vh;
  background: #fff;
}

#sidebar {
  padding: 44px 40px 30px 4vw;
  align-self: start;
  position: sticky;
  top: 0;
}

#brand {
  font-size: 21px;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0 0 52px;
}

#brand a {
  color: inherit;
  text-decoration: none;
  font-weight: 400;
  letter-spacing: -0.015em;
  text-shadow: inherit;
}

#nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 13px;
}

#nav button {
  font: inherit;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.015em;
  border: 0;
  background: none;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
  transition: opacity 0.2s ease;
}

#nav button:hover,
#nav button:focus-visible {
  opacity: 0.48;
}

#nav button.active {
  opacity: 1;
}

#nav .group-gap {
  margin-top: 40px;
}

#content {
  padding: 44px 4vw 60px 0;
  min-width: 0;
  background: #fff;
}

/* ==========================================================================
   PAGE VIEWS
   ========================================================================== */
.page {
  display: none;
  position: relative;
  min-height: 70vh;
}

.page.active {
  display: block;
}

/* Home Image (constrained to window height without scrolling) */
[data-view="home"] {
  min-height: 0;
}

#home-image-item {
  width: auto;
  max-width: 80%;
  display: inline-block;
  margin-left: 10%;
}

#home-image-item .gallery-frame {
  width: auto;
  max-height: calc((100vh - 115px) * 0.8);
}

#home-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc((100vh - 115px) * 0.8);
  height: auto;
  object-fit: contain;
  cursor: default;
}

.single-image-item {
  width: 100%;
  min-width: 0;
}

.gallery-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  min-height: 80px;
  background: #fff;
}

.gallery-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  object-fit: contain;
}

/* ==========================================================================
   PROJECT LAYOUT (portfoliokinda.html)
   ========================================================================== */
.project-layout {
  display: grid;
  grid-template-columns: auto 240px;
  gap: 40px;
  align-items: start;
  width: fit-content;
  max-width: 100%;
}

.project-title {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0 0 20px;
}

.gallery {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
  width: 100%;
  min-width: 0;
}

.caption {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.28;
  letter-spacing: -0.015em;
  min-height: 110px;
  width: 240px;
  outline: none;
  text-shadow: 0 0 0.35px currentColor, 0 0 0.55px currentColor;
}

.caption p {
  margin: 0;
  line-height: 1.28;
}

/* ==========================================================================
   EMPIRE MEDIA LAYOUT (Garment on left, 3 Cole paintings aligned on right)
   ========================================================================== */
.empire-media-container {
  display: grid;
  grid-template-columns: minmax(0, 390px) minmax(0, 285px);
  gap: 24px;
  align-items: stretch;
  width: 100%;
  max-width: 720px;
}

.empire-garment {
  width: 100%;
  display: flex;
}

.empire-garment img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

.empire-paintings {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.empire-paintings img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

/* ==========================================================================
   ORIGAMI MEDIA LAYOUT (2-column studies + wide study)
   ========================================================================== */
.origami-media-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.origami-grid-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 580px;
}

.origami-grid-pair img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

.origami-wide-item {
  max-width: 580px;
}

.origami-wide-item img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

/* ==========================================================================
   KARASU MEDIA LAYOUT (Sketches side by side)
   ========================================================================== */
.karasu-sketches-container {
  display: flex;
  gap: 18px;
  width: 100%;
  flex-wrap: wrap;
}

.sketch-item {
  flex: 1 1 200px;
  max-width: 340px;
}

.sketch-item img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}

/* ==========================================================================
   WRITINGS LAYOUT (portfoliokinda.html)
   ========================================================================== */
.pdfs {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 600px;
}

.pdf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  font-size: 14px;
}

.pdf-row a {
  color: inherit;
  text-decoration: none;
}

.pdf-row a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   ABOUT LAYOUT (portfoliokinda.html)
   ========================================================================== */
.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 250px);
  gap: 36px;
  align-items: start;
  max-width: 900px;
}

.about-copy {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: -0.015em;
  min-height: 220px;
  outline: none;
}

.about-copy a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.about-copy a:hover,
.about-copy a:focus-visible {
  opacity: 0.55;
  text-decoration: underline;
}

.about-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3/4;
  object-fit: cover;
  cursor: zoom-in;
}

/* ==========================================================================
   LIGHTBOX MODAL
   ========================================================================== */
.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.98);
  z-index: 9999;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666;
}

.lightbox-close-btn {
  font-size: 16px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 4px 8px;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 16px 0;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  user-select: none;
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ddd;
  border-radius: 50%;
  font-size: 16px;
  z-index: 10;
  cursor: pointer;
}

.lightbox-prev-btn { left: 16px; }
.lightbox-next-btn { right: 16px; }

/* ==========================================================================
   RESPONSIVE DESIGN — SIDEBAR STAYS ON THE SIDE
   ========================================================================== */

/* Tablet & Intermediate Screens */
@media (max-width: 1050px) {
  #site {
    grid-template-columns: minmax(150px, max-content) 1fr;
  }
  #sidebar {
    padding: 36px 28px 30px 3vw;
  }
  #content {
    padding: 36px 3vw 60px 0;
  }
  .project-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    width: 100%;
  }
  .caption {
    width: 100%;
    max-width: 580px;
  }
  .about-layout {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 220px);
    gap: 28px;
  }
}

@media (max-width: 800px) {
  .empire-media-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .empire-paintings {
    gap: 14px;
    height: auto !important;
  }
}

/* Mobile Screens (Menu kept on the side) */
@media (max-width: 650px) {
  #site {
    grid-template-columns: clamp(112px, 32vw, 150px) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    overflow-x: hidden;
  }

  #sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    padding: 24px 10px 24px max(14px, env(safe-area-inset-left));
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    z-index: 10;
    min-width: 0;
  }

  #sidebar::-webkit-scrollbar {
    display: none;
  }

  #brand {
    font-size: 16px;
    letter-spacing: -0.015em;
    margin: 0 0 28px;
    line-height: 1.2;
    white-space: nowrap;
  }

  #nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
  }

  #nav button {
    font-size: 14px;
    line-height: 1.25;
    letter-spacing: -0.015em;
    text-align: left;
    padding: 6px 0;
    min-height: 34px;
    display: flex;
    align-items: center;
    width: 100%;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    -webkit-tap-highlight-color: transparent;
  }

  #nav .group-gap {
    margin-top: 22px;
  }

  #content {
    padding: 24px max(14px, env(safe-area-inset-right)) 48px 10px;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
  }

  /* Home Image */
  #home-image-item {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    display: block;
  }

  #home-image-item .gallery-frame,
  #home-image {
    max-height: calc(100vh - 56px);
    max-height: calc(100dvh - 56px);
    width: 100%;
    object-fit: contain;
  }

  /* Projects General */
  .project-layout {
    grid-template-columns: 1fr;
    gap: 18px;
    width: 100%;
    max-width: 100%;
  }

  .project-title {
    font-size: 14.5px;
    margin: 0 0 16px;
    line-height: 1.25;
  }

  .gallery {
    gap: 16px;
    width: 100%;
  }

  .caption {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    font-size: 13.5px;
    line-height: 1.45;
  }

  /* Course of Empire Media */
  .empire-media-container {
    grid-template-columns: 1fr;
    gap: 14px;
    width: 100%;
    max-width: 100%;
  }

  .empire-garment {
    width: 100%;
  }

  .empire-garment img {
    width: 100%;
    height: auto;
    display: block;
  }

  .empire-paintings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: auto !important;
    width: 100%;
  }

  .empire-paintings img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* Origami Media */
  .origami-media-container {
    gap: 10px;
    width: 100%;
  }

  .origami-grid-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
  }

  .origami-grid-pair img,
  .origami-wide-item img {
    width: 100%;
    height: auto;
    display: block;
  }

  .origami-wide-item {
    width: 100%;
  }

  /* Karasu Sketches */
  .karasu-sketches-container {
    flex-direction: column;
    gap: 14px;
    width: 100%;
  }

  .sketch-item {
    max-width: 100%;
    width: 100%;
    flex: none;
  }

  /* About Layout */
  .about-layout {
    grid-template-columns: 1fr;
    gap: 22px;
    width: 100%;
    max-width: 100%;
  }

  .about-copy {
    font-size: 13.5px;
    line-height: 1.6;
    min-height: 0;
  }

  .about-image {
    width: 100%;
    max-width: 260px;
    height: auto;
    aspect-ratio: 3/4;
    object-fit: cover;
  }

  /* Lightbox on Mobile */
  .lightbox-modal {
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .lightbox-content img {
    max-width: 95vw;
    max-height: calc(100vh - 85px);
    max-height: calc(100dvh - 85px);
  }

  .lightbox-close-btn {
    font-size: 20px;
    padding: 6px 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .lightbox-nav-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .lightbox-prev-btn { left: 8px; }
  .lightbox-next-btn { right: 8px; }
}

/* Extra Small Screens (<= 360px) */
@media (max-width: 360px) {
  #site {
    grid-template-columns: clamp(100px, 31vw, 115px) 1fr;
  }

  #sidebar {
    padding: 20px 6px 20px 10px;
  }

  #content {
    padding: 20px 10px 40px 6px;
  }

  #brand {
    font-size: 14.5px;
    margin-bottom: 22px;
  }

  #nav button {
    font-size: 13px;
    min-height: 30px;
    padding: 4px 0;
  }

  #nav .group-gap {
    margin-top: 18px;
  }

  .project-title {
    font-size: 13.5px;
    margin-bottom: 12px;
  }

  .caption,
  .about-copy {
    font-size: 12.5px;
    line-height: 1.45;
  }

  .origami-grid-pair {
    gap: 6px;
  }
}
