:root {
  --cream: #FDFCF7;
  --green: #949D83;
  --green-dark: #6F7861;
  --line: #e3e5da;
  --serif: "EB Garamond", Garamond, Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  color: var(--green-dark);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}

p { margin: 0; }
a { color: inherit; text-decoration-color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green); }

/* Three sizes only: names, body (18px), labels (13px caps) */
h2, .monogram, .lang button {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--green);
}

.muted { color: var(--green); }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  /* Stays put while the page scrolls (e.g. the RSVP form). */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--cream);
}
.lang { display: flex; align-items: center; gap: .3rem; color: var(--green); }
.lang button {
  font-family: inherit;
  background: none;
  border: 0;
  padding: .2rem;
  cursor: pointer;
}
.lang button[aria-pressed="true"] { color: var(--green-dark); }

/* ---------- layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem clamp(1rem, 4vh, 2.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------- hero ---------- */
.illustration {
  display: block;
  width: 100%;
  max-width: 560px;
  max-height: 17vh;
  margin: 0 auto clamp(.5rem, 2vh, 1rem);
  object-fit: contain;
}

.names {
  margin: 0;
  font-weight: 400;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--green);
}

.details { margin-top: .25rem; color: var(--green); }

.cta {
  display: inline-block;
  text-decoration: none;
  margin-top: clamp(.75rem, 2.5vh, 1.25rem);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--green-dark);
  border: 0;
  padding: .75rem 2.4rem;
  cursor: pointer;
  transition: background .15s;
}
.cta:hover { background: var(--green); color: var(--cream); }
.cta:focus-visible { outline: 1px solid var(--green-dark); outline-offset: 3px; }

/* ---------- info grid ---------- */
.info {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(1rem, 3vh, 2rem) 2rem;
  margin-top: clamp(1rem, 3.5vh, 2.25rem);
  padding-top: clamp(1rem, 3.5vh, 2.25rem);
  border-top: 1px solid var(--line);
}

h2 { margin: 0 0 .5rem; }

/* 3 blocks on the first row, a one-line footnote beneath */
.info article { grid-column: span 2; }
.info .footnote {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
}
.footnote p { text-align: center; }

.info article > * + * { margin-top: .15rem; }
.info article > a, .info article > .text-button { display: inline-block; margin-top: .35rem; }

/* ---------- RSVP dialog ---------- */
.text-button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin-top: .35rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--green);
  text-underline-offset: 3px;
}
.text-button:hover { color: var(--green); }

dialog {
  width: min(460px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 2rem 1.75rem 1.75rem;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--green-dark);
  text-align: left;
}
dialog::backdrop { background: rgb(111 120 97 / .25); }
dialog h2, dialog > form > .muted { text-align: center; }
dialog > form > .muted { margin-bottom: 1.25rem; }

.close {
  position: absolute;
  top: .5rem;
  right: .75rem;
  font: inherit;
  font-size: 26px;
  line-height: 1;
  color: var(--green);
  background: none;
  border: 0;
  cursor: pointer;
}

form label, fieldset { display: block; margin: 0 0 1rem; }
fieldset { border: 0; padding: 0; }
legend { padding: 0; margin-bottom: .25rem; }
label > span:first-child { display: block; margin-bottom: .25rem; }
.choice { display: inline-flex; align-items: center; gap: .4rem; margin: 0 1.2rem 0 0; }
.choice.block { display: flex; margin: 0 0 .3rem; }
.choice input { accent-color: var(--green-dark); margin: 0; }

input:not([type=radio]):not([type=checkbox]), textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: .45rem .6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
}
input:focus-visible, textarea:focus-visible { outline: 1px solid var(--green); border-color: var(--green); }
textarea { resize: vertical; }

.declined .if-attending { display: none; }
.hint { color: var(--green); margin-bottom: .35rem; }
.req { color: var(--green); }
.field-hint { margin: -.75rem 0 1rem; font-size: 15px; }
.lookup { margin: 0 0 1.5rem; border: 1px solid var(--line); padding: .7rem 1rem; text-align: left; }
.lookup summary { cursor: pointer; color: var(--green); }
.lookup[open] summary { margin-bottom: .9rem; }
.lookup .submit { margin: 0; }
.req-note { text-align: right; margin-bottom: .75rem; }

.fun { margin: 0 0 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.fun summary { cursor: pointer; color: var(--green); margin-bottom: .9rem; }
.fun[open] summary { margin-bottom: 1rem; }
.hp { position: absolute; left: -9999px; }

.status { min-height: 1.5em; text-align: center; color: var(--green); margin-bottom: .5rem; }
.submit {
  display: block;
  margin: 0 auto;
  font: inherit;
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--green-dark);
  border: 0;
  padding: .7rem 2.2rem;
  cursor: pointer;
}
.submit:hover { background: var(--green); }
.submit:disabled { opacity: .6; cursor: default; }

.close:focus-visible { outline: 1px solid var(--green); outline-offset: 2px; }

/* ---------- OSA page ---------- */
a.monogram { text-decoration: none; }

