/* ---------- Token ---------- */
:root {
  color-scheme: dark;
  --ink: #131110;
  --ink-2: #1b1815;
  --ink-3: #24201c;
  --ivory: #efe6d4;
  --ivory-2: #b8ad99;
  --ivory-3: #8a8170;
  --brass: #c6a76b;
  --brass-deep: #9c8250;
  --line: rgba(239, 230, 212, .08);
  --line-strong: rgba(239, 230, 212, .14);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --r-control: 10px;
  --r-card: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ink);
  color: var(--ivory);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
html.js body:not(.is-open) { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: transparent; color: var(--ivory);
  font: 500 14px/1 var(--sans); text-decoration: none; cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .12s var(--ease);
}
.btn:hover { background: rgba(239, 230, 212, .04); border-color: rgba(239, 230, 212, .22); }
.btn:active { transform: scale(.98); }
.btn-primary { border-color: var(--brass); color: var(--brass); }
.btn-primary:hover { background: rgba(198, 167, 107, .08); border-color: var(--brass); }
.btn-block { width: 100%; }
.btn-quiet { border-color: transparent; color: var(--ivory-2); padding: 0 12px; }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }

/* ---------- Papan nama (ciri khas) ---------- */
.plaque {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  width: 100%; max-width: 360px; padding: 20px 16px;
  border-radius: 6px; color: #1d1912;
  background: linear-gradient(180deg, #c9ab70, #b89a5e);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 12px 28px rgba(0, 0, 0, .45);
}
.plaque-k { font: 500 11px/1.4 var(--sans); opacity: .78; }
.plaque-n { font: 600 22px/1.2 var(--serif); margin: 4px 0; }
.plaque-e { font: 500 11px/1.4 var(--sans); opacity: .78; }
.plaque-sm { max-width: 280px; padding: 16px; margin: 32px auto 0; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
.plaque-sm .plaque-n { font-size: 18px; margin-bottom: 0; }

/* ---------- Sampul pintu ---------- */
.cover { display: none; }
html.js .cover {
  display: block; position: fixed; inset: 0; z-index: 10; overflow: hidden;
}
.door {
  position: absolute; top: 0; bottom: 0; width: 50%;
  background:
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(239, 230, 212, .03) 39px 40px),
    var(--ink-2);
  transition: transform 1.1s var(--ease) .3s;
}
.door::before {
  content: ""; position: absolute; inset: 24px 20px; border: 1px solid rgba(239, 230, 212, .05); border-radius: 4px;
}
.door::after {
  content: ""; position: absolute; top: 50%; width: 3px; height: 64px; margin-top: -32px;
  background: var(--brass-deep); border-radius: 2px;
}
.door-l { left: 0; border-right: 1px solid rgba(198, 167, 107, .55); }
.door-r { right: 0; }
.door-l::after { right: 12px; }
.door-r::after { left: 12px; }

.cover-front {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: max(64px, 12dvh) 24px max(32px, env(safe-area-inset-bottom));
  transition: opacity .35s var(--ease);
}
.guest-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 20px 24px 24px;
}
.guest-to { font-size: 13px; color: var(--ivory-3); }
.guest-name { font: 500 22px/1.25 var(--serif); margin: 4px 0 20px; overflow-wrap: anywhere; }
.guest-card .btn { width: 100%; background: var(--ink-2); }

body.is-open .door-l { transform: translateX(-101%); }
body.is-open .door-r { transform: translateX(101%); }
body.is-open .cover-front { opacity: 0; pointer-events: none; }

