/* Zoom: the magnifier on box-art covers and the window it opens (see js/zoom.js).
   Uses the site's colours and fonts when site.css is on the page, plain EGA values when not. */

/* the cover's box, when it had no position of its own (0 specificity: any site rule wins) */
:where(.qfz-host) { position: relative; }
.qfz-click { cursor: -webkit-zoom-in; cursor: zoom-in; }

/* ---- the magnifier: a small Sierra-white square in the cover's top-right corner ---- */
.qfz-btn {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  display: block; width: 34px; height: 34px; margin: 0; padding: 0;
  background: var(--paper, #ffffff); color: var(--ink, #000000);
  border: 2px solid var(--ink, #000000); border-radius: 0;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .6);
  cursor: -webkit-zoom-in; cursor: zoom-in;
  -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity .15s steps(3, end);
}
.qfz-btn[hidden] { display: none !important; }
.qfz-btn svg { display: block; width: 24px; height: 24px; margin: 0 auto; pointer-events: none; }
/* shown while the pointer is on the cover, and whenever it has the keyboard (:focus covers :focus-visible;
   naming that here too would drop the whole rule in a Safari that does not know it) */
.qfz-btn.qfz-hot, .qfz-btn.qfz-near, .qfz-btn:focus { opacity: 1; }
@media (hover: hover) {
  .qfz-btn:hover { opacity: 1; background: var(--yellow, #ffff55); }
}
.qfz-btn:focus-visible { background: var(--yellow, #ffff55); outline: 3px solid var(--yellow, #ffff55); outline-offset: 2px; }
.qfz-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .6); }
/* phones and tablets have no hover: always there, and a bigger target for a finger */
@media (hover: none), (pointer: coarse) {
  .qfz-btn { opacity: 1; width: 40px; height: 40px; }
}
@media print { .qfz-btn { display: none !important; } }

/* ---- the window with the art ---- */
html.qfz-lock { overflow: hidden; }
.qfz-dlg {
  position: fixed; top: 0; left: 0; inset: 0; z-index: 1000;
  box-sizing: border-box; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 24px; border: 0;
  background: transparent; color: var(--ink, #000000);
  overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.qfz-dlg:not([open]) { display: none; }
.qfz-dlg[open] { display: grid; }
/* the page behind goes dark through a coarse dither, as an EGA screen would dim it.
   (::backdrop gets literal colours: older Safari and Chrome do not pass custom properties to it) */
.qfz-dlg::backdrop {
  background-color: rgba(0, 0, 40, .78);
  background-image: repeating-conic-gradient(rgba(0, 0, 0, .55) 0 25%, transparent 0 50%);
  background-size: 4px 4px;
}
/* no <dialog> support: the same look from the layer itself (a class, not :not(:modal): a browser without
   <dialog> does not know :modal either and would drop the rule) */
.qfz-dlg.qfz-plain[open] { background: rgba(0, 0, 40, .9); }

/* a Sierra window: white, a black frame with the inner line, a hard shadow */
.qfz-win {
  margin: auto; position: relative;
  background: var(--paper, #ffffff); color: var(--ink, #000000);
  border: 2px solid var(--ink, #000000);
  box-shadow: inset 0 0 0 3px var(--paper, #ffffff), inset 0 0 0 4px var(--ink, #000000), 8px 8px 0 #000000;
  padding: 12px;
}
.qfz-frame { line-height: 0; }
.qfz-art {
  display: block; box-sizing: content-box; max-width: none; max-height: none;
  border: 2px solid var(--ink, #000000); background: #000000;
  image-rendering: auto;                 /* painted box art: smooth when enlarged (site.css makes img pixelated) */
  -webkit-user-drag: auto;
}
.qfz-art.qfz-px { image-rendering: -webkit-optimize-contrast; image-rendering: pixelated; image-rendering: crisp-edges; }
.qfz-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  margin-top: 10px;
  width: 0; min-width: 100%;             /* as wide as the picture, never wider */
}
.qfz-title {
  margin: 0; flex: 1 1 12em; min-width: 0;
  font: 700 20px/1.2 var(--pixel, "Pixelify Sans", "Courier New", monospace);
  overflow-wrap: anywhere;
}
.qfz-title[hidden] { display: none; }
.qfz-close {
  flex: none; margin-left: auto;
  font: 500 17px var(--pixel, "Pixelify Sans", "Courier New", monospace);
  color: var(--ink, #000000); background: var(--paper, #ffffff);
  border: 2px solid var(--ink, #000000); border-radius: 0; padding: 4px 16px;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
@media (hover: hover) { .qfz-close:hover { background: var(--ink, #000000); color: var(--paper, #ffffff); } }
@media (pointer: coarse) { .qfz-close { padding: 9px 20px; } }   /* a finger-sized Close (44px tall) */
.qfz-close:active { background: var(--ink, #000000); color: var(--paper, #ffffff); }
/* yellow on white would vanish: the keyboard's mark here is yellow inside a black ring */
.qfz-close:focus-visible { background: var(--yellow, #ffff55); color: var(--ink, #000000); outline: 2px solid var(--ink, #000000); outline-offset: 2px; }

/* phones: the art goes from edge to edge, the window becomes a band across the screen */
@media (max-width: 560px) {
  .qfz-dlg { padding: 0; }
  .qfz-win { border-width: 2px 0; padding: 0 0 12px; box-shadow: none; }
  .qfz-art { border-width: 0 0 2px; }
  .qfz-foot { padding: 0 12px; }
  .qfz-title { font-size: 18px; }
}

/* a phone on its side (or any short window): the name and Close go beside the art, not under it */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .qfz-dlg { padding: 10px 16px; }
  .qfz-win { display: flex; align-items: stretch; gap: 14px; padding: 10px; box-shadow: inset 0 0 0 3px var(--paper, #ffffff), inset 0 0 0 4px var(--ink, #000000), 6px 6px 0 #000000; border-width: 2px; }
  .qfz-art { border-width: 2px; }
  .qfz-foot { width: 9.5em; min-width: 0; margin: 0; padding: 2px 0 0; flex-direction: column; align-items: flex-start; justify-content: space-between; flex-wrap: nowrap; }
  .qfz-title { flex: none; font-size: 18px; }
  .qfz-close { margin-left: 0; }
}
