/**
 * Custom Properties
 */
:root {
  --fl-color__green--darker: #003922;
  --fl-color__green--dark: #004F2F;
  --fl-color__green: #559234;
  --fl-color__green--light: #81c060;
  --fl-color__green--lighter: #a1dd81;

  --fl-color__green--dark--semitransparent: #004F2Fef;

  --fl-color__cream: #f6efd8;
  --fl-color__brown: #816040;
  --fl-color__blue: #387AA8;
  --fl-color__orange: #CC4C28;

  --fl-font__family: "sofia-pro", Futura, Helvetica, Arial, sans-serif;
  --fl-line-height: 1.6;

  --fl-header__height: 3.9375rem;
  @media (min-width: 550px) {
    --fl-header__height: 5rem;
  }
}

@-webkit-keyframes fade-in {
  from {
    visibility: visible;
    opacity: 0;
    height: auto;
  }
  to {
    visibility: visible;
    opacity: 1;
  }
}

@keyframes fade-in {
  from {
    visibility: visible;
    opacity: 0;
    height: auto;
  }
  to {
    visibility: visible;
    opacity: 1;
  }
}

@-webkit-keyframes fade-out {
  0% {
    visibility: visible;
    opacity: 1;
  }
  90% {
    opacity: 0;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes fade-out {
  0% {
    visibility: visible;
    opacity: 1;
  }
  90% {
    opacity: 0;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

/**
 * Base Styles
 */
* {
  box-sizing: border-box;

  &:focus {
    outline: 2px solid var(--fl-color__green);
    outline-offset: 2px;
  }
}

html,
body {
  scroll-behavior: smooth;
  -ms-scroll-snap-type: y mandatory;
  scroll-snap-type: y mandatory;
}

body {
  font-family: var(--fl-font__family);
  line-height: var(--fl-line-height);
  color: #111;
  background-color: #f5f5f5;
}

img {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 500;
  line-height: 1.3;
}

/**
 * Header
 */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 1em 2em;
  border-bottom: 2px solid #ddd;
  font-size: 0.6875rem;
  background-color: #fffb;
  /* Making sure light green trees in logo don't get lost */
  background-image: linear-gradient(to right, #fff 0, #fff5 200px, #fff0 400px);
  -webkit-backdrop-filter: blur(0.5rem);
          backdrop-filter: blur(0.5rem);
  @media (min-width: 440px) {
    font-size: 0.75em;
  }
  @media (min-width: 550px) {
    gap: 3em;
    font-size: 0.875em;
  }
  @media (update: slow) {
    background: #fff;
    -webkit-backdrop-filter: none;
            backdrop-filter: none;
  }
}

.header__logo {
  max-width: 13em;
  /* Align baseline with logo's baseline */
  transform: translateY(0.25em);
  @media (min-width: 550px) {
    max-width: 15em;
  }
}

.header__title {
  font-size: 2em;
  line-height: 1.2;
}

.header__donate {
  display: inline-block;
  padding: 0.5em 1.25em;
  border-radius: 1.5em;
  color: #fff;
  background: var(--fl-color__green--dark);
  text-decoration: none;
  @media (min-width: 700px) {
    padding: 0.75em 2em;
  }


  &:hover,
  &:focus {
    background: var(--fl-color__green--darker);
  }
}

/**
 * Environment Styles
 */
.environment-list {
  display: flex;
  flex-direction: column;
  list-style: 0;
  margin: 0;
  padding: 0;
}

.environment-list__item {
  --surface__background: #051b12;

  position: relative;
  z-index: 0;
}

/**
 * Media Preferences & Header controls
 */
.media-preferences {
  --select__padding-inline: 0.5em;

  position: -webkit-sticky;

  position: sticky;
  bottom: 0;
  z-index: 0;
  display: block;
  padding-inline: 0.5em;
  transform: translateY(calc(var(--text-block__padding-bottom)));
  color: var(--fl-color__cream);
  margin-inline: calc(var(--text-block__padding-inline) * -1);
  @media (min-width: 700px) {
    padding: 0 var(--text-block__padding-inline);
  }

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    display: block;
    background: var(--fl-color__green--darker);
  }

  label,
  select {
    @media (min-width: 1000px) {
      font-size: 0.875em;
    }
  }

  label {
    display: block;
    font-weight: 700;
    text-align: center;
  }

  li:has(> [disabled]) {
    opacity: 0.5;
  }
}

.media-preferences__blurb {
  display: none;
  padding-top: 0.75em;
  padding-inline: 1em;
  @media (min-width: 700px) {
    padding-inline: 0;
  }
}

.media-preferences__list,
.header__control-list {
  --icon__size: 1.5em;

  margin: 0;
  padding: 0;
  list-style: none;
}

.media-preferences__list {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: 1em;
  margin-right: 1em;
  padding-block: 0.75em;
  font-size: 0.875em;
  /* Apparently has mixed support */
  @supports (justify-content: end) {
    justify-content: end;
  }
  @media (min-width: 1000px) {
    font-size: 1em;
    gap: 2em;
  }

  > li {
    padding: 0.75em 0;
  }

  ul {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    margin: 0;
    padding: 0 0 0 1em;
    border-left: 3px solid #0003;
    list-style: none;

    label {
      text-align: left;
    }
  }
}

.header__control-list {
  display: flex;
  gap: 1em;
  margin-left: auto;
}

.header__control-list-item {
  border-radius: calc(2em + var(--icon__size));
  background: #00000015;
  color: #666;
  &:has(input[checked]) {
    color: #555;
  }

  label:has(input[type="checkbox"]) {
    box-sizing: content-box;
    display: block;
    padding: 0.5em 1em;
    width: var(--icon__size);
    height: var(--icon__size);
    border-radius: calc(2em + var(--icon__size));

    &[for] {
      outline-offset: -2px;
    }
  }
}

.header__control-list-item--audio {
  --volume__width: 7em;

  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.5em;
  align-items: center;
  width: calc(var(--icon__size) + 2em);
  padding-left: calc(var(--icon__size) + 2em);
  overflow: hidden;
  @media (min-width: 700px) {
    transition: width 0.25s ease-in-out;
  }

  label:has(input[type="checkbox"]) {
    margin-right: -0.75em;
  }

  &:has(input:checked) {
    @media (min-width: 700px) {
      width: calc(var(--icon__size) + var(--volume__width) + 3.25em);
    }
  }
}

[for="header-control__mute"] {
  position: absolute;
  top: 50%;
  z-index: 1;
  left: calc(var(--icon__size) / 2);
  transform: translate(calc(var(--icon__size) / -2), -50%);
}

[id="header-control__volume"] {
  position: absolute;
  top: 50%;
  left: calc(var(--icon__size) + 2em);
  z-index: 0;
  width: var(--volume__width);
  border-radius: 0.5em;
  transform: translateY(-50%);
  -webkit-animation: fade-out 0.25s forwards;
          animation: fade-out 0.25s forwards;

  .header__control-list-item--audio:has(input:checked) & {
    display: block;
    -webkit-animation: fade-in 0.25s forwards;
            animation: fade-in 0.25s forwards;
  }
}

.header-control__label {
  display: block;
  height: 0;
  text-indent: -9999em;
}

/* Checkboxes */
.media-preferences label:has([type="checkbox"]),
.header__control-list label:has([type="checkbox"]) {
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;

  /* Replacing checkbox with graphic */
  &::before,
  &::after {
    content: '';
    display: block;
    width: var(--icon__size);
    height: var(--icon__size);
    margin-inline: auto;
    background-color: currentColor;
    -webkit-mask-size: contain;
            mask-size: contain;
  }

  /* Using after element to preload other icon and avoid flashing */
  &::after {
    position: absolute;
    top: -9999em;
    left: -9999em
  }

  .checked {
    display: none;
  }

  &:has(:checked) {
    .checked {
      display: inline;
    }

    .unchecked {
      display: none;
    }
  }

  &:hover,
  &:focus,
  &:focus-within {
    outline: 2px solid var(--fl-color__green);
    outline-offset: 2px;
  }
}

.media-preferences label:has([type="checkbox"]) {
  position: relative;
  padding: 0.25em 0.5em;
  border-radius: 4px;
}

label[for="media-preferences__audio"],
label[for="header-control__mute"] {
  &::before {
    -webkit-mask-image: url(../media/icons/speaker-simple-slash.svg);
            mask-image: url(../media/icons/speaker-simple-slash.svg);
  }

  &::after,
  &:has(:checked)::before {
    -webkit-mask-image: url(../media/icons/speaker-simple.svg);
            mask-image: url(../media/icons/speaker-simple.svg);
  }
}

label[for="media-preferences__video"],
label[for="header-control__video"] {
  &::before {
    -webkit-mask-image: url(../media/icons/video-slash.svg);
            mask-image: url(../media/icons/video-slash.svg);
  }

  &::after,
  &:has(:checked)::before {
    -webkit-mask-image: url(../media/icons/video.svg);
            mask-image: url(../media/icons/video.svg);
  }
}

/* Selects */
.media-preferences select {
  background: transparent;
  padding: 0.25em var(--select__padding-inline);
  border: 0;
  border-bottom: 2px solid #aaa;
  color: inherit;
  font-family: inherit;
  font-weight: inherit;
  transition: background-color 0.25s;

  &:focus {
    border-bottom-color: var(--fl-color__green);
    background: var(--fl-color__green--dark);
  }
}

.media-preferences option {
  &:checked {
    background: var(--fl-color__green);
    color: #fff;
  }

  &:hover,
  &:focus {
    background: var(--fl-color__green--darker);
  }
}

/**
 * Control Buttons
 */
.control-button {
  border: 0;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}

.control-button--next,
.control-button--previous {
  position: absolute;
  bottom: 1.25em;
  left: 50%;
  border-radius: 50%;
  width: 2.5em;
  aspect-ratio: 1 / 1;
  text-indent: -9999em;
  background-color: #fff3;
  transform: translateX(-50%);
  @media (min-height: 800px) {
    width: 3em;
  }
  @supports (top: 100dvh) {
    top: calc(100dvh - 2.5em - 1.25em);
    bottom: auto;

  }
  transition: background-color 0.25s;
  @media (min-height: 800px) {
    font-size: 1.25em;
  }

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: #fff8;
    -webkit-mask-image: url(../media/icons/arrow-down.svg);
            mask-image: url(../media/icons/arrow-down.svg);
    -webkit-mask-size: 75% auto;
            mask-size: 75% auto;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center center;
            mask-position: center center;
  }

  &:hover,
  &:focus {
    background-color: #fff6;

    &::before {
      background-color: #fff9;
    }
  }
}

.control-button--previous::before {
  transform: rotate(180deg);
}


/**
 * Environemnts
 */
.environment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: var(--fl-header__height) 0 3em;
  background: var(--surface__background);
  background-image: var(--surface__background-image);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  scroll-snap-align: start;

  &:nth-child(even) {
    --surface__background: #03130c;
  }
}

.environment--intro,
.environment--explore {
  padding-right: 0;
  background-color: #41512d; /* Sampled from photo as a reasonable base */
  background-image: url(../media/images/20240422_Henry_Cowell_Trails_Rx_Orenda_Randuch-03-1--h800.jpg);
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: cover;
  @media (min-height: 800px) {
    background-image: url(../media/images/20240422_Henry_Cowell_Trails_Rx_Orenda_Randuch-03-1--h1000.jpg);
  }
  @media (orientation: landscape) {
    background-image: url(../media/images/20240422_Henry_Cowell_Trails_Rx_Orenda_Randuch-03-1--w1000.jpg);
    @media (min-width: 1000px) {
      background-image: url(../media/images/20240422_Henry_Cowell_Trails_Rx_Orenda_Randuch-03-1--w1200.jpg);
    }
    @media (min-width: 1200px) {
      background-image: url(../media/images/20240422_Henry_Cowell_Trails_Rx_Orenda_Randuch-03-1--w1600.jpg);
    }
  }
}

/**
 * Environment sub-components
 */
.environment__video {
  position: absolute;
  z-index: -1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
}

.environment__text-block {
  --border-top__width: 0.5rem;
  --text-block__padding-inline: 2em;
  --text-block__padding-bottom: 2.5em;
  --text-block__height-offset: 7rem;

  position: relative;
  z-index: 0;
  max-width: 90%;
  max-height: calc(100vh - var(--fl-header__height) - var(--text-block__height-offset));
  overflow-y: auto;
  margin-bottom: 1em;
  padding-top: calc(1.5em - var(--border-top__width));
  padding-inline: var(--text-block__padding-inline);
  padding-bottom: var(--text-block__padding-bottom);
  border-top: 0.5rem solid var(--fl-color__green--darker);
  font-size: 1rem;
  color: var(--fl-color__cream);
  background-color: var(--fl-color__green--dark--semitransparent);
  @supports(max-height: 100dvh) {
    max-height: calc(100dvh - var(--fl-header__height) - var(--text-block__height-offset));
    @media (min-height: 800px) {
      --text-block__height-offset: 7rem;
      max-height: calc(100dvh - var(--fl-header__height) - 7rem);
    }
  }
  @media (min-height: 800px) {
    margin-bottom: 0;
  }

  @media (min-width: 1000px) and (min-height: 1000px) {
    max-width: 40em;
    font-size: 1.25rem;
  }

  a {
    color: inherit;
    -webkit-text-decoration-color: var(--fl-color__green);
            text-decoration-color: var(--fl-color__green);

    &:hover,
    &:focus {
      text-decoration-thickness: 2px;
      -webkit-text-decoration-color: var(--fl-color__green--light);
              text-decoration-color: var(--fl-color__green--light);
    }
  }

  .environment--intro & {
    max-width: 100%;
    @media (min-width: 650px) {
      max-width: 50em;
    }
    @media (min-width: 650px) and (min-height: 800px) {
      max-width: 40em;
    }
  }
}

.environment__title {
  font-size: 1.75em;
  margin: 0 0 0.375em;
  padding: 0;
  font-weight: 500;

  .environment--intro & {
    font-size: 2em;
    @media (min-width: 700px) and (min-height: 800px) {
      font-size: 2.5em;
    }
  }

  span {
    color: var(--fl-color__green--lighter);
  }
}

.environment__subtitle {
  font-size: 1.125em;
  line-height: 1.3;
  margin-bottom: 1rem;
  font-weight: 500;
  @media (min-width: 700px) and (min-height: 800px) {
    font-size: 1.25em;
    margin-bottom: 1.75em;
  }
}

.environment__copy {
  > :first-child {
    margin-top: 0;
  }

  > :last-child {
    margin-bottom: 0;
  }
}

.explore__list {
  font-size: 1.125em;
  list-style: none;
  margin: 0;
  padding: 0.75em 0 0 2em;

  > li {
    position: relative;
    margin: 0 0 0.75em;

    &::before {
      content: '';
      position: absolute;
      top: 0.125em;
      left: -1.75em;
      display: block;
      width: 1.5em;
      aspect-ratio: 1 / 1;
      background-color: var(--fl-color__green--light);
      -webkit-mask-image: url('../media/icons/plus-circle.svg');
              mask-image: url('../media/icons/plus-circle.svg');
      -webkit-mask-repeat: no-repeat;
              mask-repeat: no-repeat;
      -webkit-mask-size: contain;
              mask-size: contain;
      transition: background-color 0.25s;
    }
  }

  > li:has(a:hover, a:focus)::before {
    background-color: #fff;
  }

  a {
    text-decoration: none;
    box-shadow: 0 1px 0 0 var(--fl-color__green--light);
    transition: box-shadow 0.25s;

    &:hover,
    &:focus {
      box-shadow: 0 2px 0 0 var(--fl-color__green--lighter);
    }
  }
}

.footer {
  --logo__width: 8.125em;
  --text-column__max-width: 34em;
  --container__padding-inline: 1em;

  display: flex;
  flex-direction: column;
  gap: 2em;
  padding: var(--fl-header__height) var(--container__padding-inline) 0;
  overflow: hidden;
  color: var(--fl-color__cream);
  background-color: var(--fl-color__green--dark);
  scroll-snap-align: start;
  @media (min-width: 800px) {
    --container__padding-inline: 2em;
    display: grid;
    gap: 0 3em;
    grid-template-columns: repeat(2, minmax(0, var(--text-column__max-width)));
  }
  @media (min-width: 1000px) {
    --container__padding-inline: 3em;

    grid-template-columns: var(--logo__width) repeat(2, minmax(0, 34em));
    justify-content: center;
    gap: 0 3em;
  }

  ul,
  li {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  ul {
    display: flex;
    flex-wrap: wrap;
    gap: 2em;
  }

  a {
    color: inherit;
    -webkit-text-decoration-color: var(--fl-color__green--light);
            text-decoration-color: var(--fl-color__green--light);
  }
}

.footer__logo-wrapper {
  max-width: var(--logo__width);
  @media (min-width: 700px) {
    grid-column: 1 / -1;
  }
  @media (min-width: 1000px) {
    grid-column: span 1;
  }
}

.footer__about,
.footer__donation {
  max-width: var(--text-column__max-width);
}

.footer__about__links[class] {
  font-weight: 500;

  li + li {
    border-left: 1px solid #fff;
    padding-left: 2em;
  }

  a {
    -webkit-text-decoration-color: transparent;
            text-decoration-color: transparent;

    &:hover,
    &:focus {
      -webkit-text-decoration-color: var(--fl-color__green--light);
              text-decoration-color: var(--fl-color__green--light);
    }
  }
}

.footer__about__logos {
  align-items: center;
  max-width: 25em;
  @media (min-width: 700px) {
    justify-content: space-between;
  }

  li {
    display: flex;
    align-items: center;
    max-width: 5em;

    &:last-child {
      max-width: 7em;
    }
  }
}

.footer-donate-now-button[class] {
  display: block;
  padding: 0.5em 1.5em;
  border-radius: 2.5em;
  text-transform: uppercase;
  color: var(--fl-color__green--dark);
  background: #fff;
  text-decoration: none;

  &:hover,
  &:focus {
    background: transparent;
    color: #fff;
    box-shadow: inset 0 0 0 2px #fff;
  }
}

.footer__social-links {
  &[class] {
    gap: 1em;
  }

  a {
    &:hover,
    &:focus {
      color: var(--fl-color__green--lighter);
    }
  }

  svg {
    width: 2em;
    aspect-ratio: 1 / 1;
  }

  path {
    fill: currentColor;
  }
}

.footer__bottom {
  position: relative;
  z-index: 0;
  grid-column: 1 / -1;
  justify-self: stretch;
  justify-content: center;

  &[class] {
    gap: 1em 2em;
  }

  /* Using pseudo element for background so it's full screen width at very large screen sizes */
  &:before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    z-index: -1;
    display: block;
    width: 100vw;
    background-color: var(--fl-color__green--darker);
    transform: translateX(-50%);
  }

  &[class][class] {
    margin-top: 3em;
    margin-inline: calc(var(--container__padding-inline) * -1);
    padding: 1.5em var(--container__padding-inline) 1.5em;
  }

  a {
    -webkit-text-decoration-color: transparent;
            text-decoration-color: transparent;

    &:hover,
    &:focus {
      -webkit-text-decoration-color: var(--fl-color__green--light);
              text-decoration-color: var(--fl-color__green--light);
    }
  }
}

.mobile-sound-message {
  --left-bar__width: 3.5em;

  position: fixed;
  z-index: 100;
  top: calc(var(--fl-header__height) + 1em);
  inset-inline: 0.5em;
  padding: 0.75em 1.5em;
  padding-left: calc(var(--left-bar__width) + 1.5em);
  overflow: hidden;
  font-size: 0.875em;
  border-radius: 0.5rem;
  background: var(--fl-color__cream);
  @media (min-width: 500px) {
    inset-inline: 1.5em;
  }
  @media (min-width: 800px) {
    display: none;
  }

  .nojs &,
  [data-closed] {
    display: none;
  }

  &::before {
    content: '';
    position: absolute;
    inset-block: 0;
    left: 0;
    width: var(--left-bar__width);
    background-color: var(--fl-color__green--light);
  }

  &::after {
    --icon__image: url(../media/icons/headphones.svg);
    content: '';
    position: absolute;
    top: 50%;
    left: calc(var(--left-bar__width) / 2);
    display: block;
    width: calc(var(--left-bar__width) * 0.7);
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    background-color: var(--fl-color__green--dark);
    -webkit-mask-image: var(--icon__image);
            mask-image: var(--icon__image);
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center center;
            mask-position: center center;
  }

  ul {
    margin: 0.25em 0;
    -webkit-padding-start: 1.5em;
            padding-inline-start: 1.5em;
  }

  &.fade-in {
    -webkit-animation: fade-in 0.5s ease-in-out forwards;
            animation: fade-in 0.5s ease-in-out forwards;
  }

  &.fade-out {
    -webkit-animation: fade-out 0.5s ease-in-out forwards;
            animation: fade-out 0.5s ease-in-out forwards;
  }
}

.mobile-sound-message__close {
  position: absolute;
  top: 0;
  right: 0;
  display: block;
  width: 2em;
  aspect-ratio: 1 / 1;
  border: 0;
  background: currentColor;
  -webkit-mask-image: url(../media/icons/x.svg);
          mask-image: url(../media/icons/x.svg);
  -webkit-mask-size: 50%;
          mask-size: 50%;
  -webkit-mask-position: center center;
          mask-position: center center;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  cursor: pointer;
  text-indent: -9999em;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}

/**
 * Utilities
 */

.visually-hidden,
.visually-hidden--focusable:not(:focus):not(:focus-within) {
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;

  &:not(caption) {
    position: absolute !important;
  }

  * {
    overflow: hidden !important;
  }
}
