/* 魂 The revenants. Three character panels stacked on one sticky stage. All three are always
   "visible": js/sections/revenants.js gives each one its own opacity and position through CSS
   variables (--portrait-x, --info-alpha, …), so the hand-over from one to the next is scrubbed.
   Behind each portrait stands a giant kanji for who they are: 墨 ink, 鐘 bell, 糸 thread. */

.characters {
  position: relative;
  height: 340svh;
}
.characters-frame {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 700px;
  overflow: clip;
  background: var(--surface-revenants);
}
.character-topline {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: 118px;
  z-index: 8;
  display: grid;
  gap: 18px;
}
/* The roster's labels dim while the arts sheet opens over it. */
.characters :is(.character-topline, .character-info, .character-tabs) {
  opacity: var(--chapter-ink, 1);
}

/* ---------- One panel per character ---------- */
.character-panels {
  position: absolute;
  inset: 0;
}
.character-panel {
  --accent: var(--shu); /* each character has its own accent colour */
  position: absolute;
  inset: 0;
  z-index: var(--portrait-z, 0);
  opacity: var(--portrait-alpha, 0);
  pointer-events: none;
}
.character-panel.active {
  pointer-events: auto;
}
.character-panel[data-character="goro"] {
  --accent: #c9a25c; /* bronze */
}
.character-panel[data-character="shion"] {
  --accent: #b9a9c9; /* aster violet: shion (紫苑) is the aster */
}
.character-wash {
  position: absolute;
  width: 43%;
  height: 85%;
  left: 8%;
  top: 12%;
  background: radial-gradient(ellipse at center, var(--accent), transparent 70%);
  opacity: 0.09;
}
.character-glyph {
  position: absolute;
  left: 4%;
  top: 12%;
  font: 800 var(--text-glyph) / 1 var(--font-display);
  color: var(--accent);
  opacity: 0.1;
  transform: translate3d(var(--number-x, 0px), 0, 0);
}
.character-art-wrap {
  position: absolute;
  left: 0;
  bottom: 8%;
  width: 61%;
  height: 72%;
  perspective: 1200px;
  transform: translate3d(var(--portrait-x, 0px), var(--portrait-y, 0px), 0) scale(var(--portrait-scale, 1))
    rotate(var(--portrait-turn, 0deg));
  transform-origin: 50% 75%;
}
.character-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 20px 22px #0005);
  transform: translate3d(var(--tilt-x, 0px), 0, 0) rotate(var(--tilt-r, 0deg)); /* the mouse lean */
  transition: transform 0.22s ease-out;
  will-change: transform;
}

/* ---------- Character record ---------- */
.character-info {
  position: absolute;
  left: 60%;
  right: var(--pad);
  top: 27%;
  max-width: 450px;
}
.character-info > :not(h3) {
  transform: translate3d(var(--info-x, 0px), 0, 0);
  opacity: var(--info-alpha, 1);
}
.character-info h3 {
  font: 800 var(--text-name) / 0.86 var(--font-display);
  white-space: nowrap; /* its letters are split for the flip, so without this GORO could break as GOR / O */
  perspective: 900px;
  opacity: var(--name-alpha, 1);
}
.character-info .role {
  margin-bottom: 14px;
  color: var(--accent);
}
.character-info .alias {
  margin: 20px 0 18px;
  font: 400 var(--text-lead) / 1.35 var(--font-display);
}
.character-info .bio {
  max-width: 340px;
  color: #b6bca9;
}
.character-info blockquote {
  max-width: 330px;
  margin: 20px 0;
  padding-left: 16px;
  border-left: 2px solid var(--accent);
  font: 400 var(--text-body) / 1.7 var(--font-display);
  color: #e0dccb;
}
.character-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  max-width: 340px;
  margin-bottom: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.character-specs dt {
  color: var(--muted);
}
.character-specs dd {
  margin: 4px 0 0;
}

/* ---------- Tabs: an ink line fills with your progress through each character ---------- */
.character-tabs {
  position: absolute;
  bottom: 26px;
  left: var(--pad);
  right: calc(var(--pad) + 30px);
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.character-tabs button {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 0 4px;
  text-align: left;
  color: var(--muted);
  transition: color 0.3s;
}
.character-tabs button::before,
.character-tabs button::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--line);
}
.character-tabs button::after {
  height: 2px;
  top: -0.5px;
  background: var(--shu);
  transform: scaleX(var(--tab-progress, 0));
  transform-origin: left;
}
.character-tabs button[aria-selected="true"] {
  color: var(--paper);
}
.character-tabs .name {
  font: 800 var(--text-line) / 1 var(--font-display);
}

