/**
 * TripChronos Web Viewer Styles
 * A beautiful, accessible design system
 */

/* ============================================
   BASE & RESET
   ============================================ */

/* Ensure .hidden works even without Tailwind loaded */
.hidden {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Constrain key images to prevent oversized rendering */
nav img,
.loading-logo-container img,
footer img {
    max-width: 80px;
    height: auto;
}

/* Touch optimizations for mobile */
body {
    -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
select {
    touch-action: manipulation;
}

/* Prevent pull-to-refresh and horizontal scroll on mobile */
/* NOTE: overflow-x must only be on body, NOT html — setting it on both
   creates dual scroll containers in Chrome, breaking mouse wheel scrolling */
body {
    overscroll-behavior-y: contain;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Skip link - visible on focus */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--theme-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    z-index: 9999;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 1rem;
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus states */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
    background: linear-gradient(135deg, var(--surface-bg) 0%, color-mix(in srgb, var(--theme-secondary) 8%, var(--surface-bg)) 50%, var(--surface-bg) 100%);
    background: -webkit-linear-gradient(315deg, var(--surface-bg) 0%, color-mix(in srgb, var(--theme-secondary) 8%, var(--surface-bg)) 50%, var(--surface-bg) 100%);
}

.loading-logo-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-logo-container img {
    position: relative;
    z-index: 2;
    animation: logoPulse 2s ease-in-out infinite;
}

.loading-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--theme-primary);
    border-right-color: var(--theme-secondary);
    animation: spin 1.2s linear infinite;
}

.loading-ring::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--theme-primary) 10%, transparent);
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Legacy spinner (kept for any other usage) */
.loading-spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 4px solid var(--border-secondary);
    border-top-color: var(--theme-primary);
    animation: spin 1s linear infinite;
}

/* Enhanced spinner for browsers that support conic-gradient */
@supports (background: conic-gradient(from 0deg, transparent, var(--theme-primary))) {
    .loading-spinner {
        border: none;
        background: conic-gradient(from 0deg, transparent, var(--theme-primary));
        -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), black calc(100% - 4px));
        mask: radial-gradient(farthest-side, transparent calc(100% - 4px), black calc(100% - 4px));
    }
}

/* ============================================
   NAVIGATION BAR
   ============================================ */

.nav-blur {
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

/* Fallback for browsers without backdrop-filter */
@supports not ((-webkit-backdrop-filter: blur(20px)) or (backdrop-filter: blur(20px))) {
    .nav-blur {
        background: rgba(255, 255, 255, 0.98) !important;
    }
}

.dark .nav-blur {
    background: var(--nav-bg) !important;
}
@supports not ((-webkit-backdrop-filter: blur(20px)) or (backdrop-filter: blur(20px))) {
    .dark .nav-blur {
        background: rgba(28,28,30,0.98) !important;
    }
}

/* ============================================
   MODE TOGGLE BUTTONS
   ============================================ */

.mode-toggle-desktop {
    display: none;
}

@media (min-width: 640px) {
    .mode-toggle-desktop {
        display: flex;
    }
}

.mode-toggle-mobile {
    display: block;
}

@media (min-width: 640px) {
    .mode-toggle-mobile {
        display: none;
    }
}

.mode-btn {
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.mode-btn:hover {
    color: var(--text-on-card);
}

.mode-btn.active {
    background: var(--surface-card);
    color: var(--theme-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   THEME PALETTE POPOVER
   ============================================ */

.theme-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-dot:hover {
    transform: scale(1.15);
}

.theme-dot[aria-checked="true"] {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-primary) 25%, transparent);
}

.theme-dot-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}

@media (max-width: 640px) {
    .theme-dot {
        width: 36px;
        height: 36px;
    }
}

/* ============================================
   BACKGROUND ORBS (AMBIENT)
   ============================================ */

.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}

.bg-orb-1 {
    width: 400px;
    height: 400px;
    top: 5%;
    left: -5%;
    background: color-mix(in srgb, var(--theme-secondary) 12%, transparent);
    animation: bg-drift-1 22s ease-in-out infinite;
}

.bg-orb-2 {
    width: 350px;
    height: 350px;
    bottom: 10%;
    right: -5%;
    background: color-mix(in srgb, var(--theme-primary) 10%, transparent);
    animation: bg-drift-2 28s ease-in-out infinite;
}

.bg-orb-3 {
    width: 280px;
    height: 280px;
    top: 45%;
    right: 15%;
    background: color-mix(in srgb, var(--theme-accent) 8%, transparent);
    animation: bg-drift-3 20s ease-in-out infinite;
}

