/* =========================================================================
   Catalogue extras: the lightbox, and the filter.

   Loaded on the page carrying [artychar_flash], alongside binder.css. Every
   colour, space and typeface is a theme.json token, so a change made in the
   Site Editor reaches these too and there is no second palette to keep in
   step.

   The site commits to one visual world - ink on paper - so there is no dark
   variant here by choice, not omission. Every surface paints its own ground.

   Note on the grid tile: .ac-flash-art is a flex container whose img is
   sized 100%/100% with object-fit:contain. The zoom anchor is a NEW element
   between the two, so it has to become the flex item and carry the size, or
   the drawing collapses to its intrinsic height. That is what .ac-flash-zoom
   below is doing.
   ====================================================================== */

/* ---------------- the zoom affordance on a tile ---------------- */

/* z-index:1 is doing something specific. style.css stretches the enquiry
   link across the whole tile - `.ac-flash-claim a::after { inset: 0 }` - so
   clicking anywhere on a tile goes to the contact form. That overlay comes
   later in the DOM than the figure, so without this it sits on top of the
   drawing and swallows every click meant for the zoom.

   The split is deliberate: the DRAWING opens the drawing, and everything
   else on the tile - the number, the name, the status, the "Ask about NN"
   link - still goes to the enquiry. Sending someone from a 340px thumbnail
   straight to an enquiry form asks them to commit to a piece they have not
   been able to look at properly. The lightbox carries the same "Ask about
   NN" link, so that path is not lost, only better informed. */
.ac-flash-zoom {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  cursor: zoom-in;
  text-decoration: none;
  border: 0;
}
.ac-flash-zoom:focus { outline: none; }
.ac-flash-zoom:focus-visible {
  outline: 2px solid var(--wp--preset--color--ink);
  outline-offset: 3px;
}

/* A small corner mark, so it is discoverable that the drawing opens. Shown
   on hover on a pointer device, and permanently on touch - where there is no
   hover to reveal it and the grid is the default view. */
.ac-flash-zoom::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 0.95rem;
  height: 0.95rem;
  border-right: 1.5px solid var(--wp--preset--color--ink-soft);
  border-bottom: 1.5px solid var(--wp--preset--color--ink-soft);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}
.ac-flash-item:hover .ac-flash-zoom::after,
.ac-flash-zoom:focus-visible::after { opacity: 0.85; }

@media (hover: none) {
  .ac-flash-zoom::after { opacity: 0.5; }
}

/* Filtered-out tiles. Belt and braces over the UA rule, because the grid
   sets display on its children. */
.ac-flash-item[hidden] { display: none !important; }

/* Progressive disclosure: twelve on show until "Show all". JS adds the
   class; without JS every tile is in the page. */
.ac-flash-grid.is-collapsed .ac-flash-item:nth-child(n + 13) { display: none !important; }

.ac-show-all {
  display: block;
  margin: var(--wp--preset--spacing--30) auto 0;
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--wp--preset--color--ink);
  background-color: var(--wp--preset--color--paper);
  border: 1px solid var(--wp--preset--color--ink);
  border-radius: 2px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: transform 120ms var(--ac-out), background-color 160ms ease, color 160ms ease;
}
.ac-show-all:hover {
  background-color: var(--wp--preset--color--ink);
  color: var(--wp--preset--color--paper);
}
.ac-show-all:active { transform: translateY(1px) scale(0.985); }
.ac-show-all:focus-visible {
  outline: 2px solid var(--wp--preset--color--ink);
  outline-offset: 3px;
}
.ac-show-all[hidden] { display: none; }
[data-ac-flash-view="binder"] .ac-show-all { display: none; }

/* ---------------- the filter ---------------- */

/* Grid-only. In binder view the grid is hidden, so a control that filters it
   would be filtering something nobody can see. */
[data-ac-flash-view="binder"] .ac-filter { display: none; }

.ac-filter {
  margin-block: var(--wp--preset--spacing--40) 0;
  max-width: 26rem;
}

.ac-filter-label {
  display: block;
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--wp--preset--color--pencil);
  margin: 0 0 0.4rem;
}

.ac-filter-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.ac-filter-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--wp--preset--font-family--body);
  font-size: 0.95rem;
  color: var(--wp--preset--color--ink);
  background-color: var(--wp--preset--color--paper);
  border: 1px solid var(--wp--preset--color--rule);
  border-radius: 2px;
  padding: 0.5rem 0.65rem;
  appearance: none;
}
.ac-filter-input::placeholder { color: var(--wp--preset--color--pencil); }
.ac-filter-input:focus {
  outline: 2px solid var(--wp--preset--color--ink);
  outline-offset: 1px;
  border-color: var(--wp--preset--color--ink-soft);
}

.ac-filter-clear {
  flex: 0 0 auto;
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--wp--preset--color--ink-soft);
  background-color: transparent;
  border: 1px solid var(--wp--preset--color--rule);
  border-radius: 2px;
  padding: 0 0.7rem;
  cursor: pointer;
}
.ac-filter-clear:hover {
  color: var(--wp--preset--color--ink);
  border-color: var(--wp--preset--color--ink-soft);
}

.ac-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.7rem;
}
.ac-chip {
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--wp--preset--color--pencil);
  background-color: var(--wp--preset--color--paper);
  border: 1px solid var(--wp--preset--color--rule);
  border-radius: 2px;
  padding: 0.38rem 0.7rem;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.ac-chip:hover { color: var(--wp--preset--color--ink); border-color: var(--wp--preset--color--pencil); }
