/* Site-wide styles for the owner pages. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #24211d;
  --muted: #6b655c;
  --border: #e2ddd3;
  --accent: #a12f5c;
  --accent-text: #ffffff;
  --error-bg: #fdecea;
  --error-text: #8a1f11;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --surface: #252320;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #3a3732;
    --accent: #ec8fb0;
    --accent-text: #2b0e1a;
    --error-bg: #3b1d18;
    --error-text: #f3b8ad;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Every page is at least one full screen tall (with the phone browser's
     address bar hidden). Firefox for Android won't zoom out further than
     "page fills the screen", so a page just slightly taller than the screen
     got stuck at about 1.08x zoom and panned sideways. */
  min-height: 100vh;
  min-height: 100lvh;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

a { color: var(--accent); }

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-name { font-weight: 700; text-decoration: none; color: var(--text); }
.site-header nav { display: flex; align-items: center; gap: 1rem; }
form.inline { display: inline; margin: 0; }
.link-button {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--accent); text-decoration: underline; cursor: pointer;
}

/* Forms */
.stack { display: flex; flex-direction: column; gap: 1rem; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
input {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  cursor: pointer;
}
.stack button { align-self: flex-start; }
.button.secondary { background: transparent; color: var(--accent); }

.errors {
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
}
.errors p { margin: 0.4rem 0; }

/* Content */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1.25rem 1rem;
  margin-bottom: 1.25rem;
}
.family-url code {
  display: block;
  overflow-wrap: anywhere;
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.hero { padding-top: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Album page: storage bar, photo grid */
.storage { margin: 1rem 0; }
.storage-bar { height: 0.5rem; background: var(--border); border-radius: 999px; overflow: hidden; }
.storage-bar span { display: block; height: 100%; background: var(--accent); }
.storage small { color: var(--muted); }

.file-button { display: inline-block; flex-direction: row; }

.photo-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.75rem;
}
.photo-grid li { display: flex; flex-direction: column; gap: 0.3rem; }
.photo-grid img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.delete-form { margin: 0; }
.delete-form button {
  width: 100%;
  padding: 0.3rem;
  font-size: 0.85rem;
  font-weight: 400;
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.delete-form button.danger { background: var(--error-bg); color: var(--error-text); border-color: var(--error-text); }

button:disabled { opacity: 0.6; cursor: default; }
button.secondary { background: transparent; color: var(--accent); }

/* Crop dialog: fills nearly the whole screen so the picture is as big as possible */
#crop-dialog {
  width: min(72rem, calc(100vw - 1rem));
  max-width: none;
  height: calc(100vh - 1rem);
  height: calc(100dvh - 1rem);   /* phones: ignore the browser's sliding toolbars */
  max-height: none;
  margin: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
#crop-dialog[open] { display: flex; flex-direction: column; gap: 0.6rem; }
#crop-dialog {
  position: fixed;
  overscroll-behavior: contain;   /* scrolling inside never moves the page behind */
  touch-action: pan-x pan-y;      /* no pinch-zoom inside the dialog */
}
/* Freeze the page behind the dialog so it can't scroll or drift. */
html:has(#crop-dialog[open]) { overflow: hidden; }
.dialog-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  z-index: 1;
}
#crop-dialog .crop-title { padding-right: 2.5rem; }   /* room for the ✕ */
#crop-dialog::backdrop { background: rgb(0 0 0 / 0.75); }
.crop-step { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.crop-step[hidden] { display: none; }
.crop-title { margin: 0; }

/* The picture area takes all the space left over */
.crop-area {
  flex: 1;
  min-height: 0;
  background: #1e1e1e;
  border-radius: 6px;
  overflow: hidden;
}
.crop-area img { display: block; max-width: 100%; }   /* required by Cropper.js */

/* Make the crop box easy to see against any picture */
.crop-area .cropper-view-box { outline: 2px solid #fff; outline-color: #fff; }
.crop-area .cropper-line { background-color: #fff; }
.crop-area .cropper-point { background-color: #fff; width: 12px; height: 12px; opacity: 1; }
.crop-area .cropper-modal { opacity: 0.65; }

/* Preview step: the saved photo drawn at game size (upload.js sets its size) */
.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e1e1e;
  border-radius: 6px;
  overflow: hidden;
}
.preview-stage img { display: block; max-width: none; }

.crop-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
#crop-dialog .errors { margin: 0; }

/* Shared bits */
.muted { color: var(--muted); }
.notice {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-radius: 6px;
  padding: 0.5rem 1rem;
}
.hint {
  border-left: 4px solid var(--accent);
  background: var(--surface);
  padding: 0.5rem 1rem;
  border-radius: 0 6px 6px 0;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.photo-grid li { position: relative; }

/* Albums list */
.album-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.9rem;
}
.album-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.album-card:hover { border-color: var(--accent); }
.album-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; border-radius: 5px; overflow: hidden; }
.album-thumbs img, .thumb-empty { width: 100%; aspect-ratio: 1; display: block; background: var(--bg); }
.album-name { font-weight: 600; overflow-wrap: anywhere; }

/* New album form */
.size-choice { border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.9rem 0.8rem; margin: 0; }
.size-choice legend { font-weight: 600; padding: 0 0.3rem; }
.size-choice legend small { font-weight: 400; color: var(--muted); }
label.radio { flex-direction: row; align-items: flex-start; gap: 0.6rem; font-weight: 400; margin-top: 0.5rem; }
label.radio input { margin-top: 0.3rem; }
label.radio small { display: block; color: var(--muted); }

/* Album editor */
.rename-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.rename-form input { flex: 1 1 12rem; font-size: 1.3rem; font-weight: 700; }

.add-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 1rem 0 0.5rem; }
.add-row .file-button { margin: 0; }

.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Dashboard: family link share box */
.share .actions { align-items: center; }
.qr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 1rem; }
.qr-row p { margin: 0; flex: 1 1 10rem; }
.qr { padding: 8px; background: #fff; border-radius: 6px; line-height: 0; }   /* white border so phones can read it in dark mode */
.qr img, .qr canvas { display: block; }
