/* ============================================
   NoThinkTravel — Interactive Pins Landing
   ============================================ */

/* --- Tokens --- */
:root {
    --bg:         #08090C;
    --surface:    rgba(14, 15, 20, 0.94);
    --amber:      #C4944E;
    --text:       #E5E2DC;
    --muted:      #9A95A0;
    --subtle:     #35323A;

    --font-serif: 'Instrument Serif', Georgia, serif;
    --font-body:  'Manrope', system-ui, sans-serif;

    --ease:       cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* --- Grain overlay --- */
.grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0.03;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") repeat;
    background-size: 200px 200px;
}

/* --- Scene --- */
.scene {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
}

/* Edge vignette — subtle darkening beyond the map fade */
.scene::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(8, 9, 12, 0.6) 100%);
    pointer-events: none;
    z-index: 2;
}

/* --- Map background — sharp centre, faded edges --- */
.map-bg {
    position: absolute;
    inset: 0;
    background: url('../tile_london.svg') center / cover no-repeat;
    filter: brightness(0.42) saturate(0.65);
    -webkit-mask-image: radial-gradient(
        ellipse 72% 72% at 50% 50%,
        black 35%,
        transparent 100%
    );
    mask-image: radial-gradient(
        ellipse 72% 72% at 50% 50%,
        black 35%,
        transparent 100%
    );
    z-index: 0;
    opacity: 0;
    animation: fadeIn 1.2s ease 0.2s forwards;
}

/* --- SVG canvas (pins only, no tile inside) --- */
.map {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
    transition: transform 0.15s linear;
}

