/* Xenogears PC: the comparison first; the game's own menu pieces (from the UI cel pack, in the game's
   palette) frame it. --gp is one game pixel; the window frame is 16 game pixels deep (8 halo, 3 line, 5 fill).
   The typeface is the lettering pack's dialogue face (tools/xg_font.py): 12 game pixels to the em, every
   character 8 wide, as the game spaces it. */
@font-face {
  font-family: 'XG Dialogue';
  src: url(/fonts/xg-dialogue.woff) format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/* Japanese (the /ja/ pages, and the language command): DotGothic16 (OFL), subset by tools/ja_font.py. It only
   fills in what the dialogue face lacks, so Latin letters and digits stay the game's. */
@font-face {
  font-family: 'XG Gothic JP';
  src: url(/fonts/xg-gothic-ja.woff2) format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  size-adjust: 88%;
  unicode-range: U+2000-206F, U+3000-30FF, U+4E00-9FFF, U+FF00-FFEF;
}
:root {
  --gp: 2px;
  --text: #f4f4f4;
  --dim: #8e8e9c;
  --u: clamp(15px, .3vw + 12px, 18px);
  --rail: clamp(200px, 15vw, 260px);
}

* { box-sizing: border-box; }
html { background: #000; }
body { margin: 0; min-height: 100vh; background: #000; color: var(--text); font-family: 'XG Dialogue', 'XG Gothic JP', ui-monospace, monospace; font-size: var(--u); line-height: 1.25; overflow-x: hidden; }
:lang(ja) { line-break: strict; word-break: auto-phrase; }   /* break between phrases, never before 。、 */
a { color: inherit; text-decoration: none; }
img { height: auto; }
i { font-style: normal; }

/* the game's text: white fading to grey down each line, a hard shadow */
.label, .sub, .cap, .key, .state, .qty, .sum, .dim, .count, .message p, .size {
  background: linear-gradient(#fff 0 42%, #a9a9ae 100%) 0 0 / 100% 1.25em;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(2px 2px 0 #000);
}
.dim, .state, .qty, .sum, .count, .size { background-image: linear-gradient(#b4b4c0, #6f6f7c); }
.name {
  /* a name in the game's menu: the white face inside the font's one-pixel outline, in the menu's blue */
  --o: calc(1em / 12);
  color: #efefef;
  text-shadow: calc(var(--o) * -1) 0 #312184, var(--o) 0 #312184, 0 calc(var(--o) * -1) #312184, 0 var(--o) #312184,
    calc(var(--o) * -1) calc(var(--o) * -1) #312184, var(--o) calc(var(--o) * -1) #312184,
    calc(var(--o) * -1) var(--o) #312184, var(--o) var(--o) #312184;
  font-weight: 400;
}

/* ---- the window: the pack's frame as a 9-slice (128 of 320 px = 16 game pixels) ---- */
.win {
  display: block;
  border: calc(var(--gp) * 16) solid transparent;
  border-image: url(/ui/frame.png) 128 fill / calc(var(--gp) * 16) stretch;
  image-rendering: pixelated;
  padding: calc(var(--gp) * 1) calc(var(--gp) * 3);
}
.win.sm { --gp: 1.25px; }
.win > * { image-rendering: auto; }

/* ---- orbs and the cursor ---- */
.orb {
  display: inline-block;
  flex: none;
  width: calc(var(--gp) * 15);
  height: calc(var(--gp) * 15);
  background: url(/ui/orb.png) center / contain no-repeat;
  image-rendering: pixelated;
}
.sel .orb, .wipe.drag .orb, .commands:not(:has(.sel)) [aria-current="page"] .orb { background-image: url(/ui/orb-sel.png); }
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 30;
  width: calc(var(--gp) * 31);
  aspect-ratio: 248 / 256;   /* sized before the image loads, so the first placement is right */
  image-rendering: pixelated;
  pointer-events: none;
  opacity: 0;
}
.cursor.on { opacity: 1; }
.cursor.go { animation: none; translate: -3px 3px; }
@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: bob .56s steps(1) infinite; }
}
@keyframes bob { 50% { translate: 3px -3px; } }

/* ---- layout: the rail and the stage ---- */
.layout { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 6px 18px 14px; }
.brand { align-self: flex-start; display: flex; align-items: baseline; gap: .55em; padding-right: calc(var(--gp) * 5); }
.brand .name { font-size: 1.35em; }
.commands { --gp: 1.65px; display: flex; flex-direction: column; gap: .25em; margin-block: auto; }
.commands a { display: flex; align-items: center; gap: .25em; width: max-content; margin-inline-start: min(calc(var(--step, 0) * .8em), 3.2em); font-size: 1.2em; outline: none; }
.commands a.sel .label { background-image: linear-gradient(#fff, #fff); }
main { min-width: 0; padding: 14px clamp(12px, 2vw, 32px) 40px 4px; }

/* ---- the stage ---- */
.viewer { display: flex; flex-direction: column; gap: 4px; }
.stage { padding: 0; width: min(100%, calc((100vh - 150px) * 16 / 9 + 64px)); margin: 0 auto; }
.wipe { --x: 50%; position: relative; margin: 0; overflow: hidden; background: #000; cursor: ew-resize; touch-action: pan-y; user-select: none; -webkit-user-select: none; outline: none; }
.wipe img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.wipe .after { clip-path: inset(0 0 0 var(--x)); }
.wipe .before { image-rendering: pixelated; }
.handle { position: absolute; top: 0; bottom: 0; left: var(--x); width: 3px; translate: -1.5px 0; background: #efefef; box-shadow: 0 0 0 1.5px #393963; }
.handle .orb { position: absolute; top: 50%; left: 50%; width: calc(var(--gp) * 22); height: calc(var(--gp) * 22); translate: -50% -50%; filter: drop-shadow(2px 2px 0 #000); }
.wipe.sel .handle .orb { background-image: url(/ui/orb-sel.png); }
.tag { position: absolute; top: .7em; max-width: calc(50% - .8em); padding: .18em .5em; font-size: .8em; background: rgba(0, 0, 0, .76); border-radius: 3px; pointer-events: none; }
.tag.left { left: .8em; }
.tag.right { right: .8em; }

.under { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; width: min(100%, calc((100vh - 150px) * 16 / 9 + 64px)); margin: 0 auto; }
.caption { display: flex; align-items: baseline; gap: .7em; }
.caption .name { font-size: 1.3em; }
.kinds { display: flex; align-items: center; gap: .2em 1.1em; }
.kinds a { display: flex; align-items: center; gap: .25em; outline: none; }
.kinds .key { font-size: .8em; }
.kinds [aria-current] .label { background-image: linear-gradient(#fff, #fff); }

.areas { list-style: none; display: flex; gap: 2px; margin: 6px auto 0; padding: 0 0 6px; overflow-x: auto; scrollbar-width: thin; width: min(100%, calc((100vh - 150px) * 16 / 9 + 64px)); }
.thumb { width: 200px; padding: 0; outline: none; }
.thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; filter: brightness(.7); transition: filter .12s; }
.thumb.sel img, .thumb[aria-current] img { filter: none; }
.thumb .cap { display: block; padding: .15em .4em .1em; font-size: .8em; }
.talk-box { width: min(100%, 980px); margin: 18px auto 0; padding: calc(var(--gp) * 2) calc(var(--gp) * 6) calc(var(--gp) * 5); }
.talk-box h2 { margin: 0 0 .4em; font-size: 1.15em; }
.talk-box p { margin: 0; }

/* ---- compare index ---- */
.index > .caption { display: inline-flex; margin-bottom: 10px; }
.area { margin: 0 0 22px; }
.area h2 { margin: 0 0 4px 14px; font-size: 1.3em; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 2px; }
.card { padding: 0; outline: none; }
.card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card .cap { display: flex; align-items: center; gap: .3em; padding: .2em .4em; font-size: .85em; background: none; filter: none; color: inherit; }
.card .count { margin-left: auto; }

/* ---- packs ---- */
.packs { max-width: 1100px; }
.release { padding: calc(var(--gp) * 3) calc(var(--gp) * 8) calc(var(--gp) * 6); }
.release h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1em; margin: 0 0 .6em; font-weight: 400; }
.release h2 .name { font-size: 1.4em; white-space: nowrap; }   /* the name stays whole; its state drops below when both don't fit */
.page-home .release { --gp: 1.25px; padding: .2em .8em .5em; }
.page-home .release h2, .page-home .release p { margin: 0 0 .45em; }
.page-home .release .get { margin: .45em 0 0; }
.state { font-size: .72em; }
.items { width: 100%; border-collapse: collapse; }
.items td { padding: .28em .9em .28em 0; }
.items .qty { padding-right: 0; text-align: right; }
.items tr + tr td { border-top: 1px dotted rgba(220, 220, 244, .16); }
.get { display: flex; flex-wrap: wrap; align-items: center; gap: .4em 2em; margin: 1.1em 0 .6em; }
.dl { display: flex; align-items: center; gap: .3em; font-size: 1.25em; outline: none; }
.dl .size { margin-left: .5em; font-size: .62em; }
.dl.off .label { background-image: linear-gradient(#8a8a90, #5c5c62); }
.sum { margin: 0 0 .2em; font-size: .72em; word-break: break-all; }
.sum i { margin-right: .5em; }
.install { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 2px; }
.install li { padding: 0; }
.install img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.slot { display: grid; place-items: center; aspect-ratio: 16 / 9; color: #4a4a50; font-size: 3em; background: repeating-linear-gradient(135deg, #2b2b2e 0 10px, #27272a 10px 20px); }
.install .cap { display: block; padding: .3em .6em .35em; font-size: .85em; }

/* ---- 404 ---- */
.lost { min-height: 70vh; display: grid; place-items: center; }
.message { padding: calc(var(--gp) * 4) calc(var(--gp) * 12) calc(var(--gp) * 6); font-size: 1.15em; }
.message p { margin: 0 0 .8em; }

/* ---- narrow screens: the rail becomes a bar ---- */
@media (max-width: 900px) {
  :root { --gp: 1.25px; }
  .layout { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 10px 4px; }
  .commands { --gp: 1.25px; flex-direction: row; flex-wrap: wrap; gap: .3em 1em; margin-block: 0; }
  .commands a { margin-inline-start: 0; font-size: 1.05em; }
  main { padding: 4px 6px 32px; }
  .stage, .under, .areas { width: 100%; }
  .thumb { width: 150px; }
}
@media (hover: none) and (pointer: coarse) { .cursor { display: none; } }
