/* Caleb Cole. One screen, no scroll. */

@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/jost-latin-wght-normal.woff2") format("woff2");
}

:root {
  --bg: #05070D;
  --fg: #F2F4F8;
  --dim: rgb(242 244 248 / 0.62);
  --line: rgb(255 255 255 / 0.14);
  --accent: #2F6BFF;

  /* Flat dark layer over the video. 0 is off; raise it (0 to 1) if a clip is too bright for the text. */
  --scrim: 0;

  /* Dark glass behind the top bar on portrait screens (0 to 1). See the note at the media query. */
  --top-glass: 0.7;

  --pad-x: clamp(20px, 4.5vw, 64px);
  --pad-y: clamp(14px, 3.6vh, 40px);
  --label: clamp(0.6875rem, 0.62rem + 0.19vw, 0.875rem);
  --small: clamp(0.625rem, 0.5rem + 0.16vw, 0.75rem);
  --avatar: clamp(52px, 44px + 1.4vw, 80px);
  --control: clamp(46px, 2.6vw + 2px, 58px);

  /*
   * Vertical rhythm, fitted to the clip.
   *
   * The clip keeps its lower third dark for the text, under a thin horizon line.
   * --band is the height of that dark band on this screen: 30.2% of the height, or
   * less when a wide screen crops the clip top and bottom. --drift is how far the
   * line wanders during one loop. The name sits just under the line and the
   * spacing below it shares out whatever room is left, so nothing ever lands on
   * the line. With a different clip these are simply proportions.
   */
  --band: min(30.2vh, 50vh - 11.14vw);
  --drift: max(1.3vh, 0.73vw);
  --clear: clamp(10px, 1.5vh, 18px);
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
  /* Footer line + button row + genre line: the parts under the name that do not flex. */
  --fixed: calc(var(--small) + var(--control) + 1.5 * var(--label));
  /* The largest name that still fits inside the band. */
  --fit: calc((var(--band) - var(--clear) - var(--fixed) - var(--safe-bottom) - 40px) / 0.85);
  /* 0 when a name fits in the band; huge when it cannot (landscape phones). */
  --cramped: clamp(0px, (1.5rem - var(--fit)) * 1000, 2000px);

  --name: clamp(1.5rem, min(8.6vw, 9vh, var(--fit) + var(--cramped)), 8rem);

  --room: calc(var(--band) - var(--clear) - var(--fixed) - 0.85 * var(--name));
  --pad-bottom: max(env(safe-area-inset-bottom), clamp(14px, var(--room) * 0.28, 72px));
  --room-above-foot: calc(var(--room) - var(--pad-bottom));
  --actions-gap: clamp(14px, var(--room-above-foot) * 0.35, 48px);
  --genre-gap: clamp(10px, var(--room-above-foot) * 0.22, 28px);
  --hero-gap: clamp(16px, var(--room-above-foot) - var(--actions-gap) - var(--genre-gap), 96px);
  /* When the name cannot fit in the band it sits above the line with the genre
     line, and this is the gap that lets the line pass between them and the buttons. */
  --straddle: calc(var(--band) + var(--drift) - var(--pad-bottom) - var(--small) - var(--hero-gap) - var(--control) + 8px);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
}

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

