/* Interactive state-fare map on the pies hub */

.pies-map-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  /* Let the map outgrow the narrower page column */
  width: min(1120px, calc(100vw - 2rem));
  margin: 2.5rem 0 2rem;
  margin-left: 50%;
  transform: translateX(-50%);
}

.pies-map-section h2 {
  text-align: center;
  margin-bottom: 1rem;
}

.pies-map-frame {
  position: relative;
  background-color: var(--primary-color);
  border: 1px solid var(--secondary-color);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 25%);
  padding: 0.5rem;
}

.pies-map-frame svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.pies-us-map .state path,
.pies-us-map .state circle {
  fill: #c5d0da;
  stroke: #1a2a3a;
  stroke-width: 1;
  transition: fill 0.15s ease, filter 0.15s ease, stroke-width 0.15s ease;
  cursor: default;
}

.pies-us-map .borders path,
.pies-us-map .separator1 {
  fill: none;
  stroke: #1a2a3a;
  stroke-width: 1;
  pointer-events: none;
}

.pies-us-map .separator1 {
  stroke: #8aa0b4;
  stroke-width: 2;
}

/* Highlighted fruit/berry states — one class per item for easy expansion.
   Must beat `.pies-us-map .state path` specificity. */

/* DC locator ring — outline only so it doesn’t read as a hole in the map */
.pies-us-map circle.dccircle {
  fill: none;
  stroke: #1a2a3a;
  stroke-width: 1.25;
  pointer-events: none;
}

.pies-us-map .state path.fruit-blueberry,
.pies-us-map .state circle.fruit-blueberry {
  fill: #2f6fd6;
  cursor: pointer;
}

.pies-us-map .state path.fruit-apple,
.pies-us-map .state circle.fruit-apple {
  fill: #c23b2e;
  cursor: pointer;
}

.pies-us-map .state path.fruit-peach,
.pies-us-map .state circle.fruit-peach {
  fill: #f08a9a;
  cursor: pointer;
}

.pies-us-map .state path.fruit-milk,
.pies-us-map .state circle.fruit-milk {
  /* Fill is set in JS (url(#pattern) from external CSS resolves against the stylesheet) */
  cursor: pointer;
}

.pies-map-focus .pies-map-focus-svg path.fruit-blueberry,
.pies-map-focus .pies-map-focus-svg circle.fruit-blueberry {
  fill: #2f6fd6;
  stroke: #e8f0ff;
  stroke-width: 1.5;
}

.pies-map-focus .pies-map-focus-svg path.fruit-apple,
.pies-map-focus .pies-map-focus-svg circle.fruit-apple {
  fill: #c23b2e;
  stroke: #ffe8e4;
  stroke-width: 1.5;
}

.pies-map-focus .pies-map-focus-svg path.fruit-peach,
.pies-map-focus .pies-map-focus-svg circle.fruit-peach {
  fill: #f08a9a;
  stroke: #ffe8ee;
  stroke-width: 1.5;
}

.pies-map-focus .pies-map-focus-svg path.fruit-milk,
.pies-map-focus .pies-map-focus-svg circle.fruit-milk {
  stroke: #f0f0f0;
  stroke-width: 1.5;
}

.pies-us-map .state path.fruit-blueberry:hover,
.pies-us-map .state path.fruit-blueberry:focus,
.pies-us-map .state path.fruit-blueberry.is-selected,
.pies-us-map .state circle.fruit-blueberry:hover,
.pies-us-map .state circle.fruit-blueberry:focus,
.pies-us-map .state circle.fruit-blueberry.is-selected {
  fill: #4d8df0;
  stroke: #fff;
  stroke-width: 1.75;
  filter: brightness(1.08);
  outline: none;
}

