/* Story Library. Shared palette and layout for the library page. */

@font-face {
  font-family: "Airstrike";
  src: url("../../webfonts/airstrike.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #0a0a0b;
  --bg-2: #101012;
  --panel: #141416;
  --panel-2: #1a1a1d;
  --ink: #ececea;
  --dim: #8d8d88;
  --dimmer: #5f5f5b;
  --line: rgba(255, 255, 255, 0.13);
  --line-soft: rgba(255, 255, 255, 0.07);
  --accent: #ffd020;
  --accent-ink: #14140c;
  --good: #7bd88f;
  --warn: #ff5b3c;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo,
    Consolas, monospace;
  --sans: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* the corner cut used across panels and buttons */
  --bevel: 9px;
  /* search, selects and buttons all sit on this line; in rem so a smaller
     type size inside them does not make the box shorter */
  --control-h: 2.15rem;
}

/* light theme */
:root[data-theme="light"] {
  --bg: #f4f2ee;
  --bg-2: #eceae5;
  --panel: #ffffff;
  --panel-2: #f2f0eb;
  --ink: #16161a;
  --dim: #5c5c58;
  --dimmer: #86867f;
  --line: rgba(0, 0, 0, 0.16);
  --line-soft: rgba(0, 0, 0, 0.08);
  --accent: #b7860a;
  --accent-ink: #fffdf4;
  --good: #2f7d43;
  --warn: #c23a1c;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

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

.hidden {
  display: none !important;
}

.muted {
  color: var(--dim);
}

.empty {
  color: var(--dim);
  padding: 3em 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* the clipped corner, used on every raised surface */
.card,
.btn,
.hero,
.g-row,
.modal-box,
.detail-box,
.stat-tile {
  clip-path: polygon(
    0 0,
    calc(100% - var(--bevel)) 0,
    100% var(--bevel),
    100% 100%,
    var(--bevel) 100%,
    0 calc(100% - var(--bevel))
  );
}

/* ------------------------------------------------------------- header -- */

#hdr {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(10, 10, 11, 0.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding-top: env(safe-area-inset-top, 0px);
}

.hdr-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75em max(1.1em, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55em 0.7em;
}

#hdr h1 {
  font-family: "Airstrike", var(--sans);
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6em;
  white-space: nowrap;
}

#hdr h1 i {
  color: var(--accent);
  font-size: 0.85em;
}

.hdr-spacer {
  flex: 1;
}

.hdr-stat {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-transform: uppercase;
  /* room for the widest count, so the buttons beside it never move */
  font-variant-numeric: tabular-nums;
  min-width: 15ch;
  text-align: right;
}

/* -------------------------------------------------------------- layout -- */

#main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.6em max(1.1em, env(safe-area-inset-left, 0px)) 5em;
}

#loading {
  color: var(--dim);
  padding: 4em 0;
  text-align: center;
  font-family: var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------- hero -- */

.hero {
  position: relative;
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 2em;
  min-height: 210px;
  display: flex;
  align-items: flex-end;
  background: var(--panel);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 32%;
}

/* readability only: the copy sits on the left over the art */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(8, 8, 9, 0.96) 0%,
    rgba(8, 8, 9, 0.8) 44%,
    rgba(8, 8, 9, 0.1) 100%
  );
}

.hero-body {
  position: relative;
  z-index: 1;
  padding: 1.5em 1.6em;
  max-width: 42em;
}

.hero-title {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin: 0;
}

/* the title and the group line open the group they belong to */
.hero-open {
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  transition: color 0.15s ease;
}

.hero-open:hover,
.hero-open:focus-visible {
  color: var(--accent);
  outline: none;
}

.hero-meta {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.55em;
  display: flex;
  gap: 1.2em;
  flex-wrap: wrap;
}

.hero-count {
  color: var(--accent);
}

.hero-meter {
  margin: 1.2em 0 1.4em;
  max-width: 30em;
}

