/* Golba Music — site styles.
   Breakpoints: 46.875em (750px) = mobile, 33.125em (530px) = small phone,
   87.5em / 118.125em scale the root font size up on large screens. */

/* ---------- Base ---------- */

/* Work Sans (SIL Open Font License, see fonts/LICENSE.txt), one variable file per character set.
   Only weights 300-700 are offered, so anything lighter falls back to 300. */
@font-face {
  font-family: 'Work Sans';
  font-weight: 300 700;
  font-display: swap;
  src: url(/assets/fonts/work-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Work Sans';
  font-weight: 300 700;
  font-display: swap;
  src: url(/assets/fonts/work-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html {
  transition: all .3s ease-in;

  @media (min-width: 87.5em) { font-size: 1.25em; }
  @media (min-width: 118.125em) { font-size: 1.5em; }
}

@media (min-width: 46.9375em) {
  html::-webkit-scrollbar { display: none; }
}

::selection {
  background: #000;
  color: #fff;
  text-shadow: none;
}

body {
  box-sizing: border-box;
  max-width: 60em;
  margin: 0 auto;
  padding: 0 1.5em 0 .625em;
  font-family: 'Work Sans', sans-serif;
  line-height: 1;
  transition: all .3s ease-in;

  @media only screen and (max-width: 46.875rem) { padding: 0 .625rem; }
}

h1, h2, p, dl, dd, address {
  margin: 0;
  font: inherit;
}

p { margin: 1.2em 0; }

a, button { cursor: pointer; }

img {
  box-sizing: border-box;
  max-width: 100%;
  height: auto;
  border: 0;
}

sup {
  font-size: 100%;
  vertical-align: baseline;
}

button {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
}

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

/* ---------- Header and navigation ---------- */

.site-header,
.site-nav {
  position: fixed;
  top: 50%;
  transform: translate(0, -50%);
  box-sizing: border-box;
  width: 19.375em;
  max-width: 39.0625%;
  max-height: 100%;
  text-align: center;
  transition: all .1s cubic-bezier(.39, .43, .41, .43);

  @media only screen and (max-width: 46.875rem) {
    width: 61.0625rem;
    max-width: 100%;
    transform: translate(0, 0);
  }
}

.site-header {
  z-index: 3;
  height: 21em;

  @media only screen and (max-width: 46.875rem) {
    position: absolute;
    top: 0;
    height: 3.9375rem;
    margin-left: -.625rem;
    padding-top: 1.0625rem;
  }
}

.logo {
  position: relative;
  display: block;
  float: right;
  width: 16.625rem;
  margin: 0 0 0 auto;
  text-align: center;
  transition: all .1s ease-in;

  & img { transition: opacity .3s linear; }

  /* Compact logo, cross-faded in once the visitor scrolls past the intro. */
  &::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 18.5rem;
    height: 1.9375rem;
    margin: 0 auto;
    padding: 0 .625em;
    background-image: url(/assets/images/golba-music-logo-small.svg);
    background-repeat: no-repeat;
    background-position: right top;
    background-origin: content-box;
    opacity: 0;
    transition: opacity .3s linear;
  }

  .logo-small & {
    & img { opacity: 0; }
    &:hover img { opacity: 1; }
    &::before { opacity: 1; }
    &:hover::before { opacity: 0; }
  }

  @media only screen and (max-width: 46.875rem) {
    width: 100%;

    & img { padding: 0 1.5625rem; }

    &::before {
      padding: 0 1.5625rem;
      background-position: left top;
    }

    .logo-small & {
      & img { opacity: 1; }
      &::before { opacity: 0; }
    }
  }
}

.site-nav {
  z-index: 2;
  height: 25em;
  align-content: end;

  & ul {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    box-sizing: border-box;
    width: 20.75rem;
    margin: 0 0 0 auto;
    padding: 0 2.125rem .75rem 1.5625rem;
    list-style: none;

    /* Underline that slides to the current section: anchored to the centre of the current link and
       as wide as the widest link plus 6px. With no current link it waits off-screen. Inline links
       (desktop) count in whole pixels, as the old site's jQuery measured them; the inline-block links
       of the mobile bar do not (see the media query below). Unlike the old site, which measured once
       per section change, it stays centred when the links move (the mobile home icon opening). */
    &::after {
      --widest: max(anchor-size(--nav-services width), anchor-size(--nav-music width),
                    anchor-size(--nav-about width), anchor-size(--nav-contact width));
      --width: calc(round(var(--widest), 1px) + 6px);
      content: '';
      position: absolute;
      bottom: 0;
      left: anchor(--nav-current center, -2999px);
      width: var(--width);
      height: 1px;
      margin-left: calc(var(--width) / -2);
      background: #000;
      transition: all .2s linear;
    }
  }

  & li {
    padding-right: 1.2em;

    &:last-child { padding-right: 0; }
  }

  & a {
    color: #000;
    font-size: .563em;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    anchor-name: var(--anchor);

    &[aria-current] { anchor-name: var(--anchor), --nav-current; }
    &[href$='#services'] { --anchor: --nav-services; }
    &[href$='#music'] { --anchor: --nav-music; }
    &[href$='#about'] { --anchor: --nav-about; }
    &[href$='#contact'] { --anchor: --nav-contact; }
  }

  /* Browsers without anchor positioning: the same underline, with the two anchor values measured by
     site.js: --bar-widest (widest link) and --bar-left (centre of the current link). */
  @supports not (anchor-name: --a) {
    & ul::after {
      --widest: var(--bar-widest, 0px);
      left: var(--bar-left, -2999px);
    }
  }

  @media only screen and (max-width: 46.875rem) {
    top: auto;
    bottom: 0;
    left: 0;
    z-index: 5;
    width: 100%;
    height: 0;

    .player-open & { z-index: 9; }

    /* The bar hangs from a zero-height nav pinned to the bottom edge, so the fixed layer starts on a
       whole pixel. A nav as tall as the bar would start on a half pixel (the bar is 39.5px tall) and
       Firefox would draw its contents 1px lower. */
    & .site-nav__bar {
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      border-top: 1px solid #000;
      background-color: #fff;
    }

    & ul {
      max-width: 100%;
      margin: 0 auto;
      padding-top: .625rem;
      padding-bottom: .75rem;

      &::after {
        --width: calc(var(--widest) + 6px);
        bottom: .5rem;
      }
    }

    & a {
      display: inline-block;
      vertical-align: middle;
    }

    /* Home icon: collapsed while the big logo at the top is still in view. */
    & .site-nav__home {
      transition: all .2s ease-in;

      & a {
        width: 1.125rem;
        height: .875rem;
        background: url(/assets/icons/logo-nav.svg) top center no-repeat;
        transition: all .2s ease-in;
      }

      .at-top & {
        padding-right: 0;

        & a { width: 0; }
      }
    }
  }

  @media only screen and (max-width: 46.875rem) and (orientation: landscape),
         only screen and (max-width: 33.125rem) {
    z-index: 9;

    .player-open & ul::after { background: #fff; }
  }
}

/* ---------- Page sections ---------- */

.panel {
  max-width: 44.375em;
  text-align: left;
}

#intro { max-width: 54.375em; }

/* Full-viewport column, pushed to the right, content centred vertically. */
.content {
  box-sizing: border-box;
  width: 20rem;
  max-width: 100%;
  min-height: 100vh;
  margin: 0 0 0 auto;
  padding: 6.25rem .625rem;
  align-content: center;
  font-size: .875em;
  font-weight: lighter;
  line-height: 1.2em;
  transition: all .3s ease-in;

  & a,
  & strong,
  & :is(h1, h2):not(.visually-hidden) {
    color: #000;
    font-weight: bold;
    text-decoration: none;
  }

  & a:hover { text-decoration: underline; }

  & :is(h1, h2):not(.visually-hidden) { margin: 1.2em 0; }

  #intro & {
    width: 35rem;
    font-size: 1.375em;
    line-height: 1.273em;
    text-align: right;

    & p { margin: 0; }
  }

  @media only screen and (max-width: 46.875rem) {
    margin: auto;
    padding: 6.25rem .9375rem;

    #intro & {
      width: 20rem;
      font-size: .875em;
    }
  }

  @media only screen and (max-width: 20em) {
    &, #intro & { width: 100%; }
  }
}

/* Privacy policy: each topic is a <section>, separated from the previous one by a blank line.
   The blank line is a real line box so that the gap rounds to the same sub-pixel as body text does. */
.policy section + section > h2::before {
  content: '\a0';
  display: block;
  margin-bottom: 1.2em;
  font-weight: lighter;
}

.social {
  margin-top: 2.4em;

  & a {
    display: inline-block;
    height: 1.25rem;
    background: center / auto no-repeat content-box;
    vertical-align: bottom;

    &:hover { opacity: .5; }
  }

  & .linkedin {
    width: .9375rem;
    padding: 0 .375rem 0 .5625rem;
    background-image: url(/assets/icons/linkedin.svg);
    background-size: .875rem auto;
  }

  & .spotify {
    width: 1.25rem;
    padding: 0 .75rem 0 .125rem;
    background-image: url(/assets/icons/spotify.svg);
    background-size: 1.25rem auto;
  }
}

.affiliations {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  margin-top: 10px;
}

/* "Would you like to hear it?" — only offered on mobile, where the player does not open by itself. */
.hearit {
  display: none;

  @media only screen and (max-width: 46.875rem) {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin-top: 1.75rem;
    padding-right: 1.6875rem;
    background: url(/assets/icons/hearit.svg) right center no-repeat;
    color: #000;
    font-weight: bold;
    line-height: 1.625rem;
    text-align: right;

    &:hover { text-decoration: underline; }
  }
}

.site-footer {
  max-width: 44.375em;
  text-align: left;

  & p {
    box-sizing: border-box;
    width: 20rem;
    max-width: 100%;
    margin: 0 0 0 auto;
    padding: 6.25rem 0;
    transition: all .3s ease-in;

    @media only screen and (max-width: 46.875rem) { margin: auto; }
    @media only screen and (max-width: 20em) { width: 100%; }
  }

  & a {
    padding: 1.0625rem;
    color: #000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: .4375rem;
    line-height: .75rem;
    letter-spacing: .07em;
    text-decoration: none;
  }
}

/* ---------- Player ---------- */

.player {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  max-width: 14.813em;
  min-height: 100vh;
  background: #000;
  color: #fff;
  text-align: center;
  transform: translateX(100%);
  transition: all .3s ease-in;

  .player-auto &,
  .player-open & { transform: translateX(0); }

  /* On mobile the player only opens on request, never just by scrolling to Music. */
  @media only screen and (max-width: 46.875rem) {
    .player-auto & { transform: translateX(100%); }
    .player-open & { transform: translateX(0); }
  }

  @media only screen and (max-width: 33.125em) { max-width: 100%; }

  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    display: flex;
    max-width: 100%;
  }

  & a {
    display: inline-block;
    color: #fff;
    text-decoration: none;
  }
}