.pies-us-map .state path.fruit-apple:hover,
.pies-us-map .state path.fruit-apple:focus,
.pies-us-map .state path.fruit-apple.is-selected,
.pies-us-map .state circle.fruit-apple:hover,
.pies-us-map .state circle.fruit-apple:focus,
.pies-us-map .state circle.fruit-apple.is-selected {
  fill: #d95a4c;
  stroke: #fff;
  stroke-width: 1.75;
  filter: brightness(1.08);
  outline: none;
}

.pies-us-map .state path.fruit-peach:hover,
.pies-us-map .state path.fruit-peach:focus,
.pies-us-map .state path.fruit-peach.is-selected,
.pies-us-map .state circle.fruit-peach:hover,
.pies-us-map .state circle.fruit-peach:focus,
.pies-us-map .state circle.fruit-peach.is-selected {
  fill: #f5a0ad;
  stroke: #fff;
  stroke-width: 1.75;
  filter: brightness(1.08);
  outline: none;
}

.pies-us-map .state path.fruit-milk:hover,
.pies-us-map .state path.fruit-milk:focus,
.pies-us-map .state path.fruit-milk.is-selected,
.pies-us-map .state circle.fruit-milk:hover,
.pies-us-map .state circle.fruit-milk:focus,
.pies-us-map .state circle.fruit-milk.is-selected {
  stroke: #fff;
  stroke-width: 1.75;
  filter: brightness(1.08);
  outline: none;
}

/* Desktop-only idle pulse so produce states invite a click */
@media (width > 768px) {
  .pies-us-map .state path.fruit-blueberry,
  .pies-us-map .state circle.fruit-blueberry,
  .pies-us-map .state path.fruit-apple,
  .pies-us-map .state circle.fruit-apple,
  .pies-us-map .state path.fruit-peach,
  .pies-us-map .state circle.fruit-peach,
  .pies-us-map .state path.fruit-milk,
  .pies-us-map .state circle.fruit-milk {
    animation: pies-map-fruit-pulse 2.6s ease-in-out infinite;
  }

  .pies-us-map .state path.fruit-blueberry:hover,
  .pies-us-map .state path.fruit-blueberry:focus,
  .pies-us-map .state path.fruit-blueberry.is-selected,
  .pies-us-map .state circle.fruit-blueberry:hover,
  .pies-us-map .state circle.fruit-blueberry:focus,
  .pies-us-map .state circle.fruit-blueberry.is-selected,
  .pies-us-map .state path.fruit-apple:hover,
  .pies-us-map .state path.fruit-apple:focus,
  .pies-us-map .state path.fruit-apple.is-selected,
  .pies-us-map .state circle.fruit-apple:hover,
  .pies-us-map .state circle.fruit-apple:focus,
  .pies-us-map .state circle.fruit-apple.is-selected,
  .pies-us-map .state path.fruit-peach:hover,
  .pies-us-map .state path.fruit-peach:focus,
  .pies-us-map .state path.fruit-peach.is-selected,
  .pies-us-map .state circle.fruit-peach:hover,
  .pies-us-map .state circle.fruit-peach:focus,
  .pies-us-map .state circle.fruit-peach.is-selected,
  .pies-us-map .state path.fruit-milk:hover,
  .pies-us-map .state path.fruit-milk:focus,
  .pies-us-map .state path.fruit-milk.is-selected,
  .pies-us-map .state circle.fruit-milk:hover,
  .pies-us-map .state circle.fruit-milk:focus,
  .pies-us-map .state circle.fruit-milk.is-selected {
    animation: none;
  }
}

@keyframes pies-map-fruit-pulse {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.14);
  }
}

.pies-map-legend {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  min-width: 7.5rem;
  max-width: 100%;
  margin: 0 auto;
  padding: 0.65rem 1.1rem 0.7rem;
  background-color: var(--primary-color);
  border: 1px solid var(--secondary-color);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgb(0 0 0 / 16%);
}

.pies-map-legend h3 {
  margin: 0;
  padding-bottom: 0.4rem;
  width: 100%;
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  font-family: Righteous, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: none;
  color: var(--subheader-color);
}