@keyframes bg-drift-1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, 30px) scale(1.05); }
    50% { transform: translate(-20px, 60px) scale(0.95); }
    75% { transform: translate(30px, -20px) scale(1.02); }
}

@keyframes bg-drift-2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    30% { transform: translate(-50px, -30px) scale(1.04); }
    60% { transform: translate(30px, 40px) scale(0.96); }
    85% { transform: translate(-20px, -50px) scale(1.02); }
}

@keyframes bg-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    20% { transform: translate(30px, -40px) scale(1.06); }
    50% { transform: translate(-40px, 20px) scale(0.94); }
    80% { transform: translate(20px, 50px) scale(1.03); }
}

@media (max-width: 640px) {
    .bg-orb {
        filter: blur(40px);
        opacity: 0.7;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-orb {
        animation: none !important;
    }
}

/* ============================================
   HERO ENTRANCE ANIMATIONS
   ============================================ */

.hero-enter .t-gradient-hero {
    animation: heroLineWipe 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: left;
    transform: scaleX(0);
}

@keyframes heroLineWipe {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.hero-enter #destination {
    animation: heroSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.hero-enter #dateRange {
    animation: heroFadeIn 0.5s ease 0.25s both;
}

.hero-enter #vibes {
    animation: heroFadeIn 0.5s ease 0.35s both;
}

.hero-enter .border-t {
    animation: heroSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.45s both;
}

@keyframes heroSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes heroFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .hero-enter .t-gradient-hero,
    .hero-enter #destination,
    .hero-enter #dateRange,
    .hero-enter #vibes,
    .hero-enter .border-t {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ============================================
   CTA FLOATING ICON
   ============================================ */

.cta-float {
    animation: ctaFloat 4s ease-in-out infinite;
}

@keyframes ctaFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@media (prefers-reduced-motion: reduce) {
    .cta-float {
        animation: none !important;
    }
}

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.dark ::-webkit-scrollbar-track {
    background: var(--surface-secondary);
}

.dark ::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.dark * {
    scrollbar-color: var(--text-tertiary) var(--surface-secondary);
}

/* ============================================
   VIBE BADGES
   ============================================ */

#vibes span {
    background: var(--badge-bg);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: slideUp 0.4s ease backwards;
    border: 1px solid var(--border-secondary);
    color: var(--badge-text);
}

#vibes span:nth-child(1) { animation-delay: 0.1s; }
#vibes span:nth-child(2) { animation-delay: 0.15s; }
#vibes span:nth-child(3) { animation-delay: 0.2s; }
#vibes span:nth-child(4) { animation-delay: 0.25s; }
#vibes span:nth-child(5) { animation-delay: 0.3s; }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   STATS CARDS
   ============================================ */

.stats-container {
    display: flex;
    justify-content: center;
    gap: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    animation: fadeInUp 0.5s ease backwards;
}

.stat-item:nth-child(1) { animation-delay: 0.1s; }
.stat-item:nth-child(2) { animation-delay: 0.15s; }
.stat-item:nth-child(3) { animation-delay: 0.2s; }

/* Divider between stats */
.stat-divider {
    width: 1px;
    height: 24px;
    background: var(--border-secondary);
    margin: 0 1.25rem;
    flex-shrink: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stat icon */
.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--theme-primary) 8%, var(--surface-card-alt)) 0%,
        color-mix(in srgb, var(--theme-secondary) 8%, var(--surface-card-alt)) 100%);
}

.stat-icon svg {
    width: 18px;
    height: 18px;
    color: var(--theme-primary);
}

.stat-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Mobile stats */
@media (max-width: 640px) {
    .stat-item {
        gap: 0.375rem;
    }

    .stat-divider {
        margin: 0 0.75rem;
        height: 20px;
    }

    .stat-icon {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }

    .stat-icon svg {
        width: 15px;
        height: 15px;
    }

    .stat-value {
        font-size: 1.0625rem;
    }

    .stat-label {
        font-size: 0.6875rem;
    }
}

/* ============================================
   VIEW TOGGLE
   ============================================ */