.ac-chip[aria-pressed="true"] {
  background-color: var(--wp--preset--color--ink);
  border-color: var(--wp--preset--color--ink);
  color: var(--wp--preset--color--paper);
}
.ac-chip:focus-visible { outline: 2px solid var(--wp--preset--color--ink); outline-offset: 2px; }
.ac-filter-count {
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  color: var(--wp--preset--color--pencil);
  margin: 0.45rem 0 0;
  min-height: 1.1em; /* reserved, so results do not shunt the grid down */
}

/* ---------------- the lightbox ---------------- */

html.ac-lb-open,
html.ac-lb-open body { overflow: hidden; }
html.ac-lb-open body { position: fixed; width: 100%; }

.ac-lb {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2.5rem);
}
.ac-lb[hidden] { display: none; }

.ac-lb-backdrop {
  position: absolute;
  inset: 0;
  background-color: color-mix(in srgb, var(--wp--preset--color--ink) 92%, transparent);
  cursor: zoom-out;
}
/* Fallback for engines without color-mix; overridden above where supported. */
@supports not (background-color: color-mix(in srgb, red 50%, transparent)) {
  .ac-lb-backdrop { background-color: rgba(20, 17, 15, 0.94); }
}

.ac-lb-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: min(100%, 1100px);
  max-height: 100%;
}
/* The entrance is no longer a fade from the centre. catalogue.js grows the
   figure out of the tile (or binder page) it came from, so the enlarged
   drawing and its thumbnail read as the same object. The backdrop fades. */
.ac-lb-figure { transform-origin: top left; will-change: transform; }

.ac-lb-figure {
  margin: 0;
  min-height: 0;
  background-color: var(--wp--preset--color--paper);
  border: 1px solid var(--wp--preset--color--rule);
  padding: clamp(0.5rem, 1.5vw, 1rem);
  display: flex;
}

.ac-lb-img {
  display: block;
  margin: auto;
  max-width: 100%;
  /* Leave room for the caption bar and the page padding, so a tall drawing
     is never cropped by the viewport. */
  max-height: calc(100vh - 11rem);
  width: auto;
  height: auto;
  object-fit: contain;
  background-color: var(--wp--preset--color--paper);
}

.ac-lb-bar {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  color: var(--wp--preset--color--paper);
}
.ac-lb-bar p { margin: 0; }

.ac-lb-no {
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--wp--preset--color--paper);
  opacity: 0.75;
}
.ac-lb-name {
  font-family: var(--wp--preset--font-family--display);
  font-size: 1.05rem;
}
.ac-lb-status {
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  opacity: 0.7;
}
.ac-lb-claim {
  margin-left: auto;
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--wp--preset--color--paper);
  border-bottom: 1px solid color-mix(in srgb, var(--wp--preset--color--paper) 55%, transparent);
  text-decoration: none;
  padding-bottom: 1px;
}
.ac-lb-claim:hover { border-bottom-color: var(--wp--preset--color--paper); }
.ac-lb-claim[hidden] { display: none; }

/* ---------------- lightbox controls ---------------- */

.ac-lb-nav,
.ac-lb-close {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: 1px solid color-mix(in srgb, var(--wp--preset--color--paper) 30%, transparent);
  border-radius: 50%;
  color: var(--wp--preset--color--paper);
  cursor: pointer;
  line-height: 1;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.ac-lb-nav:hover,
.ac-lb-close:hover {
  border-color: var(--wp--preset--color--paper);
  background-color: color-mix(in srgb, var(--wp--preset--color--paper) 12%, transparent);
}
.ac-lb-nav:focus-visible,
.ac-lb-close:focus-visible {
  outline: 2px solid var(--wp--preset--color--paper);
  outline-offset: 2px;
}
.ac-lb-nav[hidden] { display: none; }

.ac-lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.6rem;
}
.ac-lb-prev { left: clamp(0.25rem, 1.5vw, 1.25rem); }
.ac-lb-next { right: clamp(0.25rem, 1.5vw, 1.25rem); }

.ac-lb-close {
  top: clamp(0.25rem, 1.5vw, 1.25rem);
  right: clamp(0.25rem, 1.5vw, 1.25rem);
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.5rem;
}

/* Announced, not shown - the visible number lives in the caption bar. */
.ac-lb-count {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* On a phone the side arrows would sit over the drawing. Move them under it,
   where thumbs are anyway. */
@media (max-width: 620px) {
  .ac-lb-nav {
    top: auto;
    bottom: 0.4rem;
    transform: none;
    width: 2.5rem;
    height: 2.5rem;
  }
  .ac-lb-prev { left: 25%; }
  .ac-lb-next { right: 25%; }
  .ac-lb-img { max-height: calc(100vh - 14rem); }
  .ac-lb-claim { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ac-flash-zoom::after { transition: none; }
  .ac-lb-nav,
  .ac-lb-close { transition: none; }
}

/* ---------------- the binder's enlarge button ---------------- */

/* Built by binder.js into the meter row under the book. It is styled here
   rather than in binder.css because what it does is open the lightbox, and
   keeping every lightbox surface in one file is worth more than filing it by
   which script happens to create the element. */

.ac-zoom-btn {
  font-family: var(--wp--preset--font-family--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--wp--preset--color--ink-soft);
  background-color: transparent;
  border: 1px solid var(--wp--preset--color--rule);
  border-radius: 2px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}
.ac-zoom-btn:hover {
  color: var(--wp--preset--color--ink);
  border-color: var(--wp--preset--color--ink-soft);
}
.ac-zoom-btn:focus-visible {
  outline: 2px solid var(--wp--preset--color--ink);
  outline-offset: 2px;
}
.ac-zoom-btn[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ac-zoom-btn { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ac-show-all { transition: none; }
  .ac-show-all:active { transform: none; }
}
