/* ==========================================================================
   IWorld — Core design system
   Tokens, layout primitives, buttons, cards, header, footer, forms.
   Page-specific styles live in templates.css / editor.css / invitation.css
   ========================================================================== */

:root {
  /* Brand palette */
  --iw-plum: #6d2c4f;
  --iw-plum-dark: #4e1c39;
  --iw-plum-soft: #f6eef2;
  --iw-gold: #c9a227;
  --iw-gold-soft: #f7f0dc;

  /* Neutrals */
  --iw-ink: #1d1a1c;
  --iw-ink-2: #4a4348;
  --iw-ink-3: #7b7379;
  --iw-line: #e6e0e3;
  --iw-line-2: #f1ecee;
  --iw-cream: #fbf8f5;
  --iw-white: #ffffff;

  /* Status */
  --iw-green: #17795e;
  --iw-green-soft: #e6f4ef;
  --iw-red: #b3261e;

  /* Typography */
  --iw-font-head: 'Playfair Display', Georgia, serif;
  --iw-font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;

  /* Radius + shadow */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(29, 26, 28, .06), 0 1px 3px rgba(29, 26, 28, .08);
  --sh-2: 0 4px 12px rgba(29, 26, 28, .08);
  --sh-3: 0 12px 32px rgba(29, 26, 28, .14);
  --sh-4: 0 24px 60px rgba(29, 26, 28, .22);

  --iw-header-h: 68px;
}

/* --------------------------------------------------------------- reset ---- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--iw-font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--iw-ink);
  background: var(--iw-white);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--iw-font-head);
  line-height: 1.18;
  margin: 0 0 var(--sp-3);
  font-weight: 600;
  letter-spacing: -.01em;
}

h1 { font-size: clamp(2rem, 4.4vw, 3.3rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 var(--sp-4); }

a { color: var(--iw-plum); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--iw-plum);
  outline-offset: 2px;
}

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

/* -------------------------------------------------------------- layout ---- */
.iw-container {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

.iw-section { padding-block: var(--sp-8); }

.iw-section-head {
  max-width: 660px;
  margin: 0 auto var(--sp-7);
  text-align: center;
}

.iw-section-head p {
  color: var(--iw-ink-2);
  margin: 0;
}

.iw-eyebrow {
  font-size: .75rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--iw-plum);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

/* ------------------------------------------------------------- buttons ---- */
.iw-btn {
  --btn-bg: var(--iw-plum);
  --btn-fg: #fff;
  --btn-bd: var(--iw-plum);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 11px 20px;
  border-radius: var(--r-pill);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: .925rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.iw-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
}

.iw-btn:active { transform: translateY(0); }

.iw-btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--iw-ink);
  --btn-bd: var(--iw-line);
}

.iw-btn--ghost:hover { --btn-bd: var(--iw-ink-3); }

.iw-btn--gold {
  --btn-bg: var(--iw-gold);
  --btn-bd: var(--iw-gold);
  --btn-fg: #2b2306;
}

.iw-btn--light {
  --btn-bg: #fff;
  --btn-fg: var(--iw-plum);
  --btn-bd: #fff;
}

.iw-btn--sm { padding: 8px 14px; font-size: .85rem; }
.iw-btn--lg { padding: 14px 26px; font-size: 1rem; }
.iw-btn--block { width: 100%; }

.iw-btn--icon {
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.iw-btn[disabled], .iw-btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --------------------------------------------------------------- badge ---- */
.iw-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--iw-line-2);
  color: var(--iw-ink-2);
}

.iw-badge--free { background: var(--iw-green-soft); color: var(--iw-green); }
.iw-badge--premium { background: var(--iw-gold-soft); color: #7a5c05; }
.iw-badge--plum { background: var(--iw-plum-soft); color: var(--iw-plum); }

/* ---------------------------------------------------------------- card ---- */
.iw-card {
  background: #fff;
  border: 1px solid var(--iw-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

/* --------------------------------------------------------------- forms ---- */
.iw-field { margin-bottom: var(--sp-4); }

.iw-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--iw-ink-3);
  margin-bottom: 6px;
}

.iw-input,
.iw-select,
.iw-textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: .925rem;
  color: var(--iw-ink);
  background: #fff;
  border: 1px solid var(--iw-line);
  border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.iw-textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

.iw-input:focus,
.iw-select:focus,
.iw-textarea:focus {
  outline: none;
  border-color: var(--iw-plum);
  box-shadow: 0 0 0 3px rgba(109, 44, 79, .12);
}

.iw-help { font-size: .8rem; color: var(--iw-ink-3); margin: 6px 0 0; }

/* -------------------------------------------------------------- header ---- */
.iw-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--iw-header-h);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--iw-line);
}

