/* Usability layer on top of the imported Readymag pages. */

html {
  scroll-behavior: smooth;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Scroll target for in-page links. */
.page-anchor {
  position: absolute;
  width: 1px;
  height: 1px;
  scroll-margin-top: 0;
}

/* --- keyboard focus ------------------------------------------------------- */

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgb(200, 0, 0);
  border-radius: 6px;
}

/* --- navigation ----------------------------------------------------------- */

/* Plain-text links added to the copy (emails, contact line). */
.text-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.text-link:hover {
  color: rgb(255, 5, 5);
}

.snapshots-link {
  display: block;
  cursor: pointer;
}

.snapshots-link:hover span {
  color: rgb(255, 5, 5) !important;
}

/* --- portfolio sections ---------------------------------------------------- */

/* Invisible boxes over each portfolio section, used as link targets. */
.work-anchor {
  position: absolute;
  z-index: 500;
  pointer-events: none;
  scroll-margin-top: 24px;
  border-radius: 4px;
}

@keyframes work-anchor-flash {
  0%, 100% { box-shadow: none; }
  15%, 45% { box-shadow: 0 0 0 4px rgb(255, 5, 5), 0 0 30px rgb(255, 5, 5); }
  30% { box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.9), 0 0 30px rgba(0, 102, 255, 0.9); }
}

.work-anchor:target {
  animation: work-anchor-flash 1.6s ease-out 0.4s;
}

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

.widget-picture.preview-enabled {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px),
    rgba(0, 0, 0, 0.9);
  font-family: Oswald, sans-serif;
  color: #fff;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 0;
  min-width: 0;
}

/* Small GIFs are scaled up; the pixelation suits the work. */
.lightbox-figure img {
  width: min(1000px, 100%);
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 110px);
  border: 3px solid #fff;
  border-radius: 12px;
  background: #000;
  object-fit: contain;
}

.lightbox-caption {
  font-size: 15px;
  font-weight: 300;
  letter-spacing: 2px;
  opacity: 0.8;
}

.lightbox button {
  width: 52px;
  height: 52px;
  border: 3px solid #fff;
  border-radius: 6px;
  background: #000;
  color: #fff;
  font: 400 26px/1 Oswald, sans-serif;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.lightbox button:hover {
  border-color: transparent;
  background: rgba(255, 5, 5, 0.8);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* --- back to top ------------------------------------------------------------ */

.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 900;
  width: 52px;
  height: 52px;
  border: 3px solid #fff;
  border-radius: 6px;
  background: #000;
  color: #fff;
  font: 400 26px/1 Oswald, sans-serif;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, background-color 0.2s, border-color 0.2s;
}

.to-top.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.to-top:hover {
  border-color: transparent;
  background: rgba(255, 5, 5, 0.8);
}

/* --- reduced motion ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .animation-container,
  .work-anchor:target {
    animation: none !important;
    transition: none !important;
  }
}
