/* birthday-gallery — paper-craft theme for a Kajimaya (カジマヤー) album.
   Warm paper, layered-paper shadows, cut-paper edges, and paper pinwheels
   in Okinawa sea blue + pink. No framework. */

:root {
  --paper: #faf4e6;
  --paper-soft: #f3ead3;
  --card: #fffdf6;
  --line: #e3d8bf;
  --ink: #3f382c;
  --muted: #8b7d63;
  --faint: #b3a586;
  --blue: #00a0e9;        /* Okinawan sea / sky */
  --blue-deep: #0072bc;
  --pink: #ff6fa5;
  --pink-deep: #e84f8a;
  --sky: #7ed6ff;         /* link colour on the dark lightbox */
  --danger: #d64545;
  --radius: 10px;
  --paper-shadow:
    0 1px 2px rgba(101, 82, 46, 0.07),
    0 4px 10px rgba(101, 82, 46, 0.06),
    0 14px 30px rgba(101, 82, 46, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  /* faint dot grain so the background reads as paper, not a flat fill */
  background-image:
    radial-gradient(rgba(160, 130, 70, 0.055) 1px, transparent 1.4px),
    radial-gradient(rgba(160, 130, 70, 0.04) 1px, transparent 1.4px);
  background-size: 22px 22px, 34px 34px;
  background-position: 0 0, 9px 13px;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", YuGothic, "Noto Sans JP", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

/* ---------- pinwheel motif ---------- */

.pinwheel { display: inline-block; flex-shrink: 0; }
.pinwheel .rotor {
  transform-box: fill-box;
  transform-origin: center;
  animation: pinwheel-spin 16s linear infinite;
}
@keyframes pinwheel-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pinwheel .rotor { animation: none; }
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 253, 246, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
/* cut-paper zigzag along the bottom edge of the header sheet */
.topbar::after {
  content: "";
  display: block;
  height: 7px;
  background:
    linear-gradient(135deg, var(--card) 25%, transparent 25%) -7px 0,
    linear-gradient(225deg, var(--card) 25%, transparent 25%) -7px 0;
  background-size: 14px 14px;
  background-repeat: repeat-x;
  opacity: 0.94;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 114, 188, 0.35);
}
.btn-primary:hover { background: var(--blue-deep); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 15px;
  letter-spacing: 2px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--faint); }

#author-filter {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  max-width: 140px;
}

.menu {
  position: absolute;
  right: max(12px, calc((100vw - 1400px) / 2 + 12px));
  top: 58px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 230px;
  box-shadow: var(--paper-shadow);
  z-index: 30;
}
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px dashed var(--line);
}
.menu-row button, .menu > button {
  background: none;
  border: 0;
  color: var(--blue-deep);
  font-size: 13px;
  cursor: pointer;
  padding: 9px 10px;
}
.menu > button { display: block; width: 100%; text-align: left; color: var(--ink); border-radius: 6px; }
.menu > button:hover { background: var(--paper-soft); }

/* ---------- layout ---------- */

#main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

/* ---------- dropzone (a paper sheet with a scissor cut-line) ---------- */

.dropzone {
  border: 1.5px dashed var(--blue);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--paper-shadow);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--pink); }
.dropzone.dragging {
  border-color: var(--pink-deep);
  background: #fff5f9;
}
.dropzone-inner {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
}
.dropzone-inner svg { color: var(--blue); margin-bottom: 6px; }
.dropzone-inner p { margin: 4px 0; font-size: 14px; }
.dropzone-sub { font-size: 12px !important; color: var(--faint) !important; }
.linklike { color: var(--blue-deep); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- upload progress ---------- */

.upload-list { margin-top: 14px; display: grid; gap: 8px; }
.upload-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--paper-shadow);
  padding: 10px 12px;
  font-size: 13px;
}
.upload-item .row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .status { color: var(--muted); flex-shrink: 0; }
.upload-item .status.err { color: var(--danger); }
.upload-item .bar { height: 4px; background: var(--paper-soft); border-radius: 2px; overflow: hidden; }
.upload-item .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--pink)); border-radius: 2px; transition: width 0.15s; }

