/* =============================
   RESET
   ============================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* =============================
   FORCE CROSSHAIR EVERYWHERE
   (fixes links/buttons switching to pointer)
   ============================= */
*,
*::before,
*::after {
  cursor: crosshair !important;
}

/* =============================
   THEME VARIABLES
   ============================= */
:root {
  --bg: #f6faf6;
  --text: #111;
  --link: #e00;
  --muted: #666;

  --t-fast: 0.25s;
  --t-med: 0.35s;

  /* panel/viewer */
  --panel: var(--bg);
  --hair: #00000014;
}

body.dark {
  --bg: #0f1110;
  --text: #eaeaea;
  --link: #ff5a5a;
  --muted: #a7a7a7;

  --panel: var(--bg);
  --hair: #ffffff1f;
}

/* =============================
   BASE
   ============================= */
html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
  min-height: 100vh;
  margin: 0;

  transition:
    background var(--t-med) ease,
    color var(--t-med) ease,
    opacity var(--t-fast) ease;
}

/* Links */
a {
  color: var(--link);
  text-decoration: none;
  transition: opacity var(--t-fast) ease, color var(--t-fast) ease;
}
a:hover { opacity: 0.7; }

/* Optional page fade (if used in JS) */
.fade-out { opacity: 0; }

/* =============================
   HERO / CENTERED LAYOUT (optional)
   ============================= */
.center-wrap {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ART */
.art {
  width: 280px;
  max-width: 70vw;
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}

/* NAV LOCKED TO IMAGE */
.nav {
  position: absolute;
  left: 105%;
  top: 30%;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

/* THEME TOGGLE BUTTON */
#themeToggle {
  background: none;
  border: none;
  color: var(--link);
  font-size: 12px;
  padding: 0;
  transition: opacity var(--t-fast) ease, transform var(--t-fast) ease;
}
#themeToggle:hover { opacity: 0.7; }
#themeToggle:active { transform: translateY(1px); }

/* SIGNATURE */
.signature {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
}
.signature .date {
  font-size: 12px;
  color: var(--link);
}

/* =============================
   PANEL (if you use the panel layout)
   ============================= */
.panel {
  position: relative; /* IMPORTANT so viewer is constrained */
}

/* =============================
   GALLERY (UNIFORM TILES – FINAL)
   ============================= */
.gallery-wrap {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.image-grid figure {
  margin: 0;
  position: relative;
  aspect-ratio: 21 / 9;     /* ALL TILES SAME SIZE */
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--hair);
  background: #000;
}

/* image fills the tile */
.image-grid img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* caption overlay (shows on hover) */
.image-grid figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.03em;

  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
  opacity: 0;
  transition: opacity var(--t-fast) ease;
}

.image-grid figure:hover figcaption {
  opacity: 1;
}

/* =============================
   IN-PANEL VIEWER (box-limited overlay)
   ============================= */
.panel-viewer {
  position: absolute;
  inset: 0;
  background: var(--panel);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) ease;
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.panel-viewer.active {
  opacity: 1;
  pointer-events: auto;
}

.pv-stage {
  flex: 1;
  padding: 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--hair);
}

.pv-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;

  border-radius: 10px;
  border: 1px solid var(--hair);

  opacity: 0;
  transform: scale(0.99);
  transition: opacity var(--t-med) ease, transform var(--t-med) ease;

  user-select: none;
  -webkit-user-drag: none;
}

.panel-viewer.active .pv-stage img {
  opacity: 1;
  transform: scale(1);
}

.pv-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
}

.pv-btn {
  appearance: none;
  -webkit-appearance: none;

  height: 30px;
  min-width: 44px;
  padding: 0 12px;

  border-radius: 10px;
  border: 1px solid var(--hair);
  background: transparent;
  color: var(--text);

  font-family: inherit;
  font-size: 16px;
  line-height: 1;

  transition: opacity var(--t-fast) ease, transform var(--t-fast) ease;
}
.pv-btn:hover { opacity: 0.75; }
.pv-btn:active { transform: translateY(1px); }

/* =============================
   MOBILE
   ============================= */
@media (max-width: 600px) {
  body {
    overflow: auto; /* allow scrolling on mobile */
  }

  .center-wrap {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin-top: 60px;
    text-align: center;
  }

  .nav {
    position: static;
    margin-top: 30px;
  }

  .gallery-wrap {
    width: min(760px, calc(100% - 28px));
    padding: 28px 0 40px;
  }

  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .image-grid figure {
    aspect-ratio: 4 / 3; /* better on phones */
  }
}

/* =============================
   REDUCED MOTION
   ============================= */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
