/* The Heavenly Man, Brother Yun: the full audiobook in a sky.  Design: docs/DESIGN.md.  Fonts: assets/fonts.css (embedded).
   State classes on <html>: js, is-on (permanent), is-playing (reversible), has-place (reversible), is-still (reduced motion). */
:root {
  --night: #0b2038; --deep: #14385c; --cloud: #f6f1e7; --cloud-soft: #d3deea; --gold: #f2c879; --gold-deep: #c98f3a;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Alegreya Sans", system-ui, "Segoe UI", Roboto, sans-serif;
  --halo: .16;
}
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--night); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--night); color: var(--cloud); font: 400 1.125rem/1.55 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-x: hidden; }
a { color: var(--gold); text-underline-offset: .18em; }
a:hover { color: #ffe3b0; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
img { max-width: 100%; }

/* ---- the sky: one picture, fixed behind everything ---- */
.sky { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--night); pointer-events: none; }
.sky-pic { position: absolute; inset: -6%; background: var(--night) url(sky.jpg) center / cover no-repeat; transform: scale(1.06); will-change: transform; }
.sky::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(6, 20, 38, .6) 0, rgba(6, 20, 38, .18) 34%, rgba(6, 20, 38, 0) 60%, rgba(6, 20, 38, .4) 100%); }
.sky-light { position: absolute; left: -12%; bottom: -26%; width: 96%; height: 96%; background: radial-gradient(closest-side, rgba(255, 206, 120, .6), rgba(255, 206, 120, 0)); opacity: .42; transition: opacity 2s ease; z-index: 1; }
.is-playing .sky-light { opacity: .95; }

/* ---- the two corner keys (Global Menu, Share) ---- */
.keys { position: fixed; z-index: 5; top: max(10px, env(safe-area-inset-top, 0px)); left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 0 max(12px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.keys > * { pointer-events: auto; }
.key { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: .5rem 1rem; border-radius: 999px; border: 1px solid rgba(246, 241, 231, .4); background: rgba(10, 30, 52, .6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: var(--cloud); font: 700 .98rem/1 var(--sans); cursor: pointer; }
.key:hover { background: rgba(20, 56, 92, .85); }
.key .glyph { font-size: 1rem; }

/* ---- first screen ---- */
main { position: relative; z-index: 2; }
.hero { display: grid; justify-items: center; padding: 4.1rem 1rem 0; }
.head { text-align: center; }
.kicker { margin: 0 0 .3rem; font: 700 .8rem/1.2 var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--gold); text-shadow: 0 1px 12px rgba(4, 14, 28, .8); }
.title { margin: 0; font: italic 500 clamp(2.7rem, 5.8vw, 4.6rem)/1.02 var(--serif); letter-spacing: .005em; color: var(--cloud); text-shadow: 0 2px 34px rgba(6, 20, 40, .7), 0 1px 2px rgba(6, 20, 40, .5); }
.title .w { display: inline-block; white-space: nowrap; }
.title .lt { display: inline-block; animation: condense 1.7s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 60ms + 200ms); }
@keyframes condense { from { opacity: 0; filter: blur(14px); transform: translateY(12px); } to { opacity: 1; filter: blur(0); transform: none; } }
.sub { margin: .25rem 0 0; font: italic 500 clamp(1.3rem, 2.4vw, 1.75rem)/1.2 var(--serif); color: var(--cloud); text-shadow: 0 1px 16px rgba(6, 20, 40, .8); }

.stage { display: grid; justify-items: center; margin-top: 1.1rem; width: 100%; }
.frame { width: min(860px, 94vw, calc((100svh - 300px) * 16 / 9)); min-width: min(320px, 94vw); padding: 8px; border-radius: 22px; background: linear-gradient(160deg, rgba(246, 241, 231, .26), rgba(246, 241, 231, .08));
  box-shadow: 0 30px 80px rgba(4, 14, 28, .55), inset 0 0 0 1px rgba(246, 241, 231, .3), 0 0 70px rgba(255, 206, 120, var(--halo)); transition: box-shadow 2s ease; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.is-playing .frame { --halo: .5; }
.screen { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; isolation: isolate; }
.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .8s ease; }
.slot { position: absolute; inset: 0; }
.slot iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.screen[data-live="1"] .poster { opacity: 0; pointer-events: none; }
.begin { position: absolute; inset: 0; display: grid; place-items: center; text-decoration: none; z-index: 3; }
.is-on .begin { opacity: 0; pointer-events: none; transition: opacity .5s ease; }
.play { position: relative; display: grid; place-items: center; width: 86px; height: 86px; border-radius: 50%; background: rgba(246, 241, 231, .94); box-shadow: 0 10px 34px rgba(4, 14, 28, .55), 0 0 0 1px rgba(255, 255, 255, .5) inset; transition: transform .25s ease; }
.play::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(242, 200, 121, .85); animation: breathe 3.6s ease-in-out infinite; }
.begin:hover .play { transform: scale(1.06); }
.tri { display: block; width: 0; height: 0; margin-left: 7px; border-left: 26px solid var(--deep); border-top: 16px solid transparent; border-bottom: 16px solid transparent; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.14); opacity: .25; } }

