/* ============================================================
   Memento Tempus — The Memory Garden
   A quiet "garden of remembrance" theme.
   ============================================================ */

:root {
  /* Palette: dusk over a garden */
  --bg-0:        #0d110d;   /* deepest */
  --bg-1:        #10140f;
  --surface:     rgba(28, 34, 28, 0.55);
  --surface-2:   rgba(34, 41, 33, 0.7);
  --border:      rgba(168, 192, 160, 0.16);
  --border-soft: rgba(168, 192, 160, 0.10);

  --text:        #e9e6dc;   /* warm off-white */
  --text-soft:   #b7bcab;
  --text-faint:  #8a917f;

  --sage:        #8fae8b;   /* living green */
  --sage-deep:   #5f7d63;
  --gold:        #c9a86a;   /* warm candlelight accent */
  --gold-soft:   #ddc79a;
  --danger:      #c97a6a;

  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 18px 48px rgba(0, 0, 0, 0.45);
  --maxw:        1120px;

  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'Spline Sans Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  line-height: 1.6;
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(95, 125, 99, 0.20), transparent 60%),
    radial-gradient(900px 600px at 85% 110%, rgba(201, 168, 106, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---- Drifting petals (decorative) ---- */
.petals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.petals span {
  position: absolute;
  top: -8%;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle at 30% 30%, var(--gold-soft), var(--sage-deep));
  border-radius: 80% 0 55% 50% / 55% 0 80% 50%;
  opacity: 0;
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translateY(-10vh) rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.55; }
  90%  { opacity: 0.35; }
  100% { transform: translateY(112vh) rotate(360deg); opacity: 0; }
}

/* ---- Layout ---- */
main, .site-header, .site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  text-align: center;
  padding-top: clamp(56px, 9vw, 110px);
  padding-bottom: 16px;
}

.eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-size: 0.72rem;
  color: var(--gold);
  margin: 0 0 14px;
  padding-left: 0.34em;
}

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--text);
}

.lede {
  max-width: 620px;
  margin: 22px auto 0;
  font-family: var(--serif);
  font-size: clamp(1.12rem, 2.4vw, 1.4rem);
  font-style: italic;
  color: var(--text-soft);
  line-height: 1.55;
}

/* ---- Sections ---- */
.section { padding: clamp(40px, 7vw, 72px) 0 0; }

.section-head { text-align: center; margin-bottom: 32px; }

h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin: 0;
  color: var(--text);
}

.section-sub {
  margin: 8px 0 0;
  color: var(--text-faint);
  font-size: 0.98rem;
}
.section-sub em { color: var(--sage); font-style: italic; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---- World clocks ---- */
.clock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.clock-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.6s ease forwards;
}
.clock-box:hover {
  transform: translateY(-4px);
  border-color: rgba(201, 168, 106, 0.4);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(201, 168, 106, 0.12) inset;
}

.city-name {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
}
.city-country {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 2px;
}

.clock-time {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--gold-soft);
  margin: 14px 0 4px;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
}

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Obituaries list ---- */
.obits-list {
  list-style: none;
  margin: 0 auto;
  padding: 8px;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  max-height: 440px;
  overflow-y: auto;
}
.obits-list li {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
  line-height: 1.5;
}
.obits-list li:last-child { border-bottom: none; }
.obits-list a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.obits-list a:hover { color: var(--gold-soft); border-color: var(--gold); }
.obits-list .date {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.obits-list .loading { color: var(--text-faint); display: flex; align-items: center; gap: 10px; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(143, 174, 139, 0.3);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Form ---- */
.form-card {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px;
}
.form-card form { display: flex; flex-direction: column; gap: 20px; }

.field label {
  display: block;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.optional { text-transform: none; letter-spacing: 0; color: var(--text-faint); font-size: 0.8rem; }

.field input,
.field textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.98rem;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-faint); }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(201, 168, 106, 0.14);
}
.field textarea { resize: vertical; min-height: 110px; }
.field input.invalid,
.field textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(201, 122, 106, 0.16); }

/* date input color hint */
.field input[type="date"] { color-scheme: dark; }

.field-error {
  display: block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 0.82rem;
  min-height: 1em;
}

/* ---- Buttons ---- */
.btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
}
.btn-primary {
  align-self: flex-start;
  padding: 13px 30px;
  border: none;
  color: #15180f;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  box-shadow: 0 10px 26px rgba(201, 168, 106, 0.24);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(201, 168, 106, 0.34); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover { border-color: var(--sage); color: var(--text); }

/* ---- Tributes ---- */
.tributes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 640px;
  margin: 40px auto 16px;
}
.tributes-head h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.6rem;
  margin: 0;
  color: var(--text);
}

.tributes-list {
  list-style: none;
  max-width: 640px;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tribute {
  position: relative;
  padding: 20px 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sage-deep);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rise 0.45s ease forwards;
}
.tribute .name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}
.tribute .when {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 2px;
}
.tribute .msg {
  margin: 12px 0 0;
  color: var(--text-soft);
  font-family: var(--serif);
  font-size: 1.08rem;
  font-style: italic;
  line-height: 1.55;
}
.delete-btn {
  position: absolute;
  top: 16px; right: 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.74rem;
  cursor: pointer;
  transition: all 0.25s ease;
}
.delete-btn:hover { border-color: var(--danger); color: var(--danger); }

.empty-state {
  text-align: center;
  color: var(--text-faint);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.12rem;
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 72px 24px 48px;
  color: var(--text-faint);
}
.site-footer p { margin: 4px 0; }
.footer-note { font-family: var(--serif); font-style: italic; color: var(--sage); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sage);
  border-radius: var(--radius-sm);
  padding: 14px 22px;
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: var(--danger); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 8, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal-overlay.show { opacity: 1; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  transform: scale(0.96);
  transition: transform 0.25s ease;
}
.modal-overlay.show .modal { transform: scale(1); }
.modal h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.5rem;
  margin: 0 0 10px;
  color: var(--text);
}
.modal p { color: var(--text-soft); margin: 0 0 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
.modal-btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.modal-btn.cancel { background: transparent; color: var(--text-soft); }
.modal-btn.cancel:hover { border-color: var(--sage); color: var(--text); }
.modal-btn.confirm { background: var(--danger); border-color: var(--danger); color: #1a0f0c; }
.modal-btn.confirm:hover { filter: brightness(1.08); }

/* ---- Focus visibility ---- */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---- Scrollbars ---- */
.obits-list::-webkit-scrollbar { width: 8px; }
.obits-list::-webkit-scrollbar-track { background: transparent; }
.obits-list::-webkit-scrollbar-thumb { background: var(--sage-deep); border-radius: 8px; }
.obits-list::-webkit-scrollbar-thumb:hover { background: var(--sage); }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .clock-box, .tribute { opacity: 1; transform: none; }
  .petals { display: none; }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  main, .site-header, .site-footer { padding-left: 18px; padding-right: 18px; }
  .clock-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .clock-box { padding: 18px 14px; }
  .clock-time { font-size: 1.4rem; }
  .form-card { padding: 24px; }
  .btn-primary { align-self: stretch; text-align: center; }
}
