/*
 * Copyright (c) 2026 Ceeliro
 * SPDX-License-Identifier: MIT
 *
 * The welcome page (index.html). Phone first; the section "Wide screens" at the end changes the
 * layout from 960px wide. Sections: header, hero, phone, tours, language switch.
 */

.welcome {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* The page scrolls inside this box, so the pinned button below can stick to its top. */
.welcome__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-inline: 20px;
}

/* ── Header ───────────────────────────────────────────── */
.welcome__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
}

.welcome__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.welcome__logo {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}

.welcome__wordmark {
  font-size: 26px;
}

.welcome__bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* On phones the button is the pinned one (.welcome__dock), so the header has no button of its own. */
.welcome__go--bar {
  display: none;
}

/*
 * The pinned button. A zero-height strip is sticky inside the scrolling page. It starts in the
 * header row, so the button looks like part of the header. When the header scrolls away, the
 * strip stays at the top and the button stays with it.
 */
.welcome__dock {
  position: sticky;
  top: 14px;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  height: 0;
}

.welcome__go--dock {
  flex: none;
  height: 36px;
  padding-inline: 14px;
  font-size: 13px;
}

/* The header keeps the width the pinned button needs, so the language chip never sits under it. */
.welcome__go-ghost {
  visibility: hidden;
}

/* Where the browser supports it, the pinned button gets a soft shadow while the page scrolls. */
@supports (animation-timeline: scroll()) {
  .welcome__dock .welcome__go--dock {
    animation: welcome-dock-lift linear both;
    animation-timeline: scroll(nearest);
    animation-range: 0 48px;
  }
}

@keyframes welcome-dock-lift {
  to {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  }
}

/* ── Hero ─────────────────────────────────────────────── */
.welcome__main {
  display: grid;
  align-content: start;
}

.welcome__hero {
  display: grid;
  align-content: start;
  gap: 14px;
  padding-top: 8px;
}

.welcome__title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(2.6rem, 12.4vw, 4.75rem);
  line-height: 0.93;
  text-wrap: balance;
}

.welcome__title em {
  color: var(--beatme-accent);
}

.welcome__lede {
  max-width: 31rem;
  color: var(--beatme-text-muted);
  font-size: 16px;
  line-height: 1.55;
}

.welcome__go--hero {
  display: none;
}

/* On phones only the top of the phone shows, fading out under the headline. */
.welcome__phone {
  --phone-width: 200px;
  display: block;
  height: 292px;
  margin-top: 4px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 62%, transparent);
  mask-image: linear-gradient(#000 62%, transparent);
}

/* ── Phone: four screens of the app, one fact beside it ── */
.hero-phone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 14px;
}

/* Drawn like the phone on the tour pages: a dark bezel, a status strip, the screen. */
.hero-phone__frame {
  width: var(--phone-width);
  padding: calc(var(--phone-width) * 0.032);
  border-radius: calc(var(--phone-width) * 0.16);
  background: linear-gradient(
    145deg,
    var(--beatme-border-strong),
    var(--beatme-bg) 45%,
    var(--beatme-bg-elevated)
  );
  box-shadow:
    0 0 0 1px var(--beatme-border),
    0 40px 90px rgba(0, 0, 0, 0.55),
    0 0 120px var(--beatme-accent-surface);
}

.hero-phone__screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: calc(var(--phone-width) * 0.13);
  background: var(--beatme-bg-elevated);
}

.hero-phone__status {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--phone-width) * 0.11);
  padding-inline: calc(var(--phone-width) * 0.09);
  color: var(--beatme-text);
  font: 600 calc(var(--phone-width) * 0.038) / 1 Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

.hero-phone__island {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30%;
  height: calc(var(--phone-width) * 0.07);
  border-radius: 999px;
  background: var(--beatme-bg);
  transform: translate(-50%, -45%);
}

.hero-phone__shots {
  position: relative;
  width: 100%;
  aspect-ratio: 440 / 956;
}

.hero-phone__shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 300ms var(--ease-standard);
}

.hero-phone__shot--on {
  opacity: 1;
}

/* One segment per screen. The segment of the screen that is showing fills while it stays. */
.hero-phone__progress {
  display: flex;
  gap: 4px;
  width: var(--phone-width);
}

.hero-phone__progress i {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--beatme-border);
}

