@import url("../fonts/zhi-mang-xing.css");

/* ---------- Tokens ---------- */
:root {
  --night: #0c1430;        /* sky after dusk */
  --night-deep: #060a1a;   /* the space between stars */
  --candle: #f2c879;       /* candlelight, winged light */
  --ember: #e5566a;        /* the red heart, red leaves */
  --cloud: #ece8f4;        /* primary text */
  --mist: #a3a8c6;         /* secondary text */
  --line: rgba(236, 232, 244, 0.14);

  --brush: "Zhi Mang Xing", "STXingkai", "KaiTi", cursive;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong",
           "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  /* scale ~1.333 (perfect fourth) */
  --t-sm: 0.875rem;
  --t-base: 1.0625rem;
  --t-md: 1.333rem;
  --t-lg: 1.777rem;
  --t-xl: 2.369rem;
  --t-xxl: 3.157rem;

  --measure: 34em;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; background: var(--night-deep); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--t-base);
  line-height: 1.8;
  color: var(--cloud);
  background: linear-gradient(180deg, var(--night-deep) 0, var(--night) 18%, #0a1128 60%, var(--night-deep) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration-color: rgba(242, 200, 121, .5); text-underline-offset: .25em; }
a:hover { color: var(--candle); }

:focus-visible {
  outline: 2px solid var(--candle);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  background: var(--candle); color: var(--night-deep); padding: .5rem 1rem;
}
.skip-link:focus { top: 1rem; }

/* Background light motes */
#sky {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
main, footer, .site-nav { position: relative; z-index: 1; }

/* ---------- Navigation ---------- */
.site-nav {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: clamp(1rem, 3vw, 2.5rem);
  padding: 1rem var(--gutter);
  transition: background .4s var(--ease), backdrop-filter .4s;
}
.site-nav.is-solid {
  background: rgba(6, 10, 26, .72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.wordmark {
  font-family: var(--brush);
  font-size: var(--t-lg);
  line-height: 1;
  text-decoration: none;
  color: var(--cloud);
}
.nav-links {
  display: flex; gap: clamp(.9rem, 2.4vw, 2rem);
  margin: 0 auto 0 0; padding: 0; list-style: none;
  font-size: var(--t-sm);
}
.nav-links a { text-decoration: none; color: var(--mist); }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--cloud); }
.nav-tools { display: flex; align-items: center; gap: .75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-size: var(--t-sm); line-height: 1;
  padding: .75em 1.4em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent; color: var(--cloud);
  cursor: pointer; text-decoration: none;
  transition: border-color .2s, background .2s, color .2s;
}
.btn:hover { border-color: var(--candle); color: var(--candle); }
.btn--light {
  background: var(--candle); border-color: var(--candle); color: var(--night-deep);
  box-shadow: 0 0 24px rgba(242, 200, 121, .35);
}
.btn--light:hover { background: #ffd993; color: var(--night-deep); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 2.5rem; height: 2.5rem; padding: 0;
  border-radius: 50%;
}
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.icon-btn[aria-pressed="true"] { color: var(--candle); border-color: var(--candle); }

@media (max-width: 720px) {
  .nav-links { display: none; }
  .nav-tools { margin-left: auto; }
}

/* ---------- Hero: two lights, almost touching ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  overflow: hidden;
  isolation: isolate;
}
.hero__art {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 60%;
}
.hero::after {           /* night wash over the key art */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(6,10,26,.55) 0%, rgba(6,10,26,.15) 35%, rgba(6,10,26,.35) 70%, var(--night-deep) 100%);
}

.hero__glyph {
  position: absolute;
  font-family: var(--brush);
  font-weight: 400;
  line-height: .9;
  font-size: clamp(7rem, 22vw, 18rem);
  color: rgba(236, 232, 244, .92);
  text-shadow: 0 0 40px rgba(242, 200, 121, .35);
  margin: 0;
}
.hero__glyph--zhi { top: 14%; left: 8%; }
.hero__glyph--chi { bottom: 16%; right: 8%; }

