/* --------------------------------------------------------------------
   nightwatch.css — Brother Davis and the night watch, the comic.

   Full screen, on a dark ground, whatever theme is on: the drawings keep
   their own colours (see the note in nightwatch.js), and a comic reads best
   with nothing bright around the page.
   -------------------------------------------------------------------- */

.nw-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  border: 0;
  background: #0d0a08;
  color: #eadfc4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  overflow: hidden;
}
.nw-dialog:not([open]) { display: none; }
.nw-dialog::backdrop { background: #0d0a08; }

.nw-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 40px;
}
.nw-title { font-size: var(--step-0); font-weight: 600; margin: 0; color: #eadfc4; }

/*
 * One or two portrait pages. The height is worked out in nightwatch.js from
 * the window, so a page is always read whole — a panel taller than the
 * screen would have to be scrolled to reach its last caption, which is where
 * the point of the page usually is.
 */
.nw-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  touch-action: pan-y;
  user-select: none;
}

.nw-panel {
  margin: 0;
  flex: none;
  height: var(--nw-h, 60vh);
  aspect-ratio: 3 / 4;
  border: 3px solid #000;
  background: #15100c;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.6);
}

.nw-art { display: block; width: 100%; height: 100%; }

/*
 * The grain: a tile of speckle made in nightwatch.js, laid over the drawing so
 * flat colour reads as ink on paper, with the corners darkened the way a
 * printed page's are. Over the page, under nothing that can be pressed.
 */
.nw-panel { position: relative; overflow: hidden; }
.nw-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--nw-grain, none);
  background-size: 160px 160px;
  mix-blend-mode: overlay;
  opacity: 0.26;
  box-shadow: inset 0 0 70px rgb(0 0 0 / 0.5);
}

/* A page turned fades in. */
.nw-enter { animation: nw-in 420ms var(--ease) both; }
@keyframes nw-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }

/*
 * What moves in the drawings (29 Sept). Each is slow and small — a flame, a
 * drift of mist — so the page stays something to read. None of it runs for
 * e-paper or for "reduce motion"; the pictures are complete without it.
 */
.nw-art .nw-flicker {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: nw-flicker 1.9s ease-in-out infinite;
}
@keyframes nw-flicker {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  18% { transform: scale(0.94, 1.06) skewX(2.5deg); }
  37% { transform: scale(1.04, 0.95) skewX(-2deg); }
  52% { transform: scale(0.97, 1.03) skewX(1deg); }
  71% { transform: scale(1.02, 0.98) skewX(-3deg); }
  86% { transform: scale(0.96, 1.04) skewX(1.5deg); }
}
.nw-art .nw-glow { animation: nw-glow 2.6s ease-in-out infinite; }
@keyframes nw-glow { 0%, 100% { opacity: 1; } 30% { opacity: 0.84; } 55% { opacity: 0.97; } 75% { opacity: 0.88; } }
.nw-art .nw-ember { animation: nw-ember 1.7s ease-in-out infinite; }
@keyframes nw-ember { 50% { opacity: 0.3; } }
.nw-art .nw-halo { animation: nw-halo 8s ease-in-out infinite; }
@keyframes nw-halo { 50% { opacity: 0.72; } }
.nw-art .nw-twinkle { animation: nw-twinkle 3.6s ease-in-out infinite; }
@keyframes nw-twinkle { 50% { opacity: 0.12; } }
.nw-art .nw-shimmer { animation: nw-twinkle 3s ease-in-out infinite; }
.nw-art .nw-drift { animation: nw-drift 40s ease-in-out infinite alternate; }
.nw-art .nw-drift-slow { animation: nw-drift 70s ease-in-out infinite alternate-reverse; }
@keyframes nw-drift { to { transform: translateX(46px); } }
.nw-art .nw-smoke { stroke-dasharray: 12 9; animation: nw-smoke 2.6s linear infinite; }
@keyframes nw-smoke { to { stroke-dashoffset: -42; } }
.nw-art .nw-plume { animation: nw-plume 6s ease-in-out infinite; }
@keyframes nw-plume {
  0% { transform: translate(0, 6px); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(10px, -26px); opacity: 0; }
}
.nw-art .nw-rain { animation: nw-rain 0.7s linear infinite; }
@keyframes nw-rain { from { transform: translate(6px, -70px); } to { transform: translate(-6px, 70px); } }
.nw-art .nw-drip { animation: nw-drip 2.3s ease-in infinite; }
@keyframes nw-drip {
  0% { transform: translateY(-4px); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(64px); opacity: 0; }
}
.nw-art .nw-mote { animation: nw-mote 9s ease-in-out infinite alternate; }
@keyframes nw-mote { to { transform: translate(14px, -34px); opacity: 0.15; } }

@media (prefers-reduced-motion: reduce) {
  .nw-dialog *, .nw-dialog *::after { animation: none !important; }
}
[data-epaper] .nw-dialog *, [data-epaper] .nw-dialog *::after { animation: none !important; }

/* The lettering. Literata, the app's own face, a little heavier so it holds
   at the size a phone draws it. */
.nw-letter { font-family: var(--font-ui); font-weight: 500; letter-spacing: 0.005em; }
.nw-letter-title { font-weight: 600; letter-spacing: 0.06em; }
.nw-letter-sub { font-style: italic; }

.nw-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
}
.nw-where { font-variant-numeric: tabular-nums; min-width: 6rem; text-align: center; color: #b9ae94; font-size: var(--step--1); }

/* The buttons, drawn for the dark ground rather than for the theme. */
.nw-btn {
  min-width: 7rem;
  background: transparent;
  color: #eadfc4;
  border: 1px solid rgb(234 223 196 / 0.45);
}
.nw-btn:hover:not(:disabled) { background: rgb(234 223 196 / 0.1); }
.nw-btn:disabled { opacity: 0.35; }
.nw-btn:focus-visible { outline: 2px solid #eadfc4; outline-offset: 2px; }
.nw-btn-main { background: #eadfc4; color: #1e150e; border-color: #eadfc4; }
.nw-btn-main:hover:not(:disabled) { background: #fff4d8; }
.nw-close { min-width: 0; border-color: transparent; font-size: 1.4rem; }

.nw-note {
  margin: 0;
  max-width: 44rem;
  min-height: 2.6em;
  text-align: center;
  font-size: var(--step--1);
  line-height: 1.35;
  color: #b9ae94;
}

@media (max-width: 600px) {
  .nw-dialog { padding: var(--sp-1) var(--sp-2) var(--sp-2); }
  .nw-title { font-size: var(--step--1); }
  .nw-controls { gap: var(--sp-2); max-width: 100%; }
  /* The last page's button has the longest label in the set; on a phone it
     wraps onto two lines rather than pushing Back off the screen. */
  .nw-btn { min-width: 4.5rem; white-space: normal; line-height: 1.2; }
  .nw-btn-main { max-width: 46vw; }
  .nw-where { min-width: 3.5rem; }
  .nw-note { font-size: var(--step--2); }
}
