/*
  ARG / Adventure & Experience Design — seven pull-down maps hanging in the library.

  Each .slot is a fixed, full-width map. Closed, it is pulled up out of sight and only its
  tag hangs into view; open, it drops down. Tags sit at 1/8, 2/8 … 7/8 of the screen width
  (set by --i on the slot), all the same size and on equal strings.

  Art: the tags are Elliot's kraft-tag photo (tag.webp, 150×240, with a short wire through the
  grommet that the string meets). Icons are Elliot's files (slots 1–3, 5) or drawn symbols in
  index.html, all inked in --stamp red. The map paper is drawn: flat colour + SVG-noise grain
  tiles below (no gradients). A scanned paper texture can replace the tiles later.
*/
:root {
  --tag-w: clamp(36px, 11vw, 60px);          /* tag width; height is 1.6× (tag.webp is 150×240) */
  --tag-h: calc(var(--tag-w) * 1.6);
  --gap: clamp(30px, 6vh, 46px);              /* string length from roller to tag top */
  --tuck: 14px;                               /* extra lift when closed, hides the roller */
  --below: 20px;                              /* room left under an open tag */
  --chart-h: calc(100vh - var(--gap) - var(--tag-h) - var(--below));
  --ink: #3b2a17;
  --stamp: #8e2a1e;
  --paper: #efe5cb;
  --wood: #6e4b2a;
  --wood-dark: #44301a;
}
@supports (height: 100dvh) {
  :root { --chart-h: calc(100dvh - var(--gap) - var(--tag-h) - var(--below)); }
}
@media (max-width: 600px) {
  :root { --below: 58px; }                   /* keep open tags clear of the home button */
}

html, body { margin: 0; height: 100%; }
body {
  background: #2a1d12 url("/assets/img/library.webp") center / cover no-repeat fixed;
  font-family: "IM Fell English", Georgia, "Times New Roman", serif;
  color: var(--ink);
  overflow: hidden;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Home button bottom-left, clear of the tags */
.home-link { top: auto; bottom: 16px; z-index: 5000; }
@media (max-width: 600px) { .home-link { bottom: 12px; } }

/* ---------- Slot: one map + its tag ---------- */
.slot {
  position: fixed;
  top: 0;
  left: 5%;
  width: 90%;
  height: var(--chart-h);
  z-index: 1000;                              /* closed: tags stay above open maps */
  transform: translateY(calc(-100% - var(--tuck)));
  transition: transform .6s ease-in-out;
  pointer-events: none;
}
.slot.is-open { transform: none; }            /* z-index set by arg.js so the newest is on top */
.no-anim .slot, .no-anim .tag-body { transition: none !important; }

/* ---------- The map ---------- */
.chart {
  display: flex;
  flex-direction: column;
  height: 100%;
  pointer-events: auto;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45));
}
.paper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  /* top padding clears the closed tags that hang over the map */
  padding: calc(var(--gap) - var(--tuck) + var(--tag-h) + 16px) clamp(14px, 4vw, 48px) 32px;
  background-color: var(--paper);
  /* two grain tiles: fine fibres + broad mottling (SVG noise, not gradients) */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .24 0 0 0 0 .12 .55 0 0 0 -.17'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .4 0 0 0 0 .18 .7 0 0 0 -.28'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  border-left: 1px solid #c4b087;
  border-right: 1px solid #c4b087;
  scrollbar-color: #b49a68 transparent;
}
.inner {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px) clamp(16px, 3.5vw, 40px);
  border: 4px double #8b6d3f;
  line-height: 1.55;
  font-size: clamp(1.02rem, .95rem + .3vw, 1.18rem);
}
.inner > :first-child { margin-top: 0; }
.inner > :last-child { margin-bottom: 0; }