.player__toggle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1.625rem;
  z-index: 2;
  display: block;
  width: 1.625rem;
  height: 100%;
  background: #000 url(/assets/icons/player-handle.svg) center .375rem / .75rem 1.375rem no-repeat;
  transform: scaleX(-1);
  transition: left .3s linear;

  .player-auto &,
  .player-open & { transform: scaleX(1); }

  @media only screen and (max-width: 33.125em) {
    left: -.75rem;
    width: .75rem;
    background: #000 url(/assets/icons/player-handle-small.svg) center .3125rem / .5rem auto no-repeat;

    .player-open & { left: .75rem; }
  }

  @media only screen and (max-width: 33.125em) and (orientation: landscape) {
    .player-open & { left: .1875rem; }
  }

  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    .player-open & { left: 0; }
  }
}

.player__scroll {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 2.938em 1.875em 2.938em 0;
  overflow: auto;

  @media only screen and (max-width: 33.125em) { padding: 2.938em 2.875rem; }

  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    float: left;
    padding-bottom: 1.25rem;
    padding-left: 1.875rem;
  }
}

.player__main {
  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    float: left;
    box-sizing: border-box;
    width: 50%;
    padding-right: 2.0625rem;
    border-right: 1px solid #fff;
  }
}

.playlist {
  margin: 0;
  padding: .813em .25em;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #fff;
  list-style: none;
  text-align: left;

  & li {
    display: inline-block;
    width: 100%;
    overflow: hidden;
    font-size: .75em;
    font-weight: lighter;
    line-height: 1.125em;
    white-space: nowrap;
  }

  & a {
    width: 100%;

    &[aria-current] { font-weight: bold; }

    /* Titles too long for the row slide into view on hover: the label, at least as wide as the row,
       moves until its right edge meets the row's right edge. */
    & > span {
      position: relative;
      left: 0;
      display: inline-block;
      min-width: 100%;
      transition: all .1s cubic-bezier(.37, 0, .63, 1);
      transition-property: left, translate;
    }

    &:hover > span {
      left: 100%;
      translate: calc(-1 * round(100%, 1px));
      transition-duration: .8s;
    }
  }

  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    border-top: 0;
    border-bottom: 0;
    text-align: right;
  }
}