/* the two lights: one on each character, reaching toward the other */
.hero__glyph::after {
  content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: #fff6dc;
  box-shadow: 0 0 14px 5px rgba(242,200,121,.9), 0 0 70px 24px rgba(242,200,121,.35);
  animation: breathe 5s ease-in-out infinite;
}
.hero__glyph--zhi::after { right: -6%; bottom: -4%; }
.hero__glyph--chi::after { left: -6%; top: -4%; animation-delay: -2.5s; }
@keyframes breathe { 50% { transform: scale(1.5); opacity: .7; } }

.hero__text {
  align-self: end;
  justify-self: start;
  padding: 0 var(--gutter) clamp(2.5rem, 7vh, 4.5rem);
  max-width: 30rem;
}
.hero__tagline { font-size: var(--t-md); margin: 0 0 .25rem; letter-spacing: .08em; }
.hero__tagline-en { color: var(--mist); margin: 0 0 1.75rem; font-style: italic; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; }

/* one orchestrated entrance: the two characters drift toward each other */
.js .hero__glyph--zhi { animation: drift-in-left 1.8s var(--ease) both; }
.js .hero__glyph--chi { animation: drift-in-right 1.8s var(--ease) .25s both; }
.js .hero__glyph::after { animation: light-in 1.2s ease 1.6s both, breathe 5s ease-in-out 2.8s infinite; }
@keyframes drift-in-left  { from { opacity: 0; transform: translate(-6vw, -2vh); filter: blur(8px); } }
@keyframes drift-in-right { from { opacity: 0; transform: translate(6vw, 2vh);  filter: blur(8px); } }
@keyframes light-in { from { opacity: 0; transform: scale(0); } }

@media (prefers-reduced-motion: reduce) {
  .js .hero__glyph--zhi, .js .hero__glyph--chi, .hero__glyph::after, .js .hero__glyph::after { animation: none; }
}

@media (max-width: 720px) {
  .hero__glyph--zhi { top: 12%; left: 6%; }
  .hero__glyph--chi { bottom: auto; top: 34%; right: 6%; }
}

/* ---------- Sections ---------- */
.section {
  padding: clamp(4.5rem, 12vh, 8rem) var(--gutter);
  max-width: 72rem;
  margin: 0 auto;
}
.section__head {
  display: flex; align-items: baseline; gap: 1rem;
  margin: 0 0 2.5rem;
}
.section__title {
  font-family: var(--brush);
  font-weight: 400;
  font-size: var(--t-xxl);
  line-height: 1;
  margin: 0;
}
.section__sub { color: var(--mist); font-style: italic; margin: 0; }

/* Trailer */
.player {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8), 0 0 0 1px var(--line);
}
.player video { width: 100%; max-height: 80vh; margin: 0 auto; background: #000; }

/* Story: vertical Chinese beside horizontal English */
.story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(2rem, 6vw, 6rem);
  align-items: center;
}
.story__zh {
  writing-mode: vertical-rl;
  font-size: var(--t-md);
  line-height: 2.2;
  letter-spacing: .18em;
  height: 24em;
  margin: 0;
  padding: 1.5rem 0;
  border-right: 1px solid var(--line);
  padding-right: 1.25rem;
  justify-self: end;
}
.story__zh span { display: block; white-space: nowrap; }
.story__zh span:last-child { color: var(--candle); }
.story__en {
  max-width: var(--measure);
  font-size: var(--t-md);
  line-height: 1.75;
  color: var(--mist);
  font-style: italic;
  margin: 0;
}
@media (max-width: 720px) {
  .story { grid-template-columns: 1fr; }
  .story__zh { justify-self: center; height: auto; font-size: 1rem; letter-spacing: .1em; line-height: 2; order: -1; }
}