.view-toggle {
    padding: 0.5rem;
    border-radius: 9999px;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.view-toggle:hover {
    color: var(--text-on-card);
}

.view-toggle.active {
    background: var(--surface-card);
    color: var(--theme-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   FILTER CHECKBOX
   ============================================ */

.filter-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--border-secondary);
    background: var(--surface-card);
    appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.filter-checkbox:checked {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
}

.filter-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-checkbox:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* ============================================
   TIMELINE VIEW - Enhanced
   ============================================ */

.timeline-view {
    position: relative;
}

/* Day Group */
.timeline-view .day-group {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-view .day-group:last-child {
    margin-bottom: 0;
}

/* Day Header - Sticky */
.timeline-view .day-header {
    position: sticky;
    top: 64px; /* Below nav */
    z-index: 20;
    background: var(--surface-secondary);
    background: -webkit-linear-gradient(to bottom, var(--surface-secondary) 0%, var(--surface-secondary) 85%, transparent 100%);
    background: linear-gradient(to bottom, var(--surface-secondary) 0%, var(--surface-secondary) 85%, transparent 100%);
    padding: 0.75rem 0 1rem 0;
    margin-bottom: 0.5rem;
}

.timeline-view .day-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.timeline-view .day-date {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timeline-view .day-dot {
    width: 10px;
    height: 10px;
    background: var(--theme-primary);
    background: -webkit-linear-gradient(315deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 15%, transparent);
}

.timeline-view .day-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.timeline-view .day-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timeline-view .day-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--surface-card-alt);
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

.timeline-view .day-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.timeline-view .day-toggle:hover {
    background: var(--surface-card-alt);
    color: var(--text-tertiary);
}

.timeline-view .day-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.timeline-view .day-group.collapsed .day-toggle svg {
    transform: rotate(-90deg);
}

.timeline-view .day-group.collapsed .day-content {
    display: none;
}

/* Timeline Rail */
.timeline-view .day-content {
    position: relative;
    padding-left: 1.5rem;
    margin-left: 4px;
    border-left: 2px solid var(--border-secondary);
}

/* Location Group */
.timeline-view .location-group {
    margin-bottom: 1.5rem;
}

.timeline-view .location-group:last-child {
    margin-bottom: 0;
}

.timeline-view .location-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
}

.timeline-view .location-header svg {
    width: 14px;
    height: 14px;
    color: var(--theme-primary);
    flex-shrink: 0;
}

.timeline-view .location-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.timeline-view .location-count {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-left: auto;
}

/* Memories Grid within location */
.timeline-view .memories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

@media (max-width: 640px) {
    .timeline-view .memories-grid {
        grid-template-columns: 1fr;
    }

    .timeline-view .day-header {
        top: 56px;
    }
}

/* ============================================
   MEMORY CARDS - Refined
   ============================================ */

.memory-card {
    background: var(--surface-card);
    border-radius: 0.875rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-secondary);
    transition: all 0.2s ease;
}

.memory-card:hover {
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.1);
    border-color: var(--border-secondary);
}

.memory-card:focus-within {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* Photo container */
.memory-card .photo-container {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface-card-alt);
    overflow: hidden;
}

.memory-card .photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.memory-card:hover .photo-container img {
    transform: scale(1.02);
}

/* Photo overlay on hover */
.memory-card .photo-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
}

.memory-card:hover .photo-overlay {
    background: rgba(0, 0, 0, 0.25);
    opacity: 1;
}

.memory-card .photo-overlay svg {
    width: 36px;
    height: 36px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Memory content */
.memory-card .memory-content {
    padding: 0.875rem 1rem;
}

.memory-card .memory-time {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.375rem;
}

.memory-card .memory-note {
    font-size: 0.9375rem;
    color: var(--text-on-card);
    line-height: 1.5;
}

/* Card without photo - text only */
.memory-card.text-only {
    background: var(--surface-secondary);
    background: -webkit-linear-gradient(315deg, var(--surface-secondary) 0%, var(--surface-card-alt) 100%);
    background: linear-gradient(135deg, var(--surface-secondary) 0%, var(--surface-card-alt) 100%);
}

.memory-card.text-only .memory-content {
    padding: 1rem 1.125rem;
}

.memory-card.text-only .memory-note {
    font-size: 0.9375rem;
}

/* ============================================
   GRID VIEW CARDS
   ============================================ */

.grid-card {
    aspect-ratio: 1;
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    background: var(--surface-card-alt);
    background: -webkit-linear-gradient(315deg, var(--surface-card-alt) 0%, var(--border-secondary) 100%);
    background: linear-gradient(135deg, var(--surface-card-alt) 0%, var(--border-secondary) 100%);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.grid-card:hover {
    transform: scale(1.02);
}

.grid-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-card .grid-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    background: -webkit-linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 50%);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 50%);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.grid-card:hover .grid-overlay {
    opacity: 1;
}

.grid-card .grid-overlay p {
    color: white;
    font-size: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Grid card without photo */
.grid-card.no-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
}

.grid-card.no-photo svg {
    width: 24px;
    height: 24px;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}