/* ---------- Isi ---------- */
.content { --pad: 24px; max-width: 560px; margin: 0 auto; padding: 0 var(--pad) 64px; }
.sec { padding: 56px 0; border-top: 1px solid var(--line); }
.sec-open {
  border-top: 0; padding-top: max(96px, 14dvh); position: relative; isolation: isolate;
  /* melebar sampai tepi layar supaya segel terpotong rapi di tepi, bukan melebarkan halaman */
  margin-inline: calc(-1 * var(--pad)); padding-inline: var(--pad); overflow: clip;
}
.sec-open > * { position: relative; }
h1, h2 { font-family: var(--serif); font-weight: 500; }
h1 { font-size: 56px; line-height: 1; margin-top: 12px; }
h1:focus { outline: none; }
h2 { font-size: 30px; line-height: 1.15; margin-bottom: 24px; }
.kicker { font: 400 12px/1.4 var(--mono); color: var(--brass); }
.host { display: flex; flex-direction: column; margin-top: 20px; }
.host-k { font-size: 13px; color: var(--ivory-3); }
.host-n { font: 500 24px/1.25 var(--serif); color: var(--brass); }
.lead { font-size: 17px; line-height: 1.7; color: var(--ivory-2); margin-top: 24px; }
.body { color: var(--ivory-2); }
.label { font-size: 13px; color: var(--ivory-3); margin: 32px 0 12px; }

/* Hitung mundur */
.countdown {
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 20px 4px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 2px;
}
.cd-cell { display: flex; flex-direction: column; align-items: center; padding: 4px 0; overflow: hidden; }
.cd-num.tick { animation: cd-tick .4s var(--ease); }
@keyframes cd-tick { from { transform: translateY(-40%); opacity: .2; } }
.cal-btn { margin-top: 16px; }
.cd-cell + .cd-cell { border-left: 1px solid var(--line); }
.cd-num { font: 400 36px/1.1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ivory); }
.cd-unit { font-size: 12px; color: var(--ivory-3); margin-top: 4px; }
.cd-status { font: 500 24px/1.3 var(--serif); color: var(--brass); }

/* Waktu dan tempat */
.facts { display: grid; grid-template-columns: 72px 1fr; margin-bottom: 28px; }
.facts dt, .facts dd { padding: 12px 0; border-top: 1px solid var(--line); }
.facts dt:first-of-type, .facts dd:first-of-type { border-top: 0; padding-top: 0; }
.facts dt { font: 400 12px/1.9 var(--mono); color: var(--ivory-3); }
.facts dd { color: var(--ivory); }

