/* Wedding photo app — large, high-contrast, easy for older guests. */

:root {
  --ink: #222222;
  --muted: #5a5a5a;
  --accent: #7a1f3d;
  --accent-dark: #5c1029;
  --bg: #faf7f2;
  --card: #ffffff;
  --ok: #1e7d43;
  --warn-bg: #fff6df;
  --warn-ink: #7a5b00;
  --err: #b3261e;
  --err-bg: #fdecea;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px; /* base — large by default */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

/* ---------- Logo (upper-left corner, every page) ---------- */

/* Mirrors the language pill: fixed in the upper-left corner, links to
   the main page. Admin pages instead carry the brand inside their
   burgundy bar (top-left of the page), so the fixed pill rests there. */
.site-logo {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 2px solid #d9d1c3;
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-decoration: none;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
  line-height: 1.5;
  white-space: nowrap;
}

.site-logo:hover {
  border-color: var(--accent);
}

/* Admin pages: the brand lives inside the bar instead. */
body.page-admin .site-logo {
  display: none;
}

/* Brand inside the admin bar (top of the page, links to the main page). */
.admin-header .brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.admin-header .brand:hover {
  text-decoration: underline;
}

/* ---------- Language switch (upper-right corner, every page) ---------- */

.lang-switch {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-switch a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 2px solid #d9d1c3;
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #555;
  text-decoration: none;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
  line-height: 1.5;
}

.lang-switch a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Discreet admin link, sitting left of the language pill. Invisible at
   rest (opacity 0, still focusable/tappable); revealed on hover of the
   pill or the button itself, and on keyboard focus. */
.lang-switch .admin-peek {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lang-switch .admin-peek:hover,
.lang-switch .admin-peek:focus-visible,
.lang-switch:hover .admin-peek {
  opacity: 1;
}

/* ---------- Cards ---------- */

.card {
  max-width: 42rem;
  margin: 2rem auto 3rem;
  padding: 2rem 1.75rem;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.09);
}

@media (min-width: 700px) {
  .card {
    margin: 3.5rem auto;
  }
}

/* Keep the top of the guest card below the corner language switch */
.card {
  margin-top: 3.5rem;
}

h1 {
  font-size: 1.9rem;
  line-height: 1.25;
  margin: 0 0 0.4rem;
}

h2 {
  font-size: 1.4rem;
  margin: 1.5rem 0 0.5rem;
}

p {
  font-size: 1.15rem;
  margin: 0.5rem 0 1rem;
}

.lede {
  font-size: 1.35rem;
  color: var(--muted);
}

h1 + .lede,
p.lede {
  margin-bottom: 1.25rem;
}

a {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Big buttons (touch-friendly, min 56px) ---------- */

.big-btn,
button.big-btn,
input[type="submit"],
input[type="password"] + .btn {
  display: inline-block;
  width: 100%;
  min-height: 58px;
  padding: 0.8rem 1.2rem;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  border-radius: 10px;
  border: 3px solid var(--accent);
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  margin: 0.4rem 0;
}

.big-btn:hover,
button.big-btn:hover {
  background: var(--accent);
  color: #fff;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.big-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Notice banners ---------- */

.notice {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.75rem 0 1rem;
}

.notice.error {
  background: var(--err-bg);
  color: var(--err);
}

.notice.ok {
  background: #e8f5ec;
  color: var(--ok);
}

/* ---------- Guest upload ---------- */

#photos-wrap {
  margin: 1rem 0;
}

input[type="file"].hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.selected-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.selected-list li {
  background: #f3efe9;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin: 0.3rem 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
}

.selected-list img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.selected-list .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Progress: shown while the upload is in flight (spinning gear-heart
   signals "the site is working") and while the server saves the files. */

.progress-wrap {
  margin: 1rem 0 0.5rem;
  display: none;
}

.progress-wrap.active {
  display: block;
}

.progress-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 0 0 0.6rem;
}

.gear-heart {
  flex-shrink: 0;
  animation: gear-spin 2.4s linear infinite;
}

@keyframes gear-spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-track {
  height: 22px;
  background: #e8e2d8;
  border-radius: 11px;
  overflow: hidden;
}

.progress-track .bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progress-label {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  text-align: center;
}

.hint {
  font-size: 1.05rem;
  color: var(--muted);
  text-align: center;
  margin-top: 1.25rem;
}

/* ---------- Success page ---------- */

.thanks {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}

.thanks .big-icon {
  font-size: 4rem;
  line-height: 1;
}

.thanks h1 {
  font-size: 2.2rem;
}

/* ---------- Error page ---------- */

.error-page h1 {
  font-size: 2.1rem;
}

/* ---------- Admin ---------- */

.admin-header {
  background: var(--accent);
  color: #fff;
  padding: 0.8rem 4rem 0.8rem 1.25rem; /* right space for the corner language switch */
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 1.05rem;
}

.admin-header a:not(.brand) {
  color: #fff;
}

.admin-body {
  max-width: 60rem;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
}

.admin-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.05rem;
}