.grid-card.no-photo p {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   TRIP DETAIL PILLS (Compact)
   ============================================ */

.detail-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: color-mix(in srgb, var(--theme-primary) 6%, var(--surface-card-alt));
    border-radius: 9999px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.detail-pill .pill-icon {
    font-size: 0.875rem;
    line-height: 1;
}

.detail-pill .pill-value {
    font-weight: 500;
    color: var(--text-on-card);
}

/* ============================================
   LOCATION TAGS
   ============================================ */

.location-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    max-width: 100%;
    word-break: break-word;
}

/* Locations container */
#locations {
    overflow-x: hidden;
    overflow-wrap: break-word;
}

.location-tag:hover {
    transform: scale(1.02);
}

.location-tag.country {
    background: color-mix(in srgb, var(--theme-primary) 10%, transparent);
    background: -webkit-linear-gradient(315deg, color-mix(in srgb, var(--theme-primary) 10%, transparent) 0%, color-mix(in srgb, var(--theme-secondary) 10%, transparent) 100%);
    background: linear-gradient(135deg, color-mix(in srgb, var(--theme-primary) 10%, transparent) 0%, color-mix(in srgb, var(--theme-secondary) 10%, transparent) 100%);
    color: var(--theme-primary);
}

.location-tag.city {
    background: var(--surface-card-alt);
    color: var(--text-secondary);
}

/* ============================================
   LIGHTBOX
   ============================================ */

#lightbox {
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

#lightboxImage {
    animation: zoomIn 0.25s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#lightbox-caption {
    max-width: 600px;
    margin: 0 auto;
}

#lightbox-caption .caption-note {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

#lightbox-caption .caption-location {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

#toast.show {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   MAP STYLES
   ============================================ */

#map {
    z-index: 1;
}

.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

.marker-popup-photo {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

.marker-popup-photo:hover {
    opacity: 0.85;
}

.marker-popup-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.marker-popup-location {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.marker-popup-date {
    font-size: 12px;
    color: var(--text-tertiary);
}

.marker-popup-note {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 2px;
}

/* Map fullscreen button */
.map-fullscreen-btn {
    width: 36px;
    height: 36px;
    background: var(--surface-card);
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: background 0.15s;
}

.map-fullscreen-btn:hover {
    background: #f0f0f0;
}

/* Map fullscreen mode */
.map-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 45 !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: var(--surface-card);
    display: flex;
    flex-direction: column;
}

.map-fullscreen > h2 {
    display: none !important;
}

.map-fullscreen > .t-surface-card {
    border-radius: 0 !important;
    border: none !important;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.map-fullscreen #map {
    height: auto !important;
    flex: 1;
    min-height: 0;
}

.map-fullscreen #locations {
    flex-shrink: 0;
    max-height: 30vh;
    overflow-y: auto;
}

body.map-fullscreen-open {
    overflow: hidden;
}

/* Custom map marker */
.custom-marker {
    width: 32px;
    height: 32px;
    background: var(--theme-primary);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--theme-primary) 40%, transparent);
}

.dark .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9);
}

.dark .leaflet-popup-content-wrapper {
    background: var(--surface-card);
    color: var(--text-primary);
}

.dark .leaflet-popup-tip {
    background: var(--surface-card);
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    nav,
    .skip-link,
    #shareBtn,
    .view-toggle,
    #filter-btn,
    #search-input,
    footer section:first-of-type,
    #lightbox {
        display: none !important;
    }

    .memory-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }

    body {
        font-size: 12pt;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

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

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Safe area insets for notched iPhones */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    nav {
        padding-top: env(safe-area-inset-top);
    }

    footer {
        padding-bottom: env(safe-area-inset-bottom);
    }

    #lightbox {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }
}

