:root {
  --paper: #f6f1e9;
  --ink: #2c2a31;
  --muted: #6e665e;
  --accent: #7b1e2f;
  --line: #cdc2b2;
}

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

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  font-family: "David Libre", "David", "Times New Roman", serif;
  color: var(--ink);
  background-color: var(--paper);
  /* Thick cotton paper: lit relief (multiplied) + fine fibers + darker edges */
  background-image:
    radial-gradient(ellipse at 50% 45%, transparent 60%, rgba(110, 90, 65, 0.1)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9 .55' numOctaves='3' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .35 0 0 0 0 .28 0 0 0 .13 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='p' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.05' numOctaves='5' seed='4' stitchTiles='stitch'/%3E%3CfeDiffuseLighting lighting-color='%23fffdf8' surfaceScale='1.5'%3E%3CfeDistantLight azimuth='225' elevation='72'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
  background-blend-mode: normal, normal, multiply;
}

/* Pole positions/widths are percentages so they line up with the scaled SVG canopy. */
.chuppah {
  position: relative;
  width: 100%;
  max-width: 800px;
  padding-bottom: 1.5rem;
}

.chuppah::before,
.chuppah::after {
  content: "";
  position: absolute;
  top: 1rem;
  bottom: 0;
  width: 1.5%;
  border-radius: 4px;
  background: linear-gradient(90deg, #cfc6b8, #fffdf9 45%, #e4ddd1);
  box-shadow: 0 0 0 0.5px #c9bfae;
}

.chuppah::before {
  left: 3%;
}

.chuppah::after {
  right: 3%;
}

.canopy {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.base-flowers {
  position: absolute;
  bottom: 0;
  z-index: 2;
  width: 14%;
  height: auto;
  overflow: visible;
}

.base-flowers.left {
  left: 0;
}

.base-flowers.right {
  right: 0;
  transform: scaleX(-1);
}

.content {
  margin: -4% 8% 0;
  padding: 0.5rem 1rem 4.5rem;
  text-align: center;
}

.bsd {
  text-align: right;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

h1 {
  font-family: "Bellefair", "David Libre", serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 7.5vw, 3.9rem);
  line-height: 1.1;
}

.subtitle {
  font-size: clamp(1rem, 3vw, 1.2rem);
  color: var(--muted);
  margin-top: 0.6rem;
}

.rule {
  width: 120px;
  height: 1px;
  margin: 2rem auto;
  background: var(--line);
}

.date-hebrew {
  font-family: "Bellefair", "David Libre", serif;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
}

.date-gregorian {
  margin-top: 0.3rem;
  font-size: 1rem;
  color: var(--muted);
}

.countdown {
  margin-top: 2.25rem;
}

.days-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.6rem;
  font-family: "Bellefair", "David Libre", serif;
}

.days-word {
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  color: var(--muted);
}

.days {
  font-size: clamp(5rem, 17vw, 8rem);
  line-height: 0.9;
  color: var(--accent);
  font-variant-numeric: lining-nums tabular-nums;
  transform-origin: 50% 85%;
  animation: sway-big 7s ease-in-out infinite;
}

.time-line {
  margin-top: 1rem;
  font-size: clamp(1rem, 3.2vw, 1.15rem);
  color: var(--muted);
}

.time-line .pair {
  white-space: nowrap;
}

.time-line .num {
  display: inline-block;
  min-width: 1.4em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transform-origin: 50% 80%;
  animation: sway-small 4.5s ease-in-out infinite;
}

/* Offset each number so they don't move in lockstep */
#minutes {
  animation-delay: -1.5s;
}

#seconds {
  animation-delay: -3s;
}

.sep {
  margin: 0 0.5rem;
  color: var(--line);
}

.done {
  margin-top: 2.25rem;
  font-family: "Bellefair", "David Libre", serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  color: var(--accent);
}

.music-toggle {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 10;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 6px 18px rgba(44, 42, 49, 0.15);
  font-size: 1.4rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
}

.music-toggle:hover {
  transform: scale(1.06);
}

.music-toggle.playing {
  opacity: 1;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 8px rgba(123, 30, 47, 0.1), 0 6px 18px rgba(44, 42, 49, 0.15);
  }
}

/* Non-blocking invitation to play music, slides in at the corner */
.music-prompt {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 15;
  width: min(290px, calc(100vw - 2.5rem));
  padding: 1rem 1.1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(44, 42, 49, 0.16);
  animation: slide-in 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.music-prompt-text {
  font-size: 1.1rem;
}

.music-prompt .note {
  color: var(--accent);
}

.music-prompt-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 1rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.btn-primary:hover {
  background: #651726;
}

.btn-secondary {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  color: var(--ink);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
}

/*
 * Motion uses the individual `rotate` / `translate` / `scale` properties so that
 * looping sways, the entrance and the digit "tick" (script.js) can combine
 * without overriding each other's transform.
 */
@keyframes sway-big {
  0%,
  100% {
    rotate: -1.6deg;
    translate: 0 0;
  }
  50% {
    rotate: 1.6deg;
    translate: 0 -5px;
  }
}

@keyframes sway-small {
  0%,
  100% {
    rotate: -3deg;
  }
  50% {
    rotate: 3deg;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 14px;
  }
}

@keyframes rule-grow {
  from {
    scale: 0 1;
  }
}

@keyframes billow {
  0%,
  100% {
    scale: 1 1;
  }
  50% {
    scale: 1 1.035;
  }
}

@keyframes flower-sway {
  0%,
  100% {
    rotate: -2.5deg;
  }
  50% {
    rotate: 2.5deg;
  }
}

.content > * {
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 0.15s + 0.1s);
}

.content > :nth-child(2) { --i: 1; }
.content > :nth-child(3) { --i: 2; }
.content > :nth-child(4) { --i: 3; }
.content > :nth-child(5) { --i: 4; }
.content > :nth-child(6) { --i: 5; }
.content > :nth-child(7) { --i: 6; }
.content > :nth-child(8) { --i: 6; }

.content > .rule {
  animation:
    rise 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both,
    rule-grow 1.2s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: 0.55s, 0.55s;
}

.canopy {
  transform-origin: 50% 25%;
  animation: billow 8s ease-in-out infinite;
}

.base-flowers {
  transform-origin: 50% 90%;
  animation: flower-sway 6s ease-in-out infinite;
}

.base-flowers.right {
  animation-delay: -3s;
}

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

@media (max-width: 480px) {
  .content {
    margin-inline: 7%;
    padding-inline: 0.25rem;
  }
}