.pies-map-legend-list {
  list-style: none;
  padding: 0.1rem 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.pies-map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  line-height: 1.2;
}

.pies-map-legend-emoji {
  display: none;
}

.pies-map-swatch {
  flex: 0 0 auto;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  border: 1px solid rgb(255 255 255 / 35%);
}

.pies-map-swatch.fruit-blueberry {
  background-color: #2f6fd6;
}

.pies-map-swatch.fruit-apple {
  background-color: #c23b2e;
}

.pies-map-swatch.fruit-peach {
  background-color: #f08a9a;
}

.pies-map-swatch.fruit-milk {
  background-color: #f2f2f2;
  background-image:
    radial-gradient(ellipse 72% 64% at 28% 32%, #1a1a1a 0 68%, transparent 69%),
    radial-gradient(ellipse 58% 52% at 78% 78%, #1a1a1a 0 64%, transparent 65%);
  border-color: rgb(0 0 0 / 40%);
}

.pies-map-credit {
  margin: 0;
  font-size: 0.72rem;
  opacity: 0.55;
  text-align: right;
}

/* Legacy hover pie / status — replaced by the shared focus view */
.pies-map-status,
.pies-map-state-pie {
  display: none;
}

.pies-map-picker {
  width: min(22rem, 100%);
  margin: 0 auto;
}

.pies-map-picker-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--secondary-color);
  border-radius: 8px;
  background-color: var(--primary-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.95rem;
}

.pies-map-picker-select:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.pies-map-frame.is-focused > .pies-us-map {
  visibility: hidden;
  pointer-events: none;
}

.pies-map-focus {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: 0.75rem 1rem 1rem;
  border-radius: inherit;
  background-color: var(--primary-color);
}

.pies-map-focus.is-open {
  display: flex;
}

.pies-map-focus-close {
  align-self: flex-end;
  margin: 0 0 0.35rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 6px;
  background-color: rgb(255 255 255 / 8%);
  color: var(--text-color);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.pies-map-focus-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 22rem;
  display: grid;
  place-items: center;
  overflow: visible;
}

/* Clip scaled artboard so it doesn’t spill outside the frame */
.pies-map-frame.is-focused .pies-map-focus-canvas {
  overflow: hidden;
}

.pies-map-focus-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  transform-origin: center center;
}

.pies-map-focus-svg {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
}

.pies-map-focus-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pies-map-focus-fact {
  position: absolute;
  top: 1.5rem;
  left: 1rem;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-color);
  pointer-events: none;
}

.pies-map-focus-fact-name {
  max-width: var(--fact-name-max-width, 18rem);
  font-family: "Luckiest Guy", Righteous, system-ui, sans-serif;
  font-size: var(--fact-name-size, 2.35rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.05;
  text-transform: uppercase;
  white-space: var(--fact-name-white-space, normal);
  color: var(--subheader-color);
}

.pies-map-focus-fact-detail {
  display: flex;
  flex-flow: var(--fact-detail-direction, column) wrap;
  align-items: flex-start;
  gap: var(--fact-detail-gap, 0.05rem);
  max-width: var(--fact-detail-max-width, 11rem);
  font-size: var(--fact-detail-size, 0.9rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-align: left;
  opacity: 0.85;
}

.pies-map-focus-fact-line {
  display: block;
  width: var(--fact-line-width, 100%);
  white-space: var(--fact-line-white-space, normal);
}

.pies-map-focus-pie-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 1em;
  height: 1em;
  overflow: hidden;
  border-radius: 50%;
  font-size: var(--pie-size, clamp(7rem, 14vw, 10rem));
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 14px rgb(0 0 0 / 50%));
}

.pies-map-focus-pie {
  display: grid;
  place-items: center;
  width: 1em;
  height: 1em;
  line-height: 1;
}

