/* ══════════════════════════════════════
   Gallery — Skeuomorphic Sketchbook
   ══════════════════════════════════════ */

/* ── Sketchbook container ── */
.sketchbook {
  position: relative;
  max-width: 820px;
  margin: 0 auto;
  perspective: 1200px;
}

/* ── Paper page ── */
.paper-page {
  position: relative;
  background:
    /* ruled lines */
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      rgba(180, 170, 155, 0.18) 31px,
      rgba(180, 170, 155, 0.18) 32px
    ),
    /* paper grain */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E"),
    /* base paper color */
    linear-gradient(135deg, #faf6ef 0%, #f5f0e6 50%, #f0ebe0 100%);
  border-radius: 4px 12px 12px 4px;
  padding: 40px 36px;
  margin-bottom: 32px;
  box-shadow:
    2px 2px 8px rgba(80, 60, 40, 0.12),
    inset 0 0 40px rgba(80, 60, 40, 0.03);
  border: 1px solid rgba(180, 170, 155, 0.25);
  min-height: 500px;
  transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.4s;
}

/* spine shadow on left */
.paper-page::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 24px;
  background: linear-gradient(90deg, rgba(80,60,40,0.08), transparent);
  border-radius: 4px 0 0 4px;
  pointer-events: none;
}

/* margin line */
.paper-page::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 68px;
  width: 1px;
  background: rgba(200, 80, 80, 0.12);
  pointer-events: none;
}

/* ── Page header (handwritten style) ── */
.page-title {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 1.4rem;
  font-weight: 400;
  font-style: italic;
  color: #4a4035;
  margin-bottom: 8px;
  margin-left: 40px;
  letter-spacing: 0.5px;
}

.page-subtitle {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.82rem;
  color: #9a8e7e;
  font-style: italic;
  margin-left: 40px;
  margin-bottom: 24px;
}

/* ── Gallery grid ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-left: 40px;
}

@media (max-width: 600px) {
  .gallery-grid { grid-template-columns: 1fr; gap: 20px; margin-left: 8px; }
  .paper-page { padding: 24px 16px; }
  .page-title, .page-subtitle { margin-left: 8px; }
}

/* ── Gallery item (photo mount) ── */
.gallery-item {
  position: relative;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.gallery-item:hover {
  transform: scale(1.02) rotate(-0.5deg);
}

/* photo with slight random rotation */
.gallery-item:nth-child(odd) { transform: rotate(-1deg); }
.gallery-item:nth-child(even) { transform: rotate(0.8deg); }
.gallery-item:nth-child(3n) { transform: rotate(-0.5deg); }

.gallery-item:hover { transform: scale(1.03) rotate(0deg) !important; }

/* photo frame */
.photo-frame {
  position: relative;
  background: #fff;
  padding: 8px;
  box-shadow:
    0 2px 8px rgba(80, 60, 40, 0.15),
    0 1px 3px rgba(80, 60, 40, 0.1);
  border-radius: 2px;
}

.photo-frame img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  border-radius: 1px;
  filter: saturate(0.9);
  transition: filter 0.3s;
}

.gallery-item:hover .photo-frame img {
  filter: saturate(1.1);
}

/* ── Mounting elements ── */

/* washi tape */
.washi-tape {
  position: absolute;
  width: 60px;
  height: 18px;
  opacity: 0.7;
  z-index: 2;
  border-radius: 1px;
}

.washi-tape.top-left {
  top: -8px;
  left: 12px;
  transform: rotate(-8deg);
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 180, 180, 0.6),
    rgba(255, 180, 180, 0.6) 3px,
    rgba(255, 200, 200, 0.4) 3px,
    rgba(255, 200, 200, 0.4) 6px
  );
}

.washi-tape.top-right {
  top: -6px;
  right: 16px;
  transform: rotate(5deg);
  background: repeating-linear-gradient(
    -45deg,
    rgba(180, 210, 255, 0.6),
    rgba(180, 210, 255, 0.6) 3px,
    rgba(200, 220, 255, 0.4) 3px,
    rgba(200, 220, 255, 0.4) 6px
  );
}