.hero-actions {
  display: flex;
  gap: 0.5em;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------- tabs -- */

#tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.tab {
  flex: 0 0 auto;
  position: relative;
  background: none;
  border: 0;
  color: var(--dim);
  padding: 0.75em 0.85em;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab:first-child {
  padding-left: 0;
}

.tab-n {
  color: var(--dimmer);
  margin-right: 0.55em;
  font-variant-numeric: tabular-nums;
}

.tab.active .tab-n {
  color: var(--accent);
}

.tab:hover {
  color: var(--ink);
}

.tab::after {
  content: "";
  position: absolute;
  left: 0.85em;
  right: 0.85em;
  bottom: 0;
  height: 2px;
  background: transparent;
  transition: background 0.15s;
}

.tab:first-child::after {
  left: 0;
}

.tab.small::after {
  left: 0.85em;
  right: 0.85em;
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  background: var(--accent);
}

.tab.small {
  padding: 0.5em 0.85em;
  font-size: 0.72rem;
}

.art-switch {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1.2em;
  overflow-x: auto;
}

/* ------------------------------------------------------------ toolbar -- */

#toolbar {
  display: flex;
  align-items: center;
  gap: 1em;
  flex-wrap: wrap;
  margin: 1.1em 0 0.9em;
}

.search-wrap {
  position: relative;
  flex: 0 1 auto;
  width: min(560px, 100%);
}

.search-wrap i {
  position: absolute;
  left: 0.85em;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dimmer);
  font-size: 0.8em;
  pointer-events: none;
}

#search {
  width: 100%;
  height: var(--control-h);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 0.8em 0 2.4em;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

#search::placeholder {
  color: var(--dimmer);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.92em;
}

#search:focus {
  outline: none;
  border-color: var(--accent);
}

.chk#hideReadWrap {
  margin-left: auto;
}

.chk {
  display: flex;
  align-items: center;
  gap: 0.5em;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.chk input {
  accent-color: var(--accent);
}

.cat-stat {
  color: var(--dimmer);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: auto;
  padding-left: 1.2em;
  white-space: nowrap;
  order: 99;
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel)
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238d8d88' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 0.75em center;
  background-size: 10px 6px;
  border: 1px solid var(--line);
  color: var(--ink);
  height: var(--control-h);
  padding: 0 2.1em 0 0.75em;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

/* the chevron is drawn, so it needs its own colour per theme */
:root[data-theme="light"] .lang-select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235c5c58' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

.lang-select:hover {
  border-color: var(--accent);
}

/* -------------------------------------------------------------- shelf -- */

.shelf {
  display: grid;
  gap: 1.1em;
}

.shelf.wide {
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 1.6em 1.1em;
}

/* portrait shelves (operators, modules) pack far more per row */
.shelf.tall {
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 1em 0.8em;
}

.card {
  position: relative;
  align-self: start; /* cards size to their own content, not their row */
  background: none;
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.card-art {
  position: relative;
  overflow: hidden;
  background: #0e0e10;
  outline: 1px solid var(--line-soft);
  outline-offset: -1px;
  transition: outline-color 0.2s ease;
}

.card:hover .card-art {
  outline-color: var(--accent);
}

/* set per shelf by home.js from the category's native art shape */
.card-art {
  aspect-ratio: var(--card-ar, 16 / 9);
}

.card-art img.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease, filter 0.2s ease;
  filter: saturate(0.85) contrast(1.05);
}

.card-art img.cover.portrait {
  object-position: top center;
}

/* no zoom on hover: the outline and title already mark the card */
.card:hover .card-art img.cover {
  filter: saturate(1) brightness(1.06);
}

.card-art.letterbox img.cover {
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.card-wash {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(20px) brightness(0.32) saturate(0.7);
  transform: scale(1.2);
}

.card-art img.cover.avatar {
  object-fit: contain;
  object-position: center;
  padding: 18%;
}

.card-art.no-art::after {
  content: "\f02d";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2em;
  color: rgba(255, 255, 255, 0.09);
}

.card-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* only the tall shelf writes over its art, so only it needs a scrim */
.shelf.tall .card-scrim {
  background: linear-gradient(
    to top,
    rgba(8, 8, 9, 0.96) 0%,
    rgba(8, 8, 9, 0.55) 30%,
    rgba(8, 8, 9, 0) 62%
  );
}

.card-name {
  position: absolute;
  left: 0.7em;
  right: 0.7em;
  bottom: 0.5em;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  text-shadow: 0 2px 8px #000;
}

.card-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--good);
  color: var(--accent-ink);
  min-width: 2em;
  height: 1.7em;
  padding: 0 0.55em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.card-badge.partial {
  background: var(--accent);
  color: var(--accent-ink);
}

.card-foot {
  padding: 0.75em 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  flex: 1;
}

.card-head {
  min-height: 2.5em;
}

.shelf.tall .card-foot {
  padding: 0.5em 0 0;
}

/* index numeral sets the ranking; the title carries the weight */
.card-head {
  display: flex;
  align-items: baseline;
  gap: 0.65em;
}

.card-n {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--dimmer);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.card:hover .card-n {
  color: var(--accent);
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.005em;
  transition: color 0.2s ease;
}

.card:hover .card-title {
  color: var(--accent);
}

.card-blurb {
  margin: 0;
  font-size: 0.79rem;
  line-height: 1.5;
  color: var(--dim);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  /* fixed three lines so the progress rules line up across the shelf */
  min-height: calc(3 * 1.5 * 0.79rem);
  flex: 1;
}

.shelf.tall .card-blurb {
  display: none;
}

.card-line {
  display: flex;
  align-items: center;
  gap: 0.7em;
  margin-top: auto;
}

.card-line .bar {
  flex: 1;
}

.card-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--dimmer);
  white-space: nowrap;
  letter-spacing: 0.05em;
}

