/* ==========================================================================
   Week 1 map container
   --------------------------------------------------------------------------
   The flat map image stays in the markup and keeps its normal size, so the
   grid cell is the same height whether or not the 3D map loads.

   The image sits ON TOP of the map and fades out once the map has had time to
   paint. That order matters: Google's map surface is opaque while it loads,
   so with the map on top the cell goes blank for several seconds. With the
   image on top the flat map covers the whole load and then cross-fades.

   It is also the fallback. If the API never loads, nothing ever adds
   .is-ready, the image never fades, and the page keeps the map it always had.

   The image carries loading="eager" for the same reason. Lazy-loaded, it has
   not begun downloading when the map starts, so the cell is blank for the
   overlap - an image cannot be both the fallback and deferred. All four
   copies share one URL, so this is a single fetch.
   ========================================================================== */

[data-map3d] {
  position: relative;

  /* Applied to Google's map canvas only (map-3d.js), never to our overlay or
     to Google's controls. Slight contrast so roofs and roads stay crisp. */
  --m3-grade: grayscale(1) contrast(1.05);
  /* A pale wash over the photo, under the coloured overlay and Google's
     controls, so the Barbour blocks and labels stand forward. */
  --m3-wash: rgba(235, 231, 223, .5); /* #ebe7df at 50% */
}

[data-map3d] > img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity .5s ease;
}

/* The map and our overlay share one stage, which the script moves between
   the four day panes. */
.m3-stage { position: absolute; inset: 0; z-index: 1; }
[data-map3d] gmp-map-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

[data-map3d].is-ready > img { opacity: 0; pointer-events: none; }
/* With the script running, the flat image is a fallback only: hidden from
   the start, shown if the 3D map fails (.is-fallback). It still sizes the
   cell. */
[data-map3d].m3-js > img { opacity: 0; pointer-events: none; transition: none; }
[data-map3d].m3-js.is-fallback > img { opacity: 1; pointer-events: auto; }

/* Key entries drive the map ------------------------------------------------
   Hovering an entry highlights its block and dims the others. Only added by
   script once the map exists, so without a map the key stays plain text with
   no misleading affordance. */

[data-map3d] { min-height: 32rem; }

.key-area.is-linked { cursor: pointer; transition: opacity .2s ease; }
.key-area.is-linked:hover,
.key-area.is-hot { opacity: 1; }
/* Dim the others only while a location entry itself is hovered - not the
   location controls that share the panel. */
.map-key-inner:has(.key-area.is-linked:hover) .key-area.is-linked:not(:hover):not(.is-hot) { opacity: .45; }

@media screen and (min-width: 992px) {
  /* A bigger canvas: the 3D view needs room to read, and Google shows its
     full set of navigation controls only once the map is large enough. */
  [data-map3d] { min-height: 40rem; }
}

/* ---- Overlay: coloured blocks and route ------------------------------------
   Drawn over the greyscale imagery by map-3d.js, so they keep their colour.
   Matches the look the Google-drawn versions had: 80% fill, white outline,
   7 px black route. */

.m3-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.m3-shapes { position: absolute; inset: 0; width: 100%; height: 100%; }

