*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f7f4ef;
  --paper: #ffffff;
  --ink: #3a352e;
  --ink-soft: #5a5348;
  --ink-muted: #8a8175;
  --gold: #b09a6e;
  --gold-soft: #d6c6a4;
  --line: #e5ddd0;
  --dark: #1f1c18;
  --dark-soft: #2f2a24;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 18px;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(176, 154, 110, 0.05), transparent 60%),
    radial-gradient(circle at 80% 90%, rgba(176, 154, 110, 0.05), transparent 60%);
}

header {
  background: linear-gradient(180deg, var(--dark) 0%, var(--dark-soft) 100%);
  color: #ede5d6;
  text-align: center;
  padding: 3.5rem 1.5rem 3rem;
  position: relative;
  border-bottom: 1px solid #000;
}

.lang-switcher {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: #c4b8a8;
  font-family: 'Playfair Display', serif;
}
.lang-switcher button {
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.lang-switcher button:hover { opacity: 0.9; }
.lang-switcher button.active {
  opacity: 1;
  color: #ede5d6;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.lang-switcher .sep { opacity: 0.4; }

.cross {
  font-size: 1.8rem;
  color: var(--gold);
  margin-bottom: 1.5rem;
  opacity: 0.85;
}

/* Photo frame */
.photo-frame {
  width: 220px;
  height: 260px;
  margin: 0 auto 1.5rem;
  position: relative;
  background: #f0ebe1;
  border: 1px solid #5a5348;
  padding: 8px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 10px 30px rgba(0, 0, 0, 0.5);
}
.photo-frame .photo {
  width: 100%;
  height: 100%;
  background-color: #e8e0d0;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  filter: grayscale(100%) contrast(1.02) brightness(0.98);
  position: relative;
}
.photo-frame.has-photo .photo-placeholder { display: none; }
.photo-placeholder {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a09478;
  font-size: 3rem;
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.1em;
  font-style: italic;
}

/* Mourning ribbon (kir) draped across the top-right corner of the
   photo frame. A single diagonal black band is the traditional Polish
   memorial mark; keep it simple and restrained. */
.photo-frame::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 78px;
  height: 78px;
  pointer-events: none;
  background:
    linear-gradient(225deg,
      transparent 38%,
      rgba(0,0,0,0.92) 38%,
      #000 48%,
      #0d0d0d 58%,
      rgba(0,0,0,0.92) 58%,
      transparent 58%);
  filter: drop-shadow(-1px 2px 2px rgba(0,0,0,0.35));
}

header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.6rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.memory-of {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--gold-soft);
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  opacity: 0.9;
}

.dates {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: #d6c6a4;
  margin-top: 1rem;
  line-height: 1.5;
}
.dates .date-line { display: block; }
.dates .age {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  color: #b8a988;
  font-style: normal;
  text-transform: uppercase;
}

.flourish {
  width: 80px;
  height: 12px;
  margin: 1.2rem auto 0;
  color: var(--gold);
  opacity: 0.75;
}
.flourish svg { width: 100%; height: 100%; }

/* Small sub-header for secondary pages (gallery, admin) */
.subhead {
  padding: 2rem 1.5rem;
}
.subhead h1 {
  font-size: 2rem;
}
.subhead .memory-of {
  margin-bottom: 0.2rem;
}

