/* ==========================================================================
   BeauHaunt — homepage treasure map
   Requires bh-tokens.css to be loaded first.
   ========================================================================== */

html,
body {
  height: 100%;
  overflow: hidden;
}

body.bh-map-page {
  font-family: var(--bh-font-body);
  color: var(--bh-fg);
  background-color: var(--bh-ink-900);
}

/* ==========================================================================
   Shell
   ========================================================================== */

.map-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* ==========================================================================
   Background
   ========================================================================== */

.map-bg {
  position: absolute;
  inset: 0;
  background-color: var(--bh-ink-900);
  background-image: image-set(url("../img/map-bg.webp") type("image/webp"), url("../img/map-bg.jpg") type("image/jpeg"));
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  /* Fades in once script.js flags the art as decoded */
  opacity: 0;
  transition: opacity 0.6s var(--bh-ease);
}
.map-shell.is-ready .map-bg {
  opacity: 1;
}

/* Vignette so edge icons and labels stay legible */
.map-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 118% 92% at 50% 48%, transparent 46%, rgba(10, 8, 4, 0.42) 100%),
    linear-gradient(180deg, rgba(6, 10, 16, 0.28) 0%, transparent 22%, transparent 76%, rgba(6, 10, 16, 0.3) 100%);
}

/* ==========================================================================
   Treasure path
   ========================================================================== */

.treasure-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.7s var(--bh-ease) 0.2s;
}
.map-shell.is-ready .treasure-path {
  opacity: 1;
}

.treasure-path__line {
  stroke: #b8302c;
  stroke-width: 1.2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 3 5;
  shape-rendering: geometricPrecision;
  filter: drop-shadow(0 1px 1px rgba(255, 250, 235, 0.5));
  animation: bh-path-dash var(--path-dash-duration, 9s) linear infinite;
}

@keyframes bh-path-dash {
  to {
    stroke-dashoffset: var(--path-dash-offset, -3);
  }
}

/* ==========================================================================
   Logo
   ========================================================================== */

.site-logo {
  position: absolute;
  z-index: 9;
  top: max(1rem, env(safe-area-inset-top, 1rem));
  left: max(1rem, env(safe-area-inset-left, 1rem));
  display: block;
  width: min(26vw, 132px);
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.55));
  transition: transform var(--bh-med) var(--bh-ease), filter var(--bh-med) var(--bh-ease);
}
.site-logo:hover {
  transform: scale(1.04);
  filter: drop-shadow(0 5px 16px rgba(0, 0, 0, 0.6));
}
.site-logo img {
  width: 100%;
  height: auto;
}

/* ==========================================================================
   Map hotspots
   ========================================================================== */

.map-icons {
  position: absolute;
  inset: 0;
  z-index: 6;
}

.map-icon {
  position: absolute;
  transform: translate3d(-50%, -50%, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem;
  text-decoration: none;
  color: inherit;
  transition: transform var(--bh-med) var(--bh-ease);
  animation: bh-icon-drop 0.6s var(--bh-ease) backwards;
}

@keyframes bh-icon-drop {
  from {
    opacity: 0;
    transform: translate3d(-50%, calc(-50% - 16px), 0);
  }
}

.map-icon:nth-child(1) { animation-delay: 0.15s; }
.map-icon:nth-child(2) { animation-delay: 0.24s; }
.map-icon:nth-child(3) { animation-delay: 0.33s; }
.map-icon:nth-child(4) { animation-delay: 0.42s; }
.map-icon:nth-child(5) { animation-delay: 0.51s; }
.map-icon:nth-child(6) { animation-delay: 0.60s; }
.map-icon:nth-child(7) { animation-delay: 0.69s; }

.map-icon__art {
  position: relative;
  display: block;
  line-height: 0;
  transition: transform var(--bh-med) var(--bh-ease);
}

/* Soft warm backlight so dark art reads against the parchment */
.map-icon__art::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 52%;
  width: 108%;
  height: 108%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 248, 220, 0.7) 0%, rgba(255, 244, 205, 0.28) 55%, transparent 72%);
  filter: blur(10px);
  transition: opacity var(--bh-med) var(--bh-ease);
  z-index: 0;
}

.map-icon__art img {
  position: relative;
  z-index: 1;
  width: min(23vmin, 178px);
  height: auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
  transition: filter var(--bh-med) var(--bh-ease);
}

.map-icon--calendar .map-icon__art img {
  width: min(17vmin, 134px);
}
.map-icon--contact .map-icon__art img {
  width: min(19vmin, 152px);
}

