/* General Knowledge Repository pages. Standalone: the homepage's style.css is not loaded here.
   Fonts and colours match the homepage; positions are viewport shares like the homepage's. */

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

html,
body {
  margin: 0;
  min-height: 100%;
}

:root {
  --font-display: "Segoe UI Variable Display Light", "Segoe UI Variable Display", "Segoe UI Light", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-button: "Liberation Sans", Arial, Helvetica, sans-serif;
  --font-mono: "Liberation Mono", "Courier New", Courier, monospace;

  --blue: #7f90ff;          /* bars and buttons */
  --ink: #000a2e;           /* text on blue */
  --white: #ffffff;
  --text: #b9c3ff;          /* excerpt text */
  --select: #1ec8ff;        /* selected faction frame */
  --bar-h: clamp(32px, 5.4vh, 48px);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: #e6ecff;
  font-family: var(--font-button);
  background-color: #000318;
  background-image: url("../images/background.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* ---- blue grid that follows the cursor (same as the homepage) ---- */
.grid {
  position: fixed;
  inset: -120px;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(90, 120, 255, 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(90, 120, 255, 0.16) 1px, transparent 1px);
  background-size: 180px 180px;
  transform: translate3d(var(--gx, 0px), var(--gy, 0px), 0);
  transition: transform 0.25s ease-out;
  will-change: transform;
}

/* ---- title bar across the top ---- */
.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  height: var(--bar-h);
  background: var(--blue);
  color: var(--ink);
}

.bar-title {
  flex: 1 1 auto;
  margin: 0;
  padding: 0 calc(var(--bar-h) + 1vw);
  text-align: center;
  font-family: var(--font-button);
  font-weight: 700;
  font-size: clamp(13px, 1.6vw, 24px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--bar-h) * 1.2);
  height: var(--bar-h);
  color: var(--ink);
  transition: transform 0.18s ease-out;
}

.back svg {
  width: 62%;
  height: 62%;
  fill: currentColor;
}

.back:hover,
.back:focus-visible {
  transform: translateX(-4px);
}

.back:focus-visible,
.tile:focus-visible,
.faction:focus-visible,
.entry > summary:focus-visible,
.search input:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

.page {
  position: relative;
  z-index: 1;
  padding-top: var(--bar-h);
  min-height: 100vh;
}

/* ---- menu pages: tiles in a centred block ---- */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8vh 3.5vw;
  width: 74vw;
  margin: 14vh auto 0;
  padding: 0;
  list-style: none;
}

.tiles li {
  margin: 0;
}

.tiles li.span {
  grid-column: 1 / -1;
  justify-self: center;
  width: calc(50% - 1.75vw);
  max-width: 100%;
}

.tile {
  display: flex;
  align-items: center;
  gap: 1.9vw;
  height: clamp(36px, 7.2vh, 60px);
  padding: 0 1.5vw 0 1.6vw;
  background: var(--blue);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-button);
  font-weight: 700;
  font-size: clamp(13px, 1.5vw, 24px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  /* notched top-left corner, as in the mockup */
  clip-path: polygon(1.2vw 0, 100% 0, 100% 100%, 0 100%, 0 1.2vw);
  transform-origin: left center;
  transition: transform 0.18s ease-out, background 0.18s ease-out, filter 0.18s ease-out;
}

.tile svg {
  flex: 0 0 auto;
  width: clamp(22px, 2.6vw, 38px);
  height: clamp(22px, 2.6vw, 38px);
  fill: currentColor;
}

.tile:hover,
.tile:focus-visible {
  background: var(--white);
  transform: translateX(10px) scale(1.03);
  filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.55));
}

.tile:active {
  transform: translateX(10px) scale(1.01);
}

/* ---- archive pages: search, list, scroll rail ---- */
.archive {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--bar-h));
  padding: 5vh 9vw 4vh 10vw;
}

.archive-label {
  margin: 0 0 1.5vh;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(11px, 1vw, 15px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.search {
  position: relative;
  width: 60vw;
  max-width: 100%;
  margin: 0 auto 6vh;
}

.search input {
  width: 100%;
  height: clamp(30px, 4.6vh, 42px);
  padding: 0 2.6em 0 0.8em;
  border: 2px solid var(--white);
  border-radius: 0;
  background: rgba(0, 3, 24, 0.55);
  color: var(--white);
  font-family: var(--font-button);
  font-weight: 700;
  font-size: clamp(12px, 1.1vw, 17px);
}

.search input::placeholder {
  color: var(--white);
  opacity: 1;
}

.search svg {
  position: absolute;
  right: 0.5em;
  top: 50%;
  width: 1.4em;
  height: 1.4em;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--white);
  stroke-width: 2.4;
  stroke-linecap: round;
  pointer-events: none;
}

.list-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.list {
  height: 100%;
  overflow-y: auto;
  padding-right: 3vw;
  scrollbar-width: none;
}

.list::-webkit-scrollbar {
  display: none;
}

/* the thin white track on the right of the mockup */
.rail {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.85);
}

