/*
  Minimal animated Crete map ("cm-" classes)
  Used by resources/views/components/crete-map.blade.php

  Animation order (starts when the map scrolls into view, the script adds .is-visible):
    0.0s  the coastline draws itself
    1.2s  the land colour fades in
    1.4s  pins drop in, one by one, west to east
    2.6s  the dashed road appears and starts to "march"
  Then the script moves the highlight from place to place (the "tour").
*/

.cm {
    display: grid;
    gap: 1.5rem;
    align-items: center;
}

@media (min-width: 1024px) {
    .cm { grid-template-columns: 1fr 280px; }
}

/* The sea: soft gradient + a faint dotted grid, like an old chart.
   Change (Oct 2026): the sea used to be a rounded box around the map only.
   Now it sits on the whole homepage section (add class "cm-sea" to the <section>),
   so the background runs the full width of the screen. */
.cm-sea {
    background:
        radial-gradient(circle, rgba(0, 0, 109, 0.08) 1px, transparent 1.5px) 0 0 / 22px 22px,
        linear-gradient(160deg, #EAF6FC 0%, #F7FBFD 100%);
}

/* The map box: transparent now, the sea comes from .cm-sea behind it */
.cm-stage {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.cm-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ---------- Island ---------- */

.cm-land {
    fill: #FFFFFF;
    fill-opacity: 0;
    stroke: #00006D;
    stroke-width: 1.6;
    stroke-linejoin: round;
    /* Hide the line: dash as long as the whole path, pushed fully out of view */
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.cm-shadow {
    fill: #0EA5E9;
    opacity: 0;
    transform: translate(6px, 8px);
}

.cm-route {
    fill: none;
    stroke: #FF6B00;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 2 8;
    opacity: 0;
}

.cm.is-visible .cm-land {
    animation:
        cm-draw 1.8s ease-in-out forwards,
        cm-fill 1s ease 1.2s forwards;
}

.cm.is-visible .cm-shadow {
    animation: cm-shadow 1s ease 1.4s forwards;
}

.cm.is-visible .cm-route {
    animation:
        cm-appear 0.6s ease 2.6s forwards,
        cm-march 1.2s linear 2.6s infinite;
}

@keyframes cm-draw   { to { stroke-dashoffset: 0; } }
@keyframes cm-fill   { to { fill-opacity: 1; } }
@keyframes cm-shadow { to { opacity: 0.14; } }
@keyframes cm-appear { to { opacity: 0.7; } }
@keyframes cm-march  { to { stroke-dashoffset: -10; } }

/* ---------- Pins ---------- */

/* The button is centred on the place: its middle sits exactly on the coordinates */
.cm-pin {
    position: absolute;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    opacity: 0;
}

.cm.is-visible .cm-pin {
    /* --i is the pin number from the HTML: each pin waits a bit longer than the last */
    animation: cm-drop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) calc(1.4s + var(--i) * 0.08s) forwards;
}

@keyframes cm-drop {
    from { opacity: 0; transform: translateY(-18px) scale(0.4); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cm-dot {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: var(--pin);
    border: 2px solid #FFFFFF;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease;
}

/* Pulse ring around the active pin */
.cm-dot::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--pin);
    opacity: 0;
}

.cm-pin.is-active .cm-dot { transform: scale(1.35); }
.cm-pin.is-active .cm-dot::after { animation: cm-pulse 1.6s ease-out infinite; }

@keyframes cm-pulse {
    from { opacity: 0.8; transform: scale(0.6); }
    to   { opacity: 0; transform: scale(1.8); }
}

/* Place name: always visible for big towns, otherwise only for the active pin */
.cm-name {
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translate(-50%, 4px);
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #00006D;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cm-pin.has-label .cm-name { opacity: 0.75; }

/* Pins near the edge: label grows inwards instead of being centred (else it is cut off) */
.cm-pin.at-left .cm-name,
.cm-pin.at-left.is-active .cm-name { left: 4px; transform: translate(0, -2px); }
.cm-pin.at-right .cm-name,
.cm-pin.at-right.is-active .cm-name { left: auto; right: 4px; transform: translate(0, -2px); }

.cm-pin.is-active { z-index: 2; }
.cm-pin.is-active .cm-name {
    opacity: 1;
    transform: translate(-50%, -2px);
    background: #00006D;
    color: #FFFFFF;
}

.cm-pin:focus-visible { outline: 2px solid #FF6B00; outline-offset: 2px; border-radius: 50%; }

/* On small screens the town labels would overlap: show only the active one */
@media (max-width: 640px) {
    .cm-pin.has-label .cm-name { opacity: 0; }
    .cm-pin.is-active .cm-name { opacity: 1; }
}

.cm-compass {
    position: absolute;
    top: 14px;
    right: 18px;
    color: rgba(0, 0, 109, 0.45);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

/* ---------- Info card ---------- */

.cm-card {
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* The script adds this for a moment while it swaps the text */
.cm-card.is-changing { opacity: 0; transform: translateY(6px); }

.cm-card-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--pin);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cm-card h3 { margin: 0.6rem 0 0.25rem; color: #00006D; font-size: 1.35rem; font-weight: 700; }
.cm-card p  { margin: 0 0 0.9rem; color: #4B5563; line-height: 1.5; }
.cm-card a  { color: #FF6B00; font-weight: 600; text-decoration: none; }
.cm-card a:hover { text-decoration: underline; }

/* ---------- Reduced motion: show the finished map, no movement ---------- */

@media (prefers-reduced-motion: reduce) {
    .cm .cm-land, .cm .cm-shadow, .cm .cm-route, .cm .cm-pin, .cm .cm-dot::after {
        animation: none !important;
    }
    .cm-land { stroke-dashoffset: 0; fill-opacity: 1; }
    .cm-shadow { opacity: 0.14; }
    .cm-route { opacity: 0.7; }
    .cm-pin { opacity: 1; }
    .cm-card { transition: none; }
}
