/* Wine appellation map. Editorial styling, layered SVG, hover/click tooltip,
   legend, decor animations. Companion to appellation-map.js. */

.appellation-map {
    position: relative;
    width: 100%;
    background: linear-gradient(180deg, #f6f3ee 0%, #ede8e3 100%);
    border-radius: 6px 22px 6px 22px;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.85) inset,
        0 0 0 1px rgba(86,19,113,0.08),
        0 18px 36px -12px rgba(86,19,113,0.20),
        0 4px 12px rgba(86,19,113,0.06);
}

.appellation-map__svg {
    display: block;
    width: 100%;
    height: auto;
    cursor: default;
}

/* ── Province dividers + labels ─────────────────────────────── */
.appellation-map__province-label {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    /* WCAG contrast: same brand-purple hue, alpha raised 0.32 -> 0.70 so the
       composited label clears 4.5:1 on the cream/land background (was ~1.4:1). */
    fill: rgba(86,19,113,0.70);
    pointer-events: none;
    text-shadow: 0 1px 1.5px rgba(252,249,244,0.85);
}

/* ── Neighbor regions (faded land outside focal region) ───── */
.appellation-map__neighbor-label {
    font-family: "Noto Serif", serif;
    font-style: italic;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    fill: rgba(122,95,58,0.45);
    pointer-events: none;
    text-shadow: 0 1px 1.5px rgba(252,249,244,0.7);
}

/* ── Appellation zones ─────────────────────────────────────── */
.appellation-map__zone {
    cursor: pointer;
    transition: fill-opacity 0.22s ease, stroke-width 0.22s ease, opacity 0.22s ease;
    outline: none;
}
.appellation-map__zone:focus-visible {
    outline: 2px solid #561371;
    outline-offset: 2px;
}
.appellation-map__zone.is-dim {
    opacity: 0.18;
}
.appellation-map__zone.is-hot {
    fill-opacity: 0.78 !important;
    stroke-width: 2.2 !important;
    filter: drop-shadow(0 4px 10px rgba(86,19,113,0.30));
}
.appellation-map__zone.is-locked {
    fill-opacity: 0.85 !important;
    stroke-width: 2.6 !important;
    stroke-dasharray: 4 3;
    animation: amLockedPulse 2.4s ease-in-out infinite;
}
@keyframes amLockedPulse {
    0%, 100% { stroke-opacity: 1; }
    50%      { stroke-opacity: 0.55; }
}

/* ── Region icons + city labels ────────────────────────────── */
.appellation-map__icon-label {
    font-family: "Noto Serif", "Times New Roman", serif;
    font-style: italic;
    font-size: 9px;
    font-weight: 600;
    fill: #3a2a18;
    pointer-events: none;
    text-shadow: 0 1px 1.5px rgba(252,249,244,0.92);
}

.appellation-map__city-label {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 8.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    fill: rgba(42,30,38,0.85);
    pointer-events: none;
    text-shadow: 0 1px 1.5px rgba(252,249,244,0.92);
}
.appellation-map__city-label.is-capital {
    font-weight: 800;
    font-size: 10px;
    fill: #561371;
    letter-spacing: 0.08em;
}

