/* ============================================================
   ShowCare — warm, friendly photo gallery. Gentle corners,
   soft coral accent in both light and dark.
   ============================================================ */

:root {
  /* type — system humanist sans (no monospace) */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* shape (gently rounded) --------------------------------- */
  --radius: 6px;

  /* palette: defaults to light so the page is styled even
     before the inline script resolves the saved/system theme.      */
  --bg: #f6f3ed;
  --surface: #fffdf9;
  --ink: #1d1a16;
  --ink-soft: #6b5f57;
  --muted: #8b8276;
  --line: #e7e0d4;
  --line-strong: #d3c9b8;
  --accent: #f4715e;
  --accent-ink: #ffffff;
  --accent-soft: #ffeae3;
  --media-bg: #ece5d8;
}

/* ---- themes ----------------------------------------------- */
/* Light · CORAL — warm bone + coral (also the :root default) */
[data-theme="coral"] {
  --bg: #f6f3ed;        --surface: #fffdf9;
  --ink: #1d1a16;       --ink-soft: #6b5f57;  --muted: #8b8276;
  --line: #e7e0d4;      --line-strong: #d3c9b8;
  --accent: #f4715e;    --accent-ink: #ffffff;
  --accent-soft: #ffeae3;
  --media-bg: #ece5d8;
}

/* Dark · LIME — charcoal + lime */
[data-theme="lime"] {
  --bg: #141513;        --surface: #1c1e1a;
  --ink: #f1f3ee;       --ink-soft: #cdbfb6;  --muted: #9aa093;
  --line: #2b2e28;      --line-strong: #3c4137;
  --accent: #f4715e;    --accent-ink: #ffffff;
  --accent-soft: rgba(244, 113, 94, 0.16);
  --media-bg: #0d0e0c;
}

/* ---- base -------------------------------------------------- */
* { box-sizing: border-box; }

