* {
  box-sizing: border-box;
}

@font-face {
  font-family: "Joanna Sans W01";
  src: url("../fonts/joanna-sans-light.woff2") format("woff2"), url("../fonts/joanna-sans-light.woff") format("woff");
  font-weight: 300;
  font-style: normal;
}

@font-face {
  font-family: "Joanna Sans W01";
  src: url("../fonts/joanna-sans-semibold.woff") format("woff2"), url("../fonts/joanna-sans-semibold.woff") format("woff");
  font-weight: 450;
  font-style: normal;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10rem;
  background-color: #f9f9f9;
  font-family: 'Joanna Sans W01', sans-serif;
  font-weight: 300;
  font-size: clamp(0.95rem, 0.8rem + 0.4vw, 1.1rem);
  line-height: 1.6;
  color: #4d4e53;
  /* fluid gutters: text drifts left-of-centre on wide screens, centres on narrow;
     bottom clears the fixed controls, all sides respect notch safe areas */
  padding: max(2.5rem, env(safe-area-inset-top))
           max(clamp(1.5rem, 12vw, 16rem), env(safe-area-inset-right))
           max(4rem, env(safe-area-inset-bottom))
           max(clamp(1.5rem, 12vw, 16rem), env(safe-area-inset-left));
}

#fg {
  position: relative; /* anchors the close button */
  width: 100%;
  max-width: 60ch;
  margin-block: 3vh;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: opacity 0.5s ease, background 0.8s ease,
              border-color 0.8s ease, box-shadow 0.8s ease;
}

/* glass sheen: a catch-light from above, revealed only in shoal mode */
#fg::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(165deg,
    rgba(255, 255, 255, 0.45),
    rgba(255, 255, 255, 0) 40%,
    rgba(170, 210, 218, 0.12));
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

/* awake: the pane goes properly glassy — thinner paint, saturated blur,
   lit edge, sheen, and a lift off the water */
body.fishawake #fg {
  background: rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  backdrop-filter: blur(14px) saturate(1.6);
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 12px 40px rgba(2, 20, 30, 0.28);
}

body.fishawake #fg::before {
  opacity: 1;
}

#fg a {
  color: #5f8790;
}

#fg a:hover,
#fg a:focus-visible {
  text-decoration: underline;
}

#fg a:focus-visible {
  outline: 2px solid #5F8790FF;
  outline-offset: 2px;
}

#fg p {
  margin: 0 0 2em 0;
}

#fg p:last-child {
  margin-bottom: 0;
}

#fg p.address {
  color: #6f7075;
  margin-top: 2em;
}

#fg strong {
  font-weight: 700;
  font-size: 1.25em;
}

/* scroll wrapper: only real on phones; desktop layout sees straight through */
#fgscroll {
  display: contents;
}

#fghandle {
  display: none;
}

#closetext {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: #9aa0a6aa;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}

#closetext svg {
  width: 24px;
  height: 24px;
  margin: 8px;
  fill: currentColor;
}

#closetext:hover {
  color: #4d4e53ff;
}

#closetext:focus-visible {
  outline: 2px solid #5f8790;
  outline-offset: -4px;
}

/* the rim of the pane is draggable on fine pointers; words stay words */
@media (pointer: fine) {
  #fg { cursor: grab; }
  #fg p { cursor: text; }
}

/* .hideable, not #fg: the footer is hideable too */
body.notext .hideable {
  opacity: 0;
  pointer-events: none;
}

footer.desktop {
  width: 100%;
  max-width: 60ch;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  transition: opacity 0.5s ease;
  color: white;
  opacity: 0.75;
  mix-blend-mode: difference;
}

footer.mobile {
  display: none;
}

/* ---- background slideshow ---- */

#slides {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #f9f9f9;
}

.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  background: #f9f9f9; /* letterbox colour when a slide uses fit: contain */
  opacity: 0;
  transition: opacity 0.8s ease;
}