@media (max-width: 640px) {
    /* Hero section mobile */
    #destination {
        font-size: 1.75rem;
        line-height: 1.2;
        word-break: break-word;
    }

    #dateRange {
        font-size: 0.9375rem;
    }

    /* Vibes badges mobile */
    #vibes span {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }


    /* Filter controls mobile */
    .filter-controls-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    #search-input {
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    #filter-btn {
        min-height: 44px;
        justify-content: center;
    }

    #filter-menu {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        max-width: calc(100vw - 2rem);
        max-height: 80vh;
        overflow-y: auto;
        z-index: 100;
    }

    /* Filter menu backdrop for mobile */
    #filter-menu::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: -1;
    }

    /* View toggle mobile */
    .view-toggle {
        padding: 0.625rem;
        min-width: 44px;
        min-height: 44px;
    }

    /* Timeline view mobile */
    .timeline-view .day-header {
        top: 60px;
        padding: 0.5rem 0 0.75rem 0;
    }

    .timeline-view .day-title {
        font-size: 1rem;
    }

    .timeline-view .day-content {
        padding-left: 1rem;
        margin-left: 3px;
    }

    .timeline-view .location-header {
        flex-wrap: wrap;
    }

    .timeline-view .memories-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Memory cards mobile */
    .memory-card {
        border-radius: 0.75rem;
    }

    .memory-card .photo-container {
        aspect-ratio: 16 / 10;
    }

    .memory-card .memory-content {
        padding: 0.75rem 0.875rem;
    }

    .memory-card .memory-note {
        font-size: 0.875rem;
    }

    /* Grid view mobile */
    #grid-view {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .grid-card {
        border-radius: 0.75rem;
    }

    /* Detail pills mobile */
    .detail-pill {
        padding: 0.375rem 0.625rem;
        font-size: 0.8125rem;
    }

    /* Location tags mobile */
    .location-tag {
        padding: 0.375rem 0.625rem;
        font-size: 0.8125rem;
    }

    /* Map section mobile */
    #map {
        height: 220px !important;
    }

    /* Locations container mobile */
    #locations {
        padding: 0.75rem;
    }

    .location-tag {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }

    /* CTA section mobile */
    section[aria-labelledby="cta-heading"] {
        padding: 2.5rem 1rem;
    }

    section[aria-labelledby="cta-heading"] h2 {
        font-size: 1.5rem;
    }

    section[aria-labelledby="cta-heading"] p {
        font-size: 1rem;
    }

    section[aria-labelledby="cta-heading"] a {
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
    }

    /* Footer mobile */
    footer {
        padding: 2rem 1rem;
    }

    /* Lightbox mobile */
    #lightbox {
        padding: 0;
    }

    #lightbox button[onclick="closeLightbox()"] {
        top: max(0.75rem, env(safe-area-inset-top, 0.75rem));
        right: 0.75rem;
        width: 44px;
        height: 44px;
    }

    #lightbox-prev,
    #lightbox-next {
        width: 44px;
        height: 44px;
        top: 50%;
        transform: translateY(-50%);
    }

    #lightbox-prev {
        left: 0.5rem;
    }

    #lightbox-next {
        right: 0.5rem;
    }

    #lightboxImage {
        max-height: 70vh;
        border-radius: 0;
    }

    #lightbox-caption {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    #lightbox-counter {
        bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem));
    }

    /* Section headings mobile */
    h2.text-2xl {
        font-size: 1.25rem !important;
    }

    h2 .w-10 {
        width: 2rem !important;
        height: 2rem !important;
    }

    h2 .w-10 svg {
        width: 1rem !important;
        height: 1rem !important;
    }
}

/* Extra small screens (iPhone SE, smaller devices) */
@media (max-width: 375px) {
    #destination {
        font-size: 1.5rem;
    }

    #dateRange {
        font-size: 0.875rem;
    }

    .stat-icon {
        width: 26px;
        height: 26px;
        border-radius: 7px;
    }

    .stat-icon svg {
        width: 13px;
        height: 13px;
    }

    .stat-value {
        font-size: 0.9375rem;
    }

    .stat-divider {
        margin: 0 0.5rem;
    }

    .detail-pill {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    section[aria-labelledby="cta-heading"] h2 {
        font-size: 1.25rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .memory-card {
        border: 2px solid #334155;
    }

    .view-toggle.active {
        outline: 2px solid #334155;
    }

    a:focus-visible,
    button:focus-visible {
        outline-width: 3px;
    }
}

/* ============================================
   STORY MODE - Vertical Parallax Journey
   ============================================ */

#story-view {
    position: relative;
    overflow: visible;
}

/* Story Hero Section */
.story-hero {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--theme-primary) 3%, transparent) 0%,
        color-mix(in srgb, var(--theme-secondary) 8%, transparent) 50%,
        transparent 100%
    );
    border-radius: 2rem;
    margin-bottom: 2rem;
    position: relative;
}

.story-hero-content {
    max-width: 600px;
}

.story-hero-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--theme-primary);
    margin-bottom: 1rem;
}

.story-hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.story-hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-tertiary);
    line-height: 1.6;
}

.story-scroll-hint {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    animation: scrollHintBounce 2s ease-in-out infinite;
}

.story-scroll-arrow {
    width: 20px;
    height: 20px;
}

@keyframes scrollHintBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* SVG Curved Path */
.story-path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.story-curve-path {
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: dashOffset 20s linear infinite;
}

@keyframes dashOffset {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -500; }
}

.story-path-dot {
    filter: drop-shadow(0 0 12px color-mix(in srgb, var(--theme-primary) 60%, transparent));
    transition: all 0.15s ease-out;
}

/* Story Journey Container */
.story-journey {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 1rem;
}