/* ── Ambient labels (sea, mountain) ────────────────────────── */
.appellation-map__ambient-label {
    font-family: "Noto Serif", "Times New Roman", serif;
    font-style: italic;
    font-weight: 600;
    pointer-events: none;
}
.appellation-map__ambient-label--sea {
    font-size: 22px;
    fill: rgba(40,70,80,0.42);
    letter-spacing: 0.18em;
}
.appellation-map__ambient-label--mountain {
    font-size: 14px;
    fill: rgba(122,95,58,0.30);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* ── Decor: clouds, gulls, eagle ───────────────────────────── */
.appellation-map__decor {
    will-change: transform;
}

.appellation-map__cloud {
    transform: translate(-180px, var(--cloud-y, 60px)) scale(var(--cloud-scale, 1));
    animation: amCloudDrift var(--cloud-dur, 90s) linear var(--cloud-delay, 0s) infinite;
    will-change: transform;
}
@keyframes amCloudDrift {
    from { transform: translate(-180px, var(--cloud-y, 60px)) scale(var(--cloud-scale, 1)); }
    to   { transform: translate(960px,  var(--cloud-y, 60px)) scale(var(--cloud-scale, 1)); }
}

.appellation-map__gull {
    transform: translate(-40px, var(--gull-y, 80px));
    animation: amGullGlide var(--gull-dur, 40s) linear var(--gull-delay, 0s) infinite;
}
@keyframes amGullGlide {
    0%   { transform: translate(-40px,  var(--gull-y, 80px)) rotate(2deg); }
    50%  { transform: translate(380px,  calc(var(--gull-y, 80px) - 18px)) rotate(-2deg); }
    100% { transform: translate(820px,  var(--gull-y, 80px)) rotate(2deg); }
}

.appellation-map__eagle {
    transform-origin: var(--eagle-cx, 200px) var(--eagle-cy, 120px);
    animation: amEagleLoop 28s ease-in-out infinite;
    transform-box: fill-box;
}
@keyframes amEagleLoop {
    0%   { transform: translate(var(--eagle-cx)) translate(0, 0) scale(0.9); }
    25%  { transform: translate(var(--eagle-cx)) translate(40px, -20px) scale(1.0); }
    50%  { transform: translate(var(--eagle-cx)) translate(0, -40px) scale(1.05); }
    75%  { transform: translate(var(--eagle-cx)) translate(-40px, -20px) scale(1.0); }
    100% { transform: translate(var(--eagle-cx)) translate(0, 0) scale(0.9); }
}
/* Eagle keyframes use a circular drift around its spawn point. The transform-origin
   above keeps it visually anchored near Gran Sasso even though we translate. */

@media (prefers-reduced-motion: reduce) {
    .appellation-map__cloud,
    .appellation-map__gull,
    .appellation-map__eagle,
    .appellation-map__zone.is-locked {
        animation: none !important;
    }
}

/* ── Tooltip ────────────────────────────────────────────────── */
.appellation-map__tooltip {
    position: absolute;
    top: 0; left: 0;
    min-width: 220px;
    max-width: 300px;
    padding: 12px 14px;
    background: rgba(252,249,244,0.96);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    border-radius: 4px 14px 4px 14px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.9) inset,
        0 0 0 1px rgba(86,19,113,0.10),
        0 18px 32px -10px rgba(86,19,113,0.30);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 10;
}
.appellation-map__tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.appellation-map__tip-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.appellation-map__tip-tier {
    display: inline-block;
    font-family: "Inter", system-ui, sans-serif;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.16em;
    color: #FCF9F4;
    padding: 3px 7px;
    border-radius: 3px;
    flex-shrink: 0;
}
.appellation-map__tip-name {
    font-family: "Noto Serif", "Times New Roman", serif;
    font-style: italic;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.15;
    color: #561371;
    margin: 0;
}
.appellation-map__tip-grapes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    margin-top: 6px;
}
.appellation-map__grape {
    display: inline-block;
    font-family: "Inter", system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #5b1a30;
    background: rgba(86,19,113,0.08);
    padding: 2px 7px;
    border-radius: 999px;
}
.appellation-map__tip-cat {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 10.5px;
    color: rgba(42,30,38,0.65);
    margin: 6px 0 0;
    line-height: 1.3;
}

/* ── Fullscreen toggle button (top-right corner) ─────────────── */
.appellation-map__fullscreen {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(252,249,244,0.92);
    border: 1px solid rgba(86,19,113,0.18);
    border-radius: 6px;
    cursor: pointer;
    z-index: 12;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 6px rgba(86,19,113,0.10);
    transition: background 0.15s ease, transform 0.15s ease;
}
.appellation-map__fullscreen:hover {
    background: #FCF9F4;
    transform: scale(1.04);
}
.appellation-map__fullscreen-icon {
    width: 16px; height: 16px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23561371' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
}
.appellation-map:fullscreen .appellation-map__fullscreen-icon,
.appellation-map:-webkit-full-screen .appellation-map__fullscreen-icon,
.appellation-map.appellation-map--fullscreen-fallback .appellation-map__fullscreen-icon {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23561371' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M9 3v6H3M15 3v6h6M9 21v-6H3M15 21v-6h6'/></svg>");
}