main.narrow {
  max-width: 520px;
  justify-content: flex-start;
  padding-top: 1rem;
}
.narrow form, .narrow .notice { text-align: left; }
.back { align-self: flex-start; text-decoration: none; color: var(--green); margin-bottom: 1.5rem; }
.back:hover { color: var(--green-dark); }

.page-title {
  margin: 0;
  font-weight: 400;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.15;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--green);
}
.intro { margin: .4rem 0 2rem; }

.notice {
  border: 1px solid var(--line);
  padding: .8rem 1rem;
  margin-bottom: 1.5rem;
  color: var(--green-dark);
}
.draft-note { text-align: center; font-size: inherit; margin-bottom: .25rem; }

.thanks { padding: 2rem 0; }
.thanks > * + * { margin-top: 1rem; }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  .topbar { padding: .6rem 1rem; }
  main { padding: 0 1rem 1rem; }
  main.narrow { padding: 1rem 1.25rem 2.5rem; }
  .illustration { max-height: 14vh; }
  .names { font-size: 26px; letter-spacing: .1em; }
  .details { font-size: 15px; }
  .cta { padding: .65rem 2rem; }

  /* Compact two-column grid so the whole page fits on one phone screen:
     Vigsel | Fest / Boende (full width) / Önskelista | Frågor */
  .info {
    grid-template-columns: 1fr 1fr;
    gap: 1rem .75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    font-size: 14px;
    line-height: 1.35;
  }
  .info article { grid-column: auto; }
  .info article:nth-child(3) { grid-column: 1 / -1; }
  h2 { font-size: 11px; margin-bottom: .25rem; }
  .info article > a { margin-top: .2rem; }
}

a[href^="tel:"] { white-space: nowrap; }

/* ---------- First-visit intro ----------
   index.html adds .intro to <html> when the "intro" cookie is missing;
   script.js sets the cookie (6 hours) and removes the class when it's done (or on tap).
   Only opacity and transform are animated so it stays smooth on phones. */
.intro-veil { display: none; }

.intro body { overflow: hidden; }

.intro .intro-veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--cream);
  color: var(--green);
  cursor: pointer;
  will-change: opacity;
  animation: veil-out 1.2s ease-in-out 2.9s both;
}
.intro-mark {
  font-size: clamp(40px, 9vw, 72px);
  letter-spacing: .2em;
  margin-right: -.2em; /* balance the trailing letter-spacing */
  will-change: opacity, transform;
  animation: mark-in 1.8s cubic-bezier(.2, .7, .2, 1) .2s both;
}
.intro-mark i {
  font-style: normal;
  display: inline-block;
  will-change: opacity, transform;
  animation: amp-in 1.8s cubic-bezier(.3, 1.3, .5, 1) .6s both;
}
.intro-line {
  width: min(220px, 50vw);
  height: 1px;
  background: var(--green);
  transform-origin: center;
  will-change: transform;
  animation: line-in 1.3s cubic-bezier(.4, 0, .2, 1) 1.1s both;
}
.intro-date {
  font-size: clamp(20px, 3.2vw, 26px);
  letter-spacing: .22em;
  margin-right: -.22em;
  text-transform: uppercase;
  color: var(--green-dark);
  animation: fade-up 1.1s ease-out 1.7s both;
}

/* The page builds itself up behind the veil as it lifts. */
.intro .illustration,
.intro .topbar,
.intro .names,
.intro .details,
.intro .cta,
.intro .info { will-change: opacity, transform; }

.intro .illustration { animation: drawing-in 2s cubic-bezier(.2, .7, .2, 1) 3.2s both; }
.intro .topbar       { animation: fade-in 1.4s ease-out 3.6s both; }
.intro .names        { animation: fade-up 1.6s cubic-bezier(.2, .7, .2, 1) 3.6s both; }
.intro .details      { animation: fade-up 1.2s ease-out 4.1s both; }
.intro .cta          { animation: fade-up 1.2s ease-out 4.4s both; }
.intro .info         { animation: fade-up 1.3s ease-out 4.7s both; }

@keyframes veil-out {
  to { opacity: 0; visibility: hidden; }
}
@keyframes mark-in {
  from { opacity: 0; transform: scale(.94); }
}
@keyframes amp-in {
  from { opacity: 0; transform: rotate(-90deg) scale(.4); }
}
@keyframes line-in {
  from { transform: scaleX(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
}
@keyframes drawing-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
}

/* ---------- Grape run (game.js) ----------
   An overlay opened by tapping the vines in the hero drawing (script.js):
   the drawing zooms in towards the tap, the game fades in over it, and it zooms back out on close. */
.vg-zooming, .vg-zooming body { overflow: hidden; }
.vg-zooming .illustration { position: relative; z-index: 20; animation: vg-zoom-in .9s cubic-bezier(.55, 0, .8, .3) both; }
.vg-returning .illustration { animation: vg-zoom-out .8s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes vg-zoom-in { 60% { opacity: 1; } to { transform: scale(9); opacity: 0; } }
@keyframes vg-zoom-out { from { transform: scale(4); opacity: 0; } }
.vg {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--cream);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
  animation: fade-in .5s ease-out .55s both;
}
.vg-canvas { display: block; width: 100%; height: 100%; outline: none; }

.vg-hud {
  position: absolute;
  top: max(.9rem, env(safe-area-inset-top));
  left: max(1.1rem, env(safe-area-inset-left));
  display: flex;
  gap: 1.5rem;
  text-align: left;
  pointer-events: none;
}
.vg-stat b {
  display: block;
  font-weight: 400;
  font-size: 30px;
  line-height: 1;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
}
.vg-stat span, .vg-best {
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--green);
}