/* hidden must win over class-level display rules (e.g. .login-wrap display:grid) */
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  font: 400 15px/1.55 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); font-weight: 400; }
.error { color: #d23b2e; min-height: 1.2em; margin: 2px 0 0; font: 500 13px/1.4 var(--sans); }
[data-theme="lime"] .error { color: #ff6f63; }

/* surfaces: hairline, no shadow */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---- controls: buttons, inputs, selects ------------------- */
button {
  font: 600 14px/1 var(--sans);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: filter .12s ease, background .12s ease, border-color .12s ease;
}
button:hover { filter: brightness(1.06); }
button:active { filter: brightness(0.96); }
button:disabled { opacity: .45; cursor: default; filter: none; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
button.ghost:hover { filter: none; border-color: var(--accent); color: var(--accent); }
[data-theme="lime"] button.ghost:hover { color: var(--accent); }

input, select {
  font: 400 15px/1.3 var(--sans);
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input[type="date"] { font-family: var(--sans); font-size: 13px; }

/* one visible focus treatment for the whole app */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- theme toggle (sun / moon icon button) ---------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
}
.theme-toggle:hover { filter: none; border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { display: none; }
[data-theme="coral"] .theme-toggle .icon-sun { display: block; }
[data-theme="lime"] .theme-toggle .icon-moon { display: block; }

.theme-field {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 600 12px/1 var(--sans);
  letter-spacing: .01em;
  color: var(--muted);
}

/* ---- login ------------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  min-width: 0;
  padding: 30px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
/* login uses the same .brand wordmark, just larger */
.login-card h1 {
  margin: 0 0 2px;
  font-size: 36px;
}
.login-card .muted { margin: 0 0 6px; font-size: 14px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font: 600 12px/1 var(--sans);
  letter-spacing: .01em;
  color: var(--muted);
}
.login-card > button { margin-top: 4px; padding: 12px; }

/* ---- topbar ------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
/* showcare wordmark — change font-size to scale; everything else is em-relative */
.brand {
  font-size: 22px;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  text-transform: lowercase;
}
.brand .s { color: #FD3955; }
.brand .h { color: #FE8B00; }
.brand .o { color: #FECF05; }
.brand .w { color: #06BB8C; }
.brand .c { color: #006BFC; }
.brand .a { color: #885AFD; }
.brand .r { color: #F853CC; }
.brand .e { color: #FC5C6A; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---- gallery toolbar (mobile): filters + view switch ------ */
.gallery-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 16px 0;
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 12px/1 var(--sans);
  letter-spacing: .01em;
}
.filter-toggle .chevron { transition: transform .15s ease; }
.filter-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* single gallery <-> full-size toggle (reuses the round .theme-toggle).
   The icon shows the CURRENT view; tapping flips it. */
.view-toggle[data-view="gallery"] .icon-grid { display: block; }
.view-toggle[data-view="full"] .icon-rows { display: block; }

.controls {
  margin: 12px 16px 16px;
  padding: 14px;
  display: none;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}
.controls.is-open { display: flex; }
.controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font: 600 11px/1 var(--sans);
  letter-spacing: .01em;
  color: var(--muted);
}
.controls input, .controls select { flex: 1 1 auto; min-width: 0; }
.controls > button { flex: 1 1 auto; }

.status {
  margin: 0 16px 12px;
  font: 500 12px/1.4 var(--sans);
  letter-spacing: .02em;
}

/* ---- grid -------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px 28px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tile .frame { position: relative; line-height: 0; overflow: hidden; }
.tile .media {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--media-bg);
  transition: transform .35s ease;
}
.tile video.media { object-fit: contain; background: #000; }
/* in gallery view, photos are tappable (they open the overlay) */
.grid:not(.view-full) img.media { cursor: pointer; }
/* gentle zoom-in on hover (pointer devices only) */
@media (hover: hover) {
  .grid:not(.view-full) .tile:hover .media { transform: scale(1.045); }
}

/* full-size view: one photo per row, padded, natural height, with captions */
.grid.view-full {
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px 16px 28px;
}
.grid.view-full .tile .media { aspect-ratio: auto; height: auto; object-fit: contain; }

.save-btn {
  position: absolute;
  top: 7px; right: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #fff;
  background: rgba(15, 15, 18, 0.55);
  border: none;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.save-btn svg { display: block; }
.save-btn:hover { filter: none; background: var(--accent); color: var(--accent-ink); }
.save-btn:disabled { opacity: 1; }

.tile .meta { padding: 9px 10px 10px; line-height: 1.4; }
.tile .cap { font-size: 13px; margin: 0 0 5px; color: var(--ink-soft); word-break: break-word; }
.tile .when {
  font: 500 11px/1 var(--sans);
  letter-spacing: .01em;
  color: var(--muted);
}
.badge {
  display: inline-block;
  font: 700 10px/1 var(--sans);
  letter-spacing: .01em;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 6px;
  vertical-align: 1px;
}
[data-theme="lime"] .badge { color: var(--accent); }

/* ---- pager ------------------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 4px 16px 46px;
}
#pageLabel {
  font: 600 12px/1 var(--sans);
  letter-spacing: .01em;
  color: var(--muted);
}

/* ---- full-screen photo overlay ---------------------------- */
body.modal-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 8, 10, 0.92);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
  cursor: zoom-out;
}
.lightbox-save {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
}

/* ============================================================
   Larger screens: roomier bar, multi-column grid.
   (Mobile is the base above; this only adds at >=560px.)
   ============================================================ */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 0 24px 36px; }
  /* Roomier screens: filters are always open and there's only the gallery. */
  .gallery-bar { display: none; }
  .controls { display: flex; margin: 20px 24px; gap: 14px; }
  .controls input, .controls select { flex: 0 0 auto; }
  .controls > button { flex: 0 0 auto; }
  .status { margin: 0 24px 14px; }
  .pager { padding: 4px 24px 56px; }
  .topbar { padding: 14px 24px; }
  .login-card h1 { font-size: 40px; }
}

/* ---- accessibility floor ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