/* Individual Memory Item */
.story-memory {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 4rem 0;
    opacity: 0;
    transform: translateY(40px) scale(0.97);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.story-memory.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Staggered animation for card contents */
.story-memory.visible .story-memory-info {
    animation: storyContentFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.story-memory.visible .story-memory-photo {
    animation: storyPhotoReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes storyContentFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes storyPhotoReveal {
    from {
        opacity: 0;
        transform: scale(1.02);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Alternating layout */
.story-memory:nth-child(odd) {
    align-items: flex-start;
}

.story-memory:nth-child(even) {
    align-items: flex-end;
}

/* Memory Content Card */
.story-memory-card {
    max-width: 500px;
    width: 100%;
    background: var(--surface-card);
    border-radius: 1.5rem;
    overflow: visible;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 20px 40px -8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.4s ease;
    position: relative;
}

.story-memory-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        0 8px 12px -2px rgba(0, 0, 0, 0.08),
        0 30px 60px -12px rgba(0, 0, 0, 0.15);
}

/* Path anchor point - positioned at top right corner of card */
.story-anchor {
    position: absolute;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow:
        0 4px 12px color-mix(in srgb, var(--theme-primary) 40%, transparent),
        0 0 0 4px color-mix(in srgb, var(--theme-primary) 10%, transparent);
    z-index: 10;
    top: 1.5rem;
    right: -9px;
    transform: none;
}

.story-memory:nth-child(even) .story-anchor {
    right: auto;
    left: -9px;
}

.story-anchor::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--theme-primary) 15%, transparent);
    animation: anchorPulse 2.5s ease-in-out infinite;
}

@keyframes anchorPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.8); opacity: 0; }
}

/* Info Section (Above Photo) */
.story-memory-info {
    padding: 1.5rem 1.75rem 1.25rem;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--theme-primary) 4%, transparent) 0%,
        color-mix(in srgb, var(--theme-secondary) 2%, transparent) 100%
    );
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 1.5rem 1.5rem 0 0;
    position: relative;
}

.story-memory-date {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--theme-primary);
    margin-bottom: 0.625rem;
}

.story-memory-date svg {
    width: 14px;
    height: 14px;
}

.story-memory-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.story-memory-location svg {
    width: 20px;
    height: 20px;
    color: var(--theme-primary);
    flex-shrink: 0;
}

.story-memory-note {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-top: 0.75rem;
}

/* Photo Section */
.story-memory-photo {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    cursor: pointer;
    border-radius: 0 0 1.5rem 1.5rem;
}

.story-memory-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.story-memory-card:hover .story-memory-photo img {
    transform: scale(1.05);
}

.story-memory-photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
        rgba(0, 0, 0, 0.3) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-memory-card:hover .story-memory-photo-overlay {
    opacity: 1;
}

.story-memory-photo-overlay svg {
    width: 48px;
    height: 48px;
    color: white;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* Time indicator */
.story-memory-time {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: color-mix(in srgb, var(--surface-card) 95%, transparent);
    backdrop-filter: blur(8px);
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-on-card);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Text-only memory (no photo) */
.story-memory-card.no-photo {
    background: linear-gradient(135deg,
        var(--surface-secondary) 0%,
        var(--surface-card-alt) 100%
    );
    border-radius: 1.5rem;
}

.story-memory-card.no-photo .story-memory-info {
    padding: 2rem 2rem;
    background: transparent;
    border-bottom: none;
    border-radius: 1.5rem;
}

.story-memory-card.no-photo .story-memory-note {
    font-size: 1.125rem;
    color: var(--text-on-card);
}

/* Center Navigation Indicator */
.story-nav-indicator {
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.story-nav-indicator.visible {
    opacity: 1;
    pointer-events: auto;
}

.story-nav-arrow {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-card);
    border-radius: 50%;
    color: var(--text-tertiary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    cursor: pointer;
}

.story-nav-arrow:hover {
    background: var(--theme-primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--theme-primary) 35%, transparent);
}

.story-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.story-nav-arrow:disabled:hover {
    background: var(--surface-card);
    color: var(--text-tertiary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.story-nav-arrow svg {
    width: 20px;
    height: 20px;
}

.story-nav-arrow.story-nav-up:hover svg {
    animation: arrowBounceUp 0.4s ease infinite;
}

.story-nav-arrow.story-nav-down:hover svg {
    animation: arrowBounceDown 0.4s ease infinite;
}

@keyframes arrowBounceUp {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes arrowBounceDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

/* Back to top and Start over buttons */
.story-back-top,
.story-start-over {
    background: linear-gradient(135deg, var(--surface-secondary) 0%, var(--border-secondary) 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.story-back-top:hover {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-dark) 100%);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--theme-primary) 35%, transparent);
}

.story-start-over:hover {
    background: linear-gradient(135deg, var(--theme-secondary) 0%, var(--theme-primary) 100%);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--theme-secondary) 35%, transparent);
}