.vg-tools {
  position: absolute;
  top: max(.75rem, env(safe-area-inset-top));
  right: max(.75rem, env(safe-area-inset-right));
  display: flex;
  gap: .4rem;
}
.vg-tools button {
  width: 42px;
  height: 42px;
  padding: 0;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--green-dark);
  background: rgb(253 252 247 / .85);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.vg-tools [data-act="close"] { font-size: 26px; }
.vg-tools [data-act="pause"] { font-size: 13px; letter-spacing: .1em; font-weight: 700; }
.vg-tools [aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.vg-tools button[hidden], .vg-hud[hidden] { display: none; }

.vg-panel {
  position: absolute;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(430px, calc(100% - 2rem));
  padding: 1.5rem 1.5rem 1.25rem;
  background: rgb(253 252 247 / .94);
  border: 1px solid var(--line);
  color: var(--green-dark);
}
.vg-panel[hidden] { display: none; }
.vg-panel h2 {
  margin: 0 0 .5rem;
  font-size: clamp(24px, 6vw, 34px);
  letter-spacing: .16em;
  line-height: 1.15;
  color: var(--green);
}
.vg-panel[data-panel="over"] h2 { font-size: clamp(20px, 5vw, 26px); letter-spacing: .06em; text-transform: none; }
.vg-panel p + * { margin-top: 1rem; }
.vg-result b { font-weight: 400; font-size: 30px; }

.vg-ghost {
  font: inherit;
  color: var(--green-dark);
  background: none;
  border: 1px solid var(--line);
  cursor: pointer;
}

.vg-go {
  display: block;
  margin: 1rem auto 0;
  font: inherit;
  font-size: 14px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--green-dark);
  border: 0;
  padding: .8rem 2.6rem;
  cursor: pointer;
}
.vg-go:hover { background: var(--green); }
.vg-row { display: flex; justify-content: center; align-items: stretch; gap: .6rem; }
.vg-row .vg-go { margin: 0; }
.vg-ghost { font-size: 14px; letter-spacing: .22em; text-transform: uppercase; padding: .8rem 1.4rem; }
.vg-best:empty { display: none; }

/* How to play, shown for a few seconds at the start. */
.vg-toast {
  position: absolute;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: .55rem 1.1rem;
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--green-dark);
  background: rgb(253 252 247 / .9);
  border: 1px solid var(--line);
  pointer-events: none;
  animation: vg-toast 5s ease-in-out 1.2s both;
}
@keyframes vg-toast { 0%, 100% { opacity: 0; } 8%, 85% { opacity: 1; } }

/* Guest leaderboard on the game-over panel */
.vg input { user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.vg-name p { margin-bottom: .5rem; }
.vg-name input:not(.hp) { flex: 1; min-width: 0; font-size: 16px; padding: .5rem .7rem; }
.vg-name .vg-ghost { padding: .5rem 1rem; }
.vg-board { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.vg-board h3 { margin: 0 0 .4rem; font-weight: 400; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--green); }
.vg-board ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: place;
  max-height: min(13.5rem, 30vh);
  overflow-y: auto;
  text-align: left;
}
.vg-board li { counter-increment: place; display: flex; gap: .6rem; padding: .1rem .4rem; font-size: 16px; line-height: 1.4; }
.vg-board li::before { content: counter(place) "."; width: 1.6rem; color: var(--green); font-variant-numeric: tabular-nums; }
.vg-board li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vg-board li b { font-weight: 400; font-variant-numeric: tabular-nums; }
.vg-board li.me { background: #fff; outline: 1px solid var(--line); }
.vg-board ol:empty { display: none; }
.vg-rank { font-size: 14px; color: var(--green); margin-top: .35rem; }
.vg-rank:empty { display: none; }
.vg-board + .vg-row { margin-top: 1rem; }
.vg-panel { max-height: calc(100% - 4.5rem); overflow-y: auto; }
@media (max-height: 700px) {
  .vg-panel { padding: 1rem 1.1rem; max-height: calc(100% - 4rem); }
  .vg-panel p + * { margin-top: .6rem; }
  .vg-name p { display: none; }
  .vg-board { margin-top: .6rem; padding-top: .5rem; }
  .vg-board ol { max-height: 6.4rem; }
  .vg-board li { font-size: 15px; line-height: 1.3; }
  .vg-board + .vg-row { margin-top: .7rem; }
  .vg-go, .vg-ghost { padding-top: .65rem; padding-bottom: .65rem; }
}
