/* =============================================
   UNDERCOVERS — style.css
   ============================================= */

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

:root {
  --bg: #0d0d0d;
  --accent: #f0ece3;
  --title-size: clamp(5rem, 14vw, 13rem);
  --byline-size: clamp(0.6rem, 1.1vw, 0.78rem);
  --btn-size: clamp(0.6rem, 0.9vw, 0.72rem);
  --transition-speed: 0.7s;
  --frame-max: min(72vw, 820px);
  --frame-max-mobile: 92vw;
}

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  color: var(--accent);
  font-family: 'Space Mono', monospace;
}

/* ---- BG OVERLAY ---- */
#bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  transition: background-color 1.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* ---- TOP BAR ---- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.4rem 1.6rem 0;
  pointer-events: none;
}

.byline {
  font-family: 'Space Mono', monospace;
  font-size: var(--byline-size);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.5s ease;
  mix-blend-mode: difference;
  pointer-events: none;
  line-height: 1.9;
}

.byline.visible {
  opacity: 0.75;
}

.grid-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  width: 28px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.2s ease;
  pointer-events: all;
  mix-blend-mode: difference;
}

.grid-toggle.visible {
  opacity: 0.8;
}

.grid-toggle:hover {
  opacity: 1;
  transform: scale(1.12);
}

.grid-toggle svg {
  width: 100%;
  height: 100%;
}

/* ---- SITE TITLE ---- */
.site-title {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  text-align: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: var(--title-size);
  letter-spacing: 0.04em;
  line-height: 0.88;
  color: var(--accent);
  padding-top: 0.12em;
  pointer-events: none;
  mix-blend-mode: difference;
  user-select: none;
}

.cursor {
  display: inline-block;
  animation: blink 0.75s step-end infinite;
  opacity: 1;
}

.cursor.hidden {
  opacity: 0;
  animation: none;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---- SINGLE VIEW ---- */
.single-view {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding-top: calc(var(--title-size) * 0.55);
  padding-bottom: 4rem;
}

/* ---- PICTURE FRAME ---- */
.picture-frame {
  position: relative;
  width: var(--frame-max);
  max-width: 100%;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.picture-frame.visible {
  opacity: 1;
  transform: translateY(0);
}

.picture-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: cover;
  object-position: center;
}

.picture-load-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.picture-load-overlay.loaded {
  opacity: 0;
}

/* ---- CONTROLS ---- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--frame-max);
  max-width: 100%;
  margin-top: 1.4rem;
  opacity: 0;
  transition: opacity 0.6s ease 0.2s;
}

.controls.visible {
  opacity: 1;
}

.btn {
  font-family: 'Space Mono', monospace;
  font-size: var(--btn-size);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0.4em 0;
  position: relative;
  transition: opacity 0.2s ease;
  mix-blend-mode: difference;
}

.btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 1px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.btn:hover::after { width: 100%; }
.btn:hover { opacity: 1; }
.btn:not(:hover) { opacity: 0.55; }

.btn-latest {
  letter-spacing: 0.25em;
}

/* ---- GRID VIEW ---- */
.grid-view {
  position: relative;
  z-index: 10;
  padding-top: calc(var(--title-size) * 0.62);
  padding-bottom: 4rem;
  min-height: 100vh;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  padding: 0 2rem;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.grid-item {
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: rgba(255,255,255,0.04);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  transform: scale(0.94);
}

.grid-item.animate-in {
  opacity: 1;
  transform: scale(1);
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.grid-item:hover img {
  transform: scale(1.05);
}

/* ---- LIGHTBOX ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox.hidden { display: none; }

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-family: 'Space Mono', monospace;
}

.lightbox-close:hover { opacity: 1; }

/* ---- INFO TRIGGER ---- */
.info-trigger {
  position: fixed;
  bottom: 1.4rem;
  left: 1.6rem;
  z-index: 100;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: var(--btn-size);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  mix-blend-mode: difference;
  padding: 0;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.info-trigger:hover { opacity: 1; }

/* ---- INFO OVERLAY ---- */
.info-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(6, 6, 8, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.info-overlay.hidden { display: none !important; }

.info-content {
  text-align: center;
  max-width: 480px;
  padding: 2rem;
  cursor: default;
  pointer-events: none;
}

.info-content {
  text-align: center;
  max-width: 420px;
  padding: 2rem;
  cursor: default;
  pointer-events: none;
}

.info-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.8rem, 8vw, 5rem);
  letter-spacing: 0.06em;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1.6rem;
}

.info-body {
  font-family: 'Space Mono', monospace;
  font-size: clamp(0.72rem, 1.2vw, 0.82rem);
  letter-spacing: 0.08em;
  line-height: 2;
  color: var(--accent);
  opacity: 0.6;
}

.info-gap {
  margin-top: 1.8em;
}

.info-key {
  color: var(--accent);
}

.info-copy {
  opacity: 0.3;
}

.info-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(240,236,227,0.25);
  pointer-events: all;
  transition: opacity 0.2s;
}

.info-link:hover { opacity: 0.5; }

/* ---- UTIL ---- */
.hidden { display: none !important; }

/* ---- COUNTER BADGE ---- */
.counter {
  position: fixed;
  bottom: 1.4rem;
  right: 1.6rem;
  z-index: 100;
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  opacity: 0.35;
  mix-blend-mode: difference;
  color: var(--accent);
  transition: opacity 0.3s;
}
.counter:hover { opacity: 0.7; }

/* =============================================
   MOBILE
   ============================================= */
@media (max-width: 768px) {
  :root {
    --title-size: clamp(3rem, 17vw, 4.8rem);
    --byline-size: 0.58rem;
    --btn-size: 0.58rem;
    --topbar-height: 7rem; /* byline stacks 4 lines, give it room */
  }

  .top-bar {
    padding: 1rem 1rem 0;
  }

  /* Push title below the top bar on mobile */
  .site-title {
    position: relative;
    padding-top: var(--topbar-height);
    margin-bottom: 0;
  }

  /* Single view sits naturally below the title */
  .single-view {
    padding-top: 1rem;
    padding-bottom: 5rem;
  }

  .picture-frame {
    width: var(--frame-max-mobile);
  }

  .controls {
    width: var(--frame-max-mobile);
    margin-top: 1rem;
  }

  .grid-view {
    padding-top: calc(var(--topbar-height) + var(--title-size) + 1rem);
  }

  /* Keep grid-view title fixed-positioned */
  .grid-view ~ .site-title,
  body.grid-active .site-title {
    position: fixed;
    padding-top: var(--topbar-height);
  }

  .grid-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 0 1rem;
  }

  .btn-latest {
    font-size: 0.55rem;
  }

  .info-body {
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .grid-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}
