/* Resets */

html {
  box-sizing: border-box;
}

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

button {
  display: block;
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: currentColor;
  cursor: pointer;
}

/* Body */

body {
  margin: 0;
  opacity: 1;
  transition: opacity 300ms linear;
}

body.js-loading {
  opacity: 0;
}

/* Fonts */

.ff-body {
  font-family: "Permanent Marker", cursive;
  text-transform: uppercase;
  line-height: 1;
}

/* Page and controls */

.page {
  --box-animation-length: 4s;
  --box-size: 55vh;
  --lip-thickness: calc(var(--box-size) * 0.01);
  --box-size-bordered: calc(var(--box-size) + (var(--lip-thickness) * 2));
  position: relative;
  height: 100vh;
  width: 100vw;
  background: linear-gradient(to bottom, #b7eaff 0%, #94dfff 100%);
  align-items: flex-end;
  justify-content: space-around;
  overflow: clip;
  transform: translateZ(0px);

  @media (width < 720px) {
    --box-size: 75vw;
  }
}

.page[data-box-state="about"] {
  .box {
    left: calc(50vw - (var(--box-size-bordered) / 2));
    top: calc(50vh - (var(--box-size-bordered) / 2));
    transform: rotateX(0deg) rotateY(180deg) rotateZ(0deg) scale(130%);

    @media (width < 720px) {
      transform: rotateX(0deg) rotateY(180deg) rotateZ(0deg) scale(120%);
    }
  }

  .box__panel--floor {
    filter: brightness(100%);
  }
}

.page[data-box-state="location"] {
  .box__pizza-wrapper,
  .box__pizza-shadow-wrapper {
    display: none;
  }

  .box__nihon {
    display: block;
  }

  .box__lid--inside {
    display: none;
  }

  .box__lid--inside-location {
    display: flex;
  }

  .social {
    transform: translateY(-25vh);
  }

  .box[data-open-box="true"] {
    .box__nihon-arrow-wrapper {
      scale: 1 1 1;
    }
  }
}

.box[data-open-box="true"] {
  .box__lid {
    transform: rotateX(90deg) rotateY(0deg) rotateZ(0deg);

    @media (width < 720px) {
      transform: rotateX(115deg) rotateY(0deg) rotateZ(0deg);
    }
  }
}

/* Box and pizza */

.box {
  --panel-height: -12cqh;
  --flap-height: -11cqh;
  position: absolute;
  left: 15vw;
  top: 45vh;
  container: box / size;
  width: var(--box-size-bordered);
  height: var(--box-size-bordered);
  transform-style: preserve-3d;
  backface-visibility: visible;
  transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
  /* transform: rotateX(60deg) rotateY(0deg) rotateZ(-90deg); */

  @media (width < 720px) {
    left: 20vw;
    top: 55vh;
    transform: rotateX(45deg) rotateY(0deg) rotateZ(-25deg);
  }
}

.box__pizza-shadow-wrapper {
  position: absolute;
  inset: 0px;
  padding: 12cqi;
  transform: translateZ(-7.9cqi);
  animation:
    box-pizza-shadow-scale 1.5s ease-in-out infinite alternate,
    box-pizza-rotate 10s linear infinite;
}

.box__pizza-shadow {
  width: 100%;
  height: 100%;
  filter: blur(2cqi) brightness(0%) opacity(50%);
}

.box__pizza-wrapper {
  position: absolute;
  inset: 0px;
  padding: 12cqi;
  animation:
    box-pizza-hover 1.5s ease-in-out infinite alternate,
    box-pizza-rotate 10s linear infinite;
}

.box__pizza {
  width: 100%;
  height: 100%;
}

.box__nihon {
  display: none;
  position: absolute;
  left: -40%;
  top: 0px;
  width: 150%;
  height: 150%;
  animation: box-nihon-hover 1.5s ease-in-out infinite alternate;

  .box-nihon__kochi {
    position: absolute;
    inset: 0px;
    color: #c16e43;
  }
}

.box__nihon-arrow-wrapper {
  /* display: none; */
  position: absolute;
  left: -40%;
  top: 0;
  width: 150%;
  height: 150%;
  transform-style: preserve-3d;
  transform: rotateX(-90deg);
  scale: 0 0 0;
  transition: scale 150ms ease-in-out;
  pointer-events: none;
}

.box-nihon__arrow {
  position: absolute;
  inset: 0px;
  color: #c16e43;
  transform-style: preserve-3d;
  transform: translateY(-5%) rotateY(-45deg) scale(0.5);
}

/* Lid and menu */

.box__lid {
  position: relative;
  top: var(--lip-thickness);
  left: var(--lip-thickness);
  container: box-lid / size;
  width: var(--box-size);
  height: var(--box-size);
  pointer-events: none;
  transform-style: preserve-3d;
  transform-origin: top left;
  transition:
    transform 300ms ease-in-out,
    background 300ms ease-in-out;
  transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
}

.box__lid--outside {
  position: absolute;
  inset: 0;
  background: white;
  border: 0.5cqh #bbb solid;
  display: flex;
  padding: 7cqi;
  text-align: center;
  align-items: center;
  justify-content: center;
  transform: translateZ(0px);

  img {
    width: 100%;
    border-radius: 100%;
    transition: opacity 150ms ease-in;
  }
}

.box__lid--inside {
  position: absolute;
  inset: 0;
  background: #c16e43;
  padding-left: 16cqi;
  padding-right: 6cqi;
  padding-top: 16cqi;
  padding-bottom: 4cqi;
  transform: translateZ(-1px) rotateX(180deg);

  @media (width < 720px) {
    padding: 12cqi;
    padding-right: 8cqi;
    padding-bottom: 6cqi;
  }
}

.box__lid--inside-location {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  position: absolute;
  inset: 0;
  background: #c16e43;
  padding-left: 16cqi;
  padding-right: 6cqi;
  padding-top: 16cqi;
  padding-bottom: 4cqi;
  transform: translateZ(-1px) rotateX(180deg);

  @media (width < 720px) {
    padding: 12cqi;
    padding-right: 8cqi;
    padding-bottom: 6cqi;
  }

  h1 {
    margin-top: 0;
    margin-bottom: 6cqi;
    font-size: 15cqi;
    color: #f7f2e0;
  }

  p {
    margin-block: 3cqi;
    font-size: 8cqi;
    color: #f7f2e0;
  }

  .linklist__link {
    font-size: 12cqi;
    align-self: flex-end;
    color: #f7f2e0;
  }
}

.logo {
  margin-bottom: 8cqi;

  img {
    width: 100%;
  }
}

.linklist {
  color: #f7f2e0;

  &:has(.linklist__link:hover) {
    color: #f7f2e0b2;
  }
}

.linklist__link {
  display: block;
  margin-bottom: 1cqi;
  font-size: 14cqi;
  pointer-events: all;
  cursor: pointer;

  &:last-of-type {
    margin-bottom: 0px;
  }

  &:hover span {
    color: #f7f2e0;
    transform: translateX(1.45cqi) translateY(0.95cqi);
  }

  span {
    display: block;
    pointer-events: none;
    transition:
      transform 80ms ease-in,
      color 80ms ease-in;
  }
}

/* Widgets */

.social {
  --icon-size: 8vh;
  --cloud-base-size: 6vh;
  position: absolute;
  left: 75vw;
  top: 15vh;
  display: flex;
  justify-content: center;
  background: white;
  width: calc(var(--cloud-base-size) * 3);
  height: calc(var(--cloud-base-size) * 1.1);
  border-radius: calc(var(--cloud-base-size));
  box-shadow: 0.6vh 0.45vh 1.2vh -0.6vh #afafaf;
  transition:
    transform 80ms ease-in,
    box-shadow 80ms ease-in;

  @media (width < 720px) {
    --icon-size: 13.5vw;
    --cloud-base-size: 10vw;
    left: 65vw;
    top: 8vh;
  }

  &:hover {
    transform: translateX(-0.725vh) translateY(-0.475vh);
    box-shadow: 0.725vh 0.475vh 0px 0px #afafaf;
  }

  &:before {
    content: "";
    position: absolute;
    top: calc(-30%);
    left: calc(10%);
    width: calc(var(--cloud-base-size) * 1.2);
    height: calc(var(--cloud-base-size) * 1);
    border-radius: calc(var(--cloud-base-size));
    background: white;
    z-index: -1;
  }

  &:after {
    content: "";
    position: absolute;
    top: calc(-65%);
    left: calc(30%);
    width: calc(var(--cloud-base-size) * 1.6);
    height: calc(var(--cloud-base-size) * 1.2);
    border-radius: calc(var(--cloud-base-size));
    background: white;
    z-index: -1;
  }
}

.social__icon {
  color: #1f91c2;
  width: var(--icon-size);
  height: var(--icon-size);
  margin-top: -2vh;

  @media (width < 720px) {
    margin-top: -3.5vw;
  }
}

.localization {
  --button-base-size: 10vh;
  position: absolute;
  left: 3vw;
  top: 3vh;
  container-type: size;
  width: var(--button-base-size);
  height: var(--button-base-size);
  background: white;
  color: #1f91c2;
  border-radius: 100%;
  overflow: clip;
  box-shadow: 0.6vh 0.45vh 1.2vh -0.6vh #afafaf;
  cursor: pointer;

  @media (width < 720px) {
    --button-base-size: 6vh;
    left: 4vw;
    top: 2vh;
  }

  &:before {
    content: "";
    position: absolute;
    inset: 0;
    border: 0cqi solid #1f91c2;
    border-radius: 100%;
    transition: border 80ms ease-out;
  }

  &:hover:before {
    border: 8cqi solid #1f91c2;
  }
}

.localization__button {
  width: 100%;
  height: 100%;

  [data-language="ja"] & {
    font-size: 40cqi;
    letter-spacing: -4cqi;
    margin-left: -2cqi;
    margin-right: 2cqi;
  }

  [data-language="en"] & {
    font-size: 50cqi;
  }
}

.copyright {
  position: relative;
  text-align: right;
  padding: 8px;
}

/* Modals */

.modal {
  container-type: size;
  position: absolute;
  left: calc(50vw - (var(--box-size-bordered) / 2));
  top: calc(50vh - (var(--box-size-bordered) / 2));
  width: var(--box-size-bordered);
  height: var(--box-size-bordered);
  display: flex;
  flex-direction: column;
  padding: 4cqh;
  padding-right: 3cqh;

  &.modal--about {
    --scale: 1.3;
    left: calc(50vw - (var(--box-size-bordered) / 2 * var(--scale)));
    top: calc(50vh - (var(--box-size-bordered) / 2 * var(--scale)));
    width: calc(var(--box-size-bordered) * var(--scale));
    height: calc(var(--box-size-bordered) * var(--scale));

    @media (width < 720px) {
      --scale: 1.2;
    }
  }

  &.modal--location {
    --h-scale: 1.3;
    --v-scale: 0.9;
    left: calc(70vw - (var(--box-size-bordered) / 2 * var(--h-scale)));
    top: calc(35vh - (var(--box-size-bordered) / 2 * var(--v-scale)));
    width: calc(var(--box-size-bordered) * var(--h-scale));
    height: calc(var(--box-size-bordered) * var(--v-scale));
    /* background: white; */
    border: 0.5cqi solid white;
    border-radius: 5cqi;
    border-bottom-left-radius: 0px;
    transform-origin: left bottom;

    @media (width < 720px) {
      --scale: 1.2;
    }
  }
}

.modal__content {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 1cqh;

  h2 {
    margin: 0;
    color: #c16e43;
    font-size: 12cqi;
  }

  p {
    font-size: 8cqi;
    color: #333;
  }
}

.modal__back {
  position: absolute;
  top: 100%;
  right: 0px;
  color: #333;
  overflow: clip;

  .linklist__link {
    font-size: 12cqi;
    margin-right: 2cqi;
    margin-top: 2cqi;
  }

  .linklist__link:hover span {
    color: #c16e43;
  }
}

/* Animation helpers */

.do-anim .box--animate-page-load {
  animation: page-load--box var(--box-animation-length) ease-in-out;

  @media (width < 720px) {
    animation: page-load--box--mobile var(--box-animation-length) ease-in-out;
  }
}

.do-anim .box__lid--animate-page-load {
  animation: page-load--box-lid var(--box-animation-length) ease-out;

  @media (width < 720px) {
    animation: page-load--box-lid--mobile var(--box-animation-length) ease-out;
  }
}

.do-anim .social--animate-page-load {
  animation: page-load--social 600ms cubic-bezier(0.39, 0.18, 0.23, 1.09)
    backwards calc(var(--box-animation-length) + 200ms);

  @media (width < 720px) {
    animation: page-load--social--mobile 600ms
      cubic-bezier(0.39, 0.18, 0.23, 1.09) backwards
      calc(var(--box-animation-length) + 200ms);
  }
}

.do-anim .box-transition-transform {
  transition:
    transform 600ms ease-in-out,
    left 600ms ease-in-out,
    top 600ms ease-in-out;
}

.modal-animate--show {
  opacity: 1;
  pointer-events: all;
  transition: opacity 1200ms ease-in 600ms;

  .modal__content {
    filter: blur(0cqi);
    transition: filter 1200ms ease-in 300ms;
  }

  .modal__back {
    .linklist__link {
      pointer-events: all;
      transform: translateY(0);
      transition: transform 200ms ease-out 1500ms;
    }
  }
}

.modal-animate--hide {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;

  .modal__content {
    filter: blur(6cqi);
    transition: filter 200ms;
  }

  .modal__back {
    .linklist__link {
      pointer-events: none;
      transform: translateY(-110%);
      transition: transform 200ms;
    }
  }
}

/* Keyframes */

@keyframes page-load--box {
  0%,
  10% {
    left: calc(50vw - (var(--box-size) / 2));
    top: 410vh;
    transform: rotateX(0deg) rotateY(0deg) rotateZ(-45deg);
    scale: 1400%;
  }

  40%,
  60% {
    left: calc(50vw - (var(--box-size) / 2));
    top: calc(50vh - (var(--box-size) / 2));
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    scale: 100%;
  }
}

@keyframes page-load--box--mobile {
  0% {
    transform: translate(-0.6vw, 18.5vh) rotateX(0deg) rotateY(0deg)
      rotateZ(-45deg);
    scale: 2000%;
  }

  40%,
  60% {
    transform: translate(calc((50vw - 50%) - 20vw), calc((50vh - 50%) - 55vh))
      rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    scale: 100%;
  }

  100% {
    transform: rotateX(45deg) rotateY(0deg) rotateZ(-25deg);
  }
}

@keyframes page-load--box-lid {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  90% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  100% {
    transform: rotateX(90deg) rotateY(0deg) rotateZ(0deg);
  }
}

@keyframes page-load--box-lid--mobile {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  90% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  100% {
    transform: rotateX(115deg) rotateY(0deg) rotateZ(0deg);
  }
}

@keyframes page-load--social {
  0% {
    transform: translateY(-25vh);
  }

  50% {
    transform: translateY(4vh);
  }

  100% {
    transform: translateY(0px);
  }
}

@keyframes page-load--social--mobile {
  0% {
    transform: translateY(-25vh);
  }

  50% {
    transform: translateY(2vh);
  }

  100% {
    transform: translateY(0px);
  }
}

@keyframes box-pizza-hover {
  0% {
    transform: translateZ(0px);
  }

  100% {
    transform: translateZ(-4cqh);
  }
}

@keyframes box-pizza-rotate {
  0% {
    rotate: z 0deg;
  }

  100% {
    rotate: z 360deg;
  }
}

@keyframes box-pizza-shadow-scale {
  0% {
    scale: 0.8;
  }

  100% {
    scale: 0.95;
  }
}

@keyframes box-nihon-hover {
  0% {
    transform: translateZ(-1cqh);
  }

  100% {
    transform: translateZ(-3cqh);
  }
}

/* Box panels */

.box__panel--lip {
  position: absolute;
  inset: 0;
  border: 1cqh white solid;
}

.box__panel--left {
  content: "";
  position: absolute;
  background-color: white;
  filter: brightness(85%);
  transform-origin: right top;
  inset: 0px 100% 0px var(--panel-height);
  transform: rotateY(-90deg);
}

.box__panel--bottom {
  content: "";
  position: absolute;
  background-color: white;
  filter: brightness(95%);
  transform-origin: right top;
  inset: 100% 0px var(--panel-height) 0px;
  transform: rotateX(-90deg);
}

.box__panel--top {
  content: "";
  position: absolute;
  background-color: white;
  border-right: 0.5cqh #ddd solid;
  filter: brightness(80%);
  transform-origin: right top;
  inset: 0px 0px calc(100% + var(--panel-height)) 0px;
  transform: rotateX(-90deg);
}

.box__panel--right {
  content: "";
  position: absolute;
  background-color: white;
  border-top: 0.5cqh #ddd solid;
  filter: brightness(90%);
  transform-origin: right top;
  inset: 0px 0px 0px calc(100% + var(--panel-height));
  transform: rotateY(-90deg);
}

.box__panel--floor {
  content: "";
  position: absolute;
  background: white;
  border: 0.5cqh #ddd solid;
  filter: brightness(85%);
  transform-origin: right top;
  inset: 0px;
  transform: translateZ(-8cqh);
  transition: filter 600ms ease-in-out;
}

/* Lid flaps */

.box__lid-flap--left {
  content: "";
  position: absolute;
  background-color: white;
  filter: brightness(95%);
  transform-origin: right top;
  inset: 0px 100% 0px var(--flap-height);
  clip-path: polygon(0% 5%, 100% 0%, 100% 100%, 0% 95%);
  transform: rotateY(-90deg);
}

.box__lid-flap--right {
  content: "";
  position: absolute;
  background-color: white;
  filter: brightness(85%);
  transform-origin: right top;
  inset: 0px 0px 0px calc(100% + var(--flap-height));
  clip-path: polygon(0% 5%, 100% 0%, 100% 100%, 0% 95%);
  transform: rotateY(-90deg);
}

.box__lid-flap--bottom {
  content: "";
  position: absolute;
  background-color: white;
  filter: brightness(95%);
  transform-origin: right top;
  inset: 100% 0px var(--flap-height) 0px;
  clip-path: polygon(0% 0%, 100% 0%, 95% 100%, 5% 100%);
  transform: rotateX(-90deg);
}