.card.done .card-count {
  color: var(--good);
}

/* progress reads as a hairline rule, not a pill */
.bar {
  height: 2px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

.bar-fill.done {
  background: var(--good);
}

/* ------------------------------------------------------ group details -- */

.detail {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 5, 0.86);
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1em;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.detail.show {
  display: flex;
}

.detail-box {
  background: var(--panel);
  border: 1px solid var(--line);
  width: min(700px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-head {
  position: relative;
  flex: 0 0 auto;
  min-height: 180px;
  display: flex;
  align-items: flex-end;
}

.detail-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(0.85);
}

.detail-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--panel) 0%,
    rgba(20, 20, 22, 0.8) 46%,
    rgba(20, 20, 22, 0.08) 100%
  );
}

.detail-headtext {
  position: relative;
  z-index: 1;
  padding: 1.1em 1.3em 1em;
}

.detail-headtext h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 1.95rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.detail-meta {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.5em;
}

.detail-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  background: rgba(10, 10, 11, 0.8);
  border: 0;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.35em 0.6em 0.45em;
  cursor: pointer;
}

.detail-close:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.detail-body {
  padding: 1.2em 1.3em 1.4em;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-desc {
  margin: 0 0 1.2em;
  color: var(--dim);
  line-height: 1.65;
  font-size: 0.92rem;
}

.detail-meter {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-bottom: 1em;
}

.detail-meter .bar {
  flex: 1;
}

.detail-count {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

.detail-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.detail-actions {
  display: flex;
  gap: 0.5em;
  flex-wrap: wrap;
  margin-top: 1.2em;
  /* room under the controls as well as above them */
  margin-bottom: 1.1em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
}

.detail-body .art-grid {
  margin-top: 0.9em;
}

/* ------------------------------------------------------------ entries -- */

.entry {
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.5em 0.3em;
  border-bottom: 1px solid var(--line-soft);
}

.entry:hover {
  background: rgba(255, 255, 255, 0.035);
}

.entry-check {
  flex: 0 0 auto;
  width: 1.7em;
  height: 1.7em;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dimmer);
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.entry-check:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.entry-check.on {
  background: var(--good);
  border-color: var(--good);
  color: var(--accent-ink);
}

.entry-link {
  flex: 1;
  padding: 0.1em 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.94rem;
}

.entry-link:hover {
  color: var(--accent);
}

.entry.read .entry-link {
  color: var(--dim);
}

.entry-pos {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.entry-pos:hover {
  text-decoration: underline;
}

.entry-bulk {
  gap: 1.2em;
  padding-top: 0.7em;
  border-bottom: 0;
}

/* ------------------------------------------------------ reading guide -- */

.g-summary {
  display: flex;
  align-items: center;
  gap: 1em;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  padding: 0.95em 1.1em;
  margin-bottom: 1.5em;
}

.g-summary-text {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.g-summary-text b {
  color: var(--accent);
}

.g-summary .btn {
  margin-left: auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  white-space: nowrap;
}

.g-section {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 2em 0 0.8em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.7em;
}

/* how long the arc runs, and what is left of it */
.g-section-meta {
  margin-left: auto;
  color: var(--dim);
  letter-spacing: 0.08em;
  font-size: 0.92em;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* narrow enough that the figures would crowd the arc name off the line */
@media (max-width: 720px) {
  .g-section {
    flex-wrap: wrap;
  }

  .g-section-meta {
    margin-left: 0;
    flex-basis: 100%;
    padding-left: 1.4em;
  }
}

.g-section::before {
  content: "";
  width: 4px;
  height: 1em;
  background: var(--accent);
}

.g-list {
  display: flex;
  flex-direction: column;
  gap: 0.45em;
}

.g-row {
  display: grid;
  grid-template-columns: 2.4em 116px 1fr auto;
  align-items: center;
  gap: 0.95em;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.65em 0.9em;
  transition: border-color 0.15s, background 0.15s;
}

.g-row.linked {
  cursor: pointer;
}

.g-row.linked:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.g-row.done {
  border-color: rgba(123, 216, 143, 0.35);
}

.g-num {
  font-family: var(--mono);
  color: var(--dimmer);
  font-size: 0.95rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.g-row.done .g-num {
  color: var(--good);
}

.g-thumb {
  width: 116px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0e0e10;
  border: 1px solid var(--line-soft);
}

.g-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.85);
}

.g-thumb img.portrait {
  object-position: top center;
}

.g-mid {
  min-width: 0;
}

.g-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6em;
  flex-wrap: wrap;
  font-size: 0.98rem;
}

.g-row.done .g-title {
  color: var(--dim);
}

.g-tag {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
  border: 1px solid var(--line);
  padding: 0.15em 0.5em;
}

.g-tag.missing {
  color: var(--warn);
  border-color: rgba(255, 91, 60, 0.4);
}

.g-note {
  color: var(--dim);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 0.2em;
}

.g-meter {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-top: 0.5em;
  max-width: 22em;
}

.g-meter .bar {
  flex: 1;
}

.g-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--dimmer);
  white-space: nowrap;
}

.art-hint {
  color: var(--dim);
  font-size: 0.84rem;
  margin: 0 0 1.3em;
  max-width: 52em;
  line-height: 1.6;
}

.art-hint a {
  color: var(--accent);
  border-bottom: 1px solid rgba(255, 208, 32, 0.4);
}

/* ---------------------------------------------------------------- art -- */

.art-group {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 1.8em 0 0.7em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.7em;
}

.art-group::before {
  content: "";
  width: 4px;
  height: 1em;
  background: var(--accent);
}

.art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 0.7em;
}