.story-start-over:hover svg {
    animation: spinRestart 0.6s ease;
}

@keyframes spinRestart {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

.story-nav-counter {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--surface-card);
    padding: 0.5rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-on-card);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.story-nav-divider {
    color: var(--text-tertiary);
}

/* Progress dots for mobile */
.story-progress-dots {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: color-mix(in srgb, var(--surface-card) 95%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 9999px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    max-width: calc(100vw - 3rem);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.story-progress-dots::-webkit-scrollbar {
    display: none;
}

.story-progress-dots.visible {
    opacity: 1;
    pointer-events: auto;
}

.story-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-secondary);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    flex-shrink: 0;
}

.story-dot:hover {
    background: var(--text-tertiary);
    transform: scale(1.2);
}

.story-dot.active {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
    width: 24px;
    border-radius: 4px;
}

/* When there are many dots, show a condensed view */
.story-progress-dots.condensed .story-dot:not(.active):not(.near-active) {
    width: 4px;
    height: 4px;
    opacity: 0.5;
}

.story-progress-dots.condensed .story-dot.near-active {
    width: 6px;
    height: 6px;
}

/* Mobile back to top button */
.story-mobile-top {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-card);
    color: var(--text-tertiary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 51;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.story-mobile-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.story-mobile-top:active {
    transform: scale(0.95);
    background: var(--theme-primary);
    color: white;
}

.story-mobile-top svg {
    width: 20px;
    height: 20px;
}

/* Story End */
.story-end {
    text-align: center;
    padding: 6rem 2rem;
    margin-top: 2rem;
    position: relative;
    z-index: 2;
}

.story-end-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.story-end-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-tertiary);
}

/* Parallax effect for photos */
.story-memory-photo.parallax img {
    will-change: transform;
}

/* Snap scrolling for smooth navigation */
.story-memory.snap-target {
    scroll-snap-align: center;
}

/* Desktop Layout */
@media (min-width: 768px) {
    .story-hero {
        min-height: 40vh;
        padding: 4rem 3rem;
    }

    .story-hero-title {
        font-size: 3.5rem;
    }

    .story-journey {
        padding: 0 2rem;
    }

    .story-memory {
        padding: 5rem 0;
        flex-direction: row;
        align-items: flex-start;
        gap: 0;
    }

    .story-memory:nth-child(odd) {
        flex-direction: row;
        padding-left: 5%;
        padding-right: calc(50% + 2rem);
    }

    .story-memory:nth-child(even) {
        flex-direction: row;
        padding-right: 5%;
        padding-left: calc(50% + 2rem);
    }

    .story-memory-card {
        max-width: 100%;
    }

    .story-memory-info {
        padding: 1.75rem 2rem 1.5rem;
    }

    .story-memory-location {
        font-size: 1.375rem;
    }

    .story-anchor {
        width: 20px;
        height: 20px;
        top: 1.75rem;
        right: -10px;
    }

    .story-memory:nth-child(even) .story-anchor {
        left: -10px;
        right: auto;
    }

    .story-nav-indicator {
        right: 2rem;
    }
}

/* Large screens */
@media (min-width: 1024px) {
    .story-memory:nth-child(odd) {
        padding-left: 8%;
        padding-right: calc(50% + 3rem);
    }

    .story-memory:nth-child(even) {
        padding-right: 8%;
        padding-left: calc(50% + 3rem);
    }

    .story-memory-photo {
        aspect-ratio: 16 / 10;
    }

    .story-nav-indicator {
        right: 3rem;
    }
}