/* Episodes: a sequence, so they're numbered */
.episodes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.episode {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 15rem) minmax(0, 1fr) auto;
  gap: clamp(1rem, 3vw, 2.25rem);
  align-items: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.episode__num {
  font-family: var(--brush);
  font-size: var(--t-xl);
  line-height: 1;
  color: var(--candle);
  text-align: center;
}
.episode__thumb {
  aspect-ratio: 16 / 9; width: 100%; object-fit: cover;
  border-radius: 4px;
}
.episode__title { font-size: var(--t-md); margin: 0; font-weight: 600; }
.episode__title a { text-decoration: none; }
.episode__title a::after { content: ""; position: absolute; inset: 0; } /* whole row clickable */
.episode__logline { margin: .25rem 0 0; color: var(--mist); }
.episode__state { font-size: var(--t-sm); color: var(--mist); white-space: nowrap; }
.episode.is-released .episode__state { color: var(--candle); }
.episode.is-released:hover .episode__thumb { box-shadow: 0 0 0 1px var(--candle), 0 0 30px rgba(242,200,121,.25); }
.episode:not(.is-released) .episode__thumb { filter: grayscale(.6) brightness(.55); }
@media (max-width: 720px) {
  .episode { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .episode__thumb { grid-column: 2; }
  .episode__body { grid-column: 2; }
  .episode__state { grid-column: 2; }
  .episode__num { grid-row: 1; align-self: start; }
}

/* Gallery: one large still, the rest small */
.gallery {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: .75rem;
}
.gallery button {
  padding: 0; border: 0; background: none; cursor: zoom-in;
  border-radius: 4px; overflow: hidden;
}
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.gallery button:hover img { transform: scale(1.03); }
.gallery button:first-child { grid-row: span 3; }
@media (max-width: 720px) {
  .gallery { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .gallery button:first-child { grid-column: span 3; grid-row: auto; }
  .gallery button:not(:first-child) { aspect-ratio: 1; }
}

.lightbox {
  border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 92vh;
}
.lightbox::backdrop { background: rgba(6, 10, 26, .92); }
.lightbox img { max-height: 86vh; width: auto; border-radius: 4px; }
.lightbox figcaption { color: var(--mist); text-align: center; margin-top: .75rem; font-size: var(--t-sm); }
.lightbox__close {
  position: fixed; top: 1rem; right: 1rem;
}

/* Credits roll */
.credits { text-align: center; }
.credits dl { margin: 0 auto; display: grid; gap: 1.75rem; }
.credits dt { color: var(--mist); font-size: var(--t-sm); }
.credits dd { margin: .2rem 0 0; font-size: var(--t-md); }
.credits dd + dd { margin-top: 0; }

/* Footer */
.site-footer {
  padding: 3rem var(--gutter) 4rem;
  text-align: center;
  color: var(--mist);
  font-size: var(--t-sm);
  line-height: 1.7;
}
.site-footer p { margin: .25rem auto; max-width: 40rem; }

/* ---------- Watch page ---------- */
.watch {
  padding: calc(5rem + 2vh) var(--gutter) 4rem;
  max-width: 68rem;
  margin: 0 auto;
}
.watch__head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem;
  margin: 1.75rem 0 .5rem;
}
.watch__title { margin: 0; font-size: var(--t-xl); font-weight: 600; line-height: 1.2; }
.watch__title small { display: block; font-size: var(--t-base); font-weight: 400; color: var(--mist); font-style: italic; margin-top: .3rem; }
.watch__logline { color: var(--mist); margin: 0 0 1.5rem; }

.coming-soon {
  aspect-ratio: 16 / 9; position: relative; display: grid; place-items: center;
  border-radius: 6px; overflow: hidden;
}
.coming-soon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.35) grayscale(.4); }
.coming-soon p { position: relative; font-family: var(--brush); font-size: var(--t-xxl); margin: 0; }

.candle-btn .flame { width: 1rem; height: 1.2rem; }
.candle-btn[aria-pressed="true"] {
  color: var(--candle); border-color: var(--candle);
  box-shadow: 0 0 22px rgba(242, 200, 121, .3);
}

