:root {
  --bg: #f4f0e6;
  --panel: #fff;
  --ink: #1f2a24;
  --shadow: 0 2px 6px rgb(0 0 0 / 0.12), 0 8px 24px rgb(0 0 0 / 0.08);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #2d5a4a url("images/tartan-tile.jpg");
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

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

/* Desktop: three centered rows; each panel takes its image's shape. */
.collage {
  width: min(100%, 1100px);
  margin-inline: auto;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
}

.tile {
  position: relative;
  display: block;
  width: var(--w);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.35s var(--ease), transform-origin 0.35s var(--ease);
}

.tile img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: inherit;
}

.crest {
  background: none;
  box-shadow: none;
}

.crest img {
  filter: drop-shadow(0 6px 14px rgb(0 0 0 / 0.25));
}

.label {
  display: block;
  margin-top: 8px;
  font-size: 0.95rem;
  text-align: center;
}

.tile:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

/* Dock effect, only where a real pointer can hover. */
@media (hover: hover) and (pointer: fine) {
  .tile .label {
    position: absolute;
    top: 100%;
    left: 50%;
    translate: -50% 0;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--ink);
    color: var(--bg);
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .collage:has(.tile:is(:hover, :focus-visible)) .tile {
    transform: scale(0.92);
  }

  /* Shrink neighbors away from the active tile to make room. */
  .tile:has(~ .tile:is(:hover, :focus-visible)) { transform-origin: left center; }
  .tile:is(:hover, :focus-visible) ~ .tile { transform-origin: right center; }

  .collage:has(.tile:is(:hover, :focus-visible)) .tile:is(:hover, :focus-visible) {
    transform: scale(1.15);
    z-index: 1;
  }

  .tile:is(:hover, :focus-visible) .label { opacity: 1; }
}

/* Mobile: single column, crest first, captions always shown. */
@media (max-width: 700px) {
  .collage {
    align-items: center;
    gap: 28px;
    padding: 24px 16px;
  }

  .row { display: contents; }

  .crest { order: -1; }

  .tile {
    width: auto;
    max-width: 100%;
  }

  .tile img {
    width: auto;
    max-width: 100%;
    max-height: 13rem;
    margin-inline: auto;
  }

  .crest img { max-height: 15rem; }
}

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