/* Nala Pups: warm golden Cocker Spaniel colours, rounded type, paw prints. */
:root {
  --cream: #fff4e3;
  --paper: #fffaf2;
  --gold: #d9923b;
  --gold-light: #f3c98a;
  --liver: #8a4b2a;
  --ink: #3b2416;
  --muted: #8b6f5c;
  --tongue: #f28c9b;
  --leaf: #6f9a5b;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(107, 58, 32, 0.14);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pad: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--cream);
  /* faint paw prints */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 64 64'%3E%3Cg fill='%23d9923b' fill-opacity='0.08' transform='rotate(-20 32 32) scale(.5) translate(20 20)'%3E%3Cellipse cx='32' cy='42' rx='13' ry='11'/%3E%3Cellipse cx='15' cy='26' rx='6' ry='8'/%3E%3Cellipse cx='27' cy='17' rx='6' ry='8'/%3E%3Cellipse cx='41' cy='17' rx='6' ry='8'/%3E%3Cellipse cx='51' cy='27' rx='6' ry='8'/%3E%3C/g%3E%3C/svg%3E");
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.no-scroll { overflow: hidden; }
a { color: var(--liver); }
h1, h2 { line-height: 1.15; margin: 0 0 .3em; }
h1 { font-size: clamp(1.7rem, 4vw + 1rem, 2.8rem); color: var(--liver); letter-spacing: -.01em; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 700; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: .55em 1.2em; border-radius: 999px;
  background: #fff; color: var(--liver); box-shadow: inset 0 0 0 2px var(--gold-light);
  transition: transform .12s ease, background .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--gold); color: #fff; box-shadow: 0 3px 0 var(--liver); }
.btn-primary:hover { background: #c98330; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-small { min-height: 36px; font-size: .9rem; padding: .3em .9em; }
:focus-visible { outline: 3px solid var(--tongue); outline-offset: 2px; }

/* ---------- header and footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--pad) 10px;
  background: rgba(255, 244, 227, .9);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 2px dashed var(--gold-light);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.35rem; color: var(--liver); }
.brand img { transition: transform .3s; }
.brand:hover img { transform: rotate(-10deg); }
.who { display: flex; align-items: center; gap: 6px; font-size: .95rem; color: var(--muted); min-width: 0; }
.who-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
#view { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px var(--pad) 40px; outline: none; }
.site-footer { text-align: center; color: var(--muted); font-size: .9rem; padding: 20px var(--pad) max(20px, env(safe-area-inset-bottom)); }

.loading, .empty { text-align: center; padding: 60px 0; color: var(--muted); font-size: 1.1rem; }

/* ---------- home ---------- */
.hero { text-align: center; max-width: 640px; margin: 10px auto 30px; }
.hero p { font-size: 1.1rem; color: var(--muted); margin: 0; }
.albums { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.album-card {
  display: block; text-decoration: none; color: inherit; background: var(--paper);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.album-card:hover { transform: translateY(-4px) rotate(-.5deg); box-shadow: 0 12px 28px rgba(107, 58, 32, .2); }
.album-cover { position: relative; aspect-ratio: 4 / 3; background: var(--gold-light); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-empty { display: grid; place-items: center; height: 100%; color: var(--liver); font-weight: 700; }
.album-year {
  position: absolute; top: 12px; left: 12px; background: var(--tongue); color: #fff;
  font-weight: 800; padding: 4px 12px; border-radius: 999px; transform: rotate(-4deg); box-shadow: 0 2px 0 #d96a7b;
}
.album-meta { padding: 14px 18px 18px; }
.album-meta h2 { font-size: 1.25rem; color: var(--liver); }
.album-meta p { margin: 0; color: var(--muted); }
.album-count { font-weight: 700; color: var(--gold) !important; margin-top: 6px !important; }

/* ---------- album grid ---------- */
.crumbs { margin-bottom: 8px; }
.crumbs a { text-decoration: none; font-weight: 700; display: inline-block; padding: 8px 0; }
.album-head { margin-bottom: 18px; }
.album-head p { margin: 0; color: var(--muted); }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 4px;
  grid-template-columns: repeat(3, 1fr);   /* iPhone: three across, like the Photos app */
}
@media (min-width: 600px) { .grid { gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
@media (min-width: 1100px) { .grid { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.tile { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--gold-light); }
@media (min-width: 600px) { .tile { border-radius: 12px; } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.tile:hover img { transform: scale(1.05); }
.tile-badges {
  position: absolute; right: 6px; bottom: 6px; background: rgba(59, 36, 22, .7); color: #fff;
  font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}

/* ---------- photo viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 100; background: #1d120b; display: flex; flex-direction: column; }
.viewer-stage {
  position: relative; flex: 1 1 auto; min-height: 0; display: grid; place-items: center;
  padding: max(56px, env(safe-area-inset-top)) 8px 8px; touch-action: pan-y pinch-zoom;
}
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; transition: filter .3s; user-select: none; -webkit-user-drag: none; }
.viewer-img.is-loading { filter: blur(1px); }
.viewer-close, .viewer-nav {
  position: absolute; border: 0; cursor: pointer; color: #fff; background: rgba(255, 255, 255, .15);
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.4rem; line-height: 1; display: grid; place-items: center;
}
.viewer-close { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
.viewer-nav { top: 50%; transform: translateY(-50%); font-size: 2rem; display: none; }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-nav:disabled { opacity: .25; cursor: default; }
.viewer-count { position: absolute; top: max(18px, calc(env(safe-area-inset-top) + 10px)); left: 0; right: 0; text-align: center; color: #f3c98a; font-size: .9rem; pointer-events: none; }
@media (hover: hover) and (min-width: 700px) { .viewer-nav { display: grid; } }

.viewer-panel {
  flex: 0 0 auto; max-height: 45dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 16px var(--pad) max(16px, env(safe-area-inset-bottom));
}
.viewer-actions { display: flex; gap: 10px; }
.viewer-actions .save-btn { flex: 1; }
.paw-btn[aria-pressed="true"] { background: var(--tongue); color: #fff; box-shadow: 0 3px 0 #d96a7b; }
.paw-btn[aria-pressed="true"] .paw-icon { animation: wag .4s ease; }
@keyframes wag { 0%, 100% { transform: rotate(0) } 30% { transform: rotate(-20deg) scale(1.2) } 60% { transform: rotate(15deg) } }
.viewer-caption { margin: 12px 0 0; }
.comments-title { font-size: 1.05rem; color: var(--liver); margin: 16px 0 6px; }
.comments { list-style: none; margin: 0; padding: 0; }
.comments li { padding: 8px 0; border-bottom: 1px dashed var(--gold-light); }
.comments li p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comments .muted { color: var(--muted); border: 0; }
.c-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.c-head time { color: var(--muted); font-size: .85rem; }
.c-del { margin-left: auto; background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; padding: 4px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.comment-form textarea {
  flex: 1; font: inherit; font-size: 16px; /* 16px stops iPhone zooming in */
  padding: 10px 14px; border-radius: 16px; border: 2px solid var(--gold-light); background: #fff; resize: vertical; min-height: 44px;
}
.comment-form textarea:focus { border-color: var(--gold); outline: none; }

/* iPad landscape and desktop: photo on the left, comments on the right */
@media (min-width: 900px) {
  .viewer { flex-direction: row; }
  .viewer-stage { padding: 56px 70px 24px; }
  .viewer-panel { flex: 0 0 360px; max-height: none; border-radius: 0; padding: max(20px, env(safe-area-inset-top)) 22px 22px; }
}
@media (min-width: 1300px) { .viewer-panel { flex-basis: 400px; } }
/* iPhone on its side: give the photo the room */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 899px) {
  .viewer { flex-direction: row; }
  .viewer-stage { padding: 8px 56px 8px max(8px, env(safe-area-inset-left)); }
  .viewer-panel { flex: 0 0 300px; max-height: none; border-radius: 0; padding-right: max(16px, env(safe-area-inset-right)); }
}

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; padding: 24px var(--pad); }
.login-card {
  width: 100%; max-width: 420px; background: var(--paper); border-radius: 28px; box-shadow: var(--shadow);
  padding: 28px 26px 30px; text-align: center; position: relative; margin-top: 50px;
}
.spaniel-badge { width: 140px; height: 140px; margin: -90px auto 4px; display: block; filter: drop-shadow(0 6px 10px rgba(107, 58, 32, .25)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.tagline { color: var(--muted); margin: 0 0 20px; }
#login { display: grid; gap: 14px; text-align: left; }
#login label { font-weight: 700; color: var(--liver); display: grid; gap: 6px; }
#login .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
#login input { font: inherit; font-size: 16px; padding: 12px 16px; border-radius: 14px; border: 2px solid var(--gold-light); background: #fff; min-height: 48px; }
#login input:focus { border-color: var(--gold); outline: none; }
#login .btn { margin-top: 6px; font-size: 1.1rem; min-height: 52px; }
.error { color: #b3261e; margin: 0; text-align: center; font-weight: 700; }

/* small phones: keep the header on one line */
.brand span, .who .btn { white-space: nowrap; }
@media (max-width: 420px) {
  .brand { font-size: 1.15rem; gap: 6px; }
  .brand img { width: 36px; height: 36px; }
  .who-name { max-width: 30vw; font-size: .85rem; }
}

/* ---------- titles and tags ---------- */
.viewer-title { font-size: 1.2rem; color: var(--liver); margin: 14px 0 0; }
.viewer-title + .viewer-caption { margin-top: 4px; }
.viewer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.viewer-tags:empty { display: none; }
.tag-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 calc(-1 * var(--pad)) 6px; padding-inline: var(--pad);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tag-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  min-height: 36px; padding: 4px 14px; border-radius: 999px; border: 2px solid var(--gold-light);
  background: #fff; color: var(--liver); -webkit-tap-highlight-color: transparent;
}
.chip span { color: var(--muted); font-weight: 400; margin-left: 2px; }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #fff; }
.chip[aria-pressed="true"] span { color: #fff; }
@media (hover: hover) { .chip:hover { border-color: var(--gold); } }
