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

:root {
  --bg: #fff;
  --fg: #111;
  --muted: #888;
  --border: #e0e0e0;
  --font: 'Inter', -apple-system, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --flip: 0.45s;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--fg);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }
em { font-style: normal; }

/* ── Header ────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: calc(16px + var(--safe-top)) calc(20px + var(--safe-right)) 16px calc(20px + var(--safe-left));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.logo {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
}

.header-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 300;
}

/* ── Footer ────────────────────────────────────────── */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 14px calc(20px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 300;
  transition: color 0.2s;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

.footer-links a:hover {
  color: var(--fg);
}

/* ── Flipper ───────────────────────────────────────── */
.flipper {
  perspective: 1800px;
  min-height: 100dvh;
}

.flipper-viewport {
  position: relative;
}

/* ── Pages ─────────────────────────────────────────── */
.fp {
  display: none;
  min-height: 100dvh;
  background: var(--bg);
  transform-origin: left center;
  will-change: transform, opacity;
}

.fp[data-active="true"] {
  display: block;
}

/* Forward flip */
.fp.flip-out {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation: flipOut var(--flip) var(--ease) forwards;
}

@keyframes flipOut {
  from { opacity: 1; transform: rotateY(0deg); }
  to   { opacity: 0; transform: rotateY(-15deg) scale(0.97); }
}

.fp.flip-in {
  display: block;
  animation: flipIn var(--flip) var(--ease) forwards;
}

@keyframes flipIn {
  from { opacity: 0; transform: rotateY(10deg) scale(0.98); }
  to   { opacity: 1; transform: rotateY(0deg) scale(1); }
}

/* Reverse flip (going back) */
.fp.flip-out-reverse {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation: flipOutReverse var(--flip) var(--ease) forwards;
}

@keyframes flipOutReverse {
  from { opacity: 1; transform: rotateY(0deg); }
  to   { opacity: 0; transform: rotateY(15deg) scale(0.97); }
}

.fp.flip-in-reverse {
  display: block;
  animation: flipInReverse var(--flip) var(--ease) forwards;
}

@keyframes flipInReverse {
  from { opacity: 0; transform: rotateY(-10deg) scale(0.98); }
  to   { opacity: 1; transform: rotateY(0deg) scale(1); }
}

/* On mobile, use lighter transitions (no 3D) */
@media (max-width: 640px) {
  .flipper { perspective: none; }

  @keyframes flipOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-40px); }
  }
  @keyframes flipIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
  }
  @keyframes flipOutReverse {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
  }
  @keyframes flipInReverse {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
  }
}

.fp-inner {
  padding: calc(64px + var(--safe-top)) calc(20px + var(--safe-right)) calc(64px + var(--safe-bottom)) calc(20px + var(--safe-left));
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Index / Home ──────────────────────────────────── */
.index-section {
  margin-bottom: 48px;
}

.index-section h2 {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

.index-thumb {
  display: block;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.25s;
}

.index-thumb:hover {
  opacity: 0.7;
}
.index-thumb:active {
  opacity: 0.5;
}

.index-thumb img {
  width: 100%;
  aspect-ratio: 4/5;
  object-fit: cover;
}

.index-thumb span {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--fg);
  margin-top: 6px;
  line-height: 1.4;
}

.index-thumb em {
  color: var(--muted);
  font-weight: 300;
}

/* ── Gallery ───────────────────────────────────────── */
.gallery-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: calc(60px + var(--safe-top));
  padding-bottom: calc(60px + var(--safe-bottom));
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  max-width: 1100px;
  margin: 0 auto;
}

.gallery-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.gallery-title {
  font-size: 0.85rem;
  font-weight: 400;
  text-align: center;
  flex: 1;
}

.gallery-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 300;
  min-width: 60px;
  text-align: right;
}

.gallery-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.gallery-img-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: calc(100dvh - 200px);
  overflow: hidden;
}

#gallery-img {
  max-width: 100%;
  max-height: calc(100dvh - 200px);
  object-fit: contain;
  transition: opacity 0.3s;
  pointer-events: none;
}

#gallery-img.loading {
  opacity: 0.15;
}

.gallery-arrow {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--muted);
  padding: 16px 8px;
  transition: color 0.2s;
  flex-shrink: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-arrow:hover {
  color: var(--fg);
}

.gallery-arrow:disabled {
  opacity: 0.15;
  cursor: default;
}

.gallery-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  flex-shrink: 0;
}

.gallery-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 300;
}

.gallery-thumbs-btn {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 300;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.gallery-thumbs-btn:hover {
  color: var(--fg);
}

.nav-back {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 300;
  background: none;
  border: none;
  padding: 8px 0;
  transition: color 0.2s;
  flex-shrink: 0;
  min-width: 60px;
  min-height: 44px;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
}

.nav-back:hover {
  color: var(--fg);
}

/* ── Thumbs ────────────────────────────────────────── */
.thumbs-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(64px + var(--safe-top)) calc(20px + var(--safe-right)) calc(64px + var(--safe-bottom)) calc(20px + var(--safe-left));
}

.thumbs-overlay.hidden {
  display: none;
}

.thumbs-top {
  max-width: 1100px;
  margin: 0 auto 24px;
}

.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-width: 1100px;
  margin: 0 auto;
}

.thumb-item {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s;
}

.thumb-item:hover {
  opacity: 0.65;
}
.thumb-item:active {
  opacity: 0.4;
}

.thumb-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.thumb-item span {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ── About ─────────────────────────────────────────── */
.about-page {
  padding-top: calc(60px + var(--safe-top));
}

.about-body {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 40px;
  margin-top: 32px;
}

.about-img img {
  width: 100%;
  max-width: 360px;
}

.about-text p {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--fg);
  margin-bottom: 16px;
}

.about-text em {
  font-style: italic;
}

.about-info {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.about-info div {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 6px 0;
  color: var(--fg);
}

.about-info span {
  color: var(--muted);
  font-weight: 300;
}

/* ── Contact ───────────────────────────────────────── */
.contact-page {
  padding-top: calc(60px + var(--safe-top));
}

.contact-body {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 400px;
}

.contact-body > a {
  font-size: 0.9rem;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.contact-body > a:hover {
  color: var(--muted);
}

.newsletter-block {
  margin-top: 32px;
}

.newsletter-block p {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.newsletter-block form {
  display: flex;
  gap: 0;
}

.newsletter-block input {
  flex: 1;
  font-family: var(--font);
  font-size: 16px; /* prevent iOS zoom */
  padding: 12px;
  border: 1px solid var(--border);
  border-right: none;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  border-radius: 0; /* prevent iOS rounding */
  -webkit-appearance: none;
}

.newsletter-block input:focus {
  border-color: var(--fg);
}

.newsletter-block button {
  font-size: 0.75rem;
  padding: 12px 16px;
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  font-weight: 400;
  letter-spacing: 0.03em;
  transition: opacity 0.2s;
  -webkit-appearance: none;
  border-radius: 0;
  min-height: 44px;
}

.newsletter-block button:hover {
  opacity: 0.8;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 640px) {
  .index-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .about-body {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .about-img img {
    max-width: 200px;
  }

  .gallery-arrow {
    font-size: 1.6rem;
    padding: 12px 4px;
  }

  .gallery-arrow.left { display: none; }
  .gallery-arrow.right { display: none; }

  .thumbs-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

@media (min-width: 900px) {
  .index-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.loading-msg {
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

#gallery-img[src=""] {
  display: none;
}
