* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1d1a17;
  font-family: ui-monospace, "Courier New", monospace;
  color: #2b2620;
}

#scene {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

#menu {
  position: fixed;
  top: 12px;
  left: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 6px 10px;
  border: 1px solid #d8cfc0;
  border-radius: 4px;
  background: rgba(29, 26, 23, 0.88);
  color: #d8cfc0;
  font-size: 13px;
  opacity: 0.75;
}
#menu:hover, #menu[open] { opacity: 1; }
#menu summary { cursor: pointer; }
#menu details { margin-top: 8px; padding-left: 8px; border-left: 1px solid #5a5248; }
#menu details summary { opacity: 0.8; }
#menu label { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-top: 6px; }
#menu label[hidden] { display: none; }
#menu label > input, #menu label > select { grid-column: 1 / -1; width: 170px; font: inherit; }
#menu output { opacity: 0.6; }
#menu label > input[type="checkbox"] { grid-column: 2; grid-row: 1; width: auto; margin: 0; }
#menu button {
  margin-top: 10px;
  font: inherit;
  background: none;
  color: inherit;
  border: 1px solid #5a5248;
  border-radius: 3px;
  cursor: pointer;
}

#hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #d8cfc0;
  opacity: 0.6;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 0.3s;
}
#hint .read-hint, body.focused #hint .table-hint { display: none; }
body.focused #hint .read-hint { display: inline; }

#zine-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 100vw);
  height: 100vh;
  padding: 24px;
  overflow-y: auto;
  background: #f4eee2;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
  transform: translateX(110%);
  transition: transform 0.35s ease;
}
body.focused #zine-panel { transform: translateX(0); }

#zine-panel h2 { margin: 0 0 4px; font-size: 22px; }
#zine-panel .meta { margin: 0 0 16px; opacity: 0.6; }

#zine-panel .shut {
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: none;
  font: inherit;
  cursor: pointer;
}
#zine-panel .shut:hover { background: rgba(0, 0, 0, 0.06); }

#zine-panel .close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
}


/* ---- hover reader (text of the block under the mouse while reading) ----
   Departure Mono is a pixel font (SIL OFL, static/fonts/). It's drawn on an
   11px grid, so sizes are multiples of 11 to keep it crisp. */
@font-face {
  font-family: "Departure Mono";
  src: url("fonts/DepartureMono-Regular.woff2") format("woff2");
}
#text-mark, #text-reader {
  position: fixed;
  display: none;
  pointer-events: none; /* clicks still turn pages */
  z-index: 5;
}
#text-mark.on, #text-reader.on { display: block; }

/* outline around the block being read (subtitle); when the text
   is shown a piece at a time, a band shows which part of the block it is
   (--band-top / --band-h set by main.js) */
#text-mark::before, #text-mark::after {
  content: "";
  position: absolute;
  top: var(--band-top, 0);
  height: var(--band-h, 0);
  background: var(--ink, #1d1a17);
  transition: top 0.18s ease-out, height 0.18s ease-out;
}
#text-mark::after { left: -4px; right: -4px; opacity: 0.18; } /* the band over the piece */
#text-mark::before { left: -14px; width: 6px; } /* a solid marker beside it */
#text-mark {
  outline: 2px dashed var(--ink, #1d1a17);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--paper, #f4efe4);
}

#text-reader {
  font-family: "Departure Mono", monospace;
  font-size: 22px;
  line-height: 1.25;
  color: var(--ink, #1d1a17);
  background: var(--paper, #f4efe4);
  -webkit-font-smoothing: none;
  font-smooth: never;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* subtitle: a bar under the zine, like film subtitles */
#text-reader.subtitle {
  left: 50%;
  bottom: 48px;
  max-width: min(760px, 90vw);
  max-height: 40vh;
  overflow: hidden;
  padding: 11px 16px;
  border: 2px solid var(--ink, #1d1a17);
  box-shadow: 4px 4px 0 var(--ink, #1d1a17);
  transform: translateX(-50%);
}
@media (min-width: 701px) {
  body.focused #text-reader.subtitle { left: calc((100vw - 380px) / 2); } /* centered left of the panel */
}

/* a block shown a piece at a time: "2/4" in the corner (data-pos from main.js) */
#text-reader.paged::after {
  content: attr(data-pos);
  position: absolute;
  right: 6px;
  bottom: 2px;
  font-size: 11px;
  opacity: 0.6;
}

/* in place: the clean text laid right over the block on the page */
#text-reader.inplace {
  overflow: hidden;
  padding: 2px 4px;
  box-sizing: border-box;
  line-height: 1.1;
}