/* ── Fullscreen state: SVG fills left, legend docks as right side panel ──── */
.appellation-map:fullscreen,
.appellation-map:-webkit-full-screen {
    background: linear-gradient(180deg, #f6f3ee 0%, #ede8e3 100%);
    border-radius: 0;
    padding: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--am-fs-legend-w, 340px);
    gap: 0;
}
.appellation-map:fullscreen .appellation-map__svg,
.appellation-map:-webkit-full-screen .appellation-map__svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Right-rail legend: vertical stack with section headers, scroll if overflow */
.appellation-map:fullscreen .appellation-map__legend,
.appellation-map:-webkit-full-screen .appellation-map__legend {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 28px 24px;
    max-height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(252,249,244,0.94) 0%, rgba(246,239,226,0.92) 100%);
    border-left: 1px solid rgba(86,19,113,0.14);
    border-top: none;
    box-shadow: -8px 0 24px -12px rgba(86,19,113,0.18);
}
.appellation-map:fullscreen .appellation-map__legend-tier,
.appellation-map:-webkit-full-screen .appellation-map__legend-tier {
    font-size: 11px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(86,19,113,0.16);
}
.appellation-map:fullscreen .appellation-map__legend-list,
.appellation-map:-webkit-full-screen .appellation-map__legend-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.appellation-map:fullscreen .appellation-map__legend-item,
.appellation-map:-webkit-full-screen .appellation-map__legend-item {
    font-size: 14px;
    padding: 6px 8px;
    margin-left: -8px;
}

/* Locked card overlays the bottom-left of the map area, doesn't push the layout */
.appellation-map:fullscreen .appellation-map__card,
.appellation-map:-webkit-full-screen .appellation-map__card {
    position: absolute;
    left: 24px;
    bottom: 24px;
    max-width: 380px;
    margin: 0;
    z-index: 20;
}
.appellation-map:fullscreen .appellation-map__fullscreen,
.appellation-map:-webkit-full-screen .appellation-map__fullscreen {
    top: 18px;
    right: calc(var(--am-fs-legend-w, 340px) + 18px);
}

body.appellation-map-fallback-open {
    overflow: hidden;
}

.appellation-map.appellation-map--fullscreen-fallback {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 10000;
    background: linear-gradient(180deg, #f6f3ee 0%, #ede8e3 100%);
    border-radius: 0;
    padding: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--am-fs-legend-w, 340px);
    gap: 0;
}