/* --- Pins --- */
.pin {
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.pin.visible {
    opacity: 1;
}

/* Invisible hover hit area */
.pin__hit {
    fill: transparent;
    stroke: none;
}

/* Pulse ring */
.pin__pulse {
    fill: none;
    stroke-width: 1.5;
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation: none;
}

/* Color the pulse ring to match the marker */
.pin[data-index="0"] .pin__pulse { stroke: #F3B631; }
.pin[data-index="1"] .pin__pulse { stroke: #F04431; }
.pin[data-index="2"] .pin__pulse { stroke: #FF8021; }
.pin[data-index="3"] .pin__pulse { stroke: #F747C6; }
.pin[data-index="4"] .pin__pulse { stroke: #16A672; }

/* Marker group (outer drop shape + white circle + icon) */
.pin__marker {
    filter: url(#pinShadow);
    transition: filter 0.2s ease;
}

.pin.active .pin__marker {
    filter: url(#pinActiveShadow);
}

.pin.active .pin__pulse {
    animation: none;
    opacity: 0;
}

@keyframes pinPulse {
    0%   { opacity: 0.55; transform: scale(1); }
    70%  { opacity: 0;    transform: scale(2.6); }
    100% { opacity: 0;    transform: scale(2.6); }
}

/* --- Hero tagline (center of scene) --- */
.hero {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 0.9s ease 1.8s forwards;
    transition: opacity 0.35s ease;
}

body.card-open .hero,
body.card-open .hint {
    opacity: 0;
}

.hero__title {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 3.5vw, 3rem);
    font-weight: 400;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 10px;
    text-shadow: 0 2px 24px rgba(8, 9, 12, 0.9);
}

.hero__sub {
    font-size: clamp(0.8125rem, 1.2vw, 1rem);
    color: var(--muted);
    letter-spacing: 0.01em;
    text-shadow: 0 1px 12px rgba(8, 9, 12, 0.95);
}

/* --- Card — morphs from pin marker via clip-path circle expand --- */
/*
 * Icon centre in card-local space: left=18(pad)+22(r)=40px, top=16(pad)+22(r)=38px
 * clip-path origin matches that point so the reveal starts exactly at the icon.
 */
.card {
    position: absolute;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.15);
    transform-origin: 40px 38px;
    transition: transform 0.36s var(--ease), opacity 0.2s ease;
    background: var(--surface);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    width: 272px;
    max-width: calc(100vw - 32px);
    padding: 16px 18px 18px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.card.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Optional hero image — spans full card width, above the icon row */
.card__image {
    display: none;
    margin: -16px -18px 14px;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    height: 140px;
}

.card__image.visible { display: block; }

.card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Source attribution link */
.card__source {
    display: none;
    margin-top: 10px;
    font-size: 0.6875rem;
    color: rgba(229, 226, 220, 0.72);
    opacity: 0.76;
    letter-spacing: 0.02em;
    transition: opacity 0.15s;
}

.card__source.visible { display: inline-block; }
.card__source:hover   { opacity: 1; }

/* Top row: icon + meta */
.card__top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

/* Colored circle with white icon — mirrors the pin marker */
.card__icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.card__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.card__meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.card__category {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.card__name {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.card__desc {
    font-size: 0.8125rem;
    color: rgba(229, 226, 220, 0.72);
    line-height: 1.55;
}

/* --- Hint --- */
.hint {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    font-size: 0.8125rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    white-space: nowrap;
}

.hint.visible  { opacity: 0.5; }
.hint.hidden   { opacity: 0;   }

/* --- Header --- */
.ui-top {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    opacity: 0;
    animation: fadeIn 0.6s ease 0.6s forwards;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.logo__icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.lang-switch button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: var(--font-body);
    color: var(--text);
    opacity: 0.3;
    transition: opacity 0.15s;
}

.lang-switch button.active { opacity: 1; font-weight: 600; }
.lang-switch button:hover  { opacity: 0.65; }
.lang-switch span          { opacity: 0.15; user-select: none; }

/* --- Footer --- */
.ui-bottom {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 24px 28px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    opacity: 0;
    animation: fadeIn 0.6s ease 0.8s forwards;
    transition: transform 0.3s var(--ease), opacity 0.2s ease;
}

.ui-bottom__left {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 18px 18px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background:
        radial-gradient(circle at top left, rgba(196, 148, 78, 0.14), transparent 52%),
        linear-gradient(180deg, rgba(16, 17, 23, 0.88) 0%, rgba(8, 9, 12, 0.95) 100%);
    box-shadow:
        0 18px 48px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.tagline {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    color: var(--text);
    margin-bottom: 0;
    opacity: 0.7;
}

/* Store buttons — official badges inside a branded container */
.store-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.8125rem;
    color: rgba(229, 226, 220, 0.5);
}

.legal-links a {
    color: rgba(229, 226, 220, 0.72);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.legal-links a:hover,
.legal-links a:focus-visible {
    color: var(--amber);
    opacity: 1;
}

.store-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 62px;
    padding: 8px 10px;
    flex-shrink: 0;
    line-height: 0;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.store-badge[aria-disabled="true"] {
    cursor: default;
    pointer-events: none;
    border-color: rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.store-badge:hover {
    border-color: rgba(196, 148, 78, 0.28);
    box-shadow:
        0 8px 18px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.store-badge:focus-visible {
    outline: none;
    border-color: rgba(196, 148, 78, 0.46);
    box-shadow:
        0 0 0 4px rgba(196, 148, 78, 0.16),
        0 8px 18px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.store-badge img {
    display: block;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
}

.store-badge--apple img {
    height: 40px;
}

/* Google badge includes its own clear space; keep its native proportions */
.store-badge--google img {
    height: 40px;
}

.route-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8125rem;
    font-weight: 400;
    color: rgba(229, 226, 220, 0.5);
}

.route-stats__sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--subtle);
    flex-shrink: 0;
}

/* --- Debug panel --- */
.debug-panel {
    display: none;
    position: fixed;
    top: 64px;
    right: 16px;
    z-index: 500;
    width: 230px;
    background: rgba(8, 9, 12, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 14px 16px 16px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text);
}

.debug-panel.visible { display: block; }

.debug-panel__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-body);
}

.debug-hint {
    font-size: 0.6875rem;
    color: var(--muted);
    margin-bottom: 10px;
    font-family: var(--font-body);
}

.debug-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.debug-close:hover { color: var(--text); }

#debug-list {
    list-style: none;
    margin-bottom: 12px;
}

#debug-list li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    line-height: 1.6;
    cursor: grab;
}

#debug-list li:last-child { border-bottom: none; }

#debug-list li b {
    display: block;
    font-family: var(--font-body);
    font-size: 0.6875rem;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 1px;
}

#debug-list li .debug-coords {
    color: #7ec8e3;
}

#route-list {
    list-style: none;
    margin-bottom: 12px;
}

#route-list li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    line-height: 1.5;
}

#route-list li:last-child { border-bottom: none; }

#route-list li b { font-size: 0.6875rem; color: var(--muted); font-weight: 500; }
#route-list li .debug-coords { color: #7ec8e3; font-size: 0.6875rem; margin-left: auto; }

.route-list-del {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    background: rgba(255,90,90,0.2);
    color: #e88;
    font-size: 0.625rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s, background 0.15s;
}

.route-list-del:hover { opacity: 1; background: rgba(255,90,90,0.35); }

.debug-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.15s;
}
.debug-btn:hover { background: rgba(255,255,255,0.12); }

#debug-output {
    width: 100%;
    height: 72px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #6aaa6a;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.6875rem;
    font-family: monospace;
    resize: none;
}

