/* ─── Design tokens ─────────────────────────────── */
:root {
  --ocean:   #1a759f;
  --ocean-dk:#145f82;
  --sand:    #f4a261;
  --bg:      #faf7f2;
  --card:    #ffffff;
  --text:    #2c2c2c;
  --muted:   #6b7280;
  --border:  #e8e2d9;
  --green:   #52b788;
  --red:     #e07070;
  --radius:  14px;
  --shadow:  0 2px 16px rgba(0,0,0,0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:    #1a1814;
    --card:  #252220;
    --text:  #f0ece6;
    --muted: #9ca3af;
    --border:#3a3530;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a { color: var(--ocean); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────────────────── */
.site-header {
  background: var(--ocean);
  color: #fff;
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
}
.site-header h1 {
  font-family: Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.site-header .subtitle {
  opacity: 0.85;
  margin-top: 0.4rem;
  font-size: 1rem;
}
.paw { font-size: 2rem; margin-bottom: 0.5rem; display: block; }

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ─── Day cards ──────────────────────────────────── */
.day-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2.25rem;
  overflow: hidden;
  border: 1px solid var(--border);
}

.day-card-header {
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.day-card-header .day-number {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ocean);
}
.day-card-header h2 {
  font-family: Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

/* ─── Photo gallery ──────────────────────────────── */
.photo-gallery {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0.75rem 1rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.photo-gallery::-webkit-scrollbar { height: 4px; }
.photo-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.photo-gallery img {
  height: 240px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  scroll-snap-align: start;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.photo-gallery img:hover { opacity: 0.88; }

/* single photo = full width */
.photo-gallery.single img {
  width: 100%;
  height: auto;
  max-height: 420px;
}

/* Videos in gallery */
.gallery-video-wrap {
  position: relative;
  height: 240px;
  flex-shrink: 0;
  scroll-snap-align: start;
}
.gallery-video-wrap video {
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}
.gallery-video-wrap:hover video { opacity: 0.88; }
.play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: none;
}
/* single media item = full width */
.photo-gallery.single .gallery-video-wrap { height: auto; width: 100%; }
.photo-gallery.single .gallery-video-wrap video { width: 100%; height: auto; max-height: 420px; }

.day-card-body {
  padding: 1rem 1.5rem 1.5rem;
  font-size: 1rem;
  white-space: pre-line;
}

/* ─── Empty state ────────────────────────────────── */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 4rem 1rem;
}
.empty .big { font-size: 3rem; margin-bottom: 0.75rem; }

/* ─── Lightbox ───────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  object-fit: contain;
}

/* ─── Admin-specific ─────────────────────────────── */
.admin-wrap {
  max-width: 840px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-family: Georgia, serif;
  font-size: 1.15rem;
  margin-bottom: 1rem;
  color: var(--ocean);
}

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

input[type="text"], input[type="date"], input[type="password"], textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--ocean); }
textarea { resize: vertical; min-height: 140px; }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--ocean); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-success { background: var(--green); color: #fff; }
.btn-sand { background: var(--sand); color: #fff; }

/* ─── Drop zone ──────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.drag-over { border-color: var(--ocean); background: rgba(26,117,159,0.06); }
.drop-zone input { display: none; }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 1rem;
}
.thumb-wrap { position: relative; aspect-ratio: 1; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.thumb-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Cleanup comparison ─────────────────────────── */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 600px) { .compare-grid { grid-template-columns: 1fr; } }

.compare-box {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  min-height: 100px;
  white-space: pre-wrap;
  background: var(--bg);
}
.compare-box.original { opacity: 0.6; }
.compare-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.5rem; color: var(--muted); }

/* ─── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transform: translateY(120%);
  transition: transform 0.25s ease;
  z-index: 999;
  max-width: 320px;
}
.toast.show { transform: translateY(0); }
.toast.ok  { background: var(--green); color: #fff; }
.toast.err { background: var(--red);   color: #fff; }

/* ─── Auth overlay ───────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow);
}
.auth-box h2 { font-family: Georgia, serif; margin-bottom: 1.25rem; }
.auth-box input { margin-bottom: 1rem; }

/* ─── About bar ──────────────────────────────────── */
.about-bar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.about-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.mavis-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.mavis-avatar-fallback {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ocean);
  color: #fff;
  font-size: 1.6rem;
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.about-details { flex: 1; min-width: 0; }
.about-name { font-weight: 700; color: var(--text); font-size: 0.9rem; }
.about-dates { font-size: 0.8rem; margin-top: 0.1rem; }
.about-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.8rem;
  text-align: right;
}
.about-contact a { color: var(--muted); }
.about-contact a:hover { color: var(--ocean); }
@media (max-width: 560px) {
  .about-inner { flex-wrap: wrap; }
  .about-contact { text-align: left; }
}


/* ─── Admin daily log template ───────────────────── */
.log-row {
  display: grid;
  grid-template-columns: 1.6rem 1fr 2fr;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-icon { font-size: 1.1rem; text-align: center; }
.log-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.log-row input[type="text"] {
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
  min-width: 0;
}
@media (max-width: 560px) {
  .log-row { grid-template-columns: 1.6rem 1fr; }
  .log-row input[type="text"] { grid-column: 1 / -1; }
}

/* ─── Public daily log display ───────────────────── */
.day-log {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.day-log-item {
  font-size: 0.83rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}
.day-log-item .log-item-icon { flex-shrink: 0; }
.day-log-item strong { color: var(--text); font-weight: 600; margin-right: 0.25rem; }

/* ─── Mobile optimizations ───────────────────────── */

/* iOS Safari auto-zooms inputs with font-size < 16px — prevent it */
@media (max-width: 768px) {
  input[type="text"],
  input[type="date"],
  input[type="password"],
  textarea {
    font-size: 16px;
  }
  /* Larger tap targets */
  .btn { min-height: 44px; }
  .thumb-remove { width: 28px; height: 28px; font-size: 0.9rem; }
  /* Breathe more on small screens */
  .card { padding: 1.25rem 1rem; }
  .day-card-header { padding: 1rem 1.25rem 0.65rem; }
  .day-card-body { padding: 0.85rem 1.25rem 1.25rem; }
  .day-log { padding: 0.65rem 1.25rem; }
  .about-inner { padding: 0.65rem 1rem; gap: 0.75rem; }
  /* Bigger gallery images on phone */
  .photo-gallery img { height: 260px; }
}

/* iPhone safe area — home bar at bottom */
.container   { padding-bottom: max(4rem, calc(2rem + env(safe-area-inset-bottom))); }
.admin-wrap  { padding-bottom: max(4rem, calc(2rem + env(safe-area-inset-bottom))); }
.toast       { bottom: max(1.5rem, calc(0.75rem + env(safe-area-inset-bottom))); }

/* Lightbox touch — prevent rubber-band scroll behind it */
.lightbox.open { touch-action: none; }

/* ─── Loading skeleton ───────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  height: 1em;
  margin-bottom: 0.5rem;
}
@keyframes shimmer { to { background-position: -200% 0; } }
