/* =========================================================================
   Carmony Radio - Folksam
   ========================================================================= */

@font-face {
  font-family: "Folksam Sans";
  src:
    url("assets/fonts/FolksamSans-TextRegular.woff2") format("woff2"),
    url("assets/fonts/FolksamSans-TextRegular.woff")  format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-bg: #0d1620;
  --color-bg-2: #142133;
  --color-ink: #ffffff;
  --color-accent: #85CEFF;

  --btn-size: 88px;
  --btn-radius: 12px;

  /* How far below centre the button sits — overridden on mobile */
  --btn-offset-y: 15vh;
  --btn-scale: 1;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--color-ink);
  font-family: "Folksam Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  /* Slow modern gradient — fallback before the video loads */
  background:
    radial-gradient(ellipse 80% 60% at 20% 65%, rgba(36, 99, 188, 0.55), transparent 65%),
    radial-gradient(ellipse 60% 80% at 85% 30%, rgba(20, 50, 110, 0.35), transparent 70%),
    linear-gradient(180deg, #0d1620 0%, #142133 60%, #0d1620 100%);
  background-size: 200% 200%, 200% 200%, 100% 100%;
  animation: bg-drift 24s ease-in-out infinite alternate;
}

@keyframes bg-drift {
  0%   { background-position: 0% 0%, 100% 100%, 0 0; }
  100% { background-position: 100% 50%, 0% 30%, 0 0; }
}

/* ---------- Background fallback image (behind video) ---------- */
.bg-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;        /* reliable cover scaling on all browsers, incl. iOS */
}

/* ---------- Background video ---------- */
.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;                    /* same layer as fallback; DOM order puts video on top */
  opacity: 0;
  transition: opacity 0.35s ease-in-out;
}
.bg-video.is-ready {
  opacity: 1;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
  mix-blend-mode: multiply;
}

/* ---------- Stage / layout ---------- */
.stage {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 28px 32px;
}

.top-bar {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-height: 24px;
}

/* "Folksam presenterar" — centred at the top on every viewport */
.presenter {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-family: "Folksam Sans", system-ui, sans-serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--color-ink);
  white-space: nowrap;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-bar {
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

/* ---------- Folksam link ---------- */
.folksam-link {
  font-family: "Folksam Sans", system-ui, sans-serif;
  color: var(--color-ink);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: opacity 0.2s ease;
}
.folksam-link:hover,
.folksam-link:focus-visible { opacity: 0.75; outline: none; }
.folksam-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- Player button ----------
   Centred by .hero, then shifted down by --btn-offset-y.
   Hover/active scale is driven by --btn-scale so it composes cleanly with translateY. */
.player-btn {
  position: relative;
  width: var(--btn-size);
  height: var(--btn-size);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 12px 24px rgba(0, 30, 60, 0.35));
  transform: translateY(var(--btn-offset-y)) scale(var(--btn-scale));
  transition: transform 0.18s ease, opacity 0.6s ease;
  opacity: 0;
  animation: btn-fade-in 0.7s 0.25s ease-out forwards;
}
.player-btn:hover  { --btn-scale: 1.03; }
.player-btn:active { --btn-scale: 0.97; }
.player-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 6px;
  border-radius: var(--btn-radius);
}

@keyframes btn-fade-in {
  to { opacity: 1; }
}

.player-btn .icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

/* State visibility */
.player-btn[data-state="idle"]    .icon-play   { opacity: 1; }
.player-btn[data-state="loading"] .icon-loader { opacity: 1; }
.player-btn[data-state="playing"] .icon-stop   { opacity: 1; }

/* ---------- Loader animation (cycles 8 frames at 100ms each = 0.8s loop) ---------- */
.icon-loader {
  position: absolute;
  inset: 0;
}
/* Lottie loader fills the button; the JSON already matches the 80x80 button art */
.loader-lottie {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.loader-lottie svg {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ---------- Desktop layout ---------- */
@media (min-width: 769px) {
  .bottom-bar { display: none; }      /* link is top-right on desktop */
}

/* ---------- Mobile layout (touch devices only) ----------
   We use pointer:coarse so a narrow desktop window keeps the desktop layout
   and link position. The video swap is also gated on this in JS. */
@media (pointer: coarse) and (max-width: 900px) {
  :root {
    --btn-size: 84px;
    --btn-offset-y: 22dvh;            /* sits between the burnt-in subheadline and the bottom link */
  }
  .stage { padding: 24px 24px 28px; }
  /* Keep the top-bar visible for "Folksam presenterar", but hide the link here
     (the folksam link lives at the bottom on mobile). */
  .folksam-link--top { display: none; }
  .bottom-bar { display: flex; }
  .presenter { font-size: 18px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  body, .player-btn { animation: none; }
  .bg-video { transition: none; }
  .player-btn { opacity: 1; }
}
