/* tiles: a metro screen, no script. Flat colour tiles on pure black, white ink, giant light lowercase cropped off the right edge.
   Zero gradients, zero bevels, no borders. White owns every focus state; a series' name lights in its own colour on hover. */

@font-face { font-family: "Selawik"; src: url("/assets/fonts/selawik-light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("/assets/fonts/selawik-semilight.woff2") format("woff2"); font-weight: 350; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("/assets/fonts/selawik-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("/assets/fonts/selawik-semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --ground: #000;
  --ink: #fff;
  --ink-2: #b4b4b4;
  --ink-3: #8c8c8c;
  --accent: #ffffff;
  --accent-ink: #000;
  --slate: #232323;
  --slate-hi: #2e2e2e;
  --g: 8px;
  --side: 16px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sans: "Selawik", "Segoe UI", system-ui, sans-serif;
  /* the type ramp, caption to poster */
  --t-cap: 13px;
  --t-small: 15px;
  --t-body: 18px;
  --t-lede: clamp(22px, 2.1vw + 12px, 34px);
  --t-tile: 20px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 var(--t-body)/1.55 var(--sans); font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
html { scrollbar-color: #3a3a3a var(--ground); scrollbar-width: thin; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
ul, ol { margin: 0; padding: 0; }
.hub, .links, .covers, .intro-tiles, .hello-tiles, .foot-tiles { list-style: none; }
img { display: block; max-width: 100%; }
p { margin: 0; }

.skip { position: absolute; left: 8px; top: -100px; z-index: 10; padding: 12px 16px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; }
.skip:focus { top: 8px; }

/* ---------- the giant cropped lowercase header ---------- */
.pivot {
  margin: 0; font-weight: 300; text-transform: lowercase; white-space: nowrap;
  line-height: .86; letter-spacing: -.035em; contain: inline-size;
  font-size: var(--t-pivot, clamp(64px, 24vw, 220px));
  margin-left: -.055em; /* optical: light lowercase sits flush with the grid */
}

/* a pivot header is the door to its own pane: it peeks in from the right edge, and a click slides the panorama to it */
.pivot-door { color: inherit; text-decoration: none; }
/* Tales Media and the series' names keep their capitals; generic words stay lowercase */
.pivot.proper, .tile-label.proper, .proper .pivot-door { text-transform: none; }
.pivot-door:hover { color: var(--h, var(--ink-2)); }
.pivot-door:focus-visible { outline: none; color: var(--accent-ink); background: var(--accent); }

/* ---------- tiles ---------- */
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  width: 100%; height: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--c, var(--slate)); color: var(--k, var(--ink));
  text-decoration: none; overflow: hidden; isolation: isolate;
  transform-origin: center; transition: transform .45s var(--ease), filter .2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
a.tile:hover { filter: brightness(1.12); }
a.tile:active {
  transform: perspective(720px) rotateX(6deg) rotateY(-4deg) scale(.965);
  transition-duration: .09s;
}
a.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
a.tile::after { content: ""; position: absolute; inset: 0; z-index: 3; background: var(--accent); opacity: 0; transition: opacity .15s; }
a.tile:focus-visible::after { opacity: 1; }
a.tile:focus-visible .tile-label, a.tile:focus-visible .tile-sub { color: var(--accent-ink); }
.tile-label {
  position: relative; z-index: 4; font-size: var(--t-tile); font-weight: 350; line-height: 1.1;
  text-transform: lowercase; letter-spacing: -.01em;
}
.tile-sub { position: relative; z-index: 4; margin-top: 4px; font-size: var(--t-cap); line-height: 1.25; overflow-wrap: anywhere; }
.utility { --c: var(--slate); --k: var(--ink); }
a.utility:hover { filter: none; background: var(--slate-hi); }
.door { --c: var(--ink); --k: #000; }
a.door:hover { filter: none; background: #e6e6e6; }

/* the live tile: a colour field that flips through its series' real covers */
.live { padding: 0; justify-content: flex-start; }
.faces { position: relative; flex: 1 1 auto; perspective: 900px; background: var(--c); }
.face { position: absolute; inset: 0; backface-visibility: hidden; transform-origin: 50% 50%; background: var(--c); }
.face-cover { transform: rotateX(90deg); opacity: 0; }
.face-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 9%; }
.live .tile-label { flex: none; padding: 8px 12px 10px; background: var(--c); }
@media (prefers-reduced-motion: no-preference) {
  .face { animation: var(--flip) calc(var(--n) * 3.6s) linear infinite backwards; animation-delay: calc(var(--i) * 3.6s - var(--o)); }
  .live:hover .face, .live:focus-visible .face { animation-play-state: paused; }
}
@media (prefers-reduced-motion: reduce) {
  /* one still: the first cover */
  .face-field { display: none; }
  .face-cover { display: none; transform: none; }
  .face-cover[style="--i:1"] { display: block; opacity: 1; }
  .tile, a.tile:active { transition: none; transform: none; }
}

/* ---------- home: intro ---------- */
.intro { display: grid; gap: 22px; margin-top: 28px; }
.lede { font-size: var(--t-lede); font-weight: 300; line-height: 1.3; max-width: 26ch; letter-spacing: -.01em; text-wrap: balance; }
.facts { font-size: var(--t-small); color: var(--ink-2); max-width: 46ch; }
.intro-tiles, .hello-tiles, .foot-tiles {
  display: grid; grid-template-columns: repeat(4, var(--u)); grid-auto-rows: var(--u); gap: var(--g);
}
.intro-tiles .wide, .hello-tiles .wide, .foot-tiles .wide { grid-column: span 2; }

/* ---------- hub ---------- */
.hub { display: grid; gap: var(--g); margin-top: 28px; }
.hub { grid-auto-flow: row dense; }
.hub > .L { grid-column: span 2; grid-row: span 2; }
.hub > .W { grid-column: span 2; grid-row: span 1; }
.hub .W .tile-label { font-size: 17px; }
.hub .W .face-img { object-position: 50% 19%; }
.hub > .hub-extra { display: none; }
.hub .L .tile-label { font-size: 22px; }

/* ---------- a series pane ---------- */
.series-body { margin-top: 28px; }
.series-tiles { display: grid; grid-template-columns: repeat(4, var(--u)); grid-auto-rows: var(--u); gap: var(--g); }
.field { grid-column: span 4; grid-row: span 2; justify-content: space-between; padding: 14px 16px 16px; user-select: text; }
.field-line { font-size: 19px; line-height: 1.32; font-weight: 350; text-wrap: pretty; }
.field-tag { font-size: var(--t-cap); font-weight: 600; }
.links { display: contents; }
.cover { margin: 0; background: var(--c); }
.cover-img { width: 100%; height: 100%; object-fit: cover; }
.covers { display: grid; gap: var(--g); }

/* ---------- hello ---------- */
.hello { display: grid; gap: 22px; margin-top: 28px; }
.hello-who { font-size: var(--t-lede); font-weight: 300; line-height: 1.2; }
.hello-note { font-size: var(--t-small); color: var(--ink-2); }

/* ---------- phones and narrow windows: one column of tiles ---------- */
@media not ((min-width: 900px) and (min-height: 560px)) {
  :root { --u: calc((100vw - 2 * var(--side) - 3 * var(--g)) / 4); }
  .pane { padding: 28px var(--side) 48px; overflow-x: clip; }
  .pane + .pane { padding-top: 48px; }
  .pane-intro { padding-bottom: 16px; }
  .pane-intro + .pane { padding-top: 16px; }
  .pivot { --t-pivot: 22vw; }
  .pivot-stack { line-height: 1.02; }
  .pivot-stack span { display: block; }
  /* every series tile is full size on a phone (a wide tile's strip is too thin to frame a cover), and a tenth tile,
     hello, fills the last row */
  .hub > .W { grid-row: span 2; }
  .hub > .W .tile-label { font-size: var(--t-tile); }
  .hub > .hub-extra { display: block; grid-column: span 2; grid-row: span 2; }
  .intro { gap: 16px; margin-top: 20px; }
  .intro-tiles { display: none; } /* the hub follows at once; the legal links are in hello and every page's foot */
  .hub, .series-body { margin-top: 16px; }
  .pivot-name { --t-pivot: 41vw; line-height: .8; }
  .pivot-name span { display: block; }
  .hub { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: var(--u); }
  .series-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .field { grid-column: 1 / -1; }
  .links li { grid-column: span 2; }
  .links li:last-child { grid-column: 1 / -1; }
  .links .tile-sub { display: none; }
  .series-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--g); }
  .series-tiles { grid-column: 1 / -1; }
  .covers { display: contents; }
  .cover { aspect-ratio: 9 / 16; }
  .intro-tiles, .hello-tiles, .foot-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .intro-tiles > li, .hello-tiles > li, .foot-tiles > li { grid-column: span 2; }
  .intro-tiles > .wide, .hello-tiles > .wide, .foot-tiles > .wide { grid-column: 1 / -1; }
}
@media not ((min-width: 900px) and (min-height: 560px)) and (max-width: 360px) {
  .tile-label { font-size: 16px; }
  .hub .W .tile-label { font-size: 15px; }
  .tile-sub { font-size: 11px; }
}

/* ---------- wide screens: the panorama ---------- */
@media (min-width: 900px) and (min-height: 560px) {
  :root {
    --side: clamp(32px, 3.4vw, 64px);
    --top: clamp(28px, 5vh, 56px);
    --bottom: clamp(24px, 5vh, 56px);
    --peek: 11vw;
    --t-pivot: clamp(96px, 19vh, 230px);
    --head: calc(var(--t-pivot) * .86 + 28px);
    --u: clamp(64px, calc((100dvh - var(--top) - var(--bottom) - var(--head) - 3 * var(--g)) / 4), 210px);
  }
  html:has(body.home), body.home { height: 100%; overflow: hidden; }
  .panorama {
    display: flex; height: 100vh; height: 100dvh; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    scrollbar-width: thin; scrollbar-color: #4a4a4a var(--ground);
  }
  .pane {
    flex: 0 0 auto; height: 100%; scroll-snap-align: start;
    min-width: calc(100vw - var(--peek)); padding: var(--top) var(--side) var(--bottom);
    overflow: hidden auto; display: flex; flex-direction: column;
  }
  .pane-intro { width: calc(100vw - var(--peek)); }
  .pane-series { min-width: 0; padding-right: calc(var(--side) + 5vw); }
  .pane-hello { min-width: 100vw; }
  .pivot-name span { display: inline; }
  .pivot-name { --t-pivot: clamp(120px, 35vh, 380px); }
  .intro { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 1fr auto; column-gap: 6vw; row-gap: 18px; flex: 1; }
  .intro .lede { grid-column: 1; grid-row: 1; align-self: end; }
  .intro .facts { grid-column: 1; grid-row: 2; }
  .intro .intro-tiles { grid-column: 2; grid-row: 1 / span 2; align-self: end; grid-template-columns: repeat(3, var(--u)); }
  .intro-tiles .wide { grid-column: span 3; }

  .hub { grid-template-rows: repeat(4, var(--u)); grid-auto-columns: var(--u); grid-auto-flow: column dense; }

  .series-body { display: flex; gap: var(--g); height: calc(4 * var(--u) + 3 * var(--g)); }
  .series-tiles { grid-template-columns: repeat(2, var(--u)); grid-template-rows: repeat(4, var(--u)); }
  .field { grid-column: span 2; grid-row: span 2; }
  .cover-hero { flex: none; height: calc(4 * var(--u) + 3 * var(--g)); width: calc((4 * var(--u) + 3 * var(--g)) * 9 / 16); }
  .covers { flex: none; grid-template-rows: repeat(2, calc(2 * var(--u) + var(--g))); grid-auto-flow: column; grid-auto-columns: calc((2 * var(--u) + var(--g)) * 9 / 16); }
  .covers > li:last-child:nth-child(odd) { display: none; } /* two rows: an odd one out would leave a hole */

  .hello { flex: 1; align-content: end; }
  .hello-tiles { grid-template-columns: repeat(6, var(--u)); }
  .hello-who { max-width: 30ch; }
}

/* entrance: type leads, tiles follow, gliding in from the right edge */
@keyframes glide { from { transform: translateX(12vw); opacity: .15; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .pane-intro .pivot, .legal .pivots, .lost .pivot { animation: glide 1.2s var(--ease) both; }
  .intro > *, .legal .doc, .lost-body { animation: glide 1.1s var(--ease) both; animation-delay: .14s; }
  .intro > .intro-tiles { animation-delay: .26s; }
  .pane-hub .pivot { animation: glide 1.5s var(--ease) both; animation-delay: .2s; }
  .panorama { scroll-behavior: smooth; }
  html:not(:has(.panorama)) { scroll-behavior: smooth; }
}

/* ---------- legal pages: a pivot over a plain reading column ---------- */
.legal { --side: clamp(16px, 5vw, 72px); }
.doc-top { padding: 12px var(--side) 0; }
.home-link {
  display: inline-flex; align-items: center; min-height: 44px; font-size: var(--t-small); font-weight: 350;
  color: var(--ink-2); text-decoration: none; letter-spacing: .01em;
}
.home-link:hover { color: var(--ink); }
.pivots { display: flex; align-items: baseline; gap: .42em; padding: 8px var(--side) .14em; overflow: hidden; --t-pivot: clamp(46px, 12.5vw, 168px); font-size: var(--t-pivot); }
.pivot-doc { contain: none; flex: none; }
.pivot-others { display: flex; gap: .42em; flex: none; }
.pivot-others .pivot { color: var(--ink-3); text-decoration: none; }
.pivot-others .pivot:hover { color: var(--ink); }
.doc {
  max-width: calc(66ch + 2 * var(--side)); padding: 40px var(--side) 64px; font-size: 18px; line-height: 1.65; color: #ededed;
}
.doc > * + * { margin-top: 1em; }
.doc h2 { margin: 2.2em 0 .5em; font-size: clamp(28px, 3.4vw, 40px); font-weight: 300; line-height: 1.1; letter-spacing: -.02em; color: var(--ink); }
.doc h2 + * { margin-top: 0; }
.doc .date { font-size: var(--t-small); color: var(--ink-2); }
.doc .lede { max-width: none; font-size: 22px; line-height: 1.45; font-weight: 350; color: var(--ink); text-wrap: pretty; }
.doc ul, .doc ol { padding-left: 1.3em; }
.doc li + li { margin-top: .5em; }
.doc li::marker { color: var(--ink-3); }
.doc strong { font-weight: 600; color: var(--ink); }
.doc code { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: .86em; background: var(--slate); padding: .1em .35em; overflow-wrap: anywhere; }
.doc a { text-decoration-thickness: 1px; text-underline-offset: .2em; overflow-wrap: anywhere; }
.doc a:hover { color: var(--ink-2); }
.doc-foot { padding: 0 var(--side) 48px; max-width: calc(66ch + 2 * var(--side)); }
.foot-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: clamp(72px, 9vw, 120px); }
.foot-who { margin-top: 20px; font-size: var(--t-small); color: var(--ink-2); }

/* ---------- 404 ---------- */
.lost-main { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 48px 0; overflow-x: clip; }
.pivot-lost { --t-pivot: clamp(110px, 30vw, 380px); padding-left: clamp(16px, 5vw, 72px); }
.lost-body { padding: 32px clamp(16px, 5vw, 72px) 0; display: grid; gap: 10px; justify-items: start; }
.lost-line { font-size: var(--t-lede); font-weight: 300; line-height: 1.2; }
.lost-more { color: var(--ink-2); }
.lost-tile { width: min(100%, 320px); height: 150px; margin-top: 20px; }

/* a series' second material colour as a seal stamped in the tile's corner (Japan: the vermilion seal on sumi) */
.seal { position: absolute; right: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px; background: var(--seal); }
.tile-label:has(.seal) { padding-right: 36px; }
.field > .seal { top: auto; right: 16px; bottom: 16px; width: 20px; height: 20px; margin: 0; }

/* live tile flips, one per face count */
@keyframes flip5 {
  0% { transform: rotateX(90deg); opacity: 0; }
  3.056% { transform: rotateX(0deg); opacity: 1; }
  20% { transform: rotateX(0deg); opacity: 1; }
  23.056%, 100% { transform: rotateX(-90deg); opacity: 0; }
}
