/* Tanja & Sibin: royal blue sky (his), green earth (hers). */

:root {
  /* our own colours are final: a phone's forced dark mode would recolour the buttons */
  color-scheme: only light;

  --royal: #2446c8;
  --night: #0a1036;
  --green: #3a6b4a;
  --sage: #8fb098;
  --mist: #bcd3c1;
  --forest: #1c3527;
  --forest-deep: #12241a;
  --paper: #f4f1ea;
  --gold: #f3c24f;
  --ink: #1b1f3b;
  --shadow: rgba(10, 16, 54, 0.5);

  --pixel: "Pixelify Sans", ui-monospace, monospace;
  /* EB Garamond: same family feel as her site, with carons that sit right on č ž š */
  --serif: "EB Garamond", Georgia, serif;

  /* major third, from a 19px base */
  --step--1: 0.96rem;
  --step-0: 1.2rem;
  --step-1: 1.5rem;
  --step-2: 1.875rem;
  --step-3: 2.34rem;
  --step-4: 2.93rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--forest-deep);
  /* grows a little on big screens so the words keep up with the scene */
  font-size: clamp(100%, 0.55vw + 0.6rem, 125%);
  scroll-behavior: smooth;
  /* one scroll, one scene */
  scroll-snap-type: y mandatory;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--forest-deep);
  color: var(--paper);
  font: 400 var(--step-0) / 1.55 var(--serif);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ol {
  margin: 0;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.6rem 0.9rem;
  background: var(--paper);
  color: var(--ink);
  font: 500 1rem var(--pixel);
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

/* ---------- the scrolling day ---------- */

.story {
  position: relative;
  background: var(--royal);
  text-shadow: 0 1px 2px var(--shadow);
}

.stage {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

/* pull the words up over the stage; the stage itself keeps its height,
   so it lets go exactly where the story ends */
.stage + .panel {
  margin-top: -100vh;
  margin-top: -100svh;
}

/* site.js sizes the canvas to a whole-number multiple of the pixel grid */
.stage > canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: pan-y;
  cursor: pointer;
}

/* the scene buttons sit on the ground strip, under everyone's feet */
.scenes {
  position: absolute;
  right: 0;
  bottom: max(0.6rem, env(safe-area-inset-bottom));
  left: 0;
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.scenes[hidden] {
  display: none;
}

/* the teleport: a beam opens on the couple, fills the screen and closes on them at the next scene */
.flash {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: linear-gradient(90deg, #8fb1ff 0 5%, #fff 5% 95%, #8fb1ff 95%);
  pointer-events: none;
  transform: scaleX(0);
  transform-origin: 50% 50%;
}

.flash.on {
  animation: beam 460ms steps(4, end);
}

/* film.js swaps the scene at 180ms, inside the white stretch */
@keyframes beam {
  0% { transform: scaleX(0); }
  35%, 60% { transform: scaleX(1); }
  100% { transform: scaleX(0); }
}

.panel {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 12vh 6vw 0;
  padding-top: 12svh;
  text-align: center;
  pointer-events: none;
  /* a hard swipe stops at the next scene instead of skipping ahead */
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.panel a,
.panel button {
  pointer-events: auto;
}

.inner {
  max-width: 29rem;
}

.panel--hero {
  padding-top: 10svh;
}

/* the world moves behind the words, so they carry their own backing */
.panel:not(.panel--hero) .inner {
  align-self: flex-start;
  padding: 0.9rem 1.2rem 1.1rem;
  background: rgba(10, 16, 54, 0.66);
}

/* a scene card waits for its scene: film.js marks the others, and they step in when the film gets there */
.panel .inner {
  transition: opacity 240ms steps(3, end);
}

.panel.waiting .inner {
  opacity: 0;
}

/* short screens, such as a phone on its side */
@media (max-height: 500px) {
  .panel {
    padding-top: 5vh;
  }

  .panel .inner {
    font-size: var(--step--1);
    line-height: 1.35;
  }

  .lead {
    font-size: var(--step-1);
  }

  .names {
    font-size: 3rem;
  }

  .date {
    margin-top: 0.6rem;
    font-size: var(--step-1);
  }
}

.names {
  font: 700 clamp(3rem, min(17vw, 15svh), 8.5rem) / 0.92 var(--pixel);
  letter-spacing: 0.01em;
  text-shadow: 0.06em 0.06em 0 var(--shadow);
}

.names span {
  display: block;
}

.date {
  margin-top: 1.25rem;
  font-size: var(--step-2);
  font-style: italic;
  line-height: 1.2;
}

/* a little pixel arrow, drawn with box shadows */
.arrow {
  display: block;
  width: 3px;
  height: 3px;
  color: var(--paper);
  box-shadow:
    0 0, 0 3px, 0 6px, 0 9px,
    -3px 6px, 3px 6px, -6px 3px, 6px 3px;
  animation: bob 1.2s steps(2, end) infinite;
}

@keyframes bob {
  50% { transform: translateY(4px); }
}

.lead {
  margin-bottom: 0.6rem;
  font-size: var(--step-2);
  font-style: italic;
}

.countdown {
  margin-top: 0.8rem;
  font: 500 var(--step-1) / 1.2 var(--pixel);
}

/* in the serif on purpose: the pixel font's 5 reads as an 8, and a guest must not misread the time */
.time {
  font: 600 var(--step-2) / 1 var(--serif);
}

.what {
  margin-top: 0.5rem;
  font-size: var(--step-4);
  font-weight: 600;
  line-height: 1.05;
}

.where {
  margin-top: 0.5rem;
  font-size: var(--step-1);
  font-style: italic;
  line-height: 1.25;
}

.addr {
  margin-top: 0.15rem;
}

.note {
  margin-top: 0.9rem;
}

.big {
  margin-bottom: 0.6rem;
  font: 700 clamp(3rem, 13vw, 6rem) / 1 var(--pixel);
  text-shadow: 0.06em 0.06em 0 var(--shadow);
}

/* wide screens: words on the left, the scene on the right */
@media (min-width: 640px) and (min-aspect-ratio: 23/20) {
  .panel {
    justify-content: flex-start;
    padding: 14vh 0 0 max(5vw, calc((100vw - 76rem) / 2));
    text-align: left;
  }

  .panel--hero {
    padding-top: 12vh;
  }

  .inner {
    max-width: min(33rem, 36vw);
    font-size: var(--step-1);
  }

  .time {
    font-size: var(--step-3);
  }

  .what {
    font-size: 3.66rem;
  }

  .where {
    font-size: var(--step-2);
  }

  /* the camera keeps the couple right of centre here, so the beam opens on them */
  .flash {
    transform-origin: 68% 50%;
  }
}

/* a phone held upright sees a sliver of the world, so it's asked to turn */
.turn {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--night);
  text-align: center;
  touch-action: none; /* the page behind doesn't scroll while the question is up */
}

/* the controls wait until the question is answered, by turning the phone or by Nastavi ovako */
@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) {
  .js:not(.turn-skipped) .turn {
    display: flex;
  }

  .js:not(.turn-skipped) .scenes,
  .js:not(.turn-skipped) .btn--start {
    visibility: hidden;
  }
}

.turn .icon {
  width: 44px;
  height: 72px;
  margin-bottom: 1.8rem;
  animation: turn-phone 2.6s steps(4, end) infinite;
}

@keyframes turn-phone {
  0%, 25% { transform: rotate(0); }
  60%, 100% { transform: rotate(90deg); }
}

/* sized by the screen, so a larger system text size can't push it onto two lines */
.turn-title {
  font: 600 min(var(--step-3), 9vw) / 1.1 var(--pixel);
  white-space: nowrap;
}

.turn-note {
  max-width: 17rem;
  margin: 0.7rem 0 1.8rem;
  text-wrap: balance;
}

/* a phone on its side: the card has to fit, and leave the people showing */
@media (max-height: 500px) {
  .inner {
    max-width: min(27rem, 46vw);
  }

  .scenes {
    bottom: 0.2rem;
  }

  /* no backing would leave the date lost over the bright window */
  .panel--hero .inner {
    align-self: flex-start;
    max-width: none;
    padding: 0.6rem 1rem 0.7rem;
    background: rgba(10, 16, 54, 0.66);
  }

  .names {
    font-size: 2.3rem;
  }

  .date {
    margin-top: 0.3rem;
    font-size: var(--step-0);
    white-space: nowrap;
  }

  /* the time and the title share a line, so the card stays above the people */
  .time,
  .what {
    display: inline;
    margin: 0;
    font-size: var(--step-1);
  }

  .time {
    margin-right: 0.35rem;
  }

  .where {
    margin-top: 0.1rem;
    font-size: var(--step-0);
  }

  .note {
    margin-top: 0.3rem;
  }
}

/* the smallest phones: start higher, so the card clears the crowns */
@media (max-width: 639px) and (max-height: 600px) {
  .panel {
    padding-top: 5svh;
  }
}

/* ---------- below the grass: the practical bits ---------- */

.info {
  position: relative;
  padding: 5rem 6vw 4.5rem;
  background: var(--forest);
  /* taller than a screen, so it scrolls freely once you arrive */
  scroll-snap-align: start;
}

/* dithered seam where the ground ends */
.info::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 0;
  left: 0;
  height: 8px;
  background: repeating-conic-gradient(var(--forest) 0 25%, transparent 0 50%) 0 0 / 8px 8px;
}

.info-inner {
  max-width: 62rem;
  margin: 0 auto;
}

.info h2 {
  margin-bottom: 2.2rem;
  font: 600 var(--step-3) / 1.1 var(--pixel);
}

.venues {
  display: grid;
  gap: 3rem;
  margin-bottom: 5.5rem;
}

.icon {
  display: block;
  image-rendering: pixelated;
}

/* a long name wraps, so the buttons sit at the bottom of each column and line up */
.venue {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.venue .btn {
  margin-top: auto;
}

.venue .icon {
  width: 36px;
  height: 48px;
  margin-bottom: 1.1rem;
}

.venue h3 {
  color: var(--mist);
  font: 600 var(--step-0) / 1.2 var(--serif);
}

.venue-name {
  margin-top: 0.35rem;
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.2;
}

.venue-addr {
  margin: 0.2rem 0 1.4rem;
  font-style: italic;
}

/* pixel button: stepped corners and a hard bottom edge */
.btn {
  display: inline-block;
  padding: 0.9rem 1.25rem 1.05rem;
  background: var(--paper);
  color: var(--forest-deep);
  font: 500 1.1rem / 1 var(--pixel);
  text-decoration: none;
  box-shadow: inset 0 -4px 0 var(--sage);
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.btn--scene {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 0.75rem 0.8rem;
  border: 0;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.btn--scene .icon {
  width: auto;
  height: 14px;
}

.btn--play {
  min-width: 5.2rem;
  justify-content: center;
}

.icon--pause,
.btn--play.playing .icon--play {
  display: none;
}

.btn--play.playing .icon--pause {
  display: block;
}

.btn--play.playing {
  background: var(--gold);
}

/* four buttons don't fit on a phone with their words: Pusti keeps its word, the others show icons */
@media (max-width: 460px) {
  .btn--scene:not(.btn--play) .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .btn--scene {
    padding-inline: 0.95rem;
  }
}

/* what comes next, once the film has been at rest for a moment */
.nudge {
  position: absolute;
  bottom: calc(100% + 0.2rem);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.3rem 0.55rem;
  background: rgba(10, 16, 54, 0.78);
  font: 500 0.95rem / 1 var(--pixel);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 240ms steps(3, end);
  pointer-events: none;
}

.scenes.nudging .nudge {
  opacity: 1;
}

.nudge-touch {
  display: none;
}

.nudge-arrow {
  position: relative;
  display: block;
  width: 15px;
  height: 14px;
}

.nudge-arrow .arrow {
  position: absolute;
  top: 0;
  left: 6px;
}

/* a swipe pushes the page up, so the arrow points that way */
@media (pointer: coarse) {
  .nudge-mouse {
    display: none;
  }

  .nudge-touch {
    display: inline;
  }

  .nudge-arrow {
    transform: rotate(180deg);
  }
}

.scenes.nudging .btn--play:not(.playing) {
  animation: attention 1.4s steps(1, end) infinite;
}

@keyframes attention {
  50% { background: var(--gold); }
}

.btn--start {
  margin-top: 1.2rem;
  padding: 0.85rem 1.2rem 1rem;
  background: var(--gold);
  font-size: 1.15rem;
}

.btn--start[hidden] {
  display: none;
}

.btn--scene[aria-disabled="true"] {
  opacity: 0.5;
  cursor: default;
}

/* a phone on its side has very little ground under the feet */
@media (max-height: 500px) {
  .btn--scene {
    padding: 0.5rem 0.7rem 0.6rem;
    font-size: 0.9rem;
  }

  .btn--start {
    margin-top: 0.5rem;
    font-size: 1rem;
  }

  /* the sides of the screen are free here, and the ground under the feet is not */
  .nudge {
    right: 0.7rem;
    bottom: 0.1rem;
    left: auto;
    transform: none;
  }
}

.btn:hover {
  background: #fff;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 -2px 0 var(--sage);
}

/* clip-path hides outlines, so focus is shown inside the button */
.btn:focus-visible {
  outline: none;
  background: var(--gold);
  box-shadow: inset 0 0 0 3px var(--ink);
}

.facts {
  display: grid;
  gap: 2.2rem;
}

.facts dt {
  margin-bottom: 0.45rem;
  color: var(--mist);
  font: 500 var(--step-0) / 1.2 var(--pixel);
}

.facts dd {
  margin: 0;
  max-width: 24rem;
}

@media (min-width: 720px) {
  .facts {
    grid-template-columns: 1fr 2fr;
  }
}

@media (min-width: 860px) {
  .venues {
    grid-template-columns: repeat(3, 1fr);
  }
}

.foot {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 2.75rem 6vw 3.25rem;
  background: var(--forest-deep);
  color: var(--mist);
  font: 500 1.05rem / 1 var(--pixel);
  scroll-snap-align: end;
}

.foot .icon {
  width: 21px;
  height: 18px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .arrow,
  .scenes.nudging .btn--play:not(.playing) {
    animation: none;
  }

  .panel .inner,
  .nudge {
    transition: none;
  }

  .turn .icon {
    animation: none;
    transform: rotate(90deg);
  }
}
