/* ─────────────────────────────────────────────────────────────────────────────
   polish.css — interaction and motion layer (v59)

   Purely additive. It is loaded LAST, adds no new colours, no new typefaces and
   no layout changes: every rule here is about how the existing design RESPONDS
   to a finger, a cursor or a scroll. Delete the one <link> that loads it and
   the site returns exactly to how it was.

   Colours are taken from the tokens already defined in site.css / theme.css
   (var(--brand), var(--border) …), so the brand palette is untouched.
   Everything that moves is transform/opacity only, so it runs on the GPU and
   costs nothing on a phone, and all of it is switched off under
   prefers-reduced-motion at the bottom of this file.
   ───────────────────────────────────────────────────────────────────────── */


/* ── 1. Keyboard focus ───────────────────────────────────────────────────────
   The build had no :focus-visible rule anywhere, so a keyboard or switch user
   could not see where they were. This is an accessibility fix, not decoration,
   so it is NOT inside a reduced-motion guard. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--brand, #209C9C);
  outline-offset: 2px;
  border-radius: 10px;
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}


/* ── 2. The mobile menu reads as a layer ─────────────────────────────────────
   It used to appear flat against the page with nothing behind it, so on a busy
   page it was hard to tell the menu from the content under it. A scrim settles
   it, and the entries arrive one after another so the eye can follow the list
   instead of being handed all eleven at once. */
.sg-scrim {
  position: fixed; inset: 0;
  background: rgba(10, 26, 28, .38);
  -webkit-backdrop-filter: saturate(.9) blur(2px);
  backdrop-filter: saturate(.9) blur(2px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease-out;
}
.sg-scrim.on { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: no-preference) {
  .mobile-nav.open > * {
    animation: sg-nav-in .34s cubic-bezier(.22, 1, .30, 1) both;
    animation-delay: calc(var(--sg-n, 0) * 28ms);
  }
}
@keyframes sg-nav-in {
  from { opacity: 0; transform: translateY(-6px) }
  to   { opacity: 1; transform: none }
}

/* The menu button turns into the close button; spin it so the change is read
   as one control changing state, not as two different buttons. */
@media (prefers-reduced-motion: no-preference) {
  .btn-menu svg { transition: transform .26s cubic-bezier(.22, 1, .30, 1); }
  .btn-menu[aria-expanded="true"] svg { transform: rotate(90deg); }
}


/* ── 3. The header earns its shadow ──────────────────────────────────────────
   Flat at the top of the page, lifted once the page has scrolled under it, so
   the sticky bar separates from the content instead of floating ambiguously. */
.hdr {
  transition: box-shadow .25s ease-out, background-color .25s ease-out;
}
.hdr.sg-stuck {
  box-shadow: 0 6px 24px rgba(21, 41, 43, .10);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}


/* ── 4. Things that can be pressed, feel pressed ─────────────────────────────
   On a phone there is no hover, so without a press state a tap gives no sign
   it registered — which reads as "the site is slow" even when it is not. */
@media (prefers-reduced-motion: no-preference) {
  .btn, .card, .inst-card, .quick-item, .pil, .mobile-nav a {
    transition: transform .16s cubic-bezier(.22, 1, .30, 1),
                box-shadow .22s ease-out,
                border-color .22s ease-out;
  }
  .btn:active, .pil:active, .mobile-nav a:active { transform: scale(.97); }
  .card:active, .inst-card:active, .quick-item:active { transform: scale(.994); }
}

/* Hover belongs to pointers only; on a touch screen it sticks after the tap. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .card:hover, .inst-card:hover, .quick-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(21, 41, 43, .11);
  }
  .btn:hover { transform: translateY(-1px); }
}


/* ── 5. Photographs fade in ──────────────────────────────────────────────────
   Images arrive after the text and used to snap in, which on a slow connection
   makes the page look like it is still breaking. polish.js marks each one as it
   decodes. Images already in cache are marked before paint, so this never
   delays anything the reader can see. */
@media (prefers-reduced-motion: no-preference) {
  img.sg-fade { opacity: 0; transition: opacity .45s ease-out; }
  img.sg-fade.is-loaded { opacity: 1; }
}


/* ── 6. Current page is obvious in the menu ──────────────────────────────── */
.mobile-nav a[aria-current="page"] { position: relative; }
.mobile-nav a[aria-current="page"]::after {
  content: "";
  position: absolute; left: 14px; right: 14px; bottom: 6px;
  height: 2px; border-radius: 2px;
  background: currentColor; opacity: .55;
}


/* ── 7. Reduced motion: nothing moves ───────────────────────────────────────
   Everything above degrades to a plain, instant, fully usable interface. */
@media (prefers-reduced-motion: reduce) {
  .sg-scrim { transition: none; }
  .mobile-nav.open > * { animation: none; }
  .btn-menu svg { transition: none; }
  .hdr { transition: none; }
  img.sg-fade { opacity: 1; transition: none; }
}
