/* Dawat — invite renderer styles (cover + chat).
   Mobile-first. Themes swap CSS variables on .inv-theme-* classes. */

.inv-root {
  --inv-font-display: 'Fraunces', 'Georgia', serif;
  --inv-font-body: 'Karla', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* emerald (default) */
  --inv-accent: #075e54;
  --inv-on-accent: #f2fbf7;
  --inv-bg: #eae2d4;
  --inv-host-bubble: #ffffff;
  --inv-host-text: #23312b;
  --inv-guest-bubble: #dcf8c6;
  --inv-guest-text: #1d3323;
  --inv-meta: rgba(20, 30, 25, 0.42);
  --inv-tick: #4fb6e0;
  --inv-link: #075e54;
  --inv-cover-bg: linear-gradient(168deg, #f6f1e4 0%, #e9e8d5 52%, #d7e4d5 100%);
  --inv-cover-ink: #0d4237;
  --inv-cover-accent: #b98b2f;
  --inv-pattern:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170' viewBox='0 0 170 170'%3E%3Cg fill='none' stroke='%23000000' stroke-opacity='.055' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M34 28c-3.4-6.2-13-4-13 3.2 0 5.4 7.6 9.6 13 14 5.4-4.4 13-8.6 13-14 0-7.2-9.6-9.4-13-3.2Z'/%3E%3Ccircle cx='120' cy='42' r='8'/%3E%3Ccircle cx='131' cy='42' r='8'/%3E%3Cpath d='M78 100l3.2 7.6 7.6 3.2-7.6 3.2-3.2 7.6-3.2-7.6-7.6-3.2 7.6-3.2 3.2-7.6Z'/%3E%3Cpath d='M138 122c5 1.4 10-2 10-8M138 122c-1.4-5 2-10 8-10'/%3E%3Ccircle cx='40' cy='132' r='2.4'/%3E%3Ccircle cx='152' cy='84' r='2.4'/%3E%3Ccircle cx='88' cy='22' r='2.4'/%3E%3C/g%3E%3C/svg%3E");

  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--inv-font-body);
  background: var(--inv-bg);
}

