/* ==========================================================================
   Tales Archive — home page

   The archive is a reference, so the front door is built like an index rather
   than a shop window. Two things carry it:

   1. The hero is a party window. The series opens every menu on a grid of
      faces, so the archive opens on the whole cast drifting behind glass —
      the one claim the page makes ("131 of them") stated in the material
      itself rather than as a number on a card.

   2. Under it, one row per title. Each row carries the game's own colour down
      its spine and through its characteristic-genre claim, its cover, and its
      entire roster as face windows. Seventeen rows, a hundred and thirty-one
      links: the whole archive is one click deep from here.
   ========================================================================== */

/* The archive's narrow measure, the same one the character pages use. The
   index is dense, and density needs a measure you can track across, not the
   full width of a desktop. */
.home { width: min(1180px, 100%); margin: 0 auto; padding: 0 var(--gutter) 3.5rem; }

/* --- Hero ---------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 30rem);
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: center;
  padding: clamp(2.5rem, 6vw, 4.75rem) 0 clamp(2.5rem, 5vw, 4rem);
}

.hero-say { max-width: 34rem; }

/* The series' logos are ruled constructions: a small tracked "TALES OF" sitting
   on a hairline, the title dropped underneath it. The rule runs out to the full
   measure so the lockup reads as built rather than centred. */
.hero h1 { margin: 0; }

.hero h1 .of {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--ui-alt);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero h1 .of::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), rgba(124, 101, 38, 0));
}

.hero h1 .it {
  display: block;
  margin-top: 0.28rem;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.9rem, 7vw, 5rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  color: var(--gold-2);
}

.hero .lede {
  max-width: 31rem;
  margin: 1.1rem 0 0;
  font-size: 1.02rem;
  color: var(--ink-2);
}

/* --- The tally: a metadata line, not a scoreboard ------------------------ */

.tally {
  margin: 1.6rem 0 0;
  font-family: var(--ui-alt);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.tally b { font-weight: 600; color: var(--gold-2); }

.tally i {
  display: inline-block;
  width: 1px;
  height: 0.85em;
  margin: 0 0.85rem -0.08em;
  background: var(--line);
}

/* --- Search -------------------------------------------------------------- */

.find { position: relative; max-width: 34rem; margin: 1.9rem 0 0; }

.find-box { position: relative; }

#archiveSearch {
  width: 100%;
  padding: 1rem 1.2rem;
  font: inherit;
  font-size: 1.02rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--bevel), var(--hard);
  transition: border-color 0.14s, box-shadow 0.14s;
}

#archiveSearch::placeholder { color: var(--ink-3); }

#archiveSearch:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--bevel), var(--hard), 0 0 30px rgba(201, 162, 39, 0.24);
}

.find-hint {
  margin: 0.65rem 0 0;
  font-size: 0.76rem;
  color: var(--ink-3);
}

.find-hint b { color: var(--ink-2); font-weight: 500; }

/* --- Results ------------------------------------------------------------- */

.find-results {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 0.5rem);
  max-height: 24rem;
  overflow-y: auto;
  padding: 0.35rem;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--hard), 0 18px 44px rgba(0, 0, 0, 0.6);
}

.find-hit {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 0.6rem;
  border-radius: 2px;
  border-left: 2px solid transparent;
}

.find-hit:hover,
.find-hit.is-cursor {
  background: rgba(201, 162, 39, 0.14);
  border-left-color: var(--gold);
}

.find-art { flex: none; width: 38px; height: 38px; }

.find-art img,
.find-noart {
  display: block;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 2px;
  object-fit: cover;
  object-position: top center;
}

.find-noart {
  background: repeating-linear-gradient(45deg,
    rgba(242, 223, 160, 0.09) 0 5px, transparent 5px 11px);
}

.find-text { min-width: 0; flex: 1; }

.find-name {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--ink);
}

.find-name b { color: var(--gold-2); font-weight: 700; }