/* Kehadiran dan ucapan */
.stats { display: grid; grid-template-columns: 1fr 1fr; margin: 24px 0 32px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 0; }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 20px; }
.stat-n { font: 500 40px/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--brass); }
.stat-l { font-size: 13px; color: var(--ivory-3); }
.form { display: flex; flex-direction: column; gap: 20px; }
.field { border: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > label, .field > legend { font-size: 13px; color: var(--ivory-2); }
.field > legend { margin-bottom: 8px; }
input[type="text"], textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--ink-2); border: 1px solid var(--line-strong); border-radius: var(--r-control);
  font-size: 16px; line-height: 1.5; color: var(--ivory);
  transition: border-color .2s var(--ease);
}
textarea { resize: vertical; min-height: 112px; }
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--brass); }
.field.has-err input, .field.has-err textarea { border-color: #c98a74; }
.err { font-size: 13px; color: #d9a08b; min-height: 0; }
.err:empty { display: none; }

.seg { display: flex; gap: 8px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  font-size: 14px; color: var(--ivory-2);
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.seg input:checked + span { border-color: var(--brass); background: rgba(198, 167, 107, .08); color: var(--ivory); }
.seg input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
.seg-num span { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.status { font-size: 14px; color: var(--ivory-2); min-height: 22px; }

/* Kotak ucapan: tinggi terbatas, isinya di-scroll sendiri */
.wishes-box {
  margin-top: 24px; padding: 12px;
  max-height: min(560px, 68dvh); overflow-y: auto;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px;
  scrollbar-width: thin; scrollbar-color: rgba(198, 167, 107, .35) transparent;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
}
.wishes-box:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.wishes-box::-webkit-scrollbar { width: 6px; }
.wishes-box::-webkit-scrollbar-thumb { background: rgba(198, 167, 107, .35); border-radius: 3px; }
.wishes { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.wish {
  position: relative; padding: 16px 16px 16px 48px;
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 10px;
}
.wish::before {
  content: "\201C"; position: absolute; left: 14px; top: 10px;
  font: 500 48px/1 var(--serif); color: var(--brass); opacity: .55;
}
.wish-new { border-color: rgba(198, 167, 107, .45); }
.wish-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wish-name { font: 500 19px/1.3 var(--serif); color: var(--ivory); overflow-wrap: anywhere; }
.wish-org { display: block; font-size: 13px; color: var(--ivory-3); margin-top: 2px; overflow-wrap: anywhere; }
.wish-date { font: 400 11px/1.6 var(--mono); color: var(--ivory-3); white-space: nowrap; }
.wish-text { margin-top: 8px; color: var(--ivory-2); white-space: pre-line; overflow-wrap: anywhere; }
.wish-new { animation: wish-in .5s var(--ease); }
@keyframes wish-in { from { opacity: 0; transform: translateY(8px); } }
.wishes-empty {
  padding: 28px 20px; text-align: center; color: var(--ivory-3);
  border: 1px dashed var(--line-strong); border-radius: 10px;
}
#wishes-more { margin-top: 8px; }
.wishes-box #wishes-more { margin-bottom: 12px; }

.sec-close { text-align: center; }
.sec-close .lead { margin-top: 0; }

/* ---------- Hiasan ---------- */
/* Garis panel pintu, lanjutan dari sampul */
.sec-open > .panels {
  position: absolute; z-index: -1; inset: 0;
  transform: translateY(calc(var(--sy, 0) * -0.12px));
  background: repeating-linear-gradient(90deg, transparent 0 39px, rgba(239, 230, 212, .035) 39px 40px);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
}
/* Segel timbul notaris */
.sec-open > .seal {
  position: absolute; z-index: -1; top: 40px; right: -88px; width: 240px; height: 240px;
  transform: rotate(calc(var(--sy, 0) * 0.05deg));
  fill: none; stroke: rgba(198, 167, 107, .14); stroke-width: 1;
}
.seal text { fill: rgba(198, 167, 107, .2); stroke: none; font: 500 11px var(--serif); }
.seal .seal-mono { font: 500 40px var(--serif); fill: rgba(198, 167, 107, .16); }
/* Stempel tanggal */
.sec-open > .stamp {
  position: absolute; top: calc(max(96px, 14dvh) + 36px); right: var(--pad);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 14px; color: var(--brass);
  border: 1.5px solid currentColor; border-radius: 6px;
  outline: 1px solid rgba(198, 167, 107, .45); outline-offset: 3px;
  transform: rotate(-7deg); opacity: .9;
}
.stamp-d { font: 600 20px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stamp-t { font: 400 11px/1.3 var(--mono); }
/* Kepala bagian bernomor */
.sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sec-no { font: 400 12px/1 var(--mono); color: var(--brass); font-variant-numeric: tabular-nums; }
.sec-rule { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(198, 167, 107, .6), rgba(198, 167, 107, 0)); transform-origin: left; }
html.js .sec-rule { transform: scaleX(var(--p, 0)); }
/* Sudut bingkai kuningan */
.framed { position: relative; }
.framed::after {
  --c: rgba(198, 167, 107, .7);
  content: ""; position: absolute; inset: -5px; pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) top left / 14px 1px,
    linear-gradient(var(--c), var(--c)) top left / 1px 14px,
    linear-gradient(var(--c), var(--c)) top right / 14px 1px,
    linear-gradient(var(--c), var(--c)) top right / 1px 14px,
    linear-gradient(var(--c), var(--c)) bottom left / 14px 1px,
    linear-gradient(var(--c), var(--c)) bottom left / 1px 14px,
    linear-gradient(var(--c), var(--c)) bottom right / 14px 1px,
    linear-gradient(var(--c), var(--c)) bottom right / 1px 14px;
  background-repeat: no-repeat;
}
/* Peta */
.map { aspect-ratio: 4 / 3; margin-bottom: 20px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 2px; }
.map iframe {
  display: block; width: 100%; height: 100%; border: 0;
  filter: invert(.9) hue-rotate(180deg) saturate(.55) sepia(.15) brightness(.92) contrast(.92);
}
/* Sekrup papan nama */
.screws { position: relative; }
.screws::before {
  content: ""; position: absolute; inset: 8px; pointer-events: none;
  background:
    radial-gradient(circle, #6f5a33 0 1.5px, rgba(255, 255, 255, .25) 2px 2.5px, transparent 3px) top left / 6px 6px,
    radial-gradient(circle, #6f5a33 0 1.5px, rgba(255, 255, 255, .25) 2px 2.5px, transparent 3px) top right / 6px 6px,
    radial-gradient(circle, #6f5a33 0 1.5px, rgba(255, 255, 255, .25) 2px 2.5px, transparent 3px) bottom left / 6px 6px,
    radial-gradient(circle, #6f5a33 0 1.5px, rgba(255, 255, 255, .25) 2px 2.5px, transparent 3px) bottom right / 6px 6px;
  background-repeat: no-repeat;
}

/* ---------- Animasi masuk ---------- */
/* Anak tiap bagian naik bergantian; urutannya (--i) diisi main.js. */
html.js [data-reveal] > * {
  opacity: 0; translate: 0 14px;
  transition: opacity .8s var(--ease), translate .8s var(--ease);
  transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 80ms);
}
html.js [data-reveal].is-in > * { opacity: 1; translate: none; }
html.js [data-reveal] > .btn {
  transition-property: opacity, translate, background-color, border-color, color, transform;
  transition-duration: .8s, .8s, .2s, .2s, .2s, .12s;
  transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 80ms), calc(var(--d, 0ms) + var(--i, 0) * 80ms), 0s, 0s, 0s, 0s;
}
html.js .sec-open > h1 { translate: 0 28px; transition-duration: 1s; }
html.js .sec-open.is-in > .panels, html.js .sec-open.is-in > .seal { opacity: 1; }
html.js .sec-open > .panels, html.js .sec-open > .seal { translate: none; transition-duration: 1.6s; }
/* Stempel dicap */
html.js .sec-open > .stamp { opacity: 0; scale: 1.25; translate: none; transition: opacity .35s var(--ease), scale .35s cubic-bezier(.3, 0, .2, 1); transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 80ms + 300ms); }
html.js .sec-open.is-in > .stamp { opacity: .9; scale: 1; }
/* Sudut bingkai merapat */
html.js .framed::after { opacity: 0; scale: 1.04; transition: opacity .8s var(--ease) .3s, scale .8s var(--ease) .3s; }
html.js .is-in .framed::after { opacity: 1; scale: 1; }
/* Ucapan di halaman pertama muncul bergantian */
.wish-stagger { animation: wish-in .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* ---------- Layar kecil ---------- */
@media (max-width: 360px) {
  h1 { font-size: 46px; }
  .cd-num { font-size: 28px; }
}

/* ---------- Tablet ---------- */
@media (min-width: 768px) {
  .content { --pad: 32px; padding: 0 var(--pad) 96px; }
  .sec { padding: 72px 0; }
  h1 { font-size: 72px; }
  .sec-open > .seal { right: -120px; width: 320px; height: 320px; }
  .sec-open > .stamp { top: calc(max(96px, 14dvh) + 44px); }
  .map { aspect-ratio: 16 / 10; }
  .plaque { max-width: 420px; padding: 24px; }
  .plaque-n { font-size: 26px; }
}

/* Setelan "kurangi gerakan" di HP: animasi masuk tetap jalan (pendek dan tidak berulang),
   hanya gerak yang mengikuti scroll yang dimatikan. */
@media (prefers-reduced-motion: reduce) {
  .sec-open > .panels, .sec-open > .seal { transform: none; }
  html.js .sec-rule { transform: none; }
}