.iw-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  width: 100%;
}

.iw-logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--iw-font-head);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--iw-ink);
  letter-spacing: -.02em;
}

.iw-logo:hover { text-decoration: none; }

.iw-logo__mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--iw-plum), var(--iw-plum-dark));
  color: #fff;
  font-size: .85rem;
}

.iw-logo em {
  font-style: normal;
  color: var(--iw-plum);
}

.iw-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: auto;
}

.iw-nav__link {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: .925rem;
  font-weight: 500;
  color: var(--iw-ink-2);
}

.iw-nav__link:hover {
  background: var(--iw-line-2);
  color: var(--iw-ink);
  text-decoration: none;
}

.iw-nav__link.is-active {
  color: var(--iw-plum);
  font-weight: 600;
  background: var(--iw-plum-soft);
}

.iw-nav__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: var(--sp-3);
  padding-inline-start: var(--sp-3);
  border-inline-start: 1px solid var(--iw-line);
}

.iw-user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: .875rem;
  font-weight: 600;
  color: var(--iw-ink-2);
}

.iw-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--iw-plum-soft);
  color: var(--iw-plum);
  font-size: .78rem;
  font-weight: 700;
}

.iw-burger {
  display: none;
  margin-inline-start: auto;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--iw-line);
  background: #fff;
  color: var(--iw-ink);
  cursor: pointer;
}

/* -------------------------------------------------------------- footer ---- */
.iw-footer {
  margin-top: var(--sp-9);
  background: var(--iw-cream);
  border-top: 1px solid var(--iw-line);
  padding-block: var(--sp-7) var(--sp-5);
  font-size: .9rem;
}

.iw-footer__grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: var(--sp-6);
}

.iw-footer h4 {
  font-family: var(--iw-font-body);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--iw-ink-3);
  margin-bottom: var(--sp-3);
}

.iw-footer ul { list-style: none; margin: 0; padding: 0; }
.iw-footer li { margin-bottom: var(--sp-2); }
.iw-footer li a { color: var(--iw-ink-2); }
.iw-footer li a:hover { color: var(--iw-plum); }

.iw-footer__note {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--iw-line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
  color: var(--iw-ink-3);
  font-size: .82rem;
}

.iw-footer__tagline { color: var(--iw-ink-2); max-width: 34ch; }

/* ---------------------------------------------------------------- hero ---- */
.iw-hero {
  background:
    radial-gradient(900px 420px at 88% -8%, var(--iw-plum-soft), transparent 70%),
    radial-gradient(700px 380px at 4% 8%, var(--iw-gold-soft), transparent 68%),
    var(--iw-white);
  padding-block: var(--sp-8) var(--sp-7);
  border-bottom: 1px solid var(--iw-line);
}

.iw-hero__grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: var(--sp-7);
  align-items: center;
}

.iw-hero__lede {
  font-size: 1.1rem;
  color: var(--iw-ink-2);
  max-width: 52ch;
}

.iw-hero__cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }

.iw-hero__stats {
  display: flex;
  gap: var(--sp-6);
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--iw-line);
}

.iw-hero__stat strong {
  display: block;
  font-family: var(--iw-font-head);
  font-size: 1.7rem;
  color: var(--iw-plum);
}

.iw-hero__stat span { font-size: .82rem; color: var(--iw-ink-3); }

/* Hero collage of live invitation previews */
.iw-hero__collage {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  align-items: center;
}

.iw-hero__collage > * { box-shadow: var(--sh-3); border-radius: var(--r-md); overflow: hidden; }
.iw-hero__collage > *:nth-child(1) { transform: rotate(-4deg); }
.iw-hero__collage > *:nth-child(2) { transform: translateY(-18px) scale(1.06); z-index: 2; }
.iw-hero__collage > *:nth-child(3) { transform: rotate(4deg); }

/* ------------------------------------------------------------ features ---- */
.iw-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-5);
}

.iw-feature { padding: var(--sp-5); }

.iw-feature__icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--iw-plum-soft);
  color: var(--iw-plum);
  font-size: 1.05rem;
  margin-bottom: var(--sp-4);
}

.iw-feature h3 { margin-bottom: var(--sp-2); }
.iw-feature p { color: var(--iw-ink-2); margin: 0; font-size: .95rem; }

.iw-step { text-align: center; padding: var(--sp-4); }

.iw-step__num {
  width: 42px; height: 42px;
  margin: 0 auto var(--sp-4);
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--iw-ink);
  color: #fff;
  font-family: var(--iw-font-head);
  font-size: 1.1rem;
}

