/* In-game technology tree reference pass (levels, cards and hover panel). */
.tree-results {
  --rail-width: clamp(8rem, 8.5vw, 11rem);
  --lane-padding-x: clamp(.5rem, .6vw, .75rem);
  --lane-padding-y: clamp(.4rem, .5vw, .65rem);
  --card-gap: clamp(.45rem, .55vw, .7rem);
  --technology-lane-gap: 6px;
  --technology-ancient-width: calc((100% - var(--rail-width) - var(--technology-lane-gap) + 14 * var(--lane-padding-x) - 7 * var(--card-gap)) / 9);
  --technology-regular-end: calc(100% - var(--technology-ancient-width) - var(--technology-lane-gap));
  --technology-ancient-start: calc(100% - var(--technology-ancient-width));
}

.technology-lane-headings {
  position: sticky;
  z-index: 115;
  top: var(--technology-sticky-headings-top);
  display: grid;
  margin: .55rem 0 4px;
  grid-template-columns: minmax(0, 1fr) var(--technology-ancient-width);
  gap: var(--technology-lane-gap);
  background: transparent;
  box-shadow: 0 5px 10px rgba(0, 0, 0, .24);
}

.technology-lane-headings span {
  min-height: 2.45rem;
  padding: .15rem 1rem .2rem;
  color: #f2f8fa;
  background: #00636a;
  font-family: "Palworld UI", "Noto Sans", system-ui, sans-serif;
  font-size: clamp(1.05rem, 1.35vw, 1.55rem);
  font-weight: 520;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

.technology-lane-headings span:last-child {
  background: #6a287c;
}

.technology-levels {
  position: relative;
  isolation: isolate;
  background: transparent;
  border: 0;
}

.technology-levels::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    repeating-linear-gradient(120deg, transparent 0 290px, rgba(164, 188, 195, .05) 290px 440px, transparent 440px 730px),
    repeating-linear-gradient(60deg, transparent 0 290px, rgba(164, 188, 195, .035) 290px 440px, transparent 440px 730px),
    linear-gradient(to right,
      #102f38 0 var(--technology-regular-end),
      transparent var(--technology-regular-end) var(--technology-ancient-start),
      #2b113a var(--technology-ancient-start) 100%);
  -webkit-mask-image: linear-gradient(to right,
    #000 0 var(--technology-regular-end),
    transparent var(--technology-regular-end) var(--technology-ancient-start),
    #000 var(--technology-ancient-start) 100%);
  mask-image: linear-gradient(to right,
    #000 0 var(--technology-regular-end),
    transparent var(--technology-regular-end) var(--technology-ancient-start),
    #000 var(--technology-ancient-start) 100%);
}

.technology-levels::after {
  display: none;
}

.level-rail,
.level-content,
.technology-columns,
.technology-lane--regular {
  background: transparent;
}

.level-section,
.level-section:nth-child(even) {
  z-index: 1;
  background: transparent;
  border: 0;
}

.level-section::after {
  position: absolute;
  z-index: 3;
  right: clamp(.45rem, .6vw, .75rem);
  bottom: 0;
  left: clamp(.85rem, 1vw, 1.2rem);
  height: 1px;
  background: rgba(197, 220, 224, .43);
  content: "";
  pointer-events: none;
}

.technology-lane { background: transparent; }

.technology-lane--regular {
  background: transparent;
}

.technology-lane--ancient {
  background: transparent;
  border-left: 0;
}

.technology-lane[data-empty="true"]::after {
  display: none;
}

.level-meta {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tech-card {
  min-height: 0;
  aspect-ratio: 1 / 1;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: visible;
  background: #0a3554;
  border-color: #4b8fbe;
  box-shadow: inset 0 0 0 1px rgba(2, 20, 34, .62);
  transition: border-color .12s ease, filter .12s ease;
}

.tech-card:hover,
.tech-card:focus-within,
.tech-card.is-selected {
  z-index: 201;
  border-color: #00bfe3;
  transform: none;
  filter: brightness(1.025);
  box-shadow: inset 0 0 0 1px rgba(3, 25, 42, .76), 0 0 8px rgba(0, 187, 226, .24);
}

.tech-card.is-selected {
  z-index: 201;
}

.tech-card--ancient:hover,
.tech-card--ancient:focus-within,
.tech-card--ancient.is-selected {
  border-color: #d878e9;
  box-shadow: inset 0 0 0 1px rgba(36, 7, 45, .68), 0 0 9px rgba(216, 120, 233, .2);
}

.tech-media {
  min-height: 0;
  background: linear-gradient(135deg, #207bba 0 49%, #1c52a2 49% 100%);
}

.tech-card--ancient .tech-media {
  background: linear-gradient(135deg, #793787 0 49%, #4b205a 49% 100%);
}

.tech-card-category {
  min-height: 1.25rem;
  padding: .1rem .3rem;
  color: #91bcd0;
  background: rgba(9, 31, 53, .98);
  font-size: clamp(.56rem, .66vw, .76rem);
  font-weight: 500;
}

.tech-media img {
  width: 66%;
  height: 66%;
  margin-top: 1.35rem;
  object-fit: contain;
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, .42));
}

.tech-card h4 {
  min-height: 0;
  padding: .1rem .25rem .12rem;
  color: #f5fbff;
  background: rgba(32, 97, 137, .78);
  border-top: 0;
  font-size: clamp(.64rem, .74vw, .84rem);
  font-weight: 400;
  line-height: 1.04;
}

.tech-cost,
.tech-card-footer,
.tech-card-select::after {
  display: none;
}

.tech-card-select {
  inset: 0;
}

.tech-selection-frame {
  z-index: 30;
  inset: -.48rem;
  transform: scale(1);
  transform-origin: center;
  transition: opacity 100ms ease-out, transform 100ms ease-out;
  will-change: opacity, transform;
}

.tech-selection-frame i:nth-child(n) {
  width: 1.05rem;
  height: 1.05rem;
  border-color: #00cde9;
  filter: drop-shadow(0 0 4px rgba(0, 175, 220, .82));
}

.tech-card--ancient .tech-selection-frame i:nth-child(n) {
  border-color: #df79f0;
  filter: drop-shadow(0 0 5px rgba(223, 121, 240, .72));
}

.tech-card:hover .tech-selection-frame,
.tech-card:focus-within .tech-selection-frame,
.tech-card.is-selected .tech-selection-frame {
  opacity: 1;
  animation: palworld-corner-breathe 920ms cubic-bezier(.45, 0, .55, 1) infinite;
}

@keyframes palworld-corner-breathe {
  0%, 100% { opacity: .92; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.018); }
}

@media (min-width: 1200px) {
  .level-section {
    min-height: clamp(12.75rem, 11.1vw, 14.4rem);
    display: grid;
    padding: 0;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    gap: 0;
    scroll-margin-top: var(--technology-sticky-content-top);
    border-bottom-color: rgba(197, 220, 224, .43);
  }

  .level-section:first-child {
    scroll-margin-top: var(--technology-sticky-content-top);
  }

  .level-rail {
    position: relative;
    min-height: 100%;
    display: block;
    background: transparent;
    border-right: 0;
  }

  .level-rail::before {
    position: absolute;
    z-index: 0;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    height: auto;
    display: block;
    background: #08e5ff;
    content: "";
    box-shadow: 0 0 8px rgba(8, 229, 255, .62);
    transform: translateX(-50%);
  }

  .level-marker {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    width: 3.75rem;
    height: 3.75rem;
    margin: 0;
    color: #08e5ff;
    background: #092e38;
    border: 2px solid #08e5ff;
    font-family: "Palworld UI", "Noto Sans", system-ui, sans-serif;
    font-size: 2rem;
    font-weight: 360;
    box-shadow: 0 0 19px rgba(8, 229, 255, .66), inset 0 0 20px rgba(8, 229, 255, .13);
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .level-marker::before {
    display: none;
  }

  .level-marker::after {
    color: #09e7fa;
    font-family: "Palworld UI", "Noto Sans", system-ui, sans-serif;
    font-weight: 360;
    text-shadow: 0 0 8px rgba(8, 229, 255, .72);
  }

  .level-section:first-child .level-rail::before {
    top: 50%;
  }

  .level-section:first-child .level-marker {
    box-shadow: 0 0 23px rgba(8, 229, 255, .82), inset 0 0 21px rgba(8, 229, 255, .17);
  }

  .level-section:first-child .level-marker::after {
    text-shadow: 0 0 10px rgba(8, 229, 255, .9);
  }

  .level-content {
    display: block;
    min-width: 0;
  }

  .technology-columns {
    --technology-ancient-width: calc((100% - var(--technology-lane-gap) + 14 * var(--lane-padding-x) - 7 * var(--card-gap)) / 9);
    min-height: 100%;
    grid-template-columns: minmax(0, 1fr) var(--technology-ancient-width);
    gap: var(--technology-lane-gap);
  }

  .technology-lane {
    min-height: 100%;
    display: flex;
    padding: var(--lane-padding-y) var(--lane-padding-x);
    align-items: center;
  }

  .technology-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: var(--card-gap);
  }

  .technology-grid--ancient {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--card-gap);
  }
}

@media (max-width: 1199px) {
  .technology-lane-headings {
    display: none;
  }

  .level-content {
    grid-template-rows: 1fr;
  }

  .technology-levels::before {
    background:
      repeating-linear-gradient(120deg, transparent 0 290px, rgba(164, 188, 195, .05) 290px 440px, transparent 440px 730px),
      repeating-linear-gradient(60deg, transparent 0 290px, rgba(164, 188, 195, .035) 290px 440px, transparent 440px 730px),
      #102f38;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .technology-lane--ancient {
    background: #2b113a;
  }

  .technology-grid,
  .technology-grid--ancient {
    grid-template-columns: repeat(auto-fill, minmax(8.4rem, 1fr));
  }
}

@media (max-width: 560px) {
  .info-popover {
    width: calc(100vw - 1rem);
  }

  .info-game-stat {
    min-width: 9.5rem;
  }

  .info-game-preview {
    min-height: 9.5rem;
  }

  .info-game-preview > img {
    width: 7.5rem;
    height: 7.5rem;
  }
}

/* Keep mobile cards readable without making each level taller than necessary. */
@media (max-width: 780px) {
  .technology-grid,
  .technology-grid--ancient {
    grid-template-columns: repeat(auto-fit, minmax(6.4rem, 7.4rem));
    justify-content: start;
    gap: .4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tech-card:hover .tech-selection-frame,
  .tech-card:focus-within .tech-selection-frame,
  .tech-card.is-selected .tech-selection-frame {
    animation: none;
  }
}