.slide.visible {
  opacity: 1;
}

/* ---- caption & controls ---- */

#caption {
  position: fixed;
  z-index: 101; /* above the phone sheet scroller */
  right: max(1.5rem, env(safe-area-inset-right));
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  max-width: min(22em, calc(100vw - 3rem - 170px));
  padding: 0.6em 1em;
  background: rgba(0, 0, 0, 0.6);
  color: #f2f2f2;
  font-size: 85%;
  line-height: 1.5;
  border-radius: 3px;
  transition: opacity 0.8s ease;
}

#caption.hidden {
  opacity: 0;
}

#controls {
  position: fixed;
  left: max(1.5rem, env(safe-area-inset-left));
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 0.5em;
  align-items: center;
  z-index: 101; /* above the phone sheet scroller */
}

#controls button {
  border: none;
  font: inherit;
  font-size: 85%;
  padding: 0.4em 0.9em;
  min-width: 44px;
  min-height: 44px;
  border-radius: 3px;
  cursor: pointer;
  background: none;
}

#controls button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#controls button[hidden] {
  display: none;
}

#fishstate {
  transition: color 5s ease-in-out;
}

#fishstate[data-state='ball'] {
  color: rgba(255, 255, 255, 0.8);
}

#fishstate[data-state='sheet'] {
  color: #5f8790aa;
}

#fishstate[data-state='ball'] .awake {
  display: inline;
}

#fishstate[data-state='sheet'] .asleep {
  display: inline;
}

#fishstate svg {
  width: 48px;
  height: 48px;
  display: none;
  fill: currentColor;
  vertical-align: middle;
}

#showtext {
  color: white;
}

/* narrow screens: caption and controls can't share the bottom row — stack them */
@media (max-width: 600px) {
  /* bottom sheet: an invisible full-screen scroller carries the glass card
     up into view. Touches on open water fall through to the fish; touches
     on the card scroll the sheet. */
  #fgscroll {
    display: block;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    z-index: 100;
    /* NB: no pointer-events:none here — iOS Safari refuses to scroll a
       container that has it, even via pointer-events:auto children. Taps on
       open water still reach the fish (their listeners are on window), and
       the controls float above on z-index 101. */
  }

  #fg {
    width: 100%;
    max-width: none;
    margin: 90dvh 0 0;
    min-height: 10dvh;
    border-radius: 16px;
    border-left: none;
    border-right: none;
    padding-top: 1.5rem;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  body.fishawake #fg {
    background: rgba(255, 255, 255, 0.7);
  }

  /* the thumb is pure affordance: scrolling the sheet is native */
  #fghandle {
    display: block;
    position: sticky; /* rides above the text when the sheet content scrolls */
    top: 0.25rem;
    z-index: 2;
    height: 12px;
    margin: 0 auto 0.5rem;
    pointer-events: none;
  }

  #fghandle::after {
    content: '';
    display: block;
    width: 44px;
    height: 5px;
    margin: 0 auto;
    border-radius: 3px;
    background: rgba(80, 95, 100, 0.35);
  }

  #closetext {
    display: none;
  }

  #caption {
    left: max(1.5rem, env(safe-area-inset-left));
    right: max(1.5rem, env(safe-area-inset-right));
    bottom: calc(max(1.5rem, env(safe-area-inset-bottom)) + 44px + 0.75rem);
    max-width: none;
  }

  #controls {
    bottom: unset;
    left: max(1rem, env(safe-area-inset-left));
    top: max(1rem, env(safe-area-inset-top));
  }

  body {
    padding-bottom: max(11rem, env(safe-area-inset-bottom) + 10rem);
  }

  footer.desktop {
    display: none;
  }
  footer.mobile {
    display: block;
    margin-top: 3em;
  }
}

/* ---- preferences ---- */

@media (prefers-reduced-motion: reduce) {
  .slide,
  #caption,
  #fg {
    transition: none;
  }
}