.page-nav {
  text-align: center;
  margin: 1.5rem auto 0;
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.page-nav a {
  color: var(--gold-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color 0.2s, color 0.2s;
}
.page-nav a:hover {
  color: #ede5d6;
  border-bottom-color: var(--gold);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
main.wide { max-width: 960px; }

section {
  margin-bottom: 3rem;
}

section h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  margin-bottom: 1.5rem;
  text-align: center;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
}
section h2::before,
section h2::after {
  content: "";
  display: inline-block;
  width: 40px;
  height: 1px;
  background: var(--gold);
  vertical-align: middle;
  margin: 0 1rem;
  opacity: 0.5;
}

.tribute p {
  text-align: center;
  font-size: 1.25rem;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}

.biography {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 2.5rem 2rem;
  border-radius: 2px;
  box-shadow: 0 2px 20px rgba(60, 50, 30, 0.04);
}
.biography p {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin-bottom: 1.1rem;
  text-align: justify;
  hyphens: auto;
}
.biography p:last-child { margin-bottom: 0; }
.biography p:first-of-type::first-letter {
  font-family: 'Playfair Display', serif;
  font-size: 3.2rem;
  float: left;
  line-height: 1;
  padding-right: 0.6rem;
  padding-top: 0.3rem;
  color: var(--gold);
  font-style: italic;
}

.arrangements {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2rem;
  box-shadow: 0 2px 20px rgba(60, 50, 30, 0.04);
}

.event {
  text-align: center;
  padding: 1.75rem 0;
}
.event:not(:last-child) {
  border-bottom: 1px solid var(--line);
}
.event h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--gold);
  margin-bottom: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.event .datetime {
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.event .location {
  font-size: 1rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
}
.event .address {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}
.event .address a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.event .address a:hover { border-bottom-color: var(--gold); }

.condolences {
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 2.5rem 2rem;
  border-radius: 2px;
  box-shadow: 0 2px 20px rgba(60, 50, 30, 0.04);
}
.condolences > p.lead {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
  font-style: italic;
}
.btn {
  display: inline-block;
  padding: 0.85rem 1.8rem;
  background: var(--dark);
  color: #ede5d6;
  text-decoration: none;
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: 1px solid var(--gold);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}
.btn:hover {
  background: var(--gold);
  color: var(--dark);
  transform: translateY(-1px);
}
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink-soft);
}
.btn.secondary:hover {
  background: var(--ink-soft);
  color: #ede5d6;
}
.btn.danger {
  background: transparent;
  color: #9a3a3a;
  border-color: #c98a8a;
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}
.btn.danger:hover {
  background: #9a3a3a;
  color: #fff;
  border-color: #9a3a3a;
}

/* Link-style button inside the main content for "See the photo gallery". */
.page-link {
  text-align: center;
}
.page-link .btn { margin-top: 0.5rem; }
.page-link p.lead {
  font-size: 1.1rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 1rem;
}