.inv-theme-rose {
  --inv-accent: #96455a;
  --inv-on-accent: #fdf3f2;
  --inv-bg: #f3e4e0;
  --inv-host-bubble: #ffffff;
  --inv-host-text: #3c262b;
  --inv-guest-bubble: #fadfdb;
  --inv-guest-text: #55272f;
  --inv-link: #96455a;
  --inv-cover-bg: linear-gradient(168deg, #fbf3ef 0%, #f6e3de 55%, #efd3cf 100%);
  --inv-cover-ink: #6f2f3f;
  --inv-cover-accent: #c08e57;
}

.inv-theme-gold {
  --inv-accent: #7c5e1a;
  --inv-on-accent: #fdf8ea;
  --inv-bg: #f1e8d2;
  --inv-host-bubble: #fffdf6;
  --inv-host-text: #3b2f16;
  --inv-guest-bubble: #f3e3b8;
  --inv-guest-text: #4d3a10;
  --inv-link: #7c5e1a;
  --inv-cover-bg: linear-gradient(168deg, #fbf6e8 0%, #f4ead0 55%, #ecdcb4 100%);
  --inv-cover-ink: #6d5316;
  --inv-cover-accent: #b98b2f;
}

.inv-theme-midnight {
  --inv-accent: #101c2e;
  --inv-on-accent: #e9eef8;
  --inv-bg: #0b1017;
  --inv-host-bubble: #1b2432;
  --inv-host-text: #e8edf5;
  --inv-guest-bubble: #14453a;
  --inv-guest-text: #dcf5e8;
  --inv-meta: rgba(235, 242, 250, 0.45);
  --inv-tick: #6fc7ec;
  --inv-link: #86d8bf;
  --inv-cover-bg: linear-gradient(168deg, #101a29 0%, #0d1520 55%, #10241d 100%);
  --inv-cover-ink: #ecdfc0;
  --inv-cover-accent: #caa64f;
  --inv-pattern:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170' viewBox='0 0 170 170'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.05' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M34 28c-3.4-6.2-13-4-13 3.2 0 5.4 7.6 9.6 13 14 5.4-4.4 13-8.6 13-14 0-7.2-9.6-9.4-13-3.2Z'/%3E%3Ccircle cx='120' cy='42' r='8'/%3E%3Ccircle cx='131' cy='42' r='8'/%3E%3Cpath d='M78 100l3.2 7.6 7.6 3.2-7.6 3.2-3.2 7.6-3.2-7.6-7.6-3.2 7.6-3.2 3.2-7.6Z'/%3E%3Cpath d='M138 122c5 1.4 10-2 10-8M138 122c-1.4-5 2-10 8-10'/%3E%3Ccircle cx='40' cy='132' r='2.4'/%3E%3Ccircle cx='152' cy='84' r='2.4'/%3E%3Ccircle cx='88' cy='22' r='2.4'/%3E%3C/g%3E%3C/svg%3E");
}

.inv-theme-lilac {
  --inv-accent: #5b4b8a;
  --inv-on-accent: #f5f2fd;
  --inv-bg: #ece5f6;
  --inv-host-bubble: #ffffff;
  --inv-host-text: #2e2547;
  --inv-guest-bubble: #e3d7f7;
  --inv-guest-text: #3a2e5f;
  --inv-link: #5b4b8a;
  --inv-cover-bg: linear-gradient(168deg, #f6f2fc 0%, #ebe3f8 55%, #ddd2f0 100%);
  --inv-cover-ink: #453470;
  --inv-cover-accent: #b08cc9;
}

.inv-root [hidden] { display: none !important; }

.inv-icon,
.inv-icon svg { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -0.22em; }

/* ============ cover ============ */

.inv-cover {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  background: var(--inv-pattern), var(--inv-cover-bg);
  color: var(--inv-cover-ink);
  overflow-y: auto;
}

.inv-cover-inner { max-width: 340px; }

.inv-cover-inner > * {
  animation: inv-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.inv-cover-inner > :nth-child(2) { animation-delay: 0.12s; }
.inv-cover-inner > :nth-child(3) { animation-delay: 0.24s; }
.inv-cover-inner > :nth-child(4) { animation-delay: 0.36s; }
.inv-cover-inner > :nth-child(5) { animation-delay: 0.48s; }
.inv-cover-inner > :nth-child(6) { animation-delay: 0.6s; }

.inv-cover-note {
  margin: 0 0 18px;
  font-size: 1.2rem;
  opacity: 0.9;
}

.inv-cover-photo {
  width: min(52vw, 185px);
  aspect-ratio: 4 / 5;
  margin: 0 auto 6px;
  border-radius: 999px 999px 16px 16px;
  overflow: hidden;
  border: 2px solid var(--inv-cover-accent);
  outline: 1px solid var(--inv-cover-accent);
  outline-offset: 6px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.45);
}
.inv-cover-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.inv-cover-monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--inv-font-display);
  font-style: italic;
  font-size: 2.4rem;
  background: rgba(255, 255, 255, 0.28);
}
.inv-theme-midnight .inv-cover-monogram { background: rgba(255, 255, 255, 0.06); }

.inv-cover-orn {
  margin: 16px 0 4px;
  color: var(--inv-cover-accent);
  letter-spacing: 0.45em;
  font-size: 0.8rem;
}

.inv-cover-names {
  margin: 0;
  font-family: var(--inv-font-display);
  font-style: italic;
  font-weight: 560;
  font-size: clamp(1.9rem, 9vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.inv-cover-intro {
  margin: 10px 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  opacity: 0.82;
}

.inv-open {
  margin-top: 26px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 26px;
  border: none;
  border-radius: 999px;
  background: var(--inv-cover-ink);
  color: #fdfaf2;
  font-family: var(--inv-font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.5);
  animation: inv-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both, inv-pulse 2.6s 1.4s ease-in-out infinite;
  transition: transform 0.25s ease;
}
.inv-theme-midnight .inv-open { color: #101a14; }
.inv-open:active { transform: scale(0.96); }

@keyframes inv-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes inv-pulse {
  0%, 100% { box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(0, 0, 0, 0.18); }
  50% { box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.5), 0 0 0 12px rgba(0, 0, 0, 0); }
}

/* ============ chat ============ */

.inv-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.inv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--inv-accent);
  color: var(--inv-on-accent);
  flex-shrink: 0;
}

.inv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--inv-font-display);
  font-style: italic;
  font-size: 1.1rem;
}
.inv-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.inv-header-text { flex: 1; min-width: 0; }
.inv-header-text h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-header-text p {
  margin: 1px 0 0;
  font-size: 0.74rem;
  opacity: 0.78;
}

