@font-face {
  font-family: Space;
  src: url('/assets/fonts/space-grotesk-700.ttf');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: Space, system-ui, sans-serif;
  background: #18212a;
  color: #fff9ee;
}

body {
  margin: 0;
}

.hero {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  display: grid;
  align-items: center;
  min-height: 100svh;
  padding: 2rem clamp(2rem, 8vw, 9rem) 5rem;
  background: url('/assets/tallinn-waterfront-night.webp') center / cover no-repeat;
}

/* Transparent runner (alpha video) centred over the static waterfront,
   sized by height and standing on the bottom edge. */
.hero-video {
  position: absolute;
  z-index: -2;
  left: 50%;
  bottom: 0;
  height: min(94svh, 120vw);
  aspect-ratio: 720 / 918;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  transform: translateX(-50%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgb(13 20 27 / 85%), rgb(13 20 27 / 47%) 42%, transparent 64%),
    linear-gradient(0deg, rgb(13 20 27 / 64%), transparent 25%);
}

.hero-content {
  justify-self: start;
}

h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(4rem, 9vw, 8rem);
  line-height: 0.9;
  letter-spacing: -0.085em;
}

h1 span {
  display: block;
  margin-top: 0.8rem;
  padding-inline-start: 0.28em;
  font-size: clamp(0.8rem, 1.6vw, 1.2rem);
  line-height: 1.2;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.calendar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 3rem;
  padding: 0.65rem 1.5rem;
  border-radius: 999px;
  background: #fff2dc;
  color: #1b252d;
  text-decoration: none;
}

.calendar-link:hover {
  background: #fffaf0;
}

.calendar-link:focus-visible {
  outline: 2px solid white;
  outline-offset: 4px;
}

@media (max-width: 700px) and (orientation: portrait) {
  .hero {
    align-items: end;
    justify-items: center;
    padding: 2rem 1rem max(5rem, calc(env(safe-area-inset-bottom) + 4.25rem));
  }

  /* Stand the runner above the title block so the copy never sits on the shirt. */
  .hero-video {
    bottom: 21svh;
    height: min(64svh, 124vw);
  }

  .hero::after {
    background: linear-gradient(0deg, rgb(13 20 27 / 93%), rgb(13 20 27 / 64%) 23%, transparent 49%);
  }

  .hero-content {
    justify-self: center;
    text-align: center;
  }
}

html, body { height: 100%; overflow: hidden; }
.hero-content { transition: opacity .45s ease, transform .65s cubic-bezier(.22,1,.36,1), filter .45s ease; }
.calendar-open .hero-content { opacity: 0; transform: translateY(-20px) scale(.96); filter: blur(10px); pointer-events: none; }
.calendar-overlay { position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; }
.calendar-overlay::backdrop { background: rgb(6 12 22 / 24%); animation: veil-in .65s ease both; }
.calendar-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.calendar-overlay[open] .calendar-frame { animation: calendar-in .85s cubic-bezier(.16,1,.3,1) both; }
.calendar-close { position: absolute; z-index: 10; top: max(12px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); width: 42px; height: 42px; border: 1px solid rgb(210 216 255 / 28%); border-radius: 50%; color: #f1f2ff; background: rgb(23 30 47 / 80%); backdrop-filter: blur(16px); font: 28px/1 system-ui; cursor: pointer; transition: background .2s, transform .2s; }
.calendar-close:hover { background: #474b78; transform: rotate(90deg); }
.calendar-close:focus-visible { outline: 2px solid #b1b5ff; outline-offset: 4px; }
.calendar-overlay.is-closing { animation: calendar-out .32s ease both; }
@keyframes calendar-in { from { opacity: 0; transform: translateY(40px) scale(.93); filter: blur(12px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes calendar-out { to { opacity: 0; transform: translateY(18px) scale(.98); } }
@keyframes veil-in { from { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .hero-content, .calendar-close { transition: none; } .calendar-overlay, .calendar-overlay::backdrop, .calendar-overlay[open] .calendar-frame { animation: none; } }

/* Close button: draw the cross with two bars so it sits dead centre in the circle
   (the × glyph rides low in most system fonts). */
.calendar-close { display: grid; place-items: center; padding: 0; font-size: 0; }
.calendar-close::before, .calendar-close::after { content: ''; grid-area: 1 / 1; width: 18px; height: 2px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
.calendar-close::after { transform: rotate(-45deg); }

/* While the calendar is open the runner steps aside so the two never overlap:
   left of the calendar in landscape, up above the wheel in portrait. */
.hero-video { transition: left .85s cubic-bezier(.16,1,.3,1), transform .85s cubic-bezier(.16,1,.3,1); }
@media (min-aspect-ratio: 5/4) {
  .calendar-open .hero-video { left: 19%; }
  .calendar-overlay { left: auto; right: 0; width: 62%; }
}
@media (max-aspect-ratio: 5/4) {
  .hero-video { transform-origin: 50% 0; }
  .calendar-open .hero-video { transform: translate(-50%, var(--lift, -18.5svh)) scale(var(--shrink, .8)); }
  /* fade the body out below the chest (rows 440-510 of 918) so it ends above the button */
  .calendar-open .hero-video { -webkit-mask-image: linear-gradient(#000 48%, transparent 55.5%); mask-image: linear-gradient(#000 48%, transparent 55.5%); }
}
@media (prefers-reduced-motion: reduce) { .hero-video { transition: none; } }
/* Sit the button in the strip above the calendar card, flush with its right edge. */
.calendar-close { top: max(7px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 38px; height: 38px; }
/* Portrait: the close button is centred; home.js sets its top just above the wheel. */
@media (max-aspect-ratio: 5/4) {
  .calendar-close { left: 50%; right: auto; margin-left: -19px; }
}

/* Portrait calendar: logo on the left and the runner on the right, above the wheel. */
.calendar-logo { display: none; }
@media (max-aspect-ratio: 5/4) {
  .calendar-open .hero-video { left: 73%; }
  .calendar-logo { display: block; position: absolute; z-index: 5; left: 16px; top: 16px; margin: 0; font-weight: 700; font-size: 44px; line-height: .9; letter-spacing: -.085em; color: #fff9ee; pointer-events: none; }
  .calendar-logo span { display: block; margin-top: .45em; padding-inline-start: .28em; font-size: .22em; line-height: 1.2; letter-spacing: .28em; text-transform: uppercase; }
  .calendar-overlay[open] .calendar-logo { animation: calendar-in .85s cubic-bezier(.16,1,.3,1) both; }
}

/* Night Run Estonia partner logo: always bottom centre of the screen. While the
   calendar is open home.js moves it into the dialog so it stays above it. */
.partner-banner { position: fixed; z-index: 8; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom)); height: 32px; display: flex; justify-content: center; pointer-events: none; }
.partner-banner a { display: inline-flex; height: 100%; pointer-events: auto; transition: opacity .2s, transform .2s; }
.partner-banner a:hover { opacity: .82; transform: translateY(-1px); }
.partner-banner img { display: block; height: 100%; width: auto; filter: drop-shadow(0 2px 7px rgb(0 0 0 / 50%)); }

/* Portrait page wider than a phone (tablets, square windows): keep the calendar in a
   phone-width column so it uses the same stacked layout as on phones. */
@media (max-aspect-ratio: 5/4) {
  .calendar-overlay { left: 0; right: 0; width: min(100%, 760px); margin-inline: auto; }
}