@supports not (height: 100dvh) {
    .appellation-map.appellation-map--fullscreen-fallback {
        height: 100vh;
        max-height: 100vh;
    }
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__svg {
    width: 100%;
    height: 100%;
    display: block;
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 28px 24px;
    max-height: 100dvh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(252,249,244,0.94) 0%, rgba(246,239,226,0.92) 100%);
    border-left: 1px solid rgba(86,19,113,0.14);
    border-top: none;
    box-shadow: -8px 0 24px -12px rgba(86,19,113,0.18);
    -webkit-overflow-scrolling: touch;
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend-tier {
    font-size: 11px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(86,19,113,0.16);
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend-item {
    font-size: 14px;
    padding: 6px 8px;
    margin-left: -8px;
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__card {
    position: absolute;
    left: 24px;
    bottom: 24px;
    max-width: 380px;
    margin: 0;
    z-index: 20;
}

.appellation-map.appellation-map--fullscreen-fallback .appellation-map__fullscreen {
    top: 18px;
    right: calc(var(--am-fs-legend-w, 340px) + 18px);
}

/* ── Locked card (docked between SVG and legend) ──────────── */
.appellation-map__card {
    display: none;
    position: relative;
    margin: 14px 18px;
    padding: 16px 18px;
    background: linear-gradient(180deg, #FCF9F4 0%, #f6efe2 100%);
    border-radius: 4px 14px 4px 14px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.92) inset,
        0 0 0 1px rgba(86,19,113,0.10),
        0 12px 24px -6px rgba(86,19,113,0.18);
    z-index: 8;
}
.appellation-map__card.is-shown {
    display: block;
    animation: amCardIn 0.22s ease-out;
}
@keyframes amCardIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.appellation-map__card-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}
.appellation-map__card-head .iw-denom-pill {
    /* width = content, not the whole card row */
    align-self: flex-start;
    min-width: 0;
    max-width: calc(100% - 44px);  /* leave room for close button */
}
.appellation-map__card-close {
    width: 28px; height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: rgba(86,19,113,0.55);
    font-size: 22px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    margin-left: auto;  /* push to the right edge */
}
.appellation-map__card-close:hover {
    background: rgba(86,19,113,0.08);
    color: #561371;
}
.appellation-map__card-cat {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 11.5px;
    color: rgba(42,30,38,0.65);
    margin: 4px 0 10px;
    line-height: 1.3;
}
.appellation-map__card-section {
    margin-top: 12px;
}
.appellation-map__card-section-head {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(86,19,113,0.55);
    margin: 0 0 8px;
}
.appellation-map__card-chips-shell {
    position: relative;
    min-width: 0;
}
.appellation-map__card-chips-shell::after {
    display: none;
}
.appellation-map__card-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: none;
    padding: 0 2.4rem 0.45rem 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: none;
    -webkit-mask-image: none;
}
.appellation-map__card-section.has-chip-carousel:not(.is-at-end) .appellation-map__card-chips {
    mask-image: linear-gradient(90deg, #000 calc(100% - 1.6rem), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 1.6rem), transparent 100%);
}
.appellation-map__card-chips::-webkit-scrollbar {
    display: none;
}
.appellation-map__card-chips .iw-grape-pill--am {
    flex: 0 0 auto;
    scroll-snap-align: none;
    scroll-snap-stop: normal;
}
.appellation-map__card-chip-dots {
    display: flex;
    justify-content: flex-start;
    gap: 5px;
    margin-top: 0.35rem;
}
.appellation-map__card-chip-dots.is-hidden {
    display: none;
}
.appellation-map__card-chip-dot {
    width: 6px;
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(86,19,113,0.24);
    cursor: pointer;
    transition: width 0.16s ease, background 0.16s ease;
}
.appellation-map__card-chip-dot.is-active {
    width: 16px;
    background: #561371;
}

/* In-card chip variants match site partials' iw-grape-pill / iw-denom-pill,
   only sized down for the dense card context. */
.iw-grape-pill--am,
.iw-denom-pill--am {
    font-size: 12px;
}

/* ── Legend ──────────────────────────────────────────────────── */
.appellation-map__legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px 28px;
    padding: 18px 22px 20px;
    background: linear-gradient(180deg, rgba(252,249,244,0.65), rgba(252,249,244,0.4));
    border-top: 1px dashed rgba(86,19,113,0.18);
}
.appellation-map__legend-tier {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: "Inter", system-ui, sans-serif;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.20em;
    color: #561371;
    margin: 0 0 8px;
    text-transform: uppercase;
}
.appellation-map__legend-swatch {
    width: 12px; height: 12px;
    border-radius: 3px;
    border: 1px solid;
    flex-shrink: 0;
}
.appellation-map__legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.appellation-map__legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    /* WCAG 2.5.8 target size: keep the interactive legend row >= 24px tall.
       The visible row already renders ~23.5px, so this adds < 1px and does not
       shift the centred text. */
    min-height: 24px;
    font-family: "Noto Serif", "Times New Roman", serif;
    font-style: italic;
    font-size: 13.5px;
    line-height: 1.3;
    color: #2a1e26;
    padding: 3px 6px;
    margin-left: -6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.appellation-map__legend-dot {
    width: 9px; height: 9px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.18);
    flex-shrink: 0;
}
.appellation-map__legend-text {
    flex: 1;
    min-width: 0;
}
.appellation-map__legend-item.is-sister {
    color: rgba(42,30,38,0.55);
    cursor: default;
}
.appellation-map__legend-item.is-sister:hover {
    background: transparent;
}
.appellation-map__legend-tag {
    display: inline-block;
    font-family: "Inter", system-ui, sans-serif;
    font-style: normal;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(86,19,113,0.55);
    background: rgba(86,19,113,0.06);
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.appellation-map__legend-item:hover,
.appellation-map__legend-item:focus-visible {
    background: rgba(86,19,113,0.07);
    color: #561371;
    outline: none;
}

.appellation-map__detail-flip,
.appellation-map__flip-face {
    display: none;
}

@media (max-width: 720px) {
    .appellation-map {
        perspective: 1200px;
        transform-style: preserve-3d;
    }

    .appellation-map__svg {
        backface-visibility: hidden;
        transform-origin: center center;
        transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
    }

    .appellation-map__fullscreen,
    .appellation-map__detail-flip {
        transition: opacity 0.18s ease;
    }

    .appellation-map__detail-flip {
        position: absolute;
        top: calc(var(--am-map-h, 260px) - 58px);
        right: 12px;
        z-index: 22;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 46px;
        height: 46px;
        padding: 6px;
        border: 1px solid rgba(252,249,244,0.74);
        border-radius: 999px;
        background: #561371;
        color: #fcf9f4;
        box-shadow: 0 14px 26px -14px rgba(42,30,38,0.46);
        font-family: "Inter", system-ui, sans-serif;
        font-size: 0.78rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        cursor: pointer;
        touch-action: manipulation;
    }

    .appellation-map__detail-flip[hidden] {
        display: none;
    }

    .appellation-map__detail-flip:focus-visible,
    .appellation-map__flip-back:focus-visible {
        outline: 2px solid #fcf9f4;
        outline-offset: 3px;
    }

    .appellation-map__detail-flip img {
        width: 28px;
        height: 28px;
        object-fit: contain;
        padding: 3px;
        border-radius: 999px;
        background: #fcf9f4;
        box-shadow: 0 0 0 1px rgba(86,19,113,0.12) inset;
    }

    .appellation-map__flip-face {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: var(--am-map-h, 260px);
        z-index: 30;
        display: flex;
        flex-direction: column;
        min-width: 0;
        border-radius: inherit;
        background: linear-gradient(180deg, #fcf9f4 0%, #f6f3ee 100%);
        box-shadow: 0 1px 0 rgba(255,255,255,0.9) inset;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transform: rotateY(180deg);
        transform-origin: center center;
        backface-visibility: hidden;
        transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
    }

    .appellation-map.is-flipped .appellation-map__flip-face {
        opacity: 1;
        pointer-events: auto;
        transform: rotateY(0deg);
    }

    .appellation-map.is-flipped .appellation-map__svg {
        opacity: 0;
        pointer-events: none;
        transform: rotateY(-180deg);
    }

    .appellation-map.is-flipped .appellation-map__fullscreen,
    .appellation-map.is-flipped .appellation-map__detail-flip {
        opacity: 0;
        pointer-events: none;
    }

    .appellation-map__flip-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        padding: 12px 12px 8px;
        border-bottom: 1px solid rgba(86,19,113,0.10);
        background: linear-gradient(180deg, rgba(252,249,244,0.98), rgba(252,249,244,0.88));
    }

    .appellation-map__flip-copy {
        flex: 1 1 auto;
        min-width: 0;
    }

    .appellation-map__flip-kicker {
        margin: 0 0 3px;
        font-family: "Inter", system-ui, sans-serif;
        font-size: 0.62rem;
        font-weight: 900;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        color: rgba(86,19,113,0.62);
    }

    .appellation-map__flip-title {
        display: -webkit-box;
        margin: 0;
        color: #561371;
        font-family: "Noto Serif", "Times New Roman", serif;
        font-style: italic;
        font-size: 1.16rem;
        line-height: 1.05;
        overflow: hidden;
        overflow-wrap: anywhere;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .appellation-map__flip-back {
        width: 42px;
        height: 42px;
        flex: 0 0 42px;
        display: grid;
        place-items: center;
        padding: 4px;
        border: 1px solid rgba(86,19,113,0.12);
        border-radius: 12px;
        background: #fffdfa;
        box-shadow: 0 8px 18px -12px rgba(42,30,38,0.38);
        cursor: pointer;
        touch-action: manipulation;
    }

    .appellation-map__flip-back img {
        width: 30px;
        height: 30px;
        object-fit: contain;
    }

    .appellation-map__flip-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        overscroll-behavior: contain;
        padding: 8px 12px 10px;
    }

    .appellation-map__flip-identity {
        display: inline-flex;
        align-items: flex-start;
        width: max-content;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .appellation-map__flip-identity::-webkit-scrollbar {
        display: none;
    }

    .appellation-map__flip-identity .iw-denom-pill {
        flex: 0 0 auto;
        width: max-content;
        max-width: none;
        justify-content: flex-start;
        padding-left: 10px;
        padding-right: 6px;
    }

    .appellation-map__flip-identity .iw-denom-name {
        min-width: 0;
        max-width: none;
        overflow: visible;
        text-overflow: clip;
        white-space: nowrap;
    }

    .appellation-map__flip-category,
    .appellation-map__flip-empty {
        display: -webkit-box;
        margin: 8px 2px 0;
        color: rgba(42,30,38,0.72);
        font-family: "Inter", system-ui, sans-serif;
        font-size: 0.78rem;
        line-height: 1.32;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .appellation-map__flip-section {
        margin-top: 10px;
    }

    .appellation-map__flip-face .appellation-map__card-section-head {
        margin-bottom: 6px;
    }

    .appellation-map__flip-face .appellation-map__card-chips {
        padding-bottom: 0.28rem;
    }

    .appellation-map__flip-face .appellation-map__card-chips .iw-grape-pill--am {
        flex: 0 0 auto;
        width: max-content;
        max-width: 100%;
        justify-content: flex-start;
    }

    .appellation-map__legend-item {
        touch-action: pan-y;
    }
}


/* ── Failure state ───────────────────────────────────────────── */
.appellation-map--failed {
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Noto Serif", serif;
    font-style: italic;
    color: rgba(86,19,113,0.55);
}
.appellation-map--failed::before {
    content: "Map data unavailable. Refresh to try again.";
}

/* ── Mobile: tap-driven, simpler decor, full-width tooltip ──── */
@media (pointer: coarse), (max-width: 720px) {
    .appellation-map__decor { display: none; }
    .appellation-map__zone:hover { fill-opacity: inherit; }

    .appellation-map__tooltip {
        display: none !important;
        position: fixed;
        left: 12px !important;
        right: 12px;
        bottom: 12px;
        top: auto !important;
        max-width: none;
        min-width: 0;
        z-index: 1000;
    }
}

@media (max-width: 720px) {
    .appellation-map:not(:fullscreen):not(:-webkit-full-screen):not(.appellation-map--fullscreen-fallback) .appellation-map__legend {
        max-height: clamp(13rem, 42vh, 18rem);
        overflow-y: auto;
        overscroll-behavior-y: contain;
        padding: 14px 16px 4.4rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(86,19,113,0.28) transparent;
    }

    .appellation-map:not(:fullscreen):not(:-webkit-full-screen):not(.appellation-map--fullscreen-fallback)::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 2;
        display: block;
        height: 4.2rem;
        pointer-events: none;
        background: linear-gradient(180deg, rgba(252,249,244,0), rgba(252,249,244,0.38) 45%, rgba(252,249,244,0.9) 78%, #fcf9f4);
        backdrop-filter: blur(1.5px);
        -webkit-backdrop-filter: blur(1.5px);
        mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.32) 38%, #000 100%);
        -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.32) 38%, #000 100%);
    }

    .appellation-map:fullscreen,
    .appellation-map:-webkit-full-screen {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) var(--am-fs-legend-h, 220px);
    }

    .appellation-map:fullscreen .appellation-map__legend,
    .appellation-map:-webkit-full-screen .appellation-map__legend {
        max-height: var(--am-fs-legend-h, 220px);
        padding: 14px 16px 16px;
        border-left: none;
        border-top: 1px solid rgba(86,19,113,0.14);
        box-shadow: 0 -8px 24px -12px rgba(86,19,113,0.18);
    }

    .appellation-map:fullscreen .appellation-map__legend-tier,
    .appellation-map:-webkit-full-screen .appellation-map__legend-tier {
        font-size: 10px;
        margin-bottom: 6px;
        padding-bottom: 6px;
    }

    .appellation-map:fullscreen .appellation-map__legend-list,
    .appellation-map:-webkit-full-screen .appellation-map__legend-list {
        gap: 1px;
    }

    .appellation-map:fullscreen .appellation-map__legend-item,
    .appellation-map:-webkit-full-screen .appellation-map__legend-item {
        font-size: 12px;
        padding: 4px 6px;
        margin-left: -6px;
    }

    .appellation-map:fullscreen .appellation-map__fullscreen,
    .appellation-map:-webkit-full-screen .appellation-map__fullscreen {
        top: 12px;
        right: 12px;
    }

    .appellation-map:fullscreen .appellation-map__card,
    .appellation-map:-webkit-full-screen .appellation-map__card {
        left: 12px;
        right: 12px;
        bottom: calc(var(--am-fs-legend-h, 220px) + 12px);
        max-width: none;
    }
}

