/* ==========================================================================
   Harderwijk site — enhancements.css
   Zero-JS progressive polish. Safe to load on every page, after the base
   stylesheet. Nothing here is required for the site to work; it only adds
   affordances modern browsers already support.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Anchor targets — keep headings clear of a sticky header when jumping
   to #id links, so the destination is never hidden underneath the nav.
   -------------------------------------------------------------------------- */
:target,
[id] {
  scroll-margin-top: 5.5rem;      /* header height + breathing room */
  scroll-margin-block-start: 5.5rem; /* logical equivalent for writing modes */
}
/* Sub-sections need less offset than top-level anchors. */
h3[id], h4[id], dt[id] { scroll-margin-top: 4rem; }


/* --------------------------------------------------------------------------
   2. Focus-visible rings — keyboard users get a clear, high-contrast ring;
   mouse users get nothing. Never remove outlines wholesale.
   -------------------------------------------------------------------------- */
:focus { outline: none; }

:focus-visible {
  outline: 3px solid var(--focus-color, #1f6f8b);
  outline-offset: 3px;
  border-radius: 2px;
}

/* On dark surfaces, opt in with a class so the ring stays visible. */
.on-dark :focus-visible,
:focus-visible.on-dark {
  --focus-color: #ffd479;
}

/* Links inside body text: an underline reads better than a box. */
.prose a:focus-visible {
  outline-offset: 2px;
  text-decoration-thickness: 2px;
}

/* Skip link — invisible until focused. */
.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  inset-block-start: -4rem;
  z-index: 100;
  padding: 0.65rem 1.1rem;
  background: #12324a;
  color: #fff;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: inset-block-start 0.15s ease;
}
.skip-link:focus-visible { inset-block-start: 0; }


/* --------------------------------------------------------------------------
   3. Card hover / active lift — transform + shadow only (compositor-friendly,
   no layout thrash). Also gives a hover state to keyboard focus.
   -------------------------------------------------------------------------- */
.card {
  transition:
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.22s ease,
    border-color 0.22s ease;
  will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover,
  .card:focus-within {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -12px rgba(18, 50, 74, 0.35);
  }
  .card:active { transform: translateY(-1px); }
}

/* Cards that are links: make the whole surface feel clickable. */
a.card { text-decoration: none; display: block; }
a.card:hover { text-decoration: underline; text-underline-offset: 0.2em; }

/* Subtle underline-grow for nav links (no JS, no layout shift). */
.nav a {
  position: relative;
  text-decoration: none;
}
.nav a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: -0.25em;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}
.nav a:hover::after,
.nav a[aria-current="page"]::after { transform: scaleX(1); }


/* --------------------------------------------------------------------------
   4. Lazy-load friendly images — reserve the box before the bytes arrive so
   the layout never jumps (CLS). Set --ar per image or per block.
   -------------------------------------------------------------------------- */
.img-box {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ar, 16 / 9);
  background: linear-gradient(100deg, #e9e2d5 30%, #f4efe6 50%, #e9e2d5 70%);
  background-size: 200% 100%;
  border-radius: inherit;
}

/* Skeleton shimmer while the image is still loading. */
.img-box img:not([src]),
.img-box img[src=""] { opacity: 0; }

.img-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.6) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: hw-shimmer 1.6s ease-in-out infinite;
  pointer-events: none;
}
.img-box.is-loaded::before { display: none; }

@keyframes hw-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.img-box img,
figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}

/* Standalone images (not in .img-box) still need a ratio to avoid jumps. */
img[width][height] { height: auto; }

/* Figures: caption styling that survives any base reset. */
figure { margin: 0 0 1.5rem; }
figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #5c6b78;
  font-style: italic;
}

/* SVG ornaments used as decoration should never be announced or selected. */
svg[aria-hidden="true"],
.ornament {
  display: block;
  pointer-events: none;
  user-select: none;
}


/* --------------------------------------------------------------------------
   5. Reduced motion — one guard for everything on the page. Honour the OS
   setting; animations collapse to instant state changes, not removal.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .img-box::before { animation: none; }
  .card:hover { transform: none; }
  /* Reveal animations (see js/optional.js) must land visible, not stuck. */
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* Smooth scrolling is opt-in for the whole document; optional.js upgrades
   it to a guarded version that respects the setting above. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}


/* --------------------------------------------------------------------------
   6. Print — the site is a visitor guide; people print itineraries.
   Strip chrome, keep content, expose link targets.
   -------------------------------------------------------------------------- */
@media print {
  @page { margin: 1.6cm; }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.45;
  }

  /* Hide anything that only makes sense on screen. */
  nav, header .nav, footer, .skip-link, .no-print,
  form, button, .cookie-banner, [role="search"] { display: none !important; }

  /* Ornaments are decoration, not information. */
  .ornament, svg[aria-hidden="true"] { display: none !important; }

  a { color: #000 !important; text-decoration: none; }
  /* Show where external links actually go. */
  a[href^="http"]::after,
  a[href^="mailto"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #444;
    word-break: break-all;
  }

  /* Keep headings with their content and blocks intact across pages. */
  h1, h2, h3 { break-after: avoid-page; page-break-after: avoid; }
  figure, .card, li, tr { break-inside: avoid; page-break-inside: avoid; }
  img { max-width: 100% !important; }

  /* Cards print as plain bordered blocks, no shadow or lift. */
  .card {
    box-shadow: none !important;
    transform: none !important;
    border: 1px solid #bbb;
  }

  /* Force readable backgrounds for text over images. */
  .hero, .hero * { color: #000 !important; text-shadow: none !important; }
}