/* --- User marker --- */
.pin--user {
    cursor: pointer;
}

.user__pulse {
    fill: rgba(74, 143, 231, 0.3);
    transform-box: fill-box;
    transform-origin: center;
    animation: userPulse 2.8s ease-out infinite;
}

.user__ring {
    filter: url(#pinShadow);
}

@keyframes userPulse {
    0%   { opacity: 0.5; transform: scale(1);   }
    100% { opacity: 0;   transform: scale(2.0); }
}

/* --- Route line — animation managed entirely via JS inline styles --- */
.route {
    fill: none;
    stroke: rgba(74, 143, 231, 0.95);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    pointer-events: none;
}

/* Thick invisible hit area — cursor only, click handled by SVG listener */
.route-clickzone {
    fill: none;
    stroke: transparent;
    stroke-width: 18;
    pointer-events: none;
}

/* Show crosshair cursor over the route area in route-edit mode */
.debug-route-mode .route-clickzone { pointer-events: stroke; cursor: crosshair; }

/* --- Route debug handles --- */
.route-handle {
    fill: #4A8FE7;
    stroke: #fff;
    stroke-width: 1;
    cursor: grab;
    transition: r 0.1s ease;
}

.route-handle--user {
    fill: #fff;
    stroke: #4A8FE7;
    stroke-width: 1;
}

.route-handle:hover { filter: brightness(1.2); }

/* --- Debug tabs --- */
.debug-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.debug-tab {
    flex: 1;
    padding: 5px 8px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: var(--muted);
    font-size: 0.6875rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s;
}

.debug-tab.active {
    background: rgba(74, 143, 231, 0.18);
    border-color: rgba(74, 143, 231, 0.45);
    color: #7ec8e3;
}

/* --- Debug toggle button — bottom-right corner --- */
.debug-toggle-btn {
    display: none;
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 500;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(8, 9, 12, 0.7);
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.debug-toggle-btn:hover        { color: rgba(255,255,255,0.6); border-color: rgba(255,255,255,0.25); }
.debug-toggle-btn.active       { color: #7ec8e3; border-color: #7ec8e3; background: rgba(8,9,12,0.9); }

body.debug-available .debug-toggle-btn {
    display: flex;
}

/* In debug mode: freeze pin animations, disable hover pointer */
.debug-mode .pin__pulse        { animation: none !important; opacity: 0 !important; }
.debug-mode .pin               { cursor: grab !important; }
.debug-mode .pin:active        { cursor: grabbing !important; }

/* --- Keyframes --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Mobile bottom sheet --- */
@media (max-width: 767px) {
    .card {
        position: fixed;
        bottom: 0; left: 0 !important; right: 0;
        top: auto !important;
        width: 100%;
        max-width: 100%;
        max-height: min(68vh, 520px);
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        transform-origin: center bottom;
        border-bottom: none;
        border-left: none;
        border-right: none;
        padding-bottom: max(22px, calc(env(safe-area-inset-bottom) + 18px));
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .card.visible { transform: translateY(0); }

    .hero__title  { font-size: 1.625rem; }
    .hero__sub    { font-size: 0.8125rem; padding: 0 16px; }

    .hint         { bottom: 152px; font-size: 0.75rem; }

    .ui-top       { padding: 16px 20px; }

    .ui-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 18px 20px;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }

    .ui-bottom__left {
        width: 100%;
        max-width: 100%;
        padding: 14px 14px 16px;
        border-radius: 24px;
    }

    .route-stats { order: -1; }

    body.card-open .ui-bottom {
        transform: translateY(110%);
        opacity: 0;
        pointer-events: none;
    }

    .store-buttons         { gap: 8px; }
    .legal-links           { gap: 10px; }
    .store-badge           { min-height: 60px; padding: 8px 10px; }
    .store-badge--apple img  { height: 40px; }
    .store-badge--google img { height: 40px; }
}

@media (min-width: 381px) and (max-width: 767px) {
    .store-buttons {
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .store-badge {
        flex: 1 1 0;
        min-width: 0;
    }
}

@media (max-width: 380px) {
    .tagline           { font-size: 1rem; }
    .ui-bottom__left   { padding: 13px 12px 14px; }
    .store-buttons     { gap: 6px; }
    .legal-links       { gap: 8px; }
    .store-badge       { min-height: 58px; padding: 7px 8px; }
    .store-badge--apple img  { height: 40px; }
    .store-badge--google img { height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