/* Mobile - Immersive Full-Screen Experience */
@media (max-width: 767px) {
    #story-view {
        margin: 0 -1rem;
        width: calc(100% + 2rem);
        overflow-x: hidden;
    }

    .story-hero {
        min-height: 50vh;
        padding: 2.5rem 1.5rem;
        border-radius: 0;
        margin-bottom: 0;
        background: linear-gradient(180deg,
            color-mix(in srgb, var(--theme-primary) 8%, transparent) 0%,
            color-mix(in srgb, var(--theme-secondary) 12%, transparent) 50%,
            color-mix(in srgb, var(--theme-primary) 5%, transparent) 100%
        );
    }

    .story-hero-title {
        font-size: 1.875rem;
        margin-bottom: 0.75rem;
    }

    .story-hero-subtitle {
        font-size: 1rem;
        color: var(--text-secondary);
    }

    .story-scroll-hint {
        bottom: 2rem;
    }

    /* Hide SVG path on mobile - use simpler visual */
    .story-path-svg {
        display: none;
    }

    .story-journey {
        padding: 0 0.75rem;
        position: relative;
    }

    /* Compact cards that fit photo + info naturally */
    .story-memory {
        padding: 0.75rem 0;
        margin-bottom: 1rem;
        align-items: center !important;
        position: relative;
        z-index: 1;
        display: flex;
        justify-content: center;
        opacity: 1;
        transform: none;
    }

    .story-memory:first-child {
        padding-top: 1rem;
    }

    .story-memory:last-child {
        margin-bottom: 1.5rem;
    }

    /* Hide anchor dots on mobile */
    .story-anchor {
        display: none;
    }

    /* Card design - sized by content */
    .story-memory-card {
        border-radius: 1.25rem;
        position: relative;
        z-index: 2;
        max-width: 100%;
        width: 100%;
        overflow: hidden;
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.1),
            0 2px 6px rgba(0, 0, 0, 0.06);
    }

    /* Photo first on mobile */
    .story-memory-card:not(.no-photo) {
        display: flex;
        flex-direction: column;
    }

    .story-memory-card:not(.no-photo) .story-memory-photo {
        order: 1;
        aspect-ratio: 4 / 5;
        border-radius: 1.25rem 1.25rem 0 0;
        max-height: none;
    }

    .story-memory-card:not(.no-photo) .story-memory-info {
        order: 2;
        border-radius: 0 0 1.25rem 1.25rem;
        background: var(--surface-card);
        border-top: none;
    }

    .story-memory-info {
        padding: 1rem 1.25rem 1.25rem;
        background: var(--surface-card);
    }

    .story-memory-card.no-photo .story-memory-info {
        border-radius: 1.25rem;
        padding: 2rem 1.25rem;
        min-height: 160px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        background: linear-gradient(135deg,
            color-mix(in srgb, var(--theme-primary) 6%, transparent) 0%,
            color-mix(in srgb, var(--theme-secondary) 8%, transparent) 100%
        );
    }

    .story-memory-date {
        font-size: 0.6875rem;
        margin-bottom: 0.375rem;
    }

    .story-memory-location {
        font-size: 1.0625rem;
    }

    .story-memory-location svg {
        width: 16px;
        height: 16px;
    }

    .story-memory-note {
        font-size: 0.875rem;
        line-height: 1.6;
        margin-top: 0.5rem;
    }

    .story-memory-card.no-photo .story-memory-note {
        font-size: 1.0625rem;
        text-align: center;
        color: var(--text-on-card);
    }

    .story-memory-card.no-photo .story-memory-location {
        justify-content: center;
    }

    .story-memory-card.no-photo .story-memory-date {
        text-align: center;
        display: block;
    }

    /* Photo styling - no max-height restriction */
    .story-memory-photo {
        aspect-ratio: 4 / 5;
        max-height: none;
    }

    .story-memory-photo img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .story-memory-time {
        bottom: 0.75rem;
        right: 0.75rem;
        font-size: 0.6875rem;
        padding: 0.25rem 0.625rem;
    }

    /* Subtle connector between cards */
    .story-memory::after {
        content: '';
        position: absolute;
        bottom: -0.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: 3px;
        height: 1.5rem;
        background: linear-gradient(90deg, var(--theme-primary) 0%, var(--theme-secondary) 100%);
        border-radius: 2px;
        opacity: 0.3;
    }

    .story-memory:last-child::after {
        display: none;
    }

    .story-end {
        min-height: 25vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem 1.5rem;
        margin-top: 1rem;
    }

    .story-end-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .story-end-text {
        font-size: 1rem;
    }

    /* Hide desktop nav, show progress dots on mobile */
    .story-nav-indicator.story-nav-desktop {
        display: none !important;
    }

    .story-progress-dots {
        display: flex;
        bottom: 1rem;
        padding: 0.5rem 0.75rem;
    }

    .story-dot {
        width: 6px;
        height: 6px;
    }

    .story-dot.active {
        width: 18px;
    }

    /* Show mobile back to top button */
    .story-mobile-top {
        display: flex;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .story-memory {
        opacity: 1;
        transform: none;
    }

    .story-curve-path {
        animation: none;
    }

    .story-scroll-hint {
        animation: none;
    }

    .story-anchor::before {
        animation: none;
    }

    .story-nav-arrow:hover svg {
        animation: none;
    }
}

/* Dark mode is handled via the .dark class on the root element */