.rail-thumb {
  position: absolute;
  left: -2px;
  width: 6px;
  height: 20%;
  background: var(--white);
  transform: translateY(var(--thumb, 0px));
}

.entry {
  border-bottom: 2px dotted rgba(255, 255, 255, 0.85);
}

.entry > summary {
  display: flex;
  align-items: center;
  gap: 1.4vw;
  padding: 1.4vh 0 1.4vh 4.5vw;
  cursor: pointer;
  list-style: none;
  color: var(--white);
  font-weight: 700;
  font-size: clamp(14px, 1.4vw, 22px);
}

.entry > summary::-webkit-details-marker {
  display: none;
}

.marker {
  flex: 0 0 auto;
  width: 0.95em;
  height: 0.95em;
  fill: var(--white);
  transition: transform 0.15s ease-out;
}

.entry[open] > .marker,
.entry[open] > summary .marker {
  transform: rotate(90deg);
}

.entry-body {
  padding: 0.5vh 2vw 2.5vh 1vw;
  color: var(--text);
  font-weight: 700;
  font-size: clamp(11px, 1vw, 15px);
  line-height: 1.35;
}

.entry-body p {
  margin: 0 0 0.8em;
}

.entry-body p:last-child {
  margin-bottom: 0;
}

.no-match {
  padding: 2vh 1vw;
  color: var(--text);
  font-weight: 700;
}

/* ---- public figures: faction sidebar + figure sheets ---- */
.figures-page {
  display: flex;
  height: calc(100vh - var(--bar-h));
}

.factions {
  flex: 0 0 9.5vw;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 0;
  padding: 2vh 0 2vh 3.3vw;
  list-style: none;
}

.faction {
  display: block;
  width: 6vw;
  height: 6vw;
  border: 2px solid var(--white);
  overflow: hidden;
  transition: transform 0.15s ease-out, border-color 0.15s ease-out;
}

.faction img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.faction:hover,
.faction:focus-visible {
  transform: scale(1.06);
}

.faction[aria-current="page"] {
  border: 3px solid var(--select);
}

.figures-page .archive {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3vh 4vw 4vh 9vw;
}

.figures-page .entry > summary {
  padding-left: 1vw;
  font-size: clamp(16px, 1.7vw, 26px);
  text-transform: uppercase;
}

.sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21vw;
  gap: 2vh 4vw;
  padding: 1vh 2vw 3vh 1.5vw;
  color: var(--text);
  font-weight: 700;
  font-size: clamp(11px, 1.05vw, 16px);
  line-height: 1.3;
}

.sheet dl {
  grid-column: 1;
  margin: 0;
  color: var(--white);
}

.sheet .profile {
  grid-column: 1;
}

.sheet dt,
.sheet dd {
  display: inline;
  margin: 0;
}

.sheet dt::before {
  content: "- ";
}

.sheet dd::after {
  content: "";
  display: block;
}

.portrait {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 21vw;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--white);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8a93b8;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(10px, 0.9vw, 14px);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.profile p {
  margin: 0 0 0.8em;
}

.profile p:first-child {
  margin-bottom: 1.6em;
  color: var(--white);
}

/* ---- small screens: stack everything ---- */
@media (max-width: 900px) {
  .bar-title {
    padding: 0 var(--bar-h);
    white-space: normal;
    font-size: 13px;
  }

  .tiles {
    grid-template-columns: 1fr;
    gap: 22px;
    width: auto;
    margin: 36px 20px 40px;
  }

  .tiles li.span {
    width: 100%;
  }

  .tile {
    height: 44px;
    gap: 14px;
    padding: 0 16px;
    white-space: normal;
    clip-path: polygon(12px 0, 100% 0, 100% 100%, 0 100%, 0 12px);
  }

  .archive {
    height: auto;
    padding: 24px 20px 40px;
  }

  .search {
    width: 100%;
    margin-bottom: 28px;
  }

  .list {
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .rail {
    display: none;
  }

  .entry > summary {
    gap: 12px;
    padding: 12px 0 12px 8px;
  }

  .entry-body {
    padding: 4px 8px 20px;
  }

  .figures-page {
    flex-direction: column;
    height: auto;
  }

  .factions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
    padding: 16px 20px 0;
  }

  .faction {
    width: 56px;
    height: 56px;
  }

  .figures-page .archive {
    padding: 16px 20px 40px;
  }

  .sheet {
    grid-template-columns: 1fr;
    padding: 4px 8px 20px;
  }

  .portrait {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    max-width: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grid,
  .tile,
  .back,
  .faction,
  .marker {
    transition: none;
  }
}