/* ------------------------------------------------------------ cta band ---- */
.iw-cta-band {
  margin-top: var(--sp-8);
  background: linear-gradient(135deg, var(--iw-plum-dark), var(--iw-plum));
  color: #fff;
  border-radius: var(--r-xl);
  padding: var(--sp-7);
  text-align: center;
}

.iw-cta-band h2 { color: #fff; }
.iw-cta-band p { color: rgba(255, 255, 255, .82); max-width: 54ch; margin-inline: auto; }

/* ------------------------------------------------------------ page head ---- */
.iw-page-head {
  background: linear-gradient(180deg, var(--iw-cream), #fff);
  border-bottom: 1px solid var(--iw-line);
  padding-block: var(--sp-7) var(--sp-6);
}

/* ------------------------------------------------------------ dashboard ---- */
.iw-dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--sp-5);
}

.iw-dash-card { display: flex; flex-direction: column; }
.iw-dash-card__preview { background: var(--iw-cream); padding: var(--sp-4); }
.iw-dash-card__body { padding: var(--sp-4); border-top: 1px solid var(--iw-line); }
.iw-dash-card__body h3 { font-size: 1rem; margin-bottom: 2px; }
.iw-dash-card__meta { font-size: .78rem; color: var(--iw-ink-3); }
.iw-dash-card__actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

.iw-empty {
  text-align: center;
  padding: var(--sp-8) var(--sp-5);
  border: 1px dashed var(--iw-line);
  border-radius: var(--r-lg);
  background: var(--iw-cream);
}

.iw-empty i { font-size: 2rem; color: var(--iw-ink-3); margin-bottom: var(--sp-3); }

/* ---------------------------------------------------------------- auth ---- */
.iw-auth {
  min-height: calc(100vh - var(--iw-header-h));
  display: grid;
  place-items: center;
  padding: var(--sp-7) var(--sp-5);
  background:
    radial-gradient(700px 340px at 80% 0%, var(--iw-plum-soft), transparent 70%),
    var(--iw-white);
}

.iw-auth__card {
  width: 100%;
  max-width: 420px;
  padding: var(--sp-6);
  background: #fff;
  border: 1px solid var(--iw-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}

.iw-notice {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--iw-gold-soft);
  border: 1px solid #ecdfae;
  color: #6b5203;
  font-size: .85rem;
  line-height: 1.5;
}

.iw-notice i { margin-top: 3px; }

/* --------------------------------------------------------------- toast ---- */
.iw-toasts {
  position: fixed;
  z-index: 900;
  bottom: var(--sp-5);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.iw-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px 16px;
  border-radius: var(--r-pill);
  background: var(--iw-ink);
  color: #fff;
  font-size: .9rem;
  box-shadow: var(--sh-3);
  animation: iw-toast-in .22s ease;
}

.iw-toast--ok { background: #14574a; }
.iw-toast--warn { background: #7a5c05; }

.iw-toast button {
  border: 0;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  cursor: pointer;
}

@keyframes iw-toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------- modal shell ---- */
.iw-modal {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: rgba(20, 16, 18, .62);
  backdrop-filter: blur(3px);
}

.iw-modal.is-open { display: flex; animation: iw-fade .18s ease; }

@keyframes iw-fade { from { opacity: 0; } to { opacity: 1; } }

body.iw-no-scroll { overflow: hidden; }

/* --------------------------------------------------------- responsive ---- */
@media (max-width: 940px) {
  .iw-hero__grid { grid-template-columns: 1fr; }
  .iw-hero__collage { max-width: 520px; }
  .iw-footer__grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .iw-container { padding-inline: var(--sp-4); }
  .iw-burger { display: grid; place-items: center; }

  .iw-nav {
    position: fixed;
    inset: var(--iw-header-h) 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
    margin: 0;
    padding: var(--sp-4);
    background: #fff;
    border-bottom: 1px solid var(--iw-line);
    box-shadow: var(--sh-2);
    display: none;
  }

  .iw-nav.is-open { display: flex; }

  .iw-nav__link { padding: 12px; }

  .iw-nav__actions {
    margin: var(--sp-2) 0 0;
    padding: var(--sp-3) 0 0;
    border-inline-start: 0;
    border-top: 1px solid var(--iw-line);
    flex-wrap: wrap;
  }

  .iw-hero__stats { gap: var(--sp-5); flex-wrap: wrap; }
  .iw-section { padding-block: var(--sp-7); }
  .iw-cta-band { padding: var(--sp-6) var(--sp-4); }
}

@media (max-width: 520px) {
  .iw-footer__grid { grid-template-columns: 1fr; gap: var(--sp-5); }
  .iw-hero__collage { grid-template-columns: 1fr 1fr; }
  .iw-hero__collage > *:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .iw-header, .iw-footer, .iw-toasts { display: none !important; }
}