.art-tile {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.art-tile:hover {
  border-color: var(--accent);
}

.art-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0a0a0c;
  filter: saturate(0.9);
}

.art-tile:hover img {
  filter: saturate(1);
}

.art-tile figcaption {
  padding: 0.5em 0.65em;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-top: 1px solid var(--line-soft);
}

/* ----------------------------------------------------------- lightbox -- */

.lb {
  position: fixed;
  inset: 0;
  background: rgba(3, 3, 4, 0.96);
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
}

.lb.show {
  display: flex;
}

.lb img {
  max-width: 94vw;
  max-height: 86vh;
  object-fit: contain;
}

.lb-close,
.lb-nav {
  position: absolute;
  background: rgba(16, 16, 18, 0.9);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.35em 0.6em;
}

.lb-close:hover,
.lb-nav:hover {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.lb-close {
  top: 1.2em;
  right: 1.2em;
}

.lb-prev {
  left: 1.2em;
}

.lb-next {
  right: 1.2em;
}

#lbCaption {
  position: absolute;
  bottom: 1.2em;
  left: 50%;
  transform: translateX(-50%);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  background: rgba(10, 10, 11, 0.85);
  border: 1px solid var(--line);
  padding: 0.45em 1em;
  max-width: 90vw;
  text-align: center;
}