.washi-tape.bottom-left {
  bottom: -6px;
  left: 16px;
  transform: rotate(3deg);
  background: repeating-linear-gradient(
    45deg,
    rgba(200, 255, 200, 0.6),
    rgba(200, 255, 200, 0.6) 3px,
    rgba(220, 255, 220, 0.4) 3px,
    rgba(220, 255, 220, 0.4) 6px
  );
}

.washi-tape.bottom-right {
  bottom: -7px;
  right: 12px;
  transform: rotate(-6deg);
  background: repeating-linear-gradient(
    -45deg,
    rgba(255, 230, 180, 0.6),
    rgba(255, 230, 180, 0.6) 3px,
    rgba(255, 240, 200, 0.4) 3px,
    rgba(255, 240, 200, 0.4) 6px
  );
}

/* paper clip */
.paper-clip {
  position: absolute;
  top: -6px;
  right: 20px;
  width: 16px;
  height: 36px;
  z-index: 2;
}

.paper-clip::before {
  content: "";
  position: absolute;
  top: 0;
  left: 2px;
  width: 12px;
  height: 30px;
  border: 2px solid #b0b0b0;
  border-radius: 6px 6px 2px 2px;
  background: transparent;
}

.paper-clip::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 4px;
  width: 8px;
  height: 18px;
  border: 2px solid #c0c0c0;
  border-radius: 4px 4px 0 0;
  background: transparent;
}

/* corner mount */
.corner-mount {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 2;
}

.corner-mount::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

.corner-mount.tl { top: 0; left: 0; }
.corner-mount.tl::before {
  top: 0; left: 0;
  border-width: 20px 20px 0 0;
  border-color: rgba(180,170,155,0.3) transparent transparent transparent;
}

.corner-mount.tr { top: 0; right: 0; }
.corner-mount.tr::before {
  top: 0; right: 0;
  border-width: 0 20px 20px 0;
  border-color: transparent rgba(180,170,155,0.3) transparent transparent;
}

.corner-mount.bl { bottom: 0; left: 0; }
.corner-mount.bl::before {
  bottom: 0; left: 0;
  border-width: 20px 0 0 20px;
  border-color: transparent transparent transparent rgba(180,170,155,0.3);
}

.corner-mount.br { bottom: 0; right: 0; }
.corner-mount.br::before {
  bottom: 0; right: 0;
  border-width: 0 0 20px 20px;
  border-color: transparent transparent rgba(180,170,155,0.3) transparent;
}

/* ── Handwritten annotation ── */
.annotation {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.78rem;
  font-style: italic;
  color: #7a6e5e;
  margin-top: 8px;
  padding-left: 4px;
  line-height: 1.5;
  position: relative;
}

.annotation::before {
  content: "✎ ";
  color: #aaa090;
}

/* ── Collection tabs (notebook tabs) ── */
.collection-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  margin-left: 40px;
  flex-wrap: wrap;
}

.collection-tab {
  padding: 8px 18px;
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.85rem;
  font-style: italic;
  color: #7a6e5e;
  background: #ede8dd;
  border: 1px solid rgba(180, 170, 155, 0.3);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  margin-right: -1px;
}

.collection-tab:hover {
  background: #f5f0e6;
  color: #4a4035;
}

.collection-tab.active {
  background: #faf6ef;
  color: #4a4035;
  font-weight: 600;
  z-index: 1;
  box-shadow: 0 -2px 4px rgba(80, 60, 40, 0.06);
}

.collection-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #faf6ef;
}

