/* Dialogs: the sigil forge, the district archive, "About this world", the phone chapter sheet and
   the film. Native <dialog> elements, so focus trapping, Escape to close and the dimmed backdrop come
   from the browser. data-lenis-prevent on each one lets its own content scroll under Lenis. */

dialog {
  width: min(780px, calc(100% - 32px));
  max-height: 90svh;
  padding: 0;
  overflow: auto;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid #89967866;
  box-shadow: 0 35px 120px #0009;
}
dialog::backdrop {
  background: #060b08d9;
  backdrop-filter: blur(8px);
}
.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 5;
}
.dialog-inner {
  padding: 46px;
}
.dialog-inner .title {
  margin: 22px 0 16px;
  font-size: var(--text-story);
}
.dialog-intro {
  max-width: 560px;
  color: #b4bba7;
}
.dialog-intro + .dialog-intro {
  margin-top: 16px;
}
.dialog-inner > .link {
  margin-top: 18px;
}

/* ---------- Sigil forge ---------- */
.sigil-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 26px 0;
}
.sigil-option {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 10px 14px;
  overflow: hidden;
  background: #1a2016;
  border: 1px solid var(--line);
  transition:
    border-color 0.25s,
    background 0.25s;
}
.sigil-option[aria-pressed="true"] {
  border-color: var(--shu);
  background: #2a1c15;
}
.sigil-option img {
  width: 100%;
  height: 135px;
  object-fit: contain;
  object-position: 50% 20%;
  transition: transform 0.3s;
}
.sigil-option:hover img {
  transform: translateY(-5px);
}
.sigil-option strong {
  margin-top: 8px;
  font: 800 var(--text-line) / 1 var(--font-display);
}
.sigil-option .label {
  color: var(--muted);
}
.sigil-field {
  display: block;
  margin: 20px 0 8px;
}
.sigil-input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #161c13;
  color: var(--paper);
  font-size: var(--text-body);
}
.sigil-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
}
.sigil-actions p {
  font-size: var(--text-small);
  color: var(--muted);
}
.sigil-result {
  display: none;
  padding-top: 18px;
}
.sigil-result.show {
  display: block;
}
.sigil-result p {
  font-size: var(--text-small);
  color: var(--muted);
}

/* ---------- District archive ---------- */
.district-dialog-art {
  width: 100%;
  height: 235px;
  object-fit: cover;
}
.district-dialog-content {
  padding: 32px 40px 40px;
}
.district-dialog-content .title {
  margin: 16px 0 20px;
  font-size: var(--text-story);
}
.district-dialog-content > p {
  color: #bec4b1;
}
.district-dialog-content dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.district-dialog-content dt {
  color: var(--muted);
}
.district-dialog-content dd {
  margin: 4px 0 0;
}
.district-dialog-content .link {
  margin-top: 18px;
}

/* ---------- Phone chapter sheet ---------- */
.sheet {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 84px 22px 40px;
  border: 0;
  background: #0d110cf7;
}
.sheet-chapters {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.sheet-chapters a {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  font: 400 var(--text-lead) / 1 var(--font-display);
}
.sheet-chapters a[aria-current] {
  color: var(--shu-light);
}
.sheet-kanji {
  width: 32px;
  font-weight: 800;
  color: var(--shu);
}
.sheet-actions {
  display: grid;
  justify-items: start;
  gap: 6px;
  margin-top: 32px;
}
.sheet-actions .btn {
  width: 100%;
  margin-bottom: 12px;
}

/* ---------- The film: full screen, opened through the dawn iris (js/ui/film.js) ---------- */
.film {
  width: 100vw;
  max-width: none;
  height: 100svh;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border: 0;
  background: #000;
}
.film::backdrop {
  background: transparent;
  backdrop-filter: none;
}
.film-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.film-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--film-ui, 1);
  transition: opacity 0.5s;
}
.film-ui > * {
  pointer-events: auto;
}
.film-ui .chapter-mark {
  position: absolute;
  left: var(--pad);
  top: var(--chrome-top);
  min-height: 44px;
  text-shadow: 0 1px 10px #000;
}
.film-buttons {
  position: absolute;
  right: var(--pad);
  top: var(--chrome-top);
  display: flex;
  gap: 6px;
}
.film-sound {
  --icon-waves: 1;
}
.film-sound[aria-pressed="false"] {
  --icon-waves: 0;
  opacity: 0.6;
}
.film-progress {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 30px;
  height: 1px;
  background: #ece6d333;
}
.film-progress i {
  position: absolute;
  inset: 0;
  background: var(--shu);
  transform: scaleX(var(--film-progress, 0));
  transform-origin: left;
}
.film.playing:not(:hover) {
  --film-ui: 0.25; /* the UI steps back while the film plays */
}
/* When the film ends: one line and the two ways on */
.film-end {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 30px;
  padding: 0 var(--pad);
  text-align: center;
  background: radial-gradient(ellipse at 50% 55%, #1a120ecc, #000000f2 70%);
  opacity: 0;
  transition: opacity 0.8s;
}
.film.ended .film-end {
  opacity: 1;
}
.film-end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px 28px;
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  .dialog-inner {
    padding: 34px 22px;
  }
  .sigil-options {
    gap: 7px;
  }
  .sigil-option {
    padding: 8px 5px 10px;
  }
  .sigil-option img {
    height: 104px;
  }
  .sigil-option .label {
    display: none;
  }
  .sigil-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .district-dialog-content {
    padding: 26px 22px 30px;
  }
  .district-dialog-content dl {
    grid-template-columns: 1fr;
  }
  .district-dialog-art {
    height: 190px;
  }
}

/* The film's iris: the same soft circle of light as the chapters, animated by js/ui/film.js.
   Registering --film-iris as a length is what lets the browser animate it. */
@property --film-iris {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
.film.opening {
  -webkit-mask-image: radial-gradient(
    circle at var(--film-x) var(--film-y),
    #000 calc(var(--film-iris) - 160px),
    transparent var(--film-iris)
  );
  mask-image: radial-gradient(
    circle at var(--film-x) var(--film-y),
    #000 calc(var(--film-iris) - 160px),
    transparent var(--film-iris)
  );
}