/* ------------------------------------------------------------ buttons -- */

.btn {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.6em 1em;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.btn.primary:hover {
  background: #ffdf5c;
  border-color: #ffdf5c;
  color: var(--accent-ink);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 0.45em 0.75em;
  font-size: 0.7rem;
}

.btn.danger {
  border-color: rgba(255, 91, 60, 0.5);
  color: var(--warn);
}

.btn.danger:hover {
  background: var(--warn);
  border-color: var(--warn);
  color: #14140c;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  color: var(--accent);
}

/* -------------------------------------------------------------- modal -- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 5, 0.86);
  z-index: 130;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1em;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  width: min(520px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-box.wide {
  width: min(760px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9em 1.2em;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: 0;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2em;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 1.2em;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4em 0;
}

.modal-actions {
  display: flex;
  gap: 0.5em;
  flex-wrap: wrap;
  margin: 1em 0;
}

.msg {
  color: var(--good);
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  min-height: 1.3em;
  margin: 1em 0 0;
}

/* -------------------------------------------------------------- stats -- */

.readout {
  margin: 0 0 1.6em;
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: baseline;
  column-gap: 1.1em;
}

.readout dt {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 0.45em 0;
  border-bottom: 1px solid var(--line-soft);
  letter-spacing: -0.02em;
}

.readout dd {
  margin: 0;
  padding: 0.45em 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 0.9rem;
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  flex-wrap: wrap;
}

.readout-note {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dimmer);
  letter-spacing: 0.04em;
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 0.9em;
  margin-bottom: 1.6em;
}

.stat-bar .bar {
  flex: 1;
  height: 4px;
}

.stat-pct {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 1.4em;
}

.stat-table th {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
  text-align: right;
  padding: 0.5em 0.4em;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}

.stat-table th:first-child,
.stat-table td:first-child {
  text-align: left;
}

.stat-table td {
  padding: 0.5em 0.4em;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}

.stat-table td:first-child {
  color: var(--ink);
}

.stat-speed {
  display: flex;
  align-items: center;
  gap: 0.7em;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.stat-speed input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.4em 0.5em;
  width: 6em;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.stat-speed input:focus {
  outline: none;
  border-color: var(--accent);
}

.stat-note {
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 1.2em 0 0;
  text-transform: none;
  letter-spacing: 0;
}

/* ------------------------------------------------------------ credits -- */

#credits {
  margin-top: 4em;
  padding-top: 1.4em;
  border-top: 1px solid var(--line);
  color: var(--dimmer);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  line-height: 1.8;
}

#credits a {
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}

#credits a:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------- mobile -- */

@media (hover: none) {
  .card:hover,
  .g-row.linked:hover,
  .entry:hover,
  .art-tile:hover {
    background: inherit;
  }

  .card:hover .card-art img.cover {
    transform: none;
  }
}

/* the header's controls outgrow a laptop before they outgrow a phone */
@media (max-width: 1100px) {
  .btn-label {
    display: none;
  }

  .btn {
    padding: 0.6em 0.75em;
  }
}

/* narrower still: the selects take the row under the title */
@media (max-width: 620px) {
  .hdr-spacer {
    display: none;
  }

  #hdr h1 {
    flex: 1 1 auto;
  }

  #langSelect,
  #readingSelect {
    flex: 1 1 8em;
    min-width: 0;
  }
}