/* ---------- gallery (photos as paper prints) ---------- */

.count { color: var(--muted); font-size: 13px; margin: 18px 2px 10px; }

.gallery {
  columns: 240px;
  column-gap: 12px;
}
.photo {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 12px;
  padding: 7px 7px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  box-shadow: var(--paper-shadow);
  cursor: zoom-in;
  break-inside: avoid;
}
.photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  transition: transform 0.25s ease;
}
.photo:hover img { transform: scale(1.015); }
/* Loading skeleton: shimmering paper placeholders shown while the photo
   list loads, so the gallery never sits empty. */
.photo.skeleton {
  min-height: 140px;
  cursor: default;
  background: linear-gradient(100deg,
    var(--card) 35%,
    var(--paper-soft) 50%,
    var(--card) 65%);
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.3s linear infinite;
}
@keyframes skeleton-shimmer {
  to { background-position: -220% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .photo.skeleton { animation: none; }
}
.photo figcaption {
  padding: 7px 3px 9px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.photo figcaption .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo figcaption .when { color: var(--faint); flex-shrink: 0; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .pinwheel { margin-bottom: 10px; }
.empty-sub { color: var(--faint); font-size: 13px; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(43, 36, 26, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}
.lightbox[hidden] { display: none; }
.lb-figure {
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lb-figure img {
  max-width: 100vw;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}
/* While the next photo loads, the stale image hides at once (layout kept)
   and a spinner covers the wait. */
#lb-img.is-loading { visibility: hidden; }
.lb-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}
.lb-loading[hidden] { display: none; }
.lb-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--pink);
  animation: lb-spin 0.9s linear infinite;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .lb-spinner { animation-duration: 2.4s; }
}
.lb-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 900px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  font-size: 13px;
  color: #cfc4ab;
}
.lb-tools { display: flex; gap: 14px; align-items: center; flex-shrink: 0; }
.lb-tools a { color: var(--sky); text-decoration: none; }
.lb-tools button {
  background: none; border: 0; color: #ff9d9d;
  font-size: 13px; cursor: pointer; padding: 4px 2px;
}
.lb-btn {
  position: absolute;
  background: rgba(255, 253, 246, 0.12);
  border: 0;
  color: #fff;
  border-radius: 999px;
  width: 44px; height: 44px;
  font-size: 22px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.lb-btn:hover { background: rgba(255, 253, 246, 0.22); }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; font-size: 17px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) {
  .lb-prev, .lb-next { display: none; } /* swipe instead */
}

/* ---------- login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}
.login-card {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 28px;
  text-align: center;
  box-shadow: var(--paper-shadow);
}
/* a second sheet peeking out behind the card, slightly askew */
.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  transform: rotate(-1.6deg) translateY(6px);
  z-index: -1;
}
/* washi tape across the top */
.login-card::after {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 110px;
  height: 26px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(255, 111, 165, 0.45);
  border-left: 2px dashed rgba(255, 255, 255, 0.55);
  border-right: 2px dashed rgba(255, 255, 255, 0.55);
}
.login-mark { margin-bottom: 6px; }
.login-card h1 { font-size: 21px; margin: 0 0 6px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.login-card form { text-align: left; display: grid; gap: 14px; }
.login-card label span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.login-card label em { font-style: normal; color: var(--faint); }
.login-card input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 15px;
  padding: 11px 12px;
}
.login-card input:focus { outline: none; border-color: var(--blue); }
.login-card button[type="submit"] {
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 2px 6px rgba(0, 114, 188, 0.35);
}
.login-card button[type="submit"]:hover { background: var(--blue-deep); }
.login-card button[type="submit"]:disabled { opacity: 0.6; }
.login-error { color: var(--danger); font-size: 13px; margin: 0; }
