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

body {
  font-family: sans-serif;
  background-color: #f0f0f0;
  margin: 20px 0; /* Add top and bottom margin */
  overflow-x: auto; /* Enable horizontal scrolling on the body */
}

#gust-button {
  position: fixed;
  top: 20px;
  right: 20px;
  cursor: default; /* Make it not obviously clickable */
  z-index: 0;
  border: none;
  background-color: transparent;
  background-image: url('../data/windhead.png');
  background-repeat: no-repeat;
  background-position: center;
}

.mobile-container {
  padding-top: 20px;
  perspective: 1000px;
  white-space: nowrap; /* Prevent wrapping of inline-block elements */
  position: relative; /* Ensure it's a positioning context */
  z-index: 1;
  pointer-events: none;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  display: inline-flex; /* Use inline-flex to respect min-width */
  pointer-events: none;
}

li > ul {
  margin-top: 20px;
}

li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin: 0 20px;
}

li:only-child {
  margin: 0;
}

/* Vertical line going UP from a UL to its parent element */
li > ul::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: calc(50% - 0.5px);
  width: 1px;
  height: 20px;
  background: #333;
}

/* Horizontal line connecting siblings */
li > ul > li:not(:only-child)::after {
  content: '';
  position: absolute;
  top: 0;
  height: 1px;
  background: #333;
}

li > ul > li:first-child:not(:only-child)::after {
  left: 50%;
  width: calc(50% + 20px); /* Extend into the right margin */
}

li > ul > li:last-child:not(:only-child)::after {
  left: -20px; /* Extend into the left margin */
  width: calc(50% + 20px);
}

li > ul > li:not(:first-child):not(:last-child):not(:only-child)::after {
  left: -20px; /* Extend into both margins */
  width: calc(100% + 40px);
}

/* Vertical line going DOWN from the horizontal bar to an element */
li > ul > li::before {
  content: '';
  position: absolute;
  top: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  height: 21px; /* Add 1px for overlap */
  background: #333;
}

.mobile-element {
  width: 100px;
  height: 100px;
  position: relative;
  transform-style: preserve-3d;
  border: 1px solid #333;
  background-color: #fff;
  margin-top: 20px;
  transform: rotateY(var(--rotation-angle, 0deg));
  pointer-events: auto; /* Re-enable pointer events for the interactive elements */
}

.mobile-element.legendary {
    border-width: 3px;
    border-style: dashed;
}

.mobile-element.highlighted {
  outline: 3px solid red;
  outline-offset: 2px;
}

.mobile-container > ul > li > .mobile-element {
  margin-top: 0;
}

.front, .back {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  backface-visibility: hidden;
}

.back {
  transform: rotateY(180deg);
}

.back img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.infobox {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 600px;
  height: 300px;
  background-color: white;
  border: 2px solid black;
  z-index: 100;
  display: none; /* Hidden by default */
  padding: 10px;
}

.infobox.legendary {
    border: 3px dashed #333;
}

.infobox-close {
  position: absolute;
  top: 5px;
  right: 10px;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
}

.infobox-content {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
}

.infobox-item {
  width: 250px;
  height: 250px;
  border: 1px solid #ccc;
  position: relative;
}

.collage-grid {
    display: grid;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.collage-grid > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ancestor-list {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 0.8em;
    text-align: left;
}

.infobox-level {
    font-size: 0.9em;
    color: #555;
}

.infobox-name {
    font-size: 1.2em;
    font-weight: bold;
}

.infobox-common-name {
    margin-top: 10px;
    font-style: italic;
    font-size: 1em;
    color: #333;
}

.mobile-common-name {
    margin-top: 5px;
    font-style: italic;
    font-size: 0.8em;
    color: #333;
}