html {
  height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: "Jost", "Futura", "Century Gothic", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
p,
ul {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: rgb(47 107 255 / 0.45);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Small labels: one voice for every piece of secondary text. */
.top__place,
.top__contact dt,
.genre,
.listen,
.sheet__list a,
.foot {
  font-size: var(--label);
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------ background */

.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  animation: fade 1.4s cubic-bezier(0.33, 0, 0.2, 1) backwards;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: var(--scrim);
  pointer-events: none;
}

/* Slightly oversized so the pointer drift never shows an edge. */
.bg__layer {
  position: absolute;
  inset: -8px;
}

.bg__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

/* iOS draws a play button over the poster when autoplay is refused. */
.bg__video::-webkit-media-controls,
.bg__video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none;
}

/* Stand-in until a clip is added: a soft cobalt light, upper centre. */
.bg__placeholder {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.bg__placeholder::before,
.bg__placeholder::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 30%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: breathe 9s ease-in-out infinite alternate;
}

.bg__placeholder::before {
  width: min(150vw, 130vh);
  aspect-ratio: 1 / 1.08;
  background: radial-gradient(closest-side, rgb(47 107 255 / 0.3), rgb(47 107 255 / 0.17) 30%, rgb(47 107 255 / 0.07) 58%, rgb(47 107 255 / 0.02) 80%, transparent);
}

.bg__placeholder::after {
  width: min(52vw, 44vh);
  aspect-ratio: 1 / 1.3;
  background: radial-gradient(closest-side, rgb(150 182 255 / 0.5), rgb(47 107 255 / 0.3) 42%, rgb(47 107 255 / 0.08) 76%, transparent);
  animation-duration: 7s;
  animation-delay: -3s;
}

/* ------------------------------------------------------------------ page */

.page {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  padding: max(var(--pad-y), env(safe-area-inset-top)) max(var(--pad-x), env(safe-area-inset-right))
    var(--pad-bottom) max(var(--pad-x), env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  --at: 1620ms;
}

.top__place {
  color: var(--dim);
}

/* Two rows, label then address, with the labels right-aligned against the addresses. */
.top__contact {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: baseline;
  gap: 0.45em 0.9em;
  margin: 0;
  font-size: var(--label);
}

.top__contact dt {
  justify-self: end;
  font-size: inherit;
  color: var(--dim);
}

/* The addresses stay exactly as typed: lower case, lightly tracked. */
.top__contact dd {
  margin: 0;
  letter-spacing: 0.06em;
}

/* The narrowest phones: tighten the block so it still sits beside the place name. */
@media (max-width: 359px) {
  .top__contact {
    column-gap: 0.6em;
    font-size: 0.625rem;
  }

  .top__contact dt {
    letter-spacing: 0.12em;
  }

  .top__contact dd {
    letter-spacing: 0.02em;
  }
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  min-width: 0;
  padding-bottom: var(--hero-gap);
}

.avatar {
  display: block;
  flex: none;
  width: var(--avatar);
  height: var(--avatar);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

/* The files are already cropped to head and shoulders (scripts/make-assets.js). */
.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.hero > .avatar {
  --at: 1350ms;
}

.name {
  /* Enough for the horizon line to pass between the photo and the name. */
  margin-top: max(clamp(14px, 2.8vh, 30px), calc(var(--drift) + var(--clear) + 6px - 0.15 * var(--name)));
  margin-right: -0.4em;
  font-size: var(--name);
  font-weight: 300;
  line-height: 1;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  white-space: nowrap;
  --at: 700ms;
}

/* With JavaScript the letters resolve one by one instead. Each letter holds
   itself: WebKit drops child animations when a parent's visibility is animated. */
.name.name--split {
  animation: none;
}

.name__word,
.name__letter {
  display: inline-block;
}

.name__letter {
  animation: letter 0.85s var(--ease) backwards, hold 0s backwards;
  animation-delay: calc(var(--at) + var(--i, 0) * 45ms);
}

/* A wordmark stands in for the caps: same height, same position. */
.name--logo {
  margin-right: 0;
  padding: 0.14em 0;
  letter-spacing: 0;
}

.name--logo img {
  display: block;
  width: auto;
  height: 0.72em;
  max-width: 100%;
}

.genre {
  margin-top: var(--genre-gap);
  color: var(--dim);
  line-height: 1.5;
  --at: 1440ms;
}

.actions {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 14px);
  margin-top: calc(var(--actions-gap) + clamp(0px, var(--cramped), max(0px, min(var(--straddle), 96px) - var(--actions-gap))));
  --at: 1530ms;
}

.listen {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--control);
  padding: 0 calc(clamp(30px, 2vw, 40px) - 0.22em) 0 clamp(30px, 2vw, 40px);
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgb(5 7 13 / 0.38);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--fg);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* A 1px ring in the accent that fades in over the hairline; the span inside is the light that crosses it. */
.listen__edge {
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  overflow: hidden;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  transition: opacity 0.45s var(--ease);
}

.listen__edge > span {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgb(218 229 255 / 0.95) 50%, transparent 70%);
  transform: translate3d(-101%, 0, 0);
}

.social {
  display: flex;
}

.social a {
  display: grid;
  place-items: center;
  width: var(--control);
  height: var(--control);
  color: var(--dim);
  transition: color 0.4s var(--ease), transform 0.4s var(--ease);
}

.social .icon {
  width: clamp(18px, 1.15vw, 22px);
  height: clamp(18px, 1.15vw, 22px);
}

.foot {
  font-size: var(--small);
  color: var(--dim);
  --at: 1710ms;
}

/* --------------------------------------------------- fitting the clip */

/*
 * Portrait screens crop the clip to its bright centre, which puts the light
 * directly under the top bar. There the bar sits on a strip of the same dark
 * glass as the button, so its text stays readable whatever the clip is doing.
 * Set --top-glass to 0 to remove the tint.
 */
@media (max-aspect-ratio: 1/1) {
  .page {
    padding-top: calc(env(safe-area-inset-top) + 6px);
  }

  .page::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: calc(env(safe-area-inset-top) + 56px);
    border-bottom: 1px solid var(--line);
    background: rgb(5 7 13 / var(--top-glass));
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    animation: fade 0.7s var(--ease) 1620ms backwards;
  }

  .top {
    position: relative;
  }

  .top__place,
  .top__contact dt {
    color: var(--fg);
  }
}