/* Wooden roller bar with end caps */
.roller {
  position: relative;
  flex: none;
  height: 16px;
  background: var(--wood);
  border-top: 2px solid var(--wood-dark);
  box-shadow: inset 0 3px 0 #8d6538, inset 0 -3px 0 #573b20;
  border-radius: 0 0 3px 3px;
}
.roller::before, .roller::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 12px;
  height: 22px;
  background: var(--wood-dark);
  border-radius: 4px;
}
.roller::before { left: -9px; }
.roller::after  { right: -9px; }

/* ---------- Map content ---------- */
.kicker {
  margin: 0 0 .2em;
  font-family: "IM Fell English SC", Georgia, serif;
  letter-spacing: .08em;
  color: var(--stamp);
}
.inner h2 {
  margin: 0 0 .35em;
  font-weight: 400;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem);
  line-height: 1.1;
}
.meta { font-style: italic; color: #6b5636; margin-top: 0; }
.placeholder { color: #7a6747; font-style: italic; }
.hint { font-style: italic; color: #6b5636; }

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 14px;
  margin-top: 1.2em;
}
.photo-slot {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 2px dashed #b49a68;
  color: #9b845b;
  font-style: italic;
}

.cta { margin-top: 1.4em; }
.button {
  display: inline-block;
  padding: .55em 1.1em;
  background: var(--stamp);
  color: #f6ecd2;
  border: 2px solid #5e1a12;
  border-radius: 3px;
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none;
  font-family: "IM Fell English SC", Georgia, serif;
  letter-spacing: .04em;
  transition: transform .12s ease, box-shadow .12s ease;
}
.button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- Tags ---------- */
.tag {
  position: absolute;
  top: calc(100% + var(--gap));
  left: calc(var(--i) * 12.5vw - 5vw - var(--tag-w) / 2);
  width: var(--tag-w);
  height: var(--tag-h);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.string {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: calc(-1 * var(--gap));
  width: 2px;
  margin-left: -1px;
  height: calc(var(--gap) + var(--tag-h) * .02);    /* meets the wire at the top of tag.webp */
  background: #c9c9c3;                               /* matches the photo's wire */
  border-left: 1px solid #77776f;
  box-sizing: border-box;
}
.tag-body {
  position: absolute;
  inset: 0;
  transform-origin: 50% 2%;                        /* swings from where the string meets the wire */
  transition: transform .35s ease;
  filter: drop-shadow(2px 4px 4px rgba(0, 0, 0, .45));
}
.tag-paper { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tag-icon {
  position: absolute;
  left: 50%;
  top: 54%;
  width: calc(var(--tag-w) * .5);
  height: calc(var(--tag-w) * .5);
  transform: translate(-50%, -50%) rotate(-6deg);
  color: var(--stamp);
  opacity: .88;
}
/* Elliot's icon files, recoloured to the stamp ink through their transparency */
.tag-icon--img {
  background: var(--stamp);
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}
.tag-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7%;
  font-family: "IM Fell English SC", Georgia, serif;
  font-size: 12px;
  line-height: 1;
  letter-spacing: .03em;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
}
/* Titles only where they fit: tags are narrower than ~54px on phones */
@media (max-width: 560px) {
  .tag-label { display: none; }
  .tag-icon { top: 58%; }
}
.tag:hover .tag-body, .tag:focus-visible .tag-body { transform: rotate(-6deg); }
.slot.is-open .tag:hover .tag-body { transform: rotate(6deg); }
.tag:focus-visible { outline: none; }
.tag:focus-visible .tag-paper { outline: 2px solid #f6ecd2; outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  .slot, .tag-body, .button { transition: none; }
  .tag:hover .tag-body, .tag:focus-visible .tag-body, .slot.is-open .tag:hover .tag-body { transform: none; }
}

/* ---------- Without JavaScript: the maps simply stack, unrolled ---------- */
html:not(.js) body { overflow: auto; }
html:not(.js) .slot {
  position: relative;
  height: auto;
  margin: 24px auto;
  transform: none;
  left: auto;
}
html:not(.js) .paper { padding-top: 24px; }
html:not(.js) .tag { display: none; }