.episode-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 1.25rem 0; border-block: 1px solid var(--line); margin: 2rem 0 3rem;
}
.episode-nav a { text-decoration: none; color: var(--mist); }
.episode-nav a:hover { color: var(--candle); }

/* Comments */
.comments h2 { font-size: var(--t-lg); font-weight: 600; margin: 0 0 1.25rem; }
.comment-form { display: grid; gap: .75rem; margin-bottom: 2rem; }
.comment-form textarea {
  font: inherit; color: var(--cloud);
  background: rgba(236, 232, 244, .05);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .9rem 1rem;
  min-height: 6rem; resize: vertical;
}
.comment-form textarea:focus { outline: none; border-color: var(--candle); }
.comment-form__row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--mist); font-size: var(--t-sm); }
.signin-prompt {
  padding: 1.25rem; border: 1px dashed var(--line); border-radius: 6px;
  color: var(--mist); margin-bottom: 2rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem;
}
.signin-prompt p { margin: 0; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.comment__meta { display: flex; gap: .75rem; align-items: baseline; font-size: var(--t-sm); color: var(--mist); }
.comment__author { color: var(--cloud); font-weight: 600; }
.comment__body { margin: .35rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: var(--measure); }
.comment__delete {
  margin-left: auto; background: none; border: 0; color: var(--mist);
  font: inherit; font-size: var(--t-sm); cursor: pointer; text-decoration: underline;
}
.comment__delete:hover { color: var(--ember); }
.empty { color: var(--mist); font-style: italic; }
.form-error { color: var(--ember); font-size: var(--t-sm); margin: 0; }

.demo-banner {
  display: inline-block; margin: 1.25rem auto 0;
  border: 1px dashed var(--line); border-radius: 999px;
  padding: .4rem 1rem; font-size: .8rem; color: var(--mist);
}

/* ============ Phones (iPhone and friends) ============ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; -webkit-tap-highlight-color: transparent; }

/* room for the notch / Dynamic Island and the home bar */
.site-nav {
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.site-footer { padding-bottom: max(4rem, calc(env(safe-area-inset-bottom) + 2rem)); }

/* the phone menu */
.menu-btn { display: none; }
.menu-panel {
  position: fixed; inset: 0; z-index: 19;
  display: grid; place-items: center;
  background: rgba(6, 10, 26, .94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: menu-in .3s var(--ease);
}
.menu-panel[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; } }
.menu-panel__links {
  list-style: none; margin: 0; padding: 0; text-align: center;
  display: grid; gap: 1.4rem;
}
.menu-panel__links a {
  font-family: var(--brush); font-size: 2.6rem; line-height: 1;
  color: var(--cloud); text-decoration: none;
}
.menu-panel__links a:hover, .menu-panel__links a:focus-visible, .menu-panel__links a[aria-current="page"] { color: var(--candle); }
.menu-open, .menu-open body { overflow: hidden; }
.menu-open .site-nav { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }

/* credit names never split mid-name */
.credit-name { display: inline-block; white-space: nowrap; margin: 0 .55em; }

@media (max-width: 720px) {
  .menu-btn { display: inline-flex; }
  .nav-tools { gap: .5rem; }
  .nav-tools .btn:not(.icon-btn) { padding: .65em 1em; }

  .hero__text { padding-bottom: max(2.5rem, calc(env(safe-area-inset-bottom) + 1.5rem)); }
  .section { padding-top: 3.5rem; padding-bottom: 3.5rem; }
  .section__head { margin-bottom: 1.5rem; }
  .section__title { font-size: 2.6rem; }

  .gallery { grid-auto-rows: auto; }
  .gallery button:first-child { aspect-ratio: 16 / 9; }

  .watch__title { font-size: var(--t-lg); }
  .watch__head { align-items: center; }
  .episode-nav { font-size: var(--t-sm); }
  .comment-form__row { flex-wrap: wrap; }
}