th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid #e0dad0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #eee7dc;
}

code.link {
  word-break: break-all;
  font-size: 0.85rem;
  background: #f3efe9;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}

/* Admin guest table: the name opens that guest's photo page; the link
 * cell is a small "Link" label over the (tappable) path. */
.guest-name-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.1rem;
}

.size-inline {
  width: auto;
  min-width: 11rem;
  min-height: 48px;
  font-size: 1.1rem;
  border: 2px solid #c9c2b6;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin: 0.25rem 0;
}

textarea.size-inline {
  min-height: 120px;
  font-family: inherit;
  font-size: 1.1rem;
  resize: vertical;
}

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}

/* ---------- Gallery ---------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.photo-cell {
  background: #f3efe9;
  border-radius: 10px;
  overflow: hidden;
}

.photo-cell img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.photo-cell .cap {
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-head {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ---------- Gallery pagination ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 1.5rem;
}

.pager-btn {
  display: inline-block;
  width: auto;
  min-height: 48px;
  padding: 0.4rem 1.1rem;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.6;
  border: 3px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  text-decoration: none;
}

.pager-btn:hover {
  background: var(--accent);
  color: #fff;
}

.pager-page {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.2rem 0.3rem;
}

/* ---------- Start page: event cards ---------- */

/* One card per row at every width: the cover image fills the width of
   the page's text block (same width as the heading/lede lines), event
   name underneath, actions below that. */
.event-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}

.event-card {
  background: #f7f3ec;
  border: 2px solid #e5dccd;
  border-radius: 12px;
  overflow: hidden;
}

.event-cover-link {
  display: block;
}

