@font-face {
  font-family: "Tamanegi Kaisho Geki";
  src: url("../fonts/玉ねぎ楷書激無料版v7改.ttf");
  font-display: block;
  unicode-range: U+0-25B6, U+25B8-FFEF;
}

body {
  font-family: "Noto Sans JP", "Noto Sans KR", sans-serif;
}

.bg {
  background:
    linear-gradient(rgb(205 205 205 / 0.5), rgb(255 255 255 / 0.5)),
    url("../images/BAE1M.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: fixed;
  top: var(--header-height);
  width: 100vw;
  height: calc(100vh - var(--header-height));
  z-index: -69;
}

.squeaks {
  grid-area: squeaks;
  justify-self: center;
  padding-inline: 1rem;
  position: sticky;
  bottom: 4rem;
  text-align: center;
  transform: rotate(-45deg);
  z-index: 1;

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

  img {
    width: 5rem;
  }

  label {
    background-color: white;
    border: 0.2em solid white;
    border-radius: 5px;
    font-size: clamp(0.3rem, 1vmin, 0.7rem);
    font-weight: 500;
  }
}

@media (hover: hover) {
  .squeaks:hover {
    transform: scale(1.2);
  }
}

main {
  display: grid;
  grid-template-rows: min-content auto min-content min-content;
  grid-template-areas:
    "header"
    "timeline"
    "footer"
    "squeaks";
}

.timeline__header {
  grid-area: header;

  display: grid;
  grid-template-columns: minmax(1rem, 1fr) minmax(20rem, 6fr) minmax(1rem, 1fr);
  grid-template-rows: min-content min-content;
  grid-template-areas:
    "... filters ..."
    "... baetag ...";
}

#timeline__filters {
  grid-area: filters;

  summary {
    background-color: rgb(255 190 0);
    border: 5px solid #00144b;
    box-shadow: 2px 1px black;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 2;
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding-inline: 1rem;
    width: fit-content;
    float: right;
  }

  @media (hover: hover) {
    summary:hover {
      background-color: lightgrey;
    }
  }

  #timeline__typefilter {
    border: 0.5rem solid white;
    border-radius: 1rem;
    padding: 1rem;
    width: 100%;

    legend {
      background-color: #11ddee;
      border: 5px solid #00144b;
      box-shadow: 2px 1px black;
      padding-inline: 1rem;

      font-size: 1.5rem;
      font-weight: 700;
      line-height: 2;
    }
  }
}

.event_type_pill {
  display: inline-flex;
  --pill-font-size: 1.5rem;
  background-color: #fb46ce;
  cursor: pointer;
  border: 5px solid #00144b;
  box-shadow: 2px 1px black;
  margin: 0.5rem;
  font-size: var(--pill-font-size);
  font-weight: 600;
  padding-inline: 0.5rem;

  color: black;
  text-align: center;
  width: fit-content;

  border: 5px solid #00144b;
  box-shadow: 2px 1px black;

  input[type="checkbox"] {
    appearance: none;
    background-color: inherit;
    margin: 0;
    font: inherit;
    width: var(--pill-font-size);
    height: var(--pill-font-size);
    border: 0.15em solid black;
    border-radius: 0.15em;
    margin-top: 0.3rem;
    display: grid;
    place-content: center;
  }

  input[type="checkbox"]::before {
    content: "";
    width: 0.65rem;
    height: 0.65rem;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: black;
  }

  input[type="checkbox"]:checked::before {
    transform: scale(1);
  }

  span {
    display: inline-block;
    width: fit-content;
    text-align: left;
    margin-inline: 0.5rem;
  }
}

@media (hover: hover) {
  .event_type_pill:hover {
    background-color: lightgrey;
  }
}

.baetag {
  grid-area: baetag;
  display: grid;
  grid-template-columns: 2fr 1fr 2fr;
  grid-template-areas: "... baetag_img ...";
  align-items: center;
  justify-content: center;
  position: relative;
  margin-top: 1rem;

  >img {
    grid-area: baetag_img;
    width: 100%;
    height: auto;
    justify-self: center;
    position: relative;
  }

}

.baetag::before {
  content: "";
  height: 100%;
  position: absolute;
  align-self: center;
  justify-self: center;
  top: 50%;
  width: 0.5rem;
  background: white;
}

#timeline {
  grid-area: timeline;
  font-family: "Noto Sans JP", "Noto Sans KR", sans-serif;
}