@media (max-width: 700px) {
  :root {
    --bevel: 7px;
  }

  body {
    font-size: 15px;
  }

  #hdr h1 {
    font-size: 1rem;
  }

  .hdr-stat {
    display: none;
  }

  .btn-label {
    display: none;
  }

  .btn {
    padding: 0.6em 0.75em;
  }

  .cat-stat {
    width: 100%;
    margin-left: 0;
  }

  .hero {
    min-height: 0;
  }

  .hero-body {
    padding: 1.1em 1.1em 1.2em;
  }

  .hero-title {
    font-size: 1.3rem;
  }

  .shelf.wide {
    grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
    gap: 0.7em;
  }

  .shelf.tall {
    grid-template-columns: repeat(auto-fill, minmax(114px, 1fr));
    gap: 0.55em;
  }

  .card-blurb {
    -webkit-line-clamp: 2;
    font-size: 0.76rem;
  }

  .art-grid {
    grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
  }

  .detail-head {
    min-height: 132px;
  }

  .detail-headtext h2 {
    font-size: 1.2rem;
  }

  .g-row {
    grid-template-columns: 1.9em 76px 1fr;
    gap: 0.65em;
  }

  .g-thumb {
    width: 76px;
  }

  .g-act {
    grid-column: 2 / -1;
  }

  .g-summary .btn {
    margin-left: 0;
  }

  .readout dt {
    font-size: 1.2rem;
  }
}

/* a borrowed season cover is dimmed so it doesn't read as the story's own art */
.card-art img.cover.season,
.g-thumb img.season {
  filter: saturate(0.5) brightness(0.62);
}

.card:hover .card-art img.cover.season {
  filter: saturate(0.7) brightness(0.75);
}

/* roguelike monthly squads: the team, over a dimmed still of their season */
.card-art.squad {
  display: flex;
  align-items: center;
  justify-content: center;
}

.squad-bg {
  filter: blur(14px) brightness(0.3) saturate(0.6);
}

.squad-row {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.5em;
  padding: 0 0.6em;
  width: 100%;
  justify-content: center;
}

.squad-row img {
  width: 27%;
  max-width: 88px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #0e0e10;
}

.card:hover .squad-row img {
  border-color: var(--accent);
}

/* a monthly squad nested inside its roguelike season */
.sub-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 1.4em 0 0.3em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}

.sub-av {
  width: 1.9em;
  height: 1.9em;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #0e0e10;
}

.sub-name {
  margin-left: 0.3em;
}

.sub-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dimmer);
}

/* event theme playback */
.theme-btn {
  max-width: 20em;
}

.theme-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-btn.failed {
  opacity: 0.5;
  pointer-events: none;
}

/* second level of the nav, for the story categories */
#subtabs {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1.3em;
}

#subtabs.hidden {
  display: none;
}

/* what the guide says for and against each order */
.g-verdicts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px 32px;
  margin: 0 0 22px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.g-verdict h4 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.g-verdict.pros h4 {
  color: var(--accent);
}

/* the marker takes the heading's accent, the text stays as it reads */
.g-verdict.pros li::marker {
  color: var(--accent);
}

.g-verdict ul {
  margin: 0;
  /* the reset strips list markers site-wide; these read as a list and want them */
  list-style: disc outside;
  padding-left: 1.1em;
}

.g-verdict li {
  display: list-item;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dim);
}

/* source and licence credits */
#credits p {
  margin: 0 0 0.5em;
}

#credits .credits-note {
  margin-top: 0.9em;
  color: var(--dimmer);
}

/* the reset warning needs air before the button that acts on it */
.modal-body .reset-warning {
  margin-bottom: 1.1em;
}