.hero-phone__progress i::after {
  content: '';
  display: block;
  width: 0;
  height: 100%;
  background: var(--beatme-accent);
}

.hero-phone__progress .hero-phone__segment--done::after {
  width: 100%;
}

.hero-phone__progress .hero-phone__segment--now::after {
  width: 100%;
  transition: width 2800ms linear;
}

/* The fact about the screen that is showing. Each screen draws a new one, which fades in. */
.hero-phone__fact {
  position: absolute;
  z-index: 2;
  top: 132px;
  left: max(0px, calc(50% - 168px));
  display: grid;
  gap: 2px;
  min-width: 132px;
  padding: 10px 16px 11px;
  border: 1px solid rgba(94, 217, 223, 0.3);
  border-radius: 16px;
  background: var(--beatme-bg-surface);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: fact-in 300ms var(--ease-standard);
}

.hero-phone__chapter {
  color: var(--beatme-accent);
  font: 700 11px/1 Roboto, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-phone__number {
  color: var(--beatme-accent);
  font: 500 22px/1.15 var(--font-data);
  font-variant-numeric: tabular-nums;
}

.hero-phone__text {
  max-width: 15ch;
  color: var(--beatme-text);
  font-size: 12px;
  line-height: 1.3;
}

@keyframes fact-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-phone__shot,
  .hero-phone__progress .hero-phone__segment--now::after {
    transition: none;
  }

  .hero-phone__fact {
    animation: none;
  }
}

/* ── Tours ────────────────────────────────────────────── */
.welcome__tours {
  display: grid;
  align-content: start;
  gap: 12px;
  padding-block: 18px 26px;
}

.welcome__tours-head {
  display: grid;
  gap: 4px;
  padding-bottom: 4px;
}

.welcome__tours-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 34px;
  line-height: 1;
}

.welcome__tours-text {
  color: var(--beatme-text-muted);
  font-size: 14px;
}

.tour-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 196px;
  padding: 18px 18px 16px;
  overflow: hidden;
  border: 1px solid var(--beatme-border);
  border-radius: 22px;
  background: linear-gradient(160deg, var(--beatme-accent-surface), var(--beatme-bg-elevated) 55%);
  color: inherit;
  text-decoration: none;
  transition:
    border-color 120ms var(--ease-standard),
    background 120ms var(--ease-standard);
}

.tour-card:hover,
.tour-card:focus-visible {
  border-color: var(--beatme-accent);
}

.tour-card__kicker {
  color: var(--beatme-accent);
  font: 700 11px/1 Roboto, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* A tournament is about trophies, so its card uses the warm colour. */
.tour-card--warm {
  background: linear-gradient(160deg, var(--beatme-warm-surface), var(--beatme-bg-elevated) 55%);
}

.tour-card--warm .tour-card__kicker {
  color: var(--beatme-warm);
}

.tour-card--warm .tour-card__play {
  background: var(--beatme-warm-surface);
  color: var(--beatme-warm);
}

.tour-card--warm:hover,
.tour-card--warm:focus-visible {
  border-color: var(--beatme-warm);
}

.tour-card__title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 22px;
  line-height: 1.05;
  white-space: nowrap;
}

.tour-card__text {
  max-width: calc(100% - 116px);
  color: var(--beatme-text-muted);
  font-size: 13.5px;
  line-height: 1.42;
}

.tour-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 116px);
  margin-top: 2px;
  color: var(--beatme-text-muted);
  font: 500 12px var(--font-data);
}

.tour-card__play {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--beatme-accent-surface);
  color: var(--beatme-accent);
}

.tour-card__play .icon {
  width: 18px;
  height: 18px;
}

/* Two small phones, cut off by the card edge. A phone shows one; a wide screen shows both. */
.tour-card__phone {
  position: absolute;
  width: 100px;
  aspect-ratio: 9 / 19;
  padding: 3px;
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    var(--beatme-border-strong),
    var(--beatme-bg) 50%,
    var(--beatme-bg-elevated)
  );
  box-shadow:
    0 0 0 1px var(--beatme-border),
    0 16px 30px rgba(0, 0, 0, 0.45);
}

.tour-card__phone img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 13px;
  object-fit: cover;
  object-position: top;
}

.tour-card__phone--first {
  display: none;
}

.tour-card__phone--second {
  top: 72px;
  right: 16px;
}