.timeline__event {
  display: grid;
  grid-auto-flow: dense;
  grid-template-columns: minmax(1rem, 1fr) minmax(20rem, 3fr) 4rem minmax(20rem, 3fr) minmax(1rem, 1fr);
  grid-template-rows: 2rem auto 2rem;
  grid-template-areas:
    "... ... marker ... ..."
    "... left marker right ..."
    "... ... marker ... ...";
  column-gap: 2rem;
  scroll-margin-top: var(--header-height);

  .aussie {
    transform: scale(-1);
    text-align: left !important;
  }

  .timeline__info {
    grid-area: left;
    display: grid;
    justify-self: end;
    align-content: center;
    text-align: right;

    .timeline__text {
      background-color: white;
      padding: 2rem;
    }
  }

  .timeline__media {
    grid-area: right;
    justify-self: start;
    align-content: center;
    text-align: left;
    width: 100%;

    img {
      width: 100%;
      height: auto;
      border: 5px solid #00144b;
      box-shadow: 2px 1px black;

      &::before {
        content: "";
        position: absolute;
        top: 0px;
        right: 0px;
        bottom: 0px;
        left: 0px;
        border-width: 1px;
        border-style: solid;
        border-color: #ff144b #00ffff #00ffff #ff144b;
      }
    }

    .event-img {
      cursor: pointer;
    }
  }

  .timeline__marker {
    grid-area: marker;
    grid-template-rows: auto 4rem auto;
    grid-template-areas: "... icon ...";
    justify-content: center;
    align-items: center;
    display: flex;
    position: relative;

    event-marker {
      grid-area: icon;
      display: block;
      width: 4rem;
      height: 4rem;
      background-color: white;
      border: 0.5rem solid white;
      border-radius: 100%;

      .highlight {
        transform: translateY(0.1rem);
      }
    }
  }

  .timeline__marker::before {
    content: "";
    height: 100%;
    position: absolute;
    align-self: center;
    justify-self: center;
    width: 0.5rem;
    background: white;
    z-index: -1;
  }

  @media (hover: hover) {
    .timeline__marker:hover {
      event-marker {
        transform: scale(1.2);
        box-shadow: 2px 1px black;
      }
    }
  }

  .timeline__dateline {
    position: relative;
    justify-self: start;
    background-color: #11ddee;
    padding-inline: 1rem;
    text-align: center;
    font-size: clamp(0.8rem, 1.5vmin, 1.2rem);
    font-weight: 700;
    left: 0;
    top: 1rem;
    z-index: 1;
  }

  .timeline__title {
    font-family: "Edo SZ", "Tamanegi Kaisho Geki", "Noto Serif KR", serif;
    font-size: clamp(2rem, 2.5vmin, 3rem);
  }

  .timeline__subtitle {
    font-family: "Noto Sans JP", "Noto Sans KR", sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vmin, 1.5rem);
    margin-bottom: 0.5rem;
  }

  .timeline__collablist {
    list-style: none;
    padding-inline-start: 0px;
    font-size: clamp(0.8rem, 1.5vmin, 1rem);

    li {
      display: inline;
    }

    li:before {
      content: " ";
    }
  }

  .timeline__event_type {
    position: relative;
    justify-self: end;
    right: 0;
    bottom: 1rem;
    background-color: #fb46ce;
    padding-inline: 1rem;
    text-align: center;
    font-size: clamp(0.8rem, 1.5vmin, 1.2rem);
    font-weight: 600;
    z-index: 1;
  }
}

.timeline__event:nth-child(2n) {
  .timeline__info {
    grid-area: right;
    justify-self: start;
    text-align: left;
  }

  .timeline__media {
    grid-area: left;
    justify-self: end;
    text-align: right;
  }
}

@media only screen and (max-width: 42rem),
only screen and (-webkit-min-device-pixel-ratio: 2.5) {
  .timeline__header {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "... filters ...";
    column-gap: 1rem;
  }

  #timeline__filters fieldset {
    margin-bottom: 2rem;
  }

  .timeline__event {
    grid-template-columns: auto 4rem 1fr auto;
    grid-template-rows: auto auto 4rem;
    grid-template-areas:
      "... line info ..."
      "... line media ..."
      "... line ... ...";
    column-gap: 1rem;

    .aussie {
      text-align: right !important;
    }

    .timeline__info {
      width: 100%;
      word-break: break-word;
      grid-area: info;
      align-items: start;
      justify-self: start;
      text-align: left;
    }

    .timeline__dateline {
      min-width: 30vw;
      height: auto;
    }

    .timeline__event_type {
      min-width: 30vw;
      height: auto;
    }

    .timeline__media {
      grid-area: media;
      align-items: start;
      justify-self: start;
      text-align: left;
    }

    .timeline__marker {
      grid-area: line;
      display: grid;
      align-items: start;
      justify-self: center;
    }
  }

  .timeline__event:nth-child(2n) {
    .timeline__info {
      grid-area: info;
      justify-self: start;
      text-align: left;
    }

    .timeline__media {
      grid-area: media;
      justify-self: start;
      text-align: left;
    }
  }

  .baetag {
    display: none;
  }

  .squeaks {
    bottom: 2rem;
    justify-self: start;
    transform: rotate(45deg);

    img {
      transform: scaleX(-1);
    }
  }
}

.chaos_border {
  border: 5px solid #00144b;
  box-shadow: 2px 1px black;

  &::before {
    content: "";
    position: absolute;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
    border-width: 1px 2px;
    border-style: solid;
    border-color: #000ebf #fa144b #fa144b #000ebf;
  }

  /* Making the children position: relative; ensures that they go on top of the ::before pseudo-element
   * and don't get interactions blocked */
  >* {
    position: relative;
  }
}

.chaos_angle {
  transform: rotate(358.2deg);
}

.timeline__event:nth-child(6n+2) .chaos_angle {
  transform: rotate(356.9deg);
}

.timeline__event:nth-child(6n+3) .chaos_angle {
  transform: rotate(-359.9deg);
}

.timeline__event:nth-child(6n+4) .chaos_angle {
  transform: rotate(-358.9deg);
}

.timeline__event:nth-child(5n+2) .chaos_angle {
  transform: rotate(-357.9deg);
}

.timeline__event:nth-child(5n+3) .chaos_angle {
  transform: rotate(359.9deg);
}

.timeline__event:nth-child(5n+4) .chaos_angle {
  transform: rotate(357.9deg);
}