/* Forms --------------------------------------------------------------- */
.memorial-form {
  text-align: left;
  display: grid;
  gap: 1rem;
  max-width: 520px;
  margin: 0 auto;
}
.memorial-form .row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.memorial-form label {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
}
.memorial-form input[type="text"],
.memorial-form input[type="email"],
.memorial-form input[type="password"],
.memorial-form input[type="file"],
.memorial-form textarea {
  width: 100%;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  background: #fdfbf7;
  color: var(--ink);
  border-radius: 2px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.memorial-form textarea { min-height: 130px; resize: vertical; }
.memorial-form input:focus,
.memorial-form textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176, 154, 110, 0.15);
}
.memorial-form .actions {
  text-align: center;
  margin-top: 0.5rem;
}
.field-hint {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-style: italic;
}
.form-status {
  text-align: center;
  min-height: 1.4em;
  font-size: 0.95rem;
  font-style: italic;
}
.form-status.success { color: #4a7a4a; }
.form-status.error { color: #9a3a3a; }

/* Condolences list --------------------------------------------------- */
.condolences-list {
  margin-top: 2rem;
  text-align: left;
  display: grid;
  gap: 1.25rem;
}
.condolence-card {
  background: #fdfbf7;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  padding: 1.25rem 1.4rem;
  border-radius: 2px;
  position: relative;
}
.condolence-card .msg {
  font-size: 1.05rem;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 0.8rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.condolence-card .meta {
  font-family: 'Playfair Display', serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.condolence-card .meta .author {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: none;
  font-size: 0.95rem;
}
.condolences-empty {
  text-align: center;
  color: var(--ink-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* Lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 8, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 2.5rem 4.5rem;
}
.lightbox[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}
body.lightbox-open {
  overflow: hidden;
  /* Prevent iOS bounce scrolling while the viewer is open */
  touch-action: none;
}
.lightbox-stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.lightbox-img {
  max-width: 100%;
  max-height: calc(100vh - 10rem);
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  background: #1a1815;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-img.loading {
  opacity: 0.35;
  transition: opacity 0.2s ease;
}
.lightbox-meta {
  max-width: 720px;
  text-align: center;
  color: #ede5d6;
  font-family: 'Cormorant Garamond', Georgia, serif;
}
.lightbox-caption {
  font-size: 1.1rem;
  font-style: italic;
  color: #ede5d6;
  line-height: 1.5;
  word-wrap: break-word;
  min-height: 0;
}
.lightbox-caption:empty { display: none; }
.lightbox-counter {
  margin-top: 0.4rem;
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: #b8a988;
  text-transform: uppercase;
}

/* Navigation chevrons */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ede5d6;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 4px;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  font-family: 'Playfair Display', serif;
}
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scale(1.06);
}
.lightbox-nav.prev { left: 1.5rem; }
.lightbox-nav.next { right: 1.5rem; }
.lightbox-nav[hidden] { display: none; }

/* Close button */
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ede5d6;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Responsive tuning */
@media (max-width: 720px) {
  .lightbox { padding: 3rem 0.5rem 2rem; }
  .lightbox-img { max-height: calc(100vh - 9rem); }
  .lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 1.7rem;
  }
  .lightbox-nav.prev { left: 0.5rem; }
  .lightbox-nav.next { right: 0.5rem; }
  .lightbox-close { top: 0.5rem; right: 0.5rem; width: 40px; height: 40px; }
  .lightbox-caption { font-size: 0.95rem; }
}

/* Gallery ------------------------------------------------------------ */
.gallery-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2rem;
  box-shadow: 0 2px 20px rgba(60, 50, 30, 0.04);
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.gallery-grid button, .gallery-grid a, .gallery-grid .tile {
  display: block;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f0ebe1;
  aspect-ratio: 1 / 1;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-decoration: none;
}
.gallery-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(100%) brightness(0.98);
  transition: transform 0.4s ease, filter 0.4s ease;
}
.gallery-grid button:hover img,
.gallery-grid a:hover img {
  transform: scale(1.04);
  filter: grayscale(20%) brightness(1);
}
.gallery-grid button:focus-visible,
.gallery-grid a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.gallery-empty {
  text-align: center;
  color: var(--ink-muted);
  font-style: italic;
  padding: 1rem 0;
}
.gallery-actions {
  text-align: center;
  margin-top: 1.5rem;
}
.gallery-form {
  margin-top: 1.25rem;
  display: none;
}
.gallery-form.open { display: block; }

/* Admin table ------------------------------------------------------- */
.admin-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1.5rem;
  border-radius: 2px;
  box-shadow: 0 2px 20px rgba(60, 50, 30, 0.04);
}
.admin-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.admin-panel th, .admin-panel td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.admin-panel th {
  font-family: 'Playfair Display', serif;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.admin-panel .msg-cell {
  max-width: 400px;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--ink-soft);
  font-style: italic;
}
.admin-panel img.thumb {
  width: 90px;
  height: 90px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
  filter: grayscale(100%);
}
.admin-panel details.audit {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.admin-panel details.audit summary {
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.05em;
  color: var(--ink);
  list-style: none;
  padding: 0.15rem 0;
}
.admin-panel details.audit summary::-webkit-details-marker { display: none; }
.admin-panel details.audit summary::after {
  content: " \25B8";
  color: var(--ink-muted);
  transition: transform 0.2s;
}
.admin-panel details.audit[open] summary::after { content: " \25BE"; }
.admin-panel details.audit .audit-body {
  padding: 0.5rem 0 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
  color: var(--ink-muted);
  max-width: 420px;
  word-break: break-all;
  white-space: normal;
  line-height: 1.4;
}
.admin-panel details.audit .audit-body div { margin-bottom: 0.3rem; }
.admin-panel details.audit .audit-body strong {
  color: var(--ink-soft);
  font-weight: 500;
  display: inline-block;
  min-width: 3.5rem;
}

.admin-logout {
  text-align: right;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.admin-logout a {
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

footer {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--ink-muted);
  font-size: 0.95rem;
  border-top: 1px solid var(--line);
  font-style: italic;
  background: var(--bg);
}
footer p { max-width: 500px; margin: 0 auto; }

@media (max-width: 520px) {
  body { font-size: 17px; }
  header { padding: 3rem 1.25rem 2.5rem; }
  header h1 { font-size: 2.1rem; }
  .photo-frame { width: 180px; height: 220px; }
  .photo-frame::after { width: 62px; height: 62px; }
  .biography { padding: 2rem 1.25rem; }
  section h2::before, section h2::after { width: 20px; margin: 0 0.5rem; }
  .lang-switcher { top: 0.6rem; right: 0.6rem; }
  .memorial-form .row-2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  main > section {
    opacity: 0;
    transform: translateY(8px);
    animation: fadein 0.8s ease forwards;
  }
  main > section:nth-child(1) { animation-delay: 0.1s; }
  main > section:nth-child(2) { animation-delay: 0.2s; }
  main > section:nth-child(3) { animation-delay: 0.3s; }
  main > section:nth-child(4) { animation-delay: 0.4s; }
  main > section:nth-child(5) { animation-delay: 0.5s; }
  @keyframes fadein {
    to { opacity: 1; transform: none; }
  }
}