.welcome__stores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--beatme-text-muted);
  font-size: 13px;
}

/* On phones the label has a row of its own and the two store buttons share the next row. */
.welcome__stores-label {
  flex-basis: 100%;
}

.welcome__store {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--beatme-border);
  border-radius: 999px;
  background: var(--beatme-bg-elevated);
  color: var(--beatme-text);
  font-weight: 500;
  text-decoration: none;
}

.welcome__store .icon {
  width: 20px;
  height: 20px;
}

.welcome__store:hover {
  border-color: var(--beatme-accent);
}

/* ── Language switch ──────────────────────────────────── */
/*
 * Phone first: one chip shows the chosen language, a tap opens the others in a panel under it.
 * From 960px wide all three buttons sit in the one frame, as a row.
 */
.language-switch {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--beatme-border);
  background: var(--beatme-bg-elevated);
}

.language-switch__trigger,
.language-switch__button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding-inline: 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--beatme-text-muted);
  font: 700 12px/1 Roboto, sans-serif;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition:
    background 120ms var(--ease-standard),
    color 120ms var(--ease-standard);
}

.language-switch__trigger:hover,
.language-switch__button:hover {
  background: rgba(94, 217, 223, 0.1);
}

.language-switch__trigger {
  gap: 2px;
  padding-inline: 11px 5px;
  background: var(--beatme-accent-surface);
  color: var(--beatme-accent);
}

.language-switch__trigger:hover {
  background: var(--beatme-accent-surface);
}

.language-switch__caret {
  width: 18px;
  height: 18px;
  transition: transform 120ms var(--ease-standard);
}

.language-switch__trigger[aria-expanded='true'] .language-switch__caret {
  transform: rotate(180deg);
}

.language-switch__options {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 2;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
  border-radius: 20px;
  border: 1px solid var(--beatme-border);
  background: var(--beatme-bg-elevated);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.language-switch__options--open {
  display: flex;
}

/* The chip already shows the chosen language, so the panel lists only the other ones. */
.language-switch__button[aria-pressed='true'] {
  display: none;
}

/* ── Wide screens ─────────────────────────────────────── */
@media (min-width: 960px) {
  .welcome__scroll {
    padding-inline: 64px;
  }

  .welcome__bar {
    height: 76px;
  }

  .welcome__go--bar {
    display: inline-flex;
  }

  .welcome__main {
    grid-template-columns: 1.1fr 0.9fr;
    column-gap: 56px;
    grid-template-rows: auto auto;
  }

  .welcome__hero {
    grid-column: 1;
    grid-row: 1;
    gap: 20px;
    padding-top: 44px;
  }

  .welcome__title {
    font-size: 5.2rem;
  }

  .welcome__lede {
    max-width: 32rem;
    font-size: 19px;
  }

  .welcome__go--hero {
    display: inline-flex;
    justify-self: start;
  }

  .welcome__dock,
  .welcome__go-ghost {
    display: none;
  }

  .welcome__phone {
    --phone-width: 276px;
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    height: auto;
    padding-top: 18px;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .hero-phone__fact {
    top: 270px;
    left: max(0px, calc(50% - 236px));
  }

  .welcome__tours {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding-block: 34px;
  }

  .welcome__tours-head,
  .welcome__stores {
    grid-column: 1 / -1;
  }

  .welcome__tours-title {
    font-size: 40px;
  }

  .tour-card {
    min-height: 360px;
    padding: 20px 20px 214px;
  }

  .tour-card__title {
    font-size: 30px;
    white-space: normal;
    text-wrap: balance;
  }

  .tour-card__text,
  .tour-card__meta {
    max-width: none;
  }

  .tour-card__phone {
    width: 104px;
  }

  .tour-card__phone--first {
    display: block;
    bottom: -70px;
    left: 22px;
  }

  .tour-card__phone--second {
    top: auto;
    right: 22px;
    bottom: -96px;
  }

  .welcome__stores-label {
    flex-basis: auto;
  }

  .welcome__store {
    flex: none;
    min-height: 0;
  }

  .language-switch__trigger {
    display: none;
  }

  .language-switch__options {
    position: static;
    display: flex;
    flex-direction: row;
    gap: 2px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  .language-switch__button[aria-pressed='true'] {
    display: inline-flex;
    background: var(--beatme-accent-surface);
    color: var(--beatme-accent);
  }
}