@media (hover: hover) {
  .map-icon:hover .map-icon__art,
  .map-icon:focus-visible .map-icon__art {
    transform: translateY(-5px) scale(1.05);
  }
  .map-icon:hover .map-icon__art img,
  .map-icon:focus-visible .map-icon__art img {
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
  }
  .map-icon:hover .map-icon__label,
  .map-icon:focus-visible .map-icon__label {
    color: #fdf6e6;
    background: rgba(24, 15, 8, 0.94);
    border-color: var(--bh-gold);
    transform: translateY(-2px);
  }
}

/* Label as a small dark plaque — far more legible than raw text on art */
.map-icon__label {
  position: relative;
  z-index: 2;
  max-width: 13rem;
  padding: 0.3rem 0.85rem;
  font-family: var(--bh-font-display);
  font-size: clamp(1.02rem, 2.9vmin, 1.4rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.055em;
  text-align: center;
  white-space: nowrap;
  color: #f7ecd8;
  background: rgba(17, 11, 5, 0.86);
  border: 1px solid rgba(216, 180, 92, 0.5);
  border-radius: var(--bh-r-sm);
  box-shadow:
    inset 0 1px 0 rgba(242, 220, 166, 0.14),
    0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: color var(--bh-fast) var(--bh-ease), background var(--bh-fast) var(--bh-ease),
    border-color var(--bh-fast) var(--bh-ease), transform var(--bh-fast) var(--bh-ease);
}

/* ==========================================================================
   Signpost
   ========================================================================== */

/* Width is constrained on four axes so the sign never crowds the icons on a
   narrow window or a short laptop. container-type lets the plank lettering
   scale off the sign rather than the viewport. */
.map-sign {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, -50%);
  width: min(40vmin, 26vw, 28vh, 300px);
  container-type: inline-size;
  pointer-events: none;
}

/* Tilt is now gentle — the old -30deg made the plank text hard to read. */
.map-sign__stack {
  position: relative;
  width: 100%;
  line-height: 0;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
  transform: rotate(-9deg);
  transform-origin: 50% 45%;
  animation: bh-sign-sway 7s ease-in-out infinite;
}

@keyframes bh-sign-sway {
  0%,
  100% {
    transform: rotate(-9deg);
  }
  50% {
    transform: rotate(-7deg);
  }
}

/* The sign art is open line work, so the plank is transparent. This fills
   it with wood behind the drawing to give the text something to sit on. */