.pies-map-focus-slice-cue {
  position: absolute;
  top: var(--cue-y, 52%);
  left: var(--cue-x, 50%);
  z-index: 2;
  box-sizing: border-box;
  width: 84%;
  max-width: 84%;
  margin: 0;
  padding: 0;
  border: none;
  overflow: visible;
  background: none;
  color: #111;
  font-family: "Luckiest Guy", Righteous, system-ui, sans-serif;
  font-size: var(--cue-size, 0.185em);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--cue-rotate, -8deg));
  text-shadow:
    0 1px 0 rgb(255 255 255 / 35%),
    0 0 2px rgb(255 255 255 / 25%);
}

.pies-map-focus-slash {
  position: absolute;
  top: 50%;
  left: 10%;
  width: 0;
  height: 0.08em;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #fff 20%, #facaa1 50%, #fff 80%, transparent);
  opacity: 0;
  transform: translateY(-50%) rotate(-28deg);
  transform-origin: left center;
  box-shadow: 0 0 8px rgb(255 255 255 / 55%);
}

.pies-map-focus-pie-wrap.is-sliced .pies-map-focus-slash {
  animation: pies-map-slice 0.35s ease-out forwards;
}

.pies-map-focus-pie-wrap.is-sliced .pies-map-focus-pie {
  animation: pies-map-pie-split 0.35s ease-out forwards;
}

@keyframes pies-map-slice {
  0% {
    width: 0;
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    width: 80%;
    opacity: 1;
  }
}

@keyframes pies-map-pie-split {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  100% {
    transform: translate(0.08em, 0.04em) rotate(8deg);
    filter: brightness(1.08);
  }
}

.pies-map-focus-knife {
  position: absolute;
  inset: 0.35rem 0.2rem auto auto;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 1em;
  height: 1em;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: var(--knife-size, clamp(6rem, 11vw, 8.5rem));
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 4px 14px rgb(0 0 0 / 50%));
}

.pies-map-focus-knife.is-dragging {
  cursor: grabbing;
  z-index: 6;
  filter: drop-shadow(0 6px 18px rgb(0 0 0 / 55%));
}

.pies-map-focus-knife.is-over-pie {
  filter: drop-shadow(0 0 10px rgb(250 202 161 / 55%));
}

.pies-map-focus-knife-emoji {
  font-size: 1em;
  line-height: 1;
  pointer-events: none;
}

.pies-map-focus-knife:focus-visible,
.pies-map-focus-close:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .pies-us-map .state path.fruit-blueberry,
  .pies-us-map .state circle.fruit-blueberry,
  .pies-us-map .state path.fruit-apple,
  .pies-us-map .state circle.fruit-apple,
  .pies-us-map .state path.fruit-peach,
  .pies-us-map .state circle.fruit-peach,
  .pies-us-map .state path.fruit-milk,
  .pies-us-map .state circle.fruit-milk {
    animation: none;
  }

  .pies-map-focus-pie-wrap.is-sliced .pies-map-focus-slash,
  .pies-map-focus-pie-wrap.is-sliced .pies-map-focus-pie {
    animation: none;
  }
}