/* the cloud that lifts off the frame at the press */
.mist { position: absolute; inset: -25%; z-index: 4; pointer-events: none; opacity: 0; filter: blur(10px);
  background: radial-gradient(48% 42% at 28% 62%, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 70%), radial-gradient(44% 40% at 74% 40%, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 70%), radial-gradient(50% 44% at 50% 52%, rgba(235, 242, 250, .85), rgba(235, 242, 250, 0) 72%); }
.is-on .mist { animation: lift 1.5s cubic-bezier(.3, .6, .3, 1) both; }
@keyframes lift { from { opacity: 1; transform: scale(1) translate(0, 0); } to { opacity: 0; transform: scale(1.5) translate(5%, -8%); } }

.credit .nw { white-space: nowrap; }
.credit { margin: .95rem 0 0; padding: .3rem 1rem; border-radius: 999px; background: rgba(8, 24, 46, .74); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-size: .98rem; color: var(--cloud-soft); text-align: center; }
.resume { display: none; margin-top: .7rem; }
.has-place .resume { display: block; }
.resume button { min-height: 44px; padding: .5rem 1.2rem; border-radius: 999px; border: 1px solid rgba(242, 200, 121, .7); background: rgba(8, 24, 46, .66); color: var(--cloud); font: 700 1rem/1 var(--sans); cursor: pointer; }
.resume button:hover { background: rgba(242, 200, 121, .2); }
.resume b { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---- the sheet: the description, three links, the foot ---- */
.sheet { margin-top: 1.6rem; padding: 2.4rem 1.25rem 2.2rem; border-radius: 28px 28px 0 0; background: linear-gradient(180deg, rgba(11, 32, 56, .9), var(--night) 46%); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 -20px 60px rgba(4, 14, 28, .35); }
.wrap { max-width: 44rem; margin: 0 auto; }
.from { margin: 0 0 .7rem; font: 700 .78rem/1.2 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.lede { margin: 0; font: italic 400 clamp(1.4rem, 3.3vw, 1.75rem)/1.5 var(--serif); color: var(--cloud); text-align: justify; text-wrap: pretty; }
.links { list-style: none; display: flex; flex-wrap: wrap; gap: .7rem; margin: 1.7rem 0 0; padding: 0; }
.links li { margin: 0; }
.btn { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .6rem; min-height: 48px; padding: .72rem 1.25rem; border-radius: 999px; border: 1px solid rgba(242, 200, 121, .55); background: rgba(246, 241, 231, .08); color: var(--cloud); text-decoration: none; font: 700 1.05rem/1.2 var(--sans); }
.btn small { font: 400 .92rem/1.2 var(--sans); color: var(--cloud-soft); }
.btn:hover { background: rgba(242, 200, 121, .2); color: var(--cloud); }
.foot { margin-top: 2.2rem; padding-top: 1.1rem; border-top: 1px solid rgba(246, 241, 231, .16); font-size: .98rem; color: var(--cloud-soft); display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.foot a { display: inline-flex; align-items: center; min-height: 44px; }

@media (max-width: 700px) { .lede { text-align: left; } }   /* a narrow column justified makes rivers: left-aligned on a phone */
@media (max-width: 560px) {
  .hero { padding-top: 3.9rem; }
  .play { width: 70px; height: 70px; }
  .tri { border-left-width: 21px; border-top-width: 13px; border-bottom-width: 13px; margin-left: 5px; }
  .sheet { padding-top: 1.9rem; }
  .key .kl { font-size: .92rem; }
}
@media (max-height: 560px) and (min-width: 700px) { .frame { width: min(860px, 94vw, calc((100svh - 190px) * 16 / 9)); } }

/* ---- no JavaScript: the sky is still, the poster is a plain link to YouTube ---- */
html:not(.js) .title .lt { animation: none; }

/* ---- reduced motion: the same states at once, nothing moves ---- */
.is-still .title .lt, .is-still .play::before { animation: none; }
.is-still .mist { display: none; }
.is-still .sky-light, .is-still .frame, .is-still .poster, .is-still .play { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .title .lt, .play::before { animation: none; }
  .mist { display: none; }
  .sky-light, .frame, .poster, .play { transition: none; }
}
@media print { .sky, .keys { display: none; } body { background: #fff; color: #000; } }