.find-meta {
  display: block;
  font-family: var(--ui-alt);
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.find-kind {
  flex: none;
  font-family: var(--ui-alt);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0.16rem 0.5rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 2px;
}

.find-none,
.find-more {
  margin: 0;
  padding: 1rem 0.7rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-3);
}

.find-more { padding: 0.6rem; border-top: 1px solid var(--line); }

/* --- The party window ---------------------------------------------------- */

.hero-cast {
  position: relative;
  width: 100%;
  padding: 11px;
  background-color: #070B15;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--bevel), var(--hard);
}

/* The tab sits astride the frame's top edge, the way a Tales window is titled. */
.cast-plate {
  position: absolute;
  top: -0.72rem;
  left: 1.1rem;
  z-index: 2;
}

.cast-glass {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  height: clamp(19rem, 34vw, 30rem);
  overflow: hidden;

  /* Faces slide in and out under the frame instead of being cut off at it. */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 13%, #000 87%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 13%, #000 87%, transparent 100%);
}

.cast-col { overflow: hidden; }

/* Each run is printed twice and travels exactly its own length, so the copy
   behind it is already in place when the loop restarts. The spacing is a
   bottom margin rather than a grid gap: a gap would not divide evenly into the
   travel, and the column would tick at every restart. */
.cast-run {
  display: block;
  animation: cast-drift var(--dur, 90s) linear infinite;
  will-change: transform;
}

.cast-col:nth-child(2) .cast-run,
.cast-col:nth-child(3) .cast-run { animation-direction: reverse; }

.cast-run img {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: top center;
  border: 1px solid rgba(242, 223, 160, 0.13);
  border-radius: 2px;
  filter: saturate(0.86) brightness(0.84);
}

@keyframes cast-drift {
  from { transform: translateY(0); }
  to   { transform: translateY(-50%); }
}

/* --- The index ----------------------------------------------------------- */

.titles { list-style: none; margin: 0; padding: 0; }

/* An index line reads left to right: when it came out, what it looks like,
   what it is called and what it claims to be, then who is in it. The roster
   takes the right-hand half rather than hanging under the title, which keeps
   the line one screen-width of information instead of a third of one. */
.title-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 25rem) minmax(0, 1fr);
  gap: 0 clamp(1.4rem, 3vw, 2.5rem);
  align-items: start;
  padding: 1.45rem 0 1.45rem 1.55rem;
  border-top: 1px solid rgba(124, 101, 38, 0.45);
}

.titles > li:last-child { border-bottom: 1px solid rgba(124, 101, 38, 0.45); }

/* The spine. Seventeen stacked rows are otherwise indistinguishable, and the
   colour is the fastest way to tell one from the next — the same job the
   spine does on a shelf. */
.title-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.45rem;
  bottom: 1.45rem;
  width: 3px;
  background: var(--a, var(--gold));
  opacity: 0.58;
  transition: opacity 0.16s;
}

.title-row:hover::before,
.title-row:focus-within::before { opacity: 1; }

.row-open {
  display: grid;
  grid-template-columns: 3.5rem 82px minmax(0, 1fr);
  gap: 0 1.1rem;
  align-items: start;
}

.row-cover {
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #070B15;
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--bevel);
  transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s;
}

.row-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.94);
  transition: filter 0.16s;
}

.row-of {
  display: block;
  font-family: var(--ui-alt);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.row-name {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.5rem, 2.6vw, 1.95rem);
  line-height: 1.06;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: color 0.16s;
}

/* Bandai gives every title an invented genre, and it is the most characteristic
   writing the series produces. It is set as what it is — a claim, in quotes —
   with the claim itself carrying the game's colour. */
.row-genre {
  display: block;
  margin-top: 0.42rem;
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.35;
  text-wrap: balance;
  color: var(--ink-3);
}

.row-genre em { font-style: italic; color: var(--a, var(--gold-2)); }

.row-genre .qm {
  font-size: 1.3em;
  line-height: 0;
  vertical-align: -0.12em;
  color: var(--a, var(--gold));
  opacity: 0.55;
}

/* The years make a column of their own down the left edge, so the index can be
   read as the chronology it is. */