.inv-music {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.15rem;
  padding: 8px;
  cursor: pointer;
  opacity: 0.95;
}
.inv-music-off { opacity: 0.55; }

.inv-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 16px 12px max(26px, env(safe-area-inset-bottom));
  background-image: var(--inv-pattern);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.inv-msg {
  position: relative;
  max-width: 80%;
  padding: 7px 10px 8px;
  border-radius: 10px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  font-size: 0.94rem;
  line-height: 1.42;
  animation: inv-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes inv-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.inv-host {
  align-self: flex-start;
  background: var(--inv-host-bubble);
  color: var(--inv-host-text);
  border-top-left-radius: 2px;
}
.inv-host::after {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  border: 8px solid transparent;
  border-top-color: var(--inv-host-bubble);
  border-right-color: var(--inv-host-bubble);
  border-bottom: 0;
  border-left: 0;
}

.inv-guest {
  align-self: flex-end;
  background: var(--inv-guest-bubble);
  color: var(--inv-guest-text);
  border-top-right-radius: 2px;
}
.inv-guest::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  border: 8px solid transparent;
  border-top-color: var(--inv-guest-bubble);
  border-left-color: var(--inv-guest-bubble);
  border-bottom: 0;
  border-right: 0;
}

.inv-msg-text { white-space: pre-wrap; overflow-wrap: break-word; }

.inv-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0.75em -2px -3px 9px;
  font-size: 0.65rem;
  color: var(--inv-meta);
  user-select: none;
}
.inv-ticks svg { width: 15px; height: 10px; display: block; color: var(--inv-tick); }

.inv-msg-media { padding: 4px; }
.inv-msg-media img {
  display: block;
  width: min(62vw, 250px);
  border-radius: 7px;
}
.inv-msg-media .inv-meta { position: absolute; right: 10px; bottom: 8px; margin: 0; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }

.inv-msg-link {
  color: var(--inv-link);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.inv-msg-link:hover { text-decoration: underline; }

/* typing dots */
.inv-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}
.inv-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: inv-blink 1.1s infinite;
}
.inv-typing span:nth-child(2) { animation-delay: 0.18s; }
.inv-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes inv-blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 0.9; transform: translateY(-3px); }
}

/* RSVP card */
.inv-rsvp { max-width: 86%; padding: 12px 12px 10px; }
.inv-rsvp-title { margin: 0 0 10px; font-weight: 700; font-size: 0.94rem; }
.inv-rsvp-btn {
  display: block;
  text-align: center;
  padding: 11px 16px;
  margin-top: 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.inv-rsvp-btn:active { transform: scale(0.97); }
.inv-rsvp-yes { background: var(--inv-accent); color: var(--inv-on-accent); }
.inv-rsvp-bless {
  border: 1.6px solid var(--inv-accent);
  color: var(--inv-link);
  background: transparent;
}

/* ============ viewer page shell ============ */

.inv-viewer-page {
  margin: 0;
  min-height: 100dvh;
  background: #14100c;
  font-family: 'Karla', -apple-system, sans-serif;
}
.inv-stage { height: 100dvh; }

@media (min-width: 720px) {
  .inv-viewer-page {
    background:
      radial-gradient(80% 60% at 50% 0%, #2a2118 0%, #14100c 70%);
    display: grid;
    place-items: center;
    padding: 28px;
  }
  .inv-stage {
    height: min(880px, calc(100dvh - 56px));
    aspect-ratio: 9 / 19.5;   /* keep a phone shape — width follows height so a short window can't squish it square */
    width: auto;
    max-width: 430px;
    border-radius: 30px;
    overflow: hidden;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.08),
      0 40px 90px -30px rgba(0, 0, 0, 0.8);
  }
}

/* fallback screen for bad / missing invite codes */
.inv-fallback {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 32px;
  color: #efe6d6;
}
.inv-fallback h1 { font-family: 'Fraunces', serif; font-style: italic; font-weight: 500; margin: 0; }
.inv-fallback p { margin: 0; opacity: 0.75; max-width: 40ch; line-height: 1.5; }
.inv-fallback a {
  margin-top: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  background: #b98b2f;
  color: #1d1608;
  font-weight: 700;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .inv-cover-inner > *, .inv-open, .inv-msg { animation: none !important; }
  .inv-messages { scroll-behavior: auto; }
}