.player__controls {
  --margin-top: 1.75em;

  text-align: center;

  @media only screen and (max-width: 46.875em) and (orientation: landscape) { --margin-top: 2.5rem; }

  /* Invisible strut, as tall as a button with its margins and sitting on the baseline:
     it gives the row the exact height the old inline links had. */
  &::before {
    content: '';
    display: inline-block;
    height: calc(var(--margin-top) + 2.75em + 1.75em);
    overflow: hidden;
  }

  & button {
    display: inline-block;
    width: 2.75em;
    height: 2.75em;
    margin: var(--margin-top) .438em 1.75em;
    background: center / 2.625rem 2.625rem no-repeat;
    vertical-align: top;
  }

  & .prev { background-image: url(/assets/icons/prev.svg); }
  & .next { background-image: url(/assets/icons/next.svg); }
  & .play { background-image: url(/assets/icons/play.svg); }

  .is-playing & .play { background-image: url(/assets/icons/pause.svg); }
}

.player__info {
  position: relative;
  padding-top: 2.375em;
  border-top: 1px solid #fff;
  text-align: center;
  perspective: 62.5rem;

  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    float: left;
    box-sizing: border-box;
    width: 50%;
    padding-top: .9375rem;
    padding-left: 1.625rem;
    border-top: 0;
    text-align: left;
  }
}