/* ── Zoom overlay (loupe) ── */
.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 25, 20, 0.85);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.zoom-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.zoom-content {
  position: relative;
  max-width: 85vw;
  max-height: 85vh;
  animation: zoom-in 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes zoom-in {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.zoom-content img {
  max-width: 85vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.zoom-caption {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.9rem;
  font-style: italic;
  color: rgba(250, 246, 239, 0.8);
  text-align: center;
  margin-top: 16px;
}

.zoom-close {
  position: absolute;
  top: -32px;
  right: -8px;
  background: none;
  border: none;
  color: rgba(250, 246, 239, 0.6);
  font-size: 1.4rem;
  cursor: pointer;
  font-family: "Georgia", serif;
  transition: color 0.2s;
}

.zoom-close:hover { color: #fff; }

/* ── Page navigation (bookmark ribbons) ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  margin-left: 40px;
  margin-right: 8px;
}

.page-nav-btn {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.82rem;
  font-style: italic;
  color: #9a8e7e;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  transition: color 0.2s;
}

.page-nav-btn:hover { color: #4a4035; }
.page-nav-btn:disabled { opacity: 0.3; cursor: default; }

.page-indicator {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.78rem;
  color: #b0a494;
  font-style: italic;
}

/* ── Bookmark ribbon ── */
.bookmark-ribbon {
  position: absolute;
  top: -4px;
  right: 32px;
  width: 28px;
  height: 48px;
  z-index: 3;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
}

.bookmark-ribbon::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 14px 0 14px;
  border-color: var(--accent) transparent transparent transparent;
}

/* ── Loading state (sketch being drawn) ── */
.sketch-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 12px;
}

.sketch-line {
  width: 120px;
  height: 2px;
  background: #d0c8b8;
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}

.sketch-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: #7a6e5e;
  border-radius: 1px;
  animation: sketch-draw 1.2s ease-in-out infinite;
}

@keyframes sketch-draw {
  0% { width: 0; left: 0; }
  50% { width: 100%; left: 0; }
  100% { width: 0; left: 100%; }
}

.sketch-loading-text {
  font-family: "Georgia", "Noto Serif SC", serif;
  font-size: 0.82rem;
  font-style: italic;
  color: #b0a494;
}

/* ── Dark theme adjustments ── */
[data-theme="dark"] .paper-page {
  background:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      rgba(100, 90, 75, 0.12) 31px,
      rgba(100, 90, 75, 0.12) 32px
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #2a2520 0%, #252018 50%, #201c16 100%);
  border-color: rgba(100, 90, 75, 0.3);
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3), inset 0 0 40px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .paper-page::after {
  background: rgba(150, 60, 60, 0.1);
}

[data-theme="dark"] .page-title { color: #d4c8b8; }
[data-theme="dark"] .page-subtitle { color: #8a7e6e; }
[data-theme="dark"] .annotation { color: #9a8e7e; }
[data-theme="dark"] .photo-frame {
  background: #3a3530;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .collection-tab {
  background: #2a2520;
  color: #9a8e7e;
  border-color: rgba(100, 90, 75, 0.3);
}
[data-theme="dark"] .collection-tab:hover,
[data-theme="dark"] .collection-tab.active {
  background: #352f28;
  color: #d4c8b8;
}
[data-theme="dark"] .collection-tab.active::after {
  background: #352f28;
}

/* ── Ghibli theme adjustments ── */
[data-theme="ghibli"] .paper-page {
  background:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      rgba(58, 125, 68, 0.08) 31px,
      rgba(58, 125, 68, 0.08) 32px
    ),
    linear-gradient(135deg, #f0f5ec 0%, #e8f0e4 50%, #e0ead8 100%);
  border-color: rgba(160, 200, 150, 0.3);
}
[data-theme="ghibli"] .page-title { color: #2d3a2a; }
[data-theme="ghibli"] .page-subtitle { color: #5a6e54; }
[data-theme="ghibli"] .collection-tab {
  background: #d4e4cc;
  border-color: rgba(160, 200, 150, 0.3);
}
[data-theme="ghibli"] .collection-tab.active {
  background: #e8f0e4;
}