.row-year {
  padding-top: 0.05rem;
  font-family: var(--ui-alt);
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  transition: color 0.16s;
}

.title-row:hover .row-name,
.row-open:focus-visible .row-name { color: var(--gold-2); }

.title-row:hover .row-year,
.row-open:focus-visible .row-year { color: var(--a, var(--gold)); }

.title-row:hover .row-cover,
.row-open:focus-visible .row-cover {
  transform: translateY(-3px);
  border-color: var(--a, var(--gold));
  box-shadow: inset 0 0 0 1px var(--bevel), 0 8px 18px -8px rgba(0, 0, 0, 0.9);
}

.title-row:hover .row-cover img { filter: saturate(1.06); }

/* --- The roster on each row ---------------------------------------------- */

.cast {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 0.7rem 0.5rem;
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
}

.face { display: block; width: 54px; }

.face-art,
.face-none {
  display: block;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  background: #070B15;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}

.face-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  filter: saturate(0.9) brightness(0.94);
  transition: filter 0.14s;
}

.face-none {
  background: repeating-linear-gradient(45deg,
    rgba(242, 223, 160, 0.08) 0 5px, transparent 5px 11px);
}

.face-name {
  display: block;
  margin-top: 0.28rem;
  overflow: hidden;
  font-family: var(--ui-alt);
  font-weight: 500;
  font-size: 0.7rem;
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
  transition: color 0.14s;
}

.face:hover .face-art,
.face:focus-visible .face-art {
  transform: translateY(-3px);
  border-color: var(--a, var(--gold));
  box-shadow: 0 0 0 1px var(--a, var(--gold)), 0 8px 16px -8px rgba(0, 0, 0, 0.9);
}

.face:hover .face-art img { filter: none; }
.face:hover .face-name,
.face:focus-visible .face-name { color: var(--ink); }

/* --- Wordia, at the foot where a side activity belongs -------------------- */

.daily {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  margin-top: 3.25rem;
  padding: 1.25rem clamp(1.1rem, 3vw, 1.8rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--bevel), var(--hard-sm);
}

.daily .grow { flex: 1; min-width: 0; }

.daily h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  margin: 0.2rem 0 0.15rem;
  color: var(--ink);
}

.daily p { margin: 0; font-size: 0.85rem; color: var(--ink-3); }

/* --- Responsive ---------------------------------------------------------- */

/* Below the two-column hero, the party window keeps its place — it is the one
   thing on the page that says how much is in here — but flattens into a band
   the text can sit above. */
@media (max-width: 1000px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.25rem;
    padding-top: clamp(2rem, 6vw, 3rem);
  }

  /* Text and search stay first: this is a reference, and the way in outranks
     the view. The window follows as the section's closer. */
  .hero-cast { width: min(100%, 34rem); margin: 0 auto; }
  .cast-glass { height: 15rem; }
  .find { max-width: none; }
}

@media (max-width: 1180px) {
  .title-row { grid-template-columns: minmax(0, 1fr); }
  .cast { margin-top: 1rem; padding-left: calc(3.5rem + 82px + 2.2rem); }
}

/* On a phone the roster gives up its indent and runs the full width of the
   line: six faces across beats three stacked four deep. */
@media (max-width: 760px) {
  .row-open { grid-template-columns: 3.1rem 58px minmax(0, 1fr); gap: 0 0.85rem; }
  .row-year { font-size: 1.2rem; }
  .row-name { font-size: 1.45rem; }
  .row-genre { font-size: 0.95rem; }
  .cast { padding-left: 0; gap: 0.6rem 0.45rem; }
  .title-row { padding-left: 1.1rem; }
  .cast-glass { height: 13rem; }
}

@media (max-width: 560px) {
  .face, .face-art, .face-none { width: 44px; }
  .face-art, .face-none { height: 44px; }
  .face-name { font-size: 0.64rem; }
  .find-kind { display: none; }
  .daily { flex-wrap: wrap; }
}

/* --- Motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .cast-run { animation: none; transform: none; }
}
