/* ============================================================
   Keepitcloud — Gallery Page Styles
   ============================================================ */

:root {
  --accent:       #6c63ff;
  --accent-hover: #574fd6;
  --bg:           #0f0f13;
  --card-bg:      #1a1a24;
  --surface:      #22222e;
  --text:         #f0f0f5;
  --text-muted:   #9090a8;
  --border:       #2e2e3e;
  --success:      #22c55e;
  --error:        #ef4444;
  --radius:       14px;
  --radius-sm:    10px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Screens ---- */
.screen { display: none; flex-direction: column; min-height: 100vh; }
.screen.active { display: flex; }

/* ---- Loading ---- */
#screen-loading { align-items: center; justify-content: center; }

.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.sm { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Header ---- */
.page-header {
  background: rgba(15,15,19,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.header-logo { height: 32px; max-width: 140px; object-fit: contain; }
.header-logo-text { font-size: 17px; font-weight: 700; color: var(--accent); letter-spacing: -.5px; }
.header-sep { color: var(--border); font-size: 20px; }

/* ---- Center screens ---- */
.center-wrap, .center-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px;
}
.msg-icon { font-size: 52px; margin-bottom: 12px; }

/* ---- Card ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px 24px;
  width: 100%; max-width: 420px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
h2 { font-size: 20px; font-weight: 700; }
p  { font-size: 14px; color: var(--text-muted); }

/* ---- Password form ---- */
input[type="password"], #gb-name, #gb-msg {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
input[type="password"]:focus,
#gb-name:focus,
#gb-msg:focus { border-color: var(--accent); }
#gb-msg { resize: vertical; }

.error { color: var(--error); font-size: 13px; }
.hidden { display: none !important; }

/* ---- Buttons ---- */
.btn-primary {
  width: 100%; margin-top: 8px;
  padding: 13px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-primary:hover   { background: var(--accent-hover); }
.btn-primary:active  { opacity: .85; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Gallery hero ---- */
.gallery-hero {
  padding: 28px 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.gallery-hero h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.hero-date  { font-size: 14px; color: var(--text-muted); }
.hero-count { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ---- Photo grid ---- */
#gallery-main { padding: 20px 12px 0; }

.photo-grid {
  columns: 3 160px;
  column-gap: 8px;
}

.grid-item {
  break-inside: avoid;
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--surface);
  transition: transform .15s, opacity .2s;
}
.grid-item:hover { transform: scale(1.01); }

.grid-item img,
.grid-item video {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 1;
}

/* Lazy-load fade-in */
.grid-item img.lazy { opacity: 0; transition: opacity .3s; }
.grid-item img.loaded { opacity: 1; }

/* Video overlay */
.video-badge {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,.6);
  color: #fff; font-size: 18px;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* ---- Sentinels & spinners ---- */
.load-sentinel { height: 1px; }
.load-spinner  { display: flex; justify-content: center; padding: 24px; }
.all-loaded    { text-align: center; padding: 24px; font-size: 13px; color: var(--text-muted); }

/* ---- Guestbook ---- */
.guestbook-section {
  margin-top: 48px;
  padding: 28px 16px 48px;
  border-top: 1px solid var(--border);
  max-width: 640px;
  margin-left: auto; margin-right: auto;
  width: 100%;
}
.guestbook-section h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

.gb-form {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 28px;
}
.char-count { font-size: 12px; color: var(--text-muted); text-align: right; }
.gb-success { color: var(--success); font-size: 14px; text-align: center; padding: 8px 0; }

.gb-messages { display: flex; flex-direction: column; gap: 14px; }

.gb-msg-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.gb-msg-author { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.gb-msg-text   { font-size: 14px; color: var(--text-muted); white-space: pre-wrap; word-break: break-word; }
.gb-msg-date   { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ---- Footer ---- */
.page-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.page-footer a { color: var(--accent); text-decoration: none; }
.footer-social { display: flex; justify-content: center; gap: 14px; margin-bottom: 6px; }
.footer-social a { font-size: 13px; font-weight: 500; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.95);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.lightbox.hidden { display: none; }

.lb-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.1); border: none;
  color: #fff; font-size: 20px; width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer; z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
.lb-close:hover { background: rgba(255,255,255,.2); }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1); border: none;
  color: #fff; font-size: 32px; width: 48px; height: 80px;
  border-radius: 6px; cursor: pointer; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-media-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 60px 72px 0;
  overflow: hidden;
}
.lb-media-wrap img,
.lb-media-wrap video {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.lb-footer {
  width: 100%; padding: 16px 20px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}

.lb-reactions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.react-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 5px 10px;
  color: #fff; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: background .15s, transform .1s;
}
.react-btn:hover  { background: rgba(255,255,255,.15); }
.react-btn:active { transform: scale(.95); }
.react-btn.reacted {
  background: rgba(108,99,255,.35);
  border-color: var(--accent);
}
.react-btn span { font-size: 13px; min-width: 12px; text-align: center; }

.lb-share-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 8px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.lb-share-btn:hover { background: var(--accent-hover); }

/* ---- Share modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.7);
}
.modal {
  position: fixed; inset: 0; z-index: 401;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal.hidden { display: none; }

.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  width: 100%; max-width: 480px;
  position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer;
}
.modal-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; }

.share-loading { display: flex; justify-content: center; padding: 20px; }

.share-actions { display: flex; flex-direction: column; gap: 10px; }
.share-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 14px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; text-decoration: none;
  transition: opacity .15s;
}
.share-btn:active { opacity: .8; }
.share-btn.wa { background: #25d366; color: #fff; }
.share-btn.fb { background: #1877f2; color: #fff; }
.share-btn.dl { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .photo-grid { columns: 2 120px; }
  .lb-media-wrap { padding: 52px 48px 0; }
  .lb-nav { width: 36px; }
  .lb-footer { flex-direction: column; align-items: flex-start; }
}
@media (min-width: 900px) {
  .photo-grid { columns: 4 180px; }
  #gallery-main { padding: 24px 24px 0; }
}