/* ---------------------------------------------------------------- dialog */

.sheet {
  width: min(calc(100vw - 2 * var(--pad-x)), 23.5rem);
  max-width: none;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: hidden auto;
  border: 1px solid var(--line);
  border-radius: 2px;
  /* Dark enough to read on its own wherever the blur is not drawn. */
  background: rgb(7 10 18 / 0.78);
  -webkit-backdrop-filter: blur(28px);
  backdrop-filter: blur(28px);
  color: var(--fg);
}

.sheet::backdrop {
  background: rgb(5 7 13 / 0.68);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.sheet[open] {
  animation: sheet-in 0.5s var(--ease) both;
}

.sheet[open]::backdrop {
  animation: backdrop-in 0.5s ease-out both;
}

.sheet__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 8px 14px 20px;
}

.avatar--small {
  width: 44px;
  height: 44px;
  padding: 2px;
}

.sheet__name {
  font-size: 0.8125rem;
  font-weight: 300;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sheet__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
  transition: color 0.4s var(--ease), transform 0.4s var(--ease);
}

.sheet__list a {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 18px;
  min-height: clamp(48px, 13.5vh, 58px);
  padding: 0 24px 0 22px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  transition: color 0.4s var(--ease), background-color 0.4s var(--ease);
}

.sheet__list a:focus-visible {
  outline-offset: -4px;
}

.sheet__list .icon,
.sheet__list .arrow {
  transition: transform 0.4s var(--ease);
}

.sheet[open] .sheet__list li {
  animation: rise 0.6s var(--ease) both;
}

.sheet[open] .sheet__list li:nth-child(1) { animation-delay: 110ms; }
.sheet[open] .sheet__list li:nth-child(2) { animation-delay: 170ms; }
.sheet[open] .sheet__list li:nth-child(3) { animation-delay: 230ms; }
.sheet[open] .sheet__list li:nth-child(4) { animation-delay: 290ms; }

.sheet.is-closing {
  animation: sheet-out 0.24s ease-in both;
}

.sheet.is-closing::backdrop {
  animation: backdrop-out 0.24s ease-in both;
}

/* ----------------------------------------------------------- interaction */

.listen:focus-visible .listen__edge,
.listen:active .listen__edge {
  opacity: 1;
}

.listen:focus-visible .listen__edge > span {
  transform: translate3d(101%, 0, 0);
  transition: transform 0.9s var(--ease) 0.05s;
}

.social a:focus-visible,
.sheet__close:focus-visible,
.sheet__list a:focus-visible {
  color: var(--fg);
}

@media (hover: hover) {
  .listen:hover .listen__edge {
    opacity: 1;
  }

  .listen:hover .listen__edge > span {
    transform: translate3d(101%, 0, 0);
    transition: transform 0.9s var(--ease) 0.05s;
  }

  .social a:hover {
    color: var(--fg);
    transform: translate3d(0, -2px, 0);
  }

  .sheet__close:hover {
    color: var(--fg);
    transform: translate3d(0, -1px, 0);
  }

  .sheet__list a:hover {
    color: var(--fg);
    background-color: rgb(255 255 255 / 0.035);
  }

  .sheet__list a:hover .icon {
    transform: translate3d(0, -1px, 0);
  }

  .sheet__list a:hover .arrow {
    transform: translate3d(2px, -2px, 0);
  }
}

/* ---------------------------------------------------------------- motion */

/*
 * Entrance. Each piece rises and fades in at its own time (--at). The rise runs
 * on the compositor; "hold" keeps the piece properly hidden, not just
 * transparent, until its turn, so nothing invisible can be focused or tapped
 * and a late font swap cannot register as a layout shift. Everything fills
 * backwards only: once done, each piece is back in its own plain style with no
 * leftover transform or filter.
 */
.top,
.hero > .avatar,
.name,
.genre,
.actions,
.foot {
  animation: rise 0.7s var(--ease) var(--at) backwards, hold 0s var(--at) backwards;
}

.name {
  animation-duration: 0.9s, 0s;
}

@keyframes hold {
  from { visibility: hidden; }
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
}

/* Blurred and tracked wide, settling into place. */
@keyframes letter {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translate3d(calc(0.18em + var(--i, 0) * 0.07em), 0, 0);
  }
}

@keyframes breathe {
  from { opacity: 0.72; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes sheet-in {
  from { opacity: 0; transform: scale(0.98); }
}

@keyframes sheet-out {
  to { opacity: 0; transform: scale(0.985); }
}

@keyframes backdrop-in {
  from { opacity: 0; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); }
}

@keyframes backdrop-out {
  to { opacity: 0; }
}

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