@media (max-width: 720px) {
    .appellation-map.appellation-map--fullscreen-fallback {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) var(--am-fs-legend-h, 220px);
    }

    .appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend {
        max-height: var(--am-fs-legend-h, 220px);
        padding: 14px 16px 16px;
        border-left: none;
        border-top: 1px solid rgba(86,19,113,0.14);
        box-shadow: 0 -8px 24px -12px rgba(86,19,113,0.18);
    }

    .appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend-tier {
        font-size: 10px;
        margin-bottom: 6px;
        padding-bottom: 6px;
    }

    .appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend-list {
        gap: 1px;
    }

    .appellation-map.appellation-map--fullscreen-fallback .appellation-map__legend-item {
        font-size: 12px;
        padding: 4px 6px;
        margin-left: -6px;
    }

    .appellation-map.appellation-map--fullscreen-fallback .appellation-map__fullscreen {
        top: 12px;
        right: 12px;
    }

    .appellation-map.appellation-map--fullscreen-fallback .appellation-map__card {
        left: 12px;
        right: 12px;
        bottom: calc(var(--am-fs-legend-h, 220px) + 12px);
        max-width: none;
    }
}

@media (max-width: 720px) {
    .appellation-map.has-mobile-area-swiper:not(:fullscreen):not(:-webkit-full-screen):not(.appellation-map--fullscreen-fallback)::after {
        display: none;
    }

    .appellation-map.has-mobile-area-swiper:not(:fullscreen):not(:-webkit-full-screen):not(.appellation-map--fullscreen-fallback) .appellation-map__legend.appellation-map__legend--area-swiper {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        max-height: clamp(14rem, 44vh, 19rem);
        min-height: clamp(14rem, 44vh, 19rem);
        overflow: hidden;
        padding: 12px 12px 11px;
        scrollbar-width: none;
    }

    .appellation-map.has-mobile-area-swiper .appellation-map__legend--area-swiper::-webkit-scrollbar {
        display: none;
    }

    .appellation-map__area-swiper-root {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        flex-direction: column;
        gap: 0.42rem;
    }

    .appellation-map__area-swiper {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        gap: 0.85rem;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scroll-padding-inline: 0;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .appellation-map__area-swiper::-webkit-scrollbar {
        display: none;
    }

    .appellation-map__area-panel,
    .appellation-map__area-swiper .region-compass-row--area-panel {
        flex: 0 0 100% !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        min-height: 0;
        max-height: 100%;
        box-sizing: border-box;
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    .appellation-map__area-panel--list {
        display: flex;
        flex-direction: column;
        border: 1px solid rgba(86,19,113,0.12);
        border-radius: 0.9rem;
        background: rgba(252,249,244,0.76);
        box-shadow: 0 1px 0 rgba(255,255,255,0.72) inset;
        overflow: hidden;
    }

    .appellation-map__area-panel-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        padding: 0.75rem 0.75rem 0.85rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(86,19,113,0.26) transparent;
        touch-action: pan-x pan-y;
    }

    .appellation-map__legend--area-swiper .appellation-map__legend-item {
        touch-action: pan-x pan-y;
    }

    .appellation-map__legend--area-swiper .appellation-map__legend-col + .appellation-map__legend-col {
        margin-top: 0.85rem;
        padding-top: 0.85rem;
        border-top: 1px dashed rgba(86,19,113,0.16);
    }

    .appellation-map__area-swiper .region-compass-row--area-panel {
        display: grid !important;
        grid-template-columns: 2.15rem minmax(0, 1fr);
        gap: 0.8rem;
        margin: 0 !important;
        padding: 1rem !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior-y: contain;
        border: 1px solid rgba(86,19,113,0.12) !important;
        border-radius: 0.9rem;
        background: #fffdfa;
        box-shadow: 0 1px 0 rgba(255,255,255,0.78) inset;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(86,19,113,0.26) transparent;
    }

    .appellation-map__area-swiper .region-compass-row--area-panel .region-compass-row__detail {
        display: block;
    }

    .appellation-map__area-swiper .region-compass-row--area-panel .region-compass-row__chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .appellation-map__area-swiper-dots {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        /* No inter-box gap: the 24x24 hit targets sit edge-to-edge so the visible dots are
           exactly 24px centre-to-centre (the WCAG target-size floor). See dot rule below. */
        gap: 0;
        min-height: 0.9rem;
        padding: 0;
    }

    /* WCAG target-size (>=24x24): the visible dot is only 6.4px (active pill 17.6px wide),
       far below 24px. The button's OWN box is a transparent 24x24 hit target and the visible
       dot is painted via ::before at its exact original size/colour. Vertical negative margins
       absorb the box growth so the row keeps its slim height; horizontally the boxes now sit
       edge-to-edge (no negative margin, gap:0) so adjacent 24px boxes are NOT obscured and the
       visible dots land exactly 24px centre-to-centre. */
    .appellation-map__area-swiper-dot {
        position: relative;
        box-sizing: border-box;
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        /* vertical growth 24-6.4=17.6 -> -8.8 top/bottom keeps the row slim; horizontal 0. */
        margin: -8.8px 0;
        padding: 0;
        border: 0;
        background: transparent;
        cursor: pointer;
    }

    .appellation-map__area-swiper-dot::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 0.4rem;
        height: 0.4rem;
        border-radius: 999px;
        background: rgba(86,19,113,0.24);
        transition: width 0.16s ease, background 0.16s ease;
    }

    .appellation-map__area-swiper-dot.is-active {
        /* active box stays a full 24px wide (no horizontal margin) so neighbours keep their
           24px centre-to-centre spacing; only the visible ::before pill grows. */
        margin: -8.8px 0;
    }

    .appellation-map__area-swiper-dot.is-active::before {
        width: 1.1rem;
        background: #561371;
    }

    .region-compass-list.region-compass-list--mobile-swiper-source {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .appellation-map__legend {
        grid-template-columns: 1fr;
        padding: 14px 16px 18px;
    }
    .appellation-map__province-label,
    .appellation-map__city-label {
        font-size: 10px;
    }
    .appellation-map__ambient-label--sea {
        font-size: 16px;
    }
}