/* Cover art: a card that flips around its vertical axis on every track change. */
.covers {
  --size: 8.25em;

  position: relative;
  display: inline-block;
  width: var(--size);
  height: var(--size);
  text-align: center;
  perspective: 31.25em;

  @media only screen and (max-width: 46.875em) and (orientation: landscape) {
    --size: 2.75rem;

    border-top: 0;
    border-bottom: 0;
  }
}

.covers__card {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transform: rotateY(360deg) translateZ(.125rem);
  transform-style: preserve-3d;
  transition: transform .3s cubic-bezier(.98, .1, .35, .74);

  &.is-flipped { transform: rotateY(180deg) translateZ(.125rem); }

  & img,
  &::before {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: calc(var(--size) / -2);
    margin-left: calc(var(--size) / -2);
  }

  & img {
    width: 100%;
    backface-visibility: hidden;
  }

  & img.is-front,
  &.is-flipped img.is-back {
    z-index: 2;
    transform: rotateY(360deg) translateZ(.125rem) perspective(12.5rem);
  }

  & img.is-back,
  &.is-flipped img.is-front {
    z-index: 2;
    transform: rotateY(180deg) translateZ(.125rem) perspective(12.5rem);
  }

  /* The white edge of the card, visible mid-flip. */
  &::before {
    content: '';
    display: inline-block;
    width: .5em;
    height: var(--size);
    margin-left: -.25em;
    background: #fff;
    transform: translateZ(-4.125em) rotateY(-90deg);
    transform-origin: .25em 4.125em 4.125em;

    @media only screen and (max-width: 46.875em) and (orientation: landscape) {
      margin-left: -.25rem;
      transform: translateZ(-1.375rem) rotateY(-90deg);
      transform-origin: .25rem 0 1.375rem;
    }
  }
}

.spinner {
  display: none;

  .is-loading & {
    position: absolute;
    z-index: 999;
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 3.0625rem 0;
    font-size: .625rem;
    text-align: center;
  }

  & span {
    display: inline-block;
    width: .375rem;
    height: 100%;
    background-color: #fff;
    animation: spinner-stretch 1.2s infinite ease-in-out;

    &:nth-child(2) { animation-delay: -1.1s; }
    &:nth-child(3) { animation-delay: -1s; }
    &:nth-child(4) { animation-delay: -.9s; }
    &:nth-child(5) { animation-delay: -.8s; }
  }
}

@keyframes spinner-stretch {
  0%, 40%, 100% { transform: scaleY(.4); }
  20% { transform: scaleY(1); }
}

.track-details {
  padding-top: 2.375em;
  clear: both;

  &::after {
    content: '';
    display: table;
    clear: both;
  }

  @media only screen and (max-width: 46.875em) and (orientation: landscape) { padding-top: .9375rem; }

  /* All tracks' details are stacked on top of each other; only the current one is opaque. */
  & dl {
    float: left;
    width: 100%;
    margin-right: -100%;
    visibility: hidden;
    opacity: 0;
    text-align: left;
    transition: opacity .2s linear, visibility .2s linear;

    &.is-current {
      visibility: visible;
      opacity: 1;
    }
  }

  & dl > div {
    display: inline-block;
    box-sizing: border-box;
    width: 100%;
    padding: .25rem 0 .25rem 3.75em;
    border-bottom: 1px solid #fff;
    font-size: .625em;
    line-height: .875rem;

    @media only screen and (max-width: 46.875em) and (orientation: landscape) {
      border-top: 0;
      border-bottom: 0;
    }
  }

  & dt {
    display: inline-block;
    min-width: 3.75em;
    margin-left: -3.75em;
  }

  & dd { display: inline; }
}

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

/* Visitors who ask their system for less motion get instant state changes: no sliding panel,
   no flipping cover, no gliding underline. The loading spinner keeps turning. */
@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after { transition-duration: 0s !important; }
}