/* No outlines; the walls a darker shade than the roofs so blocks read as solid. */
.m3-area polygon { fill: var(--c); fill-opacity: .8; stroke: none; }
.m3-walls polygon { fill: #000; fill: color-mix(in srgb, var(--c) 60%, #000); fill-opacity: .92; }

/* Rollover changes nothing on the blocks themselves - only the callout. */


/* The route: a road-width band on the ground (map-3d.js), black at 50%.
   Opacity on the group, so overlapping pieces don't double up. */
.m3-route { opacity: .5; }
.m3-route polygon { fill: #000; stroke: none; }

/* ---- Overlay: labels --------------------------------------------------------
   JS sets `transform` to the anchor point; `translate` (which adds to it)
   then hangs the box off that point so the tail tip lands on it. */

.m3-label {
  position: absolute;
  top: 0;
  left: 0;
  height: 24px;
  padding: 0 10px;
  box-sizing: border-box;
  font: 500 13px/21px Barboursans, "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: .01em;
  white-space: nowrap;
  color: #fff;
  background-color: var(--c, #111);
  border: 1.5px solid #fff;
  border-radius: 3px;
  translate: -50% -100%;
  will-change: transform;
}
.m3-label.is-hidden { visibility: hidden; }

/* Tails: a white triangle with a filled one inside it, like the artwork's
   arrows. */
.m3-label[class*="m3-point-"]::before,
.m3-label[class*="m3-point-"]::after {
  content: "";
  position: absolute;
  border-style: solid;
  border-color: transparent;
}
/* --lift (set per label by the script) stretches the tail to raise a label. */
.m3-label[class*="m3-point-"]::before { top: calc(100% + 1px); border-width: calc(10px + var(--lift, 0px)) 7px 0; border-top-color: #fff; }
.m3-label[class*="m3-point-"]::after  { top: calc(100% - 1px); border-width: calc(9px + var(--lift, 0px)) 6px 0;  border-top-color: var(--c, #111); }

.m3-point-down  { translate: -50% calc(-100% - 10px - var(--lift, 0px)); }
.m3-point-down::before { left: 50%; margin-left: -7px; }
.m3-point-down::after  { left: 50%; margin-left: -6px; }
.m3-point-left  { translate: -6px calc(-100% - 10px); }
.m3-point-left::before { left: -1.5px; }
.m3-point-left::after  { left: -.5px; }
.m3-point-right { translate: calc(-100% + 6px) calc(-100% - 10px); }
.m3-point-right::before { right: -1.5px; }
.m3-point-right::after  { right: -.5px; }

/* ---- Overlay: road names ----------------------------------------------------
   Google's own labels are off (satellite mode); these replace the road names
   only. JS sets the whole transform, so no `translate` here. */

.m3-road {
  position: absolute;
  top: 0;
  left: 0;
  font: 500 12px/1 Barboursans, "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: .02em;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, .9), 0 0 1px #000;
  will-change: transform;
}
.m3-road.is-hidden { visibility: hidden; }

@media screen and (max-width: 599px) {
  .m3-label { height: 22px; padding: 0 8px; font-size: 12px; line-height: 19px; }
  .m3-road { font-size: 11px; }
}

/* ---- Site callouts ------------------------------------------------------------
   The branded name bubbles (assets/custom/callouts/), shown while a block is
   active. The wrapper is positioned by JS (transform) and hung off the roof
   by `translate`; the image inside does the pop, scaling from the pointer. */

/* Clipped at the sides (no sideways page scroll on phones), open at the top. */
.m3-pops {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow-x: clip;
  overflow-y: visible;
}

.m3-callout {
  position: absolute;
  top: 0;
  left: 0;
  width: 150px;
  translate: -50% -100%;  /* the triangle's tip sits on the middle of the roof */
  will-change: transform;
}
.m3-callout img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: translateY(6px) scale(.85);
  transform-origin: 50% 100%;
  transition: opacity .18s ease, transform .18s ease;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25));
}
.m3-callout.is-on img { opacity: 1; transform: none; }

/* Per-callout sizes, relative to the 150px default. */
.m3-callout--factory { width: 140.625px; }   /* 187.5px less 25% */
.m3-callout--showrooms { width: 234.375px; }   /* 25% larger, twice */

@media screen and (max-width: 599px) {
  .m3-callout { width: 120px; }
  .m3-callout--factory { width: 112.5px; }
  .m3-callout--showrooms { width: 187.5px; }
}

/* ---- Key ------------------------------------------------------------------------
   Swatches take the callout colours. Webflow's own swatch colours are in the
   vendored stylesheet - mirror these back into Webflow. */

.map-key .key-color.green { background-color: #103e1d; }
.map-key .key-color.gold  { background-color: #a0825a; }
.map-key .key-color.blue  { background-color: #10283d; }
.map-key .key-color.red   { background-color: #3d1028; }

/* "Barbour Locations" title above the key (hand-added to week-1.html; mirror
   into Webflow). */
.map-key-title { display: block; width: 220px; max-width: 100%; height: auto; margin: 0 auto .75rem; grid-column: 1 / -1; justify-self: center; }
/* Prompt under the title: "Roll over" with a mouse, "Tap" on touch. */
.map-key-hint {
  grid-column: 1 / -1;
  justify-self: stretch;  /* rules span the same width as the controls above */
  width: 100%;
  box-sizing: border-box;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center;
  margin: 0 0 .75rem;
  padding: .6rem 0;
  border-top: 1px solid #103e1d;
  border-bottom: 1px solid #103e1d;
  font-family: Barbourserif, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  letter-spacing: .04em;
  color: #103e1d;
  text-transform: uppercase;
  font-weight: 500;
}
.map-key-hint .hint-touch { display: none; }
@media (hover: none) {
  .map-key-hint .hint-hover { display: none; }
  .map-key-hint .hint-touch { display: inline; }
}

/* Parking sign in the middle of the (flat) car park. */
.m3-sign {
  position: absolute;
  top: 0;
  left: 0;
  width: 100px;      /* mapped onto the ground by JS (matrix3d) */
  height: 100px;
  transform-origin: 0 0;
  pointer-events: none;
  will-change: transform;
}

/* Entrance pins: the point (bottom centre of the artwork) on the doorway. */
.m3-pin {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: auto;
  translate: -50% -100%;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .25));
  will-change: transform;
}
.m3-pin.is-hidden { visibility: hidden; }

/* The showroom pin sits on its own dark-navy block: 50% larger, and in a
   lighter navy (#264766) so it stands out from it. */
.m3-pin--showroom { width: 120px; margin-top: 12px; }   /* nudged down */
.m3-pin--launch { width: 80px; }   /* 25% larger */
/* The house and car park pins line up from the opening view: nudge them
   apart a little on screen. */
.m3-pin--house { margin-left: -14px; }
.m3-pin--parking { margin-left: 14px; }
.m3-pin--factory { margin-top: 12px; }   /* nudged down */

@media screen and (max-width: 599px) {
  .m3-pin { width: 46px; }
  .m3-pin--showroom { width: 86px; }
  .m3-pin--launch { width: 57.5px; }
}

/* ---- Find my location ------------------------------------------------------
   In the key panel, under the title: find / stop, the entrance picker, and
   one status line ending in Get Directions. */

.m3-locate {
  grid-column: 1 / -1;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 1.75rem;
  font-family: Barbourserif, Georgia, "Times New Roman", serif;
  color: #103e1d;
}
.m3-locate button, .m3-locate select { font: inherit; }
.m3-locate-row { display: flex; gap: 10px; margin-bottom: 1rem; }
.m3-locate-btn,
.m3-locate-stop {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  color: #fff;
  font-size: 1rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  cursor: pointer;
}
.m3-locate-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: #103e1d; }
.m3-locate-icon { width: 16px; height: 16px; flex: none; }
.m3-locate-btn[disabled] { opacity: .8; cursor: progress; }
.m3-locate-stop { background: #a0825a; }
.m3-locate-stop[hidden] { display: none; }
.m3-locate-label {
  display: block;
  margin-bottom: .4rem;
  font-size: .9375rem;
  letter-spacing: .02em;
  text-transform: none;
  color: #000;
  font-weight: 300;
}
.m3-locate-selectwrap { position: relative; }
.m3-locate-selectwrap::after {         /* chevron */
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -8px;
  border-right: 1.5px solid #103e1d;
  border-bottom: 1.5px solid #103e1d;
  transform: rotate(45deg);
  pointer-events: none;
}
.m3-locate-select {
  width: 100%;
  min-height: 44px;
  padding: 8px 44px 8px 16px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #4a4a4a;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  box-shadow: none;
  cursor: pointer;
}
.m3-locate-line { margin: .75rem 0 0; font-size: .9375rem; line-height: 1.4; color: #000; }
.m3-locate-status.is-error { color: #8a1c1c; }
.m3-locate-status.is-warn { color: #7a5200; }
.m3-locate-go {
  padding: 0;
  border: 0;
  background: none;
  color: #a0825a;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.m3-locate button:focus-visible { outline: 2px solid #103e1d; outline-offset: 2px; }
/* Keyboard focus on the dropdown: a soft ring, not a dark border. */
.m3-locate select:focus-visible { box-shadow: 0 0 0 2px #d0c4b3; }

/* Google walking route, drawn on the ground in conventional blue. */
.m3-dir { fill: #1a73e8; fill-opacity: .85; }

/* The dot: blue with a white border and a soft halo, label beneath. */
.m3-you {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  will-change: transform;
}
.m3-you[hidden] { display: none; }
.m3-you-dot {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 0 0 6px rgba(26, 115, 232, .22), 0 1px 4px rgba(0, 0, 0, .35);
}
.m3-you-label {
  position: absolute;
  top: 14px;
  left: 0;
  translate: -50% 0;
  padding: 2px 7px;
  border-radius: 2px;
  background: #fff;
  color: #1a3a6b;
  font: 600 11px/1.4 Barboursans, "Helvetica Neue", Helvetica, Arial, sans-serif;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
/* Direction of travel: a small wedge ahead of the dot. */
.m3-you-heading {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  transform-origin: 8px 8px;
}
.m3-you-heading::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -14px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid rgba(26, 115, 232, .85);
}
.m3-you-heading[hidden] { display: none; }
.m3-you.is-stale .m3-you-dot { background: #8a8f98; box-shadow: 0 0 0 6px rgba(138, 143, 152, .2); }
.m3-you-acc { fill: rgba(26, 115, 232, .14); stroke: rgba(26, 115, 232, .45); stroke-width: 1; }


/* Desktop: the key panel sizes to its contents, so fix the controls' width
   (the width they have with Stop showing) - showing Stop then doesn't
   resize the panel. */
@media screen and (min-width: 992px) {
  .m3-locate,
  .map-key-hint { width: 20.25rem; max-width: 100%; }
}

/* Selected entrance: its pin bobs gently. Animates `translate`, which the
   pin already uses to hang its point on the doorway. */
@keyframes m3-bob {
  0%, 100% { translate: -50% -100%; }
  50% { translate: -50% calc(-100% - 7px); }
}
.m3-pin.is-selected { animation: m3-bob 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .m3-pin.is-selected { animation: none; }
}

.map-key-inner { row-gap: 1rem; }
