@font-face { font-family: 'Playfair Display'; src: url('../assets/fonts/PlayfairDisplay-BoldItalic.ttf') format('truetype'); font-style: italic; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Invitation Sans'; src: url('../assets/fonts/BeVietnamPro-400.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Sans'; src: url('../assets/fonts/BeVietnamPro-500.ttf') format('truetype'); font-style: normal; font-weight: 500; font-display: swap; }
@font-face { font-family: 'Invitation Sans'; src: url('../assets/fonts/BeVietnamPro-600.ttf') format('truetype'); font-style: normal; font-weight: 600; font-display: swap; }
@font-face { font-family: 'Invitation Sans'; src: url('../assets/fonts/BeVietnamPro-700.ttf') format('truetype'); font-style: normal; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Invitation Sans'; src: url('../assets/fonts/BeVietnamPro-400-Italic.ttf') format('truetype'); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Sans'; src: url('../assets/fonts/BeVietnamPro-600-Italic.ttf') format('truetype'); font-style: italic; font-weight: 600; font-display: swap; }
@font-face { font-family: 'Invitation Classic'; src: url('../assets/fonts/LiberationSerif-Regular.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Classic'; src: url('../assets/fonts/LiberationSerif-Italic.ttf') format('truetype'); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Classic'; src: url('../assets/fonts/LiberationSerif-Bold.ttf') format('truetype'); font-style: normal; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Invitation Classic'; src: url('../assets/fonts/LiberationSerif-BoldItalic.ttf') format('truetype'); font-style: italic; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Invitation Title'; src: url('../assets/fonts/LiberationSerif-BoldItalic.ttf') format('truetype'); font-style: italic; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Guest Name'; src: url('../assets/fonts/Lora-Bold.ttf') format('truetype'); font-style: normal; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Invitation Body'; src: url('../assets/fonts/Lora-Regular.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Serif'; src: url('../assets/fonts/Tinos-400.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Serif'; src: url('../assets/fonts/Tinos-700.ttf') format('truetype'); font-style: normal; font-weight: 700; font-display: swap; }
@font-face { font-family: 'Invitation Serif'; src: url('../assets/fonts/Tinos-400-Italic.ttf') format('truetype'); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: 'Invitation Serif'; src: url('../assets/fonts/Tinos-700-Italic.ttf') format('truetype'); font-style: italic; font-weight: 700; font-display: swap; }

:root {
  --ink: #653A17;
  --ink-deep: #4A2910;
  --muted: #84664B;
  --accent: #9C6B3F;
  --line: #DFD1BE;
  --paper: #FAF6F0;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Invitation Sans', system-ui, sans-serif;
}

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

body.theme-wabi {
  background: linear-gradient(135deg, #FBF8F3, #EFE6D8);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #9C6B3F; outline-offset: 5px; }

.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;
}

/* Envelope Overlay */
.envelope-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 30px 22px;
  background: radial-gradient(ellipse at 80% 10%, #E7D8C3BB, transparent 58%), linear-gradient(135deg, #FBF8F3, #EFE6D8);
  transition: opacity .65s, visibility .65s;
}
.envelope-overlay.opened { display: none; }
.envelope-overlay.opening { opacity: 0; visibility: hidden; pointer-events: none; }

.envelope-wrapper { width: min(100%, 640px); margin: auto; text-align: center; }
.envelope-eyebrow { color: var(--muted); font-size: 10px; letter-spacing: 2.6px; margin-bottom: 22px; text-transform: uppercase; }
.envelope-eyebrow span { margin: 0 10px; color: var(--accent); }

.envelope {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #FAF6F0;
  overflow: hidden;
  box-shadow: 0 18px 60px -20px #653A1738;
  transition: transform .6s, opacity .6s;
}
.envelope-art { display: block; width: 100%; height: auto; }
.envelope:hover { transform: translateY(-3px); }
.envelope.is-opening { transform: translateY(-20px) scale(1.03); opacity: .2; }

.envelope-instruction { margin: 24px auto 0; }
.cover-salutation { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.cover-guest {
  font-family: var(--serif);
  font-weight: 700;
  font-style: italic;
  font-size: 28px;
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cover-event { color: var(--muted); font-size: 12px; margin-top: 9px; }

.btn-open-wabi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  min-height: 48px;
  padding: 12px 30px;
  margin-top: 22px;
  border: 1px solid #C5AD91;
  border-radius: 30px;
  background: linear-gradient(135deg, #F6EFE5, #E4D4BE);
  color: var(--ink-deep);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 5px 18px #653A171C;
  transition: transform .2s, background .2s;
}
.btn-open-wabi:hover { transform: translateY(-2px); background: #F5ECE0; }
body.envelope-active { overflow: hidden; }

/* Main Container & Card */
.invitation-container { width: min(100%, 850px); padding: 20px 26px 28px; margin: auto; }
.invitation-card {
  position: relative;
  isolation: isolate;
  width: 100%;
  background: #FAF6F0;
  box-shadow: 0 18px 65px #653A171A;
  border-radius: 5px;
  overflow: hidden;
}

/* Keep the approved artwork intact; personalize only its reserved name area. */
.approved-artwork { aspect-ratio: 2 / 3; }
.approved-artwork .approved-poster { display: block; width: 100%; height: auto; }
.approved-artwork .guest-personalization {
  position: absolute;
  left: 9%;
  top: 34.3%;
  width: 82%;
  height: 9.4%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guest-person-name {
  width: 100%;
  text-align: center;
  font-family: 'Guest Name', Georgia, serif;
  font-weight: 700;
  font-size: clamp(16px, 4.8vw, 46px);
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: pre-line;
  text-wrap: balance;
}
.guest-editor { display: grid; gap: 10px; margin-bottom: 18px; font-size: 13px; }
.guest-editor label { font-weight: 600; }
.guest-editor textarea { width: 100%; resize: vertical; min-height: 80px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
.guest-editor button { justify-self: start; }
.guest-editor p { overflow-wrap: anywhere; }

/* Editor Toolbar */
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12px; }
.editor-toolbar button, .editor-toolbar a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #FAF6F0;
  color: var(--ink);
  font-size: 12px;
  text-decoration: none;
  line-height: inherit;
}

/* Details Accordion */
.event-more { margin-top: 18px; border-bottom: 1px solid var(--line); font-size: 12px; }
.event-more summary { display: flex; align-items: center; justify-content: space-between; padding: 16px 2px; list-style: none; cursor: pointer; color: var(--ink); }
.event-more summary::-webkit-details-marker { display: none; }
.event-more summary span { font-size: 20px; transition: transform .2s; }
.event-more[open] summary span { transform: rotate(45deg); }
.event-more-content { padding: 2px 2px 20px; color: var(--muted); }
.details-intro, .agenda-item { margin-bottom: 16px; }
.agenda-item h3 { font-size: 12px; color: var(--ink); font-weight: 600; margin-bottom: 6px; }
.agenda-item ol { padding-left: 18px; }
.agenda-item p, .agenda-item li { line-height: 1.9; }
.organizer { margin-top: 12px; font-weight: 500; color: var(--ink); }

/* Action Buttons Deck */
.action-buttons-deck { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.btn-primary-action, .btn-secondary-action {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 22px;
  border: 1px solid #CBB9A4;
  border-radius: 26px;
  background: #FAF6F0CC;
  color: var(--ink);
  font: 11px var(--sans);
  font-weight: 500;
  text-decoration: none;
  transition: transform .2s, background .2s;
}
.btn-primary-action {
  background: linear-gradient(135deg, #F6EFE5, #E4D4BE);
  color: var(--ink-deep);
  border-color: #C5AD91;
}
.btn-primary-action:hover, .btn-secondary-action:hover { transform: translateY(-2px); background: #F5ECE0; }

.utility-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-action-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #FAF6F0B3;
  color: var(--ink);
  font-size: 21px;
  display: grid;
  place-items: center;
}
.btn-action-icon:hover { background: #fff; }
.action-buttons-deck .btn-action-icon { width: 46px; height: 46px; }
.action-buttons-deck svg { width: 16px; height: 16px; }

.toast-notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 200;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid #CBB9A4;
  border-radius: 8px;
  background: #FAF5EC;
  color: var(--ink-deep);
  padding: 12px 20px;
  font-size: 12px;
  text-align: center;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 5px 24px #653A1722;
}
.toast-notification.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .invitation-container { padding: 12px 9px 24px; }
  .btn-primary-action { width: 100%; }
  .btn-secondary-action { flex: 1; padding: 12px 8px; font-size: 10px; }
  .event-more { margin-left: 5px; margin-right: 5px; }
  .envelope-overlay { padding: 25px 16px; }
  .envelope { border-radius: 12px; }
  .envelope-eyebrow { font-size: 9px; letter-spacing: 2px; }
  .cover-guest { font-size: 24px; }
  .cover-event { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: white; }
  .editor-toolbar, .guest-editor, .action-buttons-deck, .envelope-overlay, .toast-notification, .event-more { display: none !important; }
  .invitation-container { width: 100%; max-width: none; padding: 0; }
  .invitation-card { box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