.event-cover {
  width: 100%;
  /* 4:3 frame — covers are cropped to this ratio at upload, so phones and
     desktops get the exact same picture, no squashing. */
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.event-cover-link:hover img,
.event-cover-link:focus img {
  opacity: 0.9;
}

.event-card-name {
  font-weight: 800;
  font-size: 1.2rem;
  text-align: center;
  margin: 0.7rem 0.5rem 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.4rem 0.75rem 0.9rem;
  margin: 0;
}

.event-btn {
  display: inline-block;
  min-height: 48px;
  padding: 0.45rem 1rem;
  line-height: 1.6;
  font-size: 1.05rem;
  font-weight: 700;
  border: 3px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.event-btn:hover {
  background: var(--accent);
  color: #fff;
}

.event-btn.btn-primary {
  background: var(--accent);
  color: #fff;
}

.event-btn.btn-primary:hover {
  background: var(--accent-dark);
}

/* Single column at every width — the cover is as wide as the card's
   text block (matches the heading/lede); 4:3 ratio. */

/* ---------- Start page: name search ---------- */

.root-status {
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0.5rem 0 0;
}

.root-results {
  margin: 0.5rem 0 0;
}

.search-result {
  display: block;
  background: #f3efe9;
  border: 2px solid #e0d8c9;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  margin: 0.4rem 0;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.2rem;
}

.search-result:hover,
.search-result:focus {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-result .sr-name {
  font-weight: 700;
}

.search-result .sr-event {
  display: block;
  font-size: 0.95rem;
  color: var(--muted);
}

.search-result:hover .sr-event,
.search-result:focus .sr-event {
  color: #ffd9e4;
}

/* ---------- Public gallery (guests) ---------- */

.guest-gallery {
  max-width: 60rem;
  margin: 0.75rem auto 3rem;
  padding: 0 1rem;
}

/* Keep the first row clear of the fixed logo (upper-left corner). */
.guest-gallery {
  margin-top: 3.25rem;
}

/* ---------- Cover image crop widget ---------- */

/* A photo being framed for the event cover: fixed 4:3 window, move by
   drag, zoom by pinch/wheel. The form submits the cropped image. */
.crop-widget {
  width: 100%;
  margin: 0.5rem 0 1rem;
}

.crop-frame {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  border: 3px solid var(--accent);
  border-radius: 10px;
  overflow: hidden;
  background: #f3efe9;
  touch-action: none;
  cursor: move;
}

.crop-frame canvas {
  display: block;
  width: 100%;
}

.crop-widget .crop-btns {
  justify-content: center;
}

/* ---------- QR print page ---------- */

/* QR cards — subtle wedding design: soft border, corner floral sprigs,
 * elegant serif name, clean domain under the code. */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.qr-card {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 90/100; /* winietka shape — true size at print */
  box-sizing: border-box;
  border: 1.5px solid #d8c2c8;
  border-radius: 14px;
  padding: 6px;
  text-align: center;
  background: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Fold style of a classic winietka: the upper half is the blank backing,
   the lower half is the front face (name + motif + QR + address).
   Folding along the midline gives a 90×50 mm standing tent card. */
.qpane {
  flex: 1 1 50%;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.qpane-back {
  border-bottom: 0.5px dashed #e3d0d5;
}

.qr-card .qr-wrap img.qr {
  display: block;
  margin: 4px auto 6px;
  width: 110px;
  height: 110px;
  image-rendering: pixelated;
}

.qr-card .qname {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #3a3234;
  line-height: 1.25;
}

.qfallback {
  font-size: 1.6rem;
  letter-spacing: 0.35em;
  color: var(--muted);
}

.qr-card .qorn {
  display: block;
  margin: 6px auto 0;
}

.qr-card .qurl {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  word-break: break-all;
}

/* Floral sprigs in the bottom corners of the front face (the upper half
   stays a clean blank backing). */
.qr-card .qr-motif {
  position: absolute;
  width: 44px;
  height: 44px;
  opacity: 0.75;
  pointer-events: none;
}

.qr-card .qr-motif-bl {
  bottom: 6px;
  left: 6px;
  transform: scaleX(-1);
}

.qr-card .qr-motif-br {
  bottom: 6px;
  right: 6px;
  transform: rotate(180deg);
}

.qr-card.generic {
  border-style: dashed;
}

.noprint {
  margin: 1rem 0;
}

@page { size: A4; margin: 0 10mm; }

@media print {
  .admin-header,
  .noprint,
  .lang-switch,
  .site-logo {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .admin-body {
    margin: 0;
    padding: 0;
  }
  /* Folded winietki: exactly 90×100 mm cards. Upper half = blank
     backing, lower half = front face (name + QR). Fold along the
     dashed midline → classic 90×50 mm standing tent card.
     2 per row, 4 per A4 page. */
  .qr-grid {
    width: 184mm;
    margin: 12mm auto 0;
    grid-template-columns: repeat(2, 90mm);
    grid-auto-rows: 100mm;
    gap: 4mm;
  }
  .qr-card {
    width: 90mm;
    height: 100mm;
    padding: 0;
    border-width: 1px;
    break-inside: avoid;
  }
  .qr-card .qr-motif {
    width: 11mm;
    height: 11mm;
  }
  .qr-motif-bl { bottom: 1.5mm; left: 1.5mm; }
  .qr-motif-br { bottom: 1.5mm; right: 1.5mm; }
  .qname {
    font-size: 5mm;
  }
  .qr-card .qr-wrap img.qr {
    width: 33mm;
    height: 33mm;
    margin: 1mm auto 1.5mm;
  }
  .qurl {
    font-size: 2.8mm;
  }
  /* Folding guide along the 50 mm midline. */
  .qr-card::after {
    content: "";
    position: absolute;
    left: 3mm;
    right: 3mm;
    top: 50%;
    border-top: 0.5px dashed #d8c2c8;
  }
}

/* ---------- Mobile (phones) ---------- */
/* Smaller screens: two comfy photo columns (older guests tap with
 * fingers, not thumbs over 100px-tiny cells), bigger pager buttons,
 * tighter admin table. */
@media (max-width: 560px) {
  .site-logo {
    font-size: 0.72rem;
    padding: 2px 8px 2px 6px;
  }
  .admin-header .brand {
    font-size: 1rem;
  }
  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .photo-cell img {
    height: 140px;
  }
  .group-head {
    font-size: 1.1rem;
    margin-top: 1.1rem;
  }
  .photo-cell .cap {
    font-size: 0.8rem;
  }
  table {
    font-size: 0.95rem;
  }
  th,
  td {
    padding: 0.4rem 0.3rem;
  }
  .pager {
    flex-direction: column;
    gap: 0.5rem;
  }
  .pager-btn {
    width: 100%;
    min-height: 52px;
  }
}

/* Wedding Simple: admin photo-cell delete button (inside the caption row). */
.photo-cell { display: block; }
.photo-cell form, form.photo-cell { margin: 0; background: #f3efe9; border-radius: 10px; overflow: hidden; }
.photo-cell .cap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.cap-del {
  margin-left: auto;
  background: transparent;
  border: 2px solid #c9c2b6;
  color: #5a5a5a;
  border-radius: 8px;
  min-width: 34px;
  min-height: 34px;
  line-height: 1;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0.4rem;
}
.cap-del:hover {
  border-color: var(--err);
  color: var(--err);
  background: var(--err-bg);
}

/* Wedding Simple: guest's per-photo "Remove" button (their own gallery
   only) — hides the photo from that guest; the admin still sees it. */
.photo-remove {
  margin: 0;
}
.photo-remove button {
  width: 100%;
  border: none;
  border-top: 2px solid #c9c2b6;
  background: #fff;
  color: var(--err);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  min-height: 38px;
  padding: 0.3rem;
}
.photo-remove button:hover {
  background: var(--err-bg);
}

/* Soft-deleted (guest-removed) cells: dimmed + a badge until the admin
   makes the final deletion. */
.photo-cell.pending img {
  opacity: 0.55;
  filter: grayscale(0.4);
}
.cap-badge {
  background: var(--err-bg);
  color: var(--err);
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 9rem;
}
@media (max-width: 560px) {
  .cap-badge {
    display: none;
  }
}