/* how long a group is, under its progress meter */
.detail-size {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.4em;
  margin: -0.4em 0 1.2em;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.detail-size-words {
  color: var(--dim);
}

/* "31m" should not become "31M" */
.detail-size-time,
.detail-size-left {
  text-transform: none;
}

/* filtered out, but kept in place so its art never has to load again */
.card.filtered {
  display: none;
}

.shelf.all-filtered {
  display: none;
}

/* the longest stories, on the statistics sheet */
.stat-longest {
  margin-top: 1.8em;
}

.stat-longest h3 {
  margin: 0 0 0.6em;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.stat-longest tbody tr {
  cursor: pointer;
}

/* the ranking table reads left to right: rank, story, then the figures */
.stat-longest th:nth-child(2),
.stat-longest td:nth-child(2) {
  text-align: left;
}

.stat-longest tbody tr:hover {
  background: var(--panel-2);
}

.stat-rank {
  font-family: var(--mono);
  color: var(--dimmer);
  width: 2.4em;
}

.stat-story {
  display: block;
}

.stat-where {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.stat-longest tr.read .stat-story {
  color: var(--dim);
}

/* scrollbars hidden site-wide */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* the storyline an arc belongs to, above the arc heading */
.g-section-under {
  margin: 1.6em 0 -0.5em;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.g-credit {
  margin-top: 2.4em;
}

.btn.icon-only {
  padding: 0.5em 0.7em;
}

/* cover art is made for a dark ground; invert its scrims on the light theme */
:root[data-theme="light"] .card-scrim {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent 55%);
}

:root[data-theme="light"] #hdr,
:root[data-theme="light"] .detail-box,
:root[data-theme="light"] .modal-box {
  background: var(--panel);
}

:root[data-theme="light"] .card-art {
  background: #dedbd4;
}

/* the cast of a story, a row per character */
.sprite-row {
  margin-bottom: 1.6em;
}

.sprite-who {
  margin: 0 0 0.5em;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.sprite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.sprite-cell {
  padding: 0;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.16s ease;
}

.sprite-cell:hover {
  border-color: var(--accent);
}

.sprite-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.art-mode {
  margin-bottom: 0.4em;
}

/* the side reads an event files in the in-game archive */
.archive {
  margin-top: 1.8em;
  padding-top: 1.4em;
  border-top: 1px solid var(--line);
}

.archive-head {
  margin: 0 0 0.2em;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.archive-kind {
  margin: 1.1em 0 0.4em;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.archive-item {
  border-bottom: 1px solid var(--line-soft);
}

.archive-item summary {
  display: flex;
  align-items: baseline;
  gap: 0.8em;
  padding: 0.55em 0;
  cursor: pointer;
  list-style: none;
}

.archive-item summary::-webkit-details-marker {
  display: none;
}

.archive-item summary::before {
  content: "+";
  font-family: var(--mono);
  color: var(--dimmer);
}

.archive-item[open] summary::before {
  content: "\2212";
  color: var(--accent);
}

.archive-title {
  flex: 1;
}

.archive-meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.archive-text {
  margin: 0 0 1em 1.4em;
  white-space: pre-wrap;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--dim);
}

/* ---------------------------------------------------------- stats chart -- */

.chart-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0 0 1.2em;
  overflow-x: auto;
}

.chart-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1em;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--dimmer);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.chart-area {
  fill: rgba(255, 208, 32, 0.09);
}

.chart-line-views {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.chart-line-visitors {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}




.chart-hit {
  fill: transparent;
  cursor: default;
}

.chart-legend {
  display: flex;
  gap: 1.4em;
  margin-top: 0.7em;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chart-key {
  display: inline-block;
  width: 1.6em;
  height: 2px;
  margin-right: 0.5em;
  vertical-align: middle;
  background: var(--dim);
}

.chart-key.visitors {
  background: var(--accent);
}




.chart-empty {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3.5em 0;
  text-align: center;
}

/* contact details read as a short spec list, like the stats readout */
.contact-list {
  margin: 1.2em 0 0.4em;
  column-gap: 1.4em;
  row-gap: 0.5em;
}

.contact-list dt {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--dim);
  text-align: left;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.contact-list dd {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

.contact-list a {
  color: var(--accent);
}

.contact-list a:hover {
  text-decoration: underline;
}