/* ---------- Large, tablet and short screens ---------- */
@media (max-width: 1100px) {
  .character-info {
    left: 56%;
  }
  .character-art-wrap {
    width: 60%;
    left: -2%;
  }
  .character-tabs .desc {
    display: none;
  }
}
@media (min-width: 761px) and (max-height: 880px) {
  /* below 880 px the quote would push the button into the tabs */
  .character-info blockquote {
    display: none;
  }
}
@media (min-width: 761px) and (max-height: 760px) {
  .characters-frame {
    min-height: 620px;
  }
  .character-topline {
    top: 100px;
  }
  .character-info {
    top: 24%;
  }
  .character-info .alias {
    margin: 12px 0;
  }
  .character-info blockquote {
    display: none;
  }
  .character-specs {
    margin-bottom: 14px;
    padding-top: 12px;
  }
}

/* ---------- Phone: the portrait stands behind, the record sits at the bottom ---------- */
@media (max-width: 760px) {
  .characters-frame {
    min-height: 760px;
  }
  .character-topline {
    top: 84px;
    gap: 10px;
  }
  .character-glyph {
    top: 14%;
    left: auto;
    right: -12%;
  }
  .character-art-wrap {
    top: 13%;
    bottom: auto;
    left: auto;
    right: -20%;
    width: 96%;
    height: 58%;
  }
  .character-art {
    object-position: center top;
  }
  .character-panel::after {
    /* fade the portrait's feet into the dark so the record reads */
    content: "";
    position: absolute;
    inset: 52% 0 0;
    background: linear-gradient(transparent, var(--surface-revenants) 42%);
  }
  .character-info {
    z-index: 2;
    top: auto;
    left: var(--pad);
    right: var(--pad);
    bottom: 88px;
    max-width: none;
  }
  .character-info .role {
    margin-bottom: 8px;
  }
  .character-info .alias {
    margin: 10px 0;
  }
  .character-info .bio {
    max-width: 330px;
    margin-bottom: 18px;
    font-size: var(--text-small);
    line-height: 1.6;
  }
  .character-info blockquote,
  .character-specs {
    display: none;
  }
  .character-tabs {
    right: var(--pad);
    bottom: 22px;
    gap: 12px;
  }
  .character-tabs button {
    padding-top: 14px;
  }
}

/* ---------- Reduced motion: the three characters one after another ---------- */
html:is(.reduced, .compact-layout) .characters {
  height: auto;
}
html:is(.reduced, .compact-layout) .characters-frame {
  position: relative;
  height: auto;
  min-height: 0;
  padding-top: 230px;
  overflow: visible;
}
html:is(.reduced, .compact-layout) .character-panels {
  position: relative;
}
html:is(.reduced, .compact-layout) .character-panel {
  position: relative;
  height: 700px;
  opacity: 1;
  pointer-events: auto;
}
html:is(.reduced, .compact-layout) .character-panel .character-info {
  top: 10%;
}
html:is(.reduced, .compact-layout) .character-panel .character-art-wrap {
  height: 95%;
  bottom: 0;
}
html:is(.reduced, .compact-layout) .character-tabs {
  display: none;
}
html:is(.reduced, .compact-layout) .character-art {
  transform: none !important;
}
html:is(.reduced, .compact-layout) .character-glyph {
  top: 0;
  transform: none !important;
}
html:is(.reduced, .compact-layout) main :is(.character-art-wrap, .character-info > *) {
  transform: none !important;
  clip-path: none !important;
  opacity: 1 !important;
}
@media (max-width: 760px) {
  html:is(.reduced, .compact-layout) .characters-frame {
    padding-top: 190px;
  }
  html:is(.reduced, .compact-layout) .character-panel {
    height: 720px;
    border-bottom: 1px solid var(--line);
  }
  html:is(.reduced, .compact-layout) .character-panel .character-info {
    top: auto;
    bottom: 36px;
  }
  html:is(.reduced, .compact-layout) .character-panel .character-art-wrap {
    top: 0;
    height: 62%;
  }
}