/* Tablet and phone: compact key above the map with emoji labels */
@media (width <= 768px) {
  /* Touch phones only — narrow desktop keeps the wide breakout below. */
  .pies-map-section {
    gap: 0.7rem;
  }

  @media (pointer: coarse) {
    .pies-map-section {
      width: 100%;
      max-width: 100%;
      margin-left: 0;
      transform: none;
    }
  }


  .pies-map-frame {
    padding: 0.35rem;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgb(0 0 0 / 18%);
  }

  .pies-us-map .state path,
  .pies-us-map .state circle {
    stroke-width: 0.65;
  }

  .pies-us-map .borders path {
    stroke-width: 0.65;
  }

  .pies-us-map .separator1 {
    stroke-width: 1.25;
  }

  .pies-us-map .state path.fruit-blueberry,
  .pies-us-map .state circle.fruit-blueberry {
    stroke: #e8f0ff;
    stroke-width: 1.35;
  }

  .pies-us-map .state path.fruit-apple,
  .pies-us-map .state circle.fruit-apple {
    stroke: #ffe8e4;
    stroke-width: 1.35;
  }

  .pies-us-map .state path.fruit-peach,
  .pies-us-map .state circle.fruit-peach {
    stroke: #ffe8ee;
    stroke-width: 1.35;
  }

  .pies-us-map .state path.fruit-milk,
  .pies-us-map .state circle.fruit-milk {
    stroke: #f0f0f0;
    stroke-width: 1.35;
  }

  .pies-us-map .state path.fruit-blueberry:hover,
  .pies-us-map .state path.fruit-blueberry:focus,
  .pies-us-map .state path.fruit-blueberry.is-selected,
  .pies-us-map .state circle.fruit-blueberry:hover,
  .pies-us-map .state circle.fruit-blueberry:focus,
  .pies-us-map .state circle.fruit-blueberry.is-selected,
  .pies-us-map .state path.fruit-apple:hover,
  .pies-us-map .state path.fruit-apple:focus,
  .pies-us-map .state path.fruit-apple.is-selected,
  .pies-us-map .state circle.fruit-apple:hover,
  .pies-us-map .state circle.fruit-apple:focus,
  .pies-us-map .state circle.fruit-apple.is-selected,
  .pies-us-map .state path.fruit-peach:hover,
  .pies-us-map .state path.fruit-peach:focus,
  .pies-us-map .state path.fruit-peach.is-selected,
  .pies-us-map .state circle.fruit-peach:hover,
  .pies-us-map .state circle.fruit-peach:focus,
  .pies-us-map .state circle.fruit-peach.is-selected,
  .pies-us-map .state path.fruit-milk:hover,
  .pies-us-map .state path.fruit-milk:focus,
  .pies-us-map .state path.fruit-milk.is-selected,
  .pies-us-map .state circle.fruit-milk:hover,
  .pies-us-map .state circle.fruit-milk:focus,
  .pies-us-map .state circle.fruit-milk.is-selected {
    stroke-width: 1.85;
  }

  .pies-map-legend {
    min-width: 0;
    margin: 0 auto;
    gap: 0.3rem;
    padding: 0.45rem 0.75rem 0.5rem;
    border-radius: 8px;
  }

  .pies-map-picker {
    width: 100%;
  }

  .pies-map-legend h3 {
    padding-bottom: 0.3rem;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
  }

  .pies-map-legend-list {
    padding-top: 0;
    gap: 0.28rem;
  }

  .pies-map-legend-item {
    gap: 0.35rem;
    font-size: 0.78rem;
    line-height: 1;
  }

  .pies-map-legend-label {
    display: none;
  }

  .pies-map-legend-emoji {
    display: inline;
    font-size: 0.85rem;
    line-height: 1;
  }

  .pies-map-swatch {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
  }

  .pies-map-focus {
    /* Tight top so name + art sit higher in the card */
    padding: 0.3rem 0.45rem 0.45rem;
  }

  .pies-map-focus-close {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    z-index: 6;
    margin: 0;
    padding: 0.2rem 0.45rem;
    font-size: 0.85rem;
  }

  /*
   * Focused phone view: don’t let the hidden US map dictate height.
   * Size the frame to the artboard aspect so the locked desktop
   * composition scales to width without a huge empty letterbox.
   */
  .pies-map-frame.is-focused {
    aspect-ratio: 1080 / 640;
    width: 100%;
    min-height: 0;
  }

  .pies-map-frame.is-focused > .pies-us-map {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
  }

  .pies-map-focus-canvas {
    min-height: 0;
    flex: 1 1 auto;
  }

  /* Artboard-local type — keep near the top (was 2.1rem and sat too low). */
  .pies-map-focus-fact {
    top: 0.4rem;
    left: 0.55rem;
    gap: 0.25rem;
  }

  .pies-map-credit {
    font-size: 0.68rem;
    text-align: right;
  }
}
