/* 
  photoweb default style 
  A modern, premium look with responsive grid and dark mode support.
*/

:root {
  --bg-color: #ffffff;
  --text-color: #1d1d1f;
  --secondary-text: #86868b;
  --accent-color: #0066cc;
  --border-color: #d2d2d7;
  --card-bg: #f5f5f7;
  --overlay-bg: rgba(255, 255, 255, 0.8);
  --gap: 20px;
  --transition-speed: 0.3s;
  --transition-ease: ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #000000;
    --text-color: #f5f5f7;
    --secondary-text: #86868b;
    --accent-color: #2997ff;
    --border-color: #424245;
    --card-bg: #1d1d1f;
    --overlay-bg: rgba(29, 29, 31, 0.8);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color var(--transition-speed) var(--transition-ease);
}

a:hover {
  text-decoration: underline;
}

/* Info Section */
.info {
  padding: 40px 20px 20px;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.info h1 {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
}

.info .caption {
  font-size: 21px;
  color: var(--secondary-text);
  max-width: 600px;
  margin: 0 auto;
  overflow-wrap: break-word;
}

/* Gallery Grid */
.gallery {
  width: 100%;
  max-width: 1400px;
  margin: 20px auto;
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.cell {
  display: block;
}

.pic {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background-color: var(--card-bg);
  transition: transform var(--transition-speed) var(--transition-ease), 
              box-shadow var(--transition-speed) var(--transition-ease);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.pic:not(.is-fullscreen *):hover {
  transform: scale(1.02);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.pic img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

.pic .small.num {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: var(--overlay-bg);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.pic h3 {
  padding: 12px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
}

/* Detail Page */
.nav {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  font-size: 17px;
}

.picmd {
  margin-top: 16px;
}

.picmd h2 {
  font-size: 32px;
  margin-bottom: 8px;
}

.wrap {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.wrap .pic {
  max-width: 95vw;
  border-radius: 18px;
  transition: transform var(--transition-speed) var(--transition-ease),
              box-shadow var(--transition-speed) var(--transition-ease);
  cursor: zoom-in;
}

.wrap .pic img {
  max-height: 80vh;
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  transition: opacity var(--transition-speed) var(--transition-ease);
}

.wrap .num, .wrap .date {
  text-align: center;
  margin-top: 12px;
  color: var(--secondary-text);
  font-size: 14px;
  transition: color var(--transition-speed) var(--transition-ease);
}

/* Immersive Fullscreen Mode */
.detail-layout.is-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  background-color: #000 !important;
  z-index: 2000 !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
  display: block !important; /* Standard block for root-level scrolling */
  padding: 0 !important;
  margin: 0 !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #666 #000;
}

.is-fullscreen .info,
.is-fullscreen .num,
.is-fullscreen .date,
.is-fullscreen .picmd {
  display: none !important;
}

.is-fullscreen .wrap {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
  box-sizing: border-box;
}

.is-fullscreen .wrap .pic {
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  display: flex !important;
  justify-content: center;
  align-items: center;
  overflow: visible !important;
  border-radius: 0;
  background: transparent;
}

.is-fullscreen .wrap .pic img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  transition: none; /* Instant transition for zoom feel */
}

/* Zoomed State (Actual Size) */
.is-fullscreen.is-zoomed .wrap {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0;
}

.is-fullscreen.is-zoomed .wrap .pic {
  width: max-content !important;
  min-width: 100% !important;
  min-height: 100% !important;
}

.is-fullscreen.is-zoomed .wrap .pic img {
  max-width: none !important;
  max-height: none !important;
  width: auto !important;
  height: auto !important;
  object-fit: none !important; /* Native bit-for-bit zoom */
  cursor: zoom-out;
}

/* Custom Scrollbars for the Immersive Overlay */
.detail-layout.is-fullscreen::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.detail-layout.is-fullscreen::-webkit-scrollbar-track {
  background: #000;
}

.detail-layout.is-fullscreen::-webkit-scrollbar-thumb {
  background-color: #666;
  border-radius: 7px;
  border: 3px solid #000;
}

.detail-layout.is-fullscreen::-webkit-scrollbar-thumb:hover {
  background-color: #888;
}

/* Responsive Detail Layout */
.detail-layout {
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .detail-layout {
    flex-direction: row-reverse;
    align-items: flex-start;
    padding: 60px 40px;
    gap: 60px;
    max-width: 1800px;
    margin: 0 auto;
  }

  .detail-layout .info {
    position: sticky;
    top: 60px;
    width: 380px;
    flex-shrink: 0;
    text-align: left;
    padding: 0;
    margin: 0;
  }

  .detail-layout .info h1 {
    font-size: 28px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    max-width: 100%;
    overflow-wrap: break-word;
  }

  .detail-layout .nav {
    justify-content: flex-start;
    margin-bottom: 40px;
  }

  .detail-layout .picmd {
    margin-top: 0;
  }

  .detail-layout .picmd h2 {
    font-size: 24px;
    font-weight: 600;
    max-width: 100%;
    overflow-wrap: break-word;
  }

  .detail-layout .wrap {
    flex-grow: 1;
    padding: 0;
  }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .info h1 {
    font-size: 32px;
  }

  .is-fullscreen .wrap {
    padding: env(safe-area-inset-top, 10px) env(safe-area-inset-right, 10px) env(safe-area-inset-bottom, 10px) env(safe-area-inset-left, 10px);
  }
}