.map-sign__plank {
  position: absolute;
  left: 12.6%;
  top: 14.5%;
  width: 74.5%;
  height: 32%;
  z-index: 0;
  border-radius: 2px;
  /* Dark stained wood — light enough to read as timber, dark enough that the
     cream lettering clears 7:1 contrast at every stop of the gradient. */
  background-image:
    repeating-linear-gradient(89deg, rgba(24, 13, 4, 0.22) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(91deg, rgba(255, 226, 178, 0.06) 0 1px, transparent 1px 11px),
    linear-gradient(180deg, #6d451e 0%, #5a3818 45%, #4a2d13 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 178, 0.22),
    inset 0 -7px 14px -6px rgba(20, 10, 3, 0.8);
}

.map-sign__post,
.map-sign__post img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
}

.map-sign__copy {
  position: absolute;
  left: 12.6%;
  top: 14.5%;
  width: 74.5%;
  height: 32%;
  display: grid;
  place-items: center;
  padding: 0 4%;
  text-align: center;
  pointer-events: auto;
  z-index: 2;
}

.map-sign__text {
  margin: 0;
  font-family: var(--bh-font-display);
  /* Fallback for browsers without container query units */
  font-size: clamp(0.62rem, 2.2vmin, 1.3rem);
  /* Sized off the sign, so the lettering always fits the plank */
  font-size: clamp(0.62rem, 7cqw, 1.3rem);
  line-height: 1.18;
  letter-spacing: 0.04em;
  color: #fdf1d8;
  text-shadow:
    0 1px 1px rgba(30, 16, 5, 0.9),
    0 0 10px rgba(20, 10, 2, 0.5);
}

.map-sign__link {
  color: #ffe6a8;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  pointer-events: auto;
  cursor: pointer;
  transition: color var(--bh-fast) var(--bh-ease);
}
.map-sign__link:hover {
  color: #fff;
}

/* ==========================================================================
   Announcement pill (bottom of map) — NOT CURRENTLY USED
   --------------------------------------------------------------------------
   Removed from index.html because the signpost already carries the season
   message. Kept here for a genuine one-off alert ("CLOSED TONIGHT — STORM").
   To bring it back, paste this just before </main> in index.html:

     <aside class="map-note" role="note" data-bh-dismissible="alert-id">
       <span class="map-note__dot" aria-hidden="true"></span>
       <span>Your message here</span>
       <button type="button" class="map-note__close" data-bh-dismiss
               aria-label="Dismiss this notice">&times;</button>
     </aside>

   Change data-bh-dismissible whenever the message changes, so people who
   dismissed the previous one still see the new one.
   ========================================================================== */

.map-note {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: max(1.1rem, env(safe-area-inset-bottom, 1.1rem));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: min(92vw, 620px);
  padding: 0.45rem 1.1rem;
  font-family: var(--bh-font-display);
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  text-align: center;
  color: #f7ecd8;
  background: rgba(14, 9, 4, 0.86);
  border: 1px solid rgba(216, 180, 92, 0.5);
  border-radius: var(--bh-r-sm);
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: bh-note-in 0.6s var(--bh-ease) 0.85s backwards;
}
.map-note[hidden] {
  display: none;
}
.map-note a {
  color: var(--bh-gold-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
}
.map-note__close {
  flex: none;
  padding: 0 0.1rem;
  font-size: 1.05rem;
  line-height: 1;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--bh-fast) var(--bh-ease);
}
.map-note__close:hover {
  opacity: 1;
}

.map-note__dot {
  flex: none;
  width: 16px;
  height: 16px;
  background: var(--bh-gold);
  -webkit-mask: url("../img/marks/compass-rose.png") center / contain no-repeat;
  mask: url("../img/marks/compass-rose.png") center / contain no-repeat;
  animation: bh-mark-glow 3s var(--bh-ease) infinite;
}

@keyframes bh-mark-glow {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

@keyframes bh-note-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

/* ==========================================================================
   Tablet
   ========================================================================== */

@media (max-width: 900px) {
  .site-logo {
    width: min(28vw, 112px);
  }
  .map-icon__art img {
    width: min(19vmin, 146px);
  }
  .map-icon--calendar .map-icon__art img {
    width: min(14vmin, 112px);
  }
  .map-icon--contact .map-icon__art img {
    width: min(15.5vmin, 122px);
  }
  .map-icon__label {
    font-size: clamp(0.9rem, 2.6vmin, 1.15rem);
    padding: 0.24rem 0.65rem;
  }
}

/* ==========================================================================
   Mobile — map becomes a card grid
   ========================================================================== */

@media (max-width: 640px) {
  html,
  body {
    height: auto;
    overflow: visible;
  }

  .map-shell {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    display: flex;
    flex-direction: column;
  }

  .map-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 1;
    filter: brightness(0.42) saturate(0.85);
    /* Dimmed to 42% here, so the small plate is indistinguishable */
    background-image: image-set(url("../img/map-bg@900.webp") type("image/webp"), url("../img/map-bg@900.jpg") type("image/jpeg"));
  }

  .map-vignette {
    position: fixed;
    background: linear-gradient(180deg, rgba(6, 10, 16, 0.78) 0%, rgba(6, 10, 16, 0.55) 45%, rgba(6, 10, 16, 0.88) 100%);
  }

  .treasure-path,
  .map-sign {
    display: none;
  }

  .site-logo {
    position: relative;
    top: auto;
    left: auto;
    z-index: 6;
    width: min(46vw, 152px);
    margin: max(1.5rem, env(safe-area-inset-top, 1.5rem)) auto 0.35rem;
  }
  .site-logo:hover {
    transform: none;
  }

  .map-icons {
    position: relative;
    inset: auto;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 0.75rem max(1rem, env(safe-area-inset-left, 1rem)) 1.25rem;
  }

  .map-icon {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1.05rem 0.7rem 0.9rem;
    background: linear-gradient(165deg, rgba(21, 31, 43, 0.82) 0%, rgba(10, 16, 24, 0.9) 100%);
    border: 1px solid var(--bh-line);
    border-radius: var(--bh-r);
    box-shadow: var(--bh-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: none;
    transition: border-color var(--bh-fast) var(--bh-ease), transform var(--bh-fast) var(--bh-ease);
  }
  .map-icon:active {
    transform: scale(0.98) !important;
    border-color: var(--bh-line-gold);
  }

  .map-icon__art::before {
    opacity: 0.55;
    filter: blur(14px);
  }

  .map-icon__art img,
  .map-icon--calendar .map-icon__art img,
  .map-icon--contact .map-icon__art img {
    width: clamp(58px, 19vw, 92px);
  }

  .map-icon__label {
    max-width: none;
    white-space: normal;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    font-size: clamp(1rem, 4.4vw, 1.22rem);
    color: #f7ecd8;
  }

  .map-note {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    margin: 0 max(1rem, env(safe-area-inset-left, 1rem)) max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
    max-width: none;
    justify-content: center;
    animation: none;
  }
}
