/* ============================================================
   DORIA – Animations & Micro-interactions
   Keyframes and transition utility classes.
   ============================================================ */

/* ── Entry Animations ───────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse for live indicators */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Slow rotation for ring decorations */
@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Brand glow pulse */
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 4px  rgba(var(--clr-brand-rgb), 0.18); }
    50%       { box-shadow: 0 0 14px rgba(var(--clr-brand-rgb), 0.38); }
}

/* ── Utility Classes ────────────────────────────────────────── */
.anim-fade-in-up {
    animation: fadeInUp var(--transition-slow) both;
}

.anim-fade-in {
    animation: fadeIn var(--transition-slow) both;
}

.anim-slide-in {
    animation: slideInLeft var(--transition-slow) both;
}

.anim-scale-in {
    animation: scaleIn var(--transition-slow) both;
}

/* Stagger helpers */
.anim-delay-1 { animation-delay: 0.08s; }
.anim-delay-2 { animation-delay: 0.16s; }
.anim-delay-3 { animation-delay: 0.24s; }
.anim-delay-4 { animation-delay: 0.32s; }

/* ── Skeleton Loader ────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--clr-surface-2) 25%,
        rgba(var(--ink), 0.05) 50%,
        var(--clr-surface-2) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.6s ease infinite;
}

@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Live Pulse Dot ─────────────────────────────────────────── */
.live-dot {
    width: 7px;
    height: 7px;
    background: var(--clr-brand);
    animation: glowPulse 2s ease-in-out infinite;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Tactical flicker keyframe ──────────────────────────────── */
@keyframes tac-flicker {
    0%   { opacity: 0; }
    18%  { opacity: 1; }
    22%  { opacity: 0; }
    38%  { opacity: 1; }
    42%  { opacity: 0; }
    58%  { opacity: 1; }
    100% { opacity: 1; }
}

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: max(32px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    right: max(32px, calc(env(safe-area-inset-right, 0px) + 16px));
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(var(--ink), 0.4);
    font-size: 0.8125rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
    margin: -2px -2px -2px 4px;
    flex-shrink: 0;
    align-self: flex-start;
    transition: color 0.13s;
}
@media (hover: hover) and (pointer: fine) {
    .toast-close:hover {
        color: rgba(var(--ink), 0.85);
    }
}
.toast-close:active {
    color: rgba(var(--ink), 0.85);
}

.toast {
    position: relative;
    /* hatch accent strip at top — same pattern as route card fallback segment */
    background-color: rgba(13, 17, 23, 0.94);
    background-image: repeating-linear-gradient(
        45deg,
        rgba(var(--ink), 0.09) 0px, rgba(var(--ink), 0.09) 2px,
        transparent 2px, transparent 6px
    );
    background-size: 100% 4px;
    background-repeat: no-repeat;
    background-position: 0 0;
    border: 1px solid rgba(var(--ink), 0.11);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 14px 16px 12px;
    pointer-events: all;
    animation: fadeInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
    max-width: 300px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-radius: 0;
    overflow: visible;
}

/* corner ticks — exact route-card approach */
.toast::before,
.toast::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-color: #b8f000;
    border-style: solid;
    opacity: 0;
    animation: tac-flicker 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.18s both;
}
.toast::before { top: -1px;    left: -1px;  border-width: 1px 0 0 1px; }
.toast::after  { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

.toast-icon {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 2px 6px;
    border: 1px solid currentColor;
    flex-shrink: 0;
    margin-top: 2px;
    line-height: 1.4;
    opacity: 0;
    animation: tac-flicker 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.toast-message {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    color: rgba(230, 237, 243, 0.85);
    letter-spacing: 0.04em;
    line-height: 1.5;
    opacity: 0;
    animation: fadeIn 0.3s ease 0.38s both;
}

.toast--success .toast-icon { color: #b8f000; border-color: rgba(var(--clr-brand-rgb), 0.55); }
.toast--error   .toast-icon { color: #f05050; border-color: rgba(240, 80, 80, 0.55); }
.toast--warning .toast-icon { color: #e8a020; border-color: rgba(232, 160, 32, 0.55); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 9, 14, 0.78);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.18s both;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal {
    position: relative;
    background: rgba(13, 17, 23, 0.94);
    border: 1px solid rgba(var(--ink), 0.11);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 24px 28px;
    width: min(520px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: visible;
    animation: fadeInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
    border-radius: 0;
}

/* corner ticks — flickered in after shell appears */
.modal::before,
.modal::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: #b8f000;
    border-style: solid;
    opacity: 0;
    animation: tac-flicker 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
    pointer-events: none;
}
.modal::before { top: -1px;    left: -1px;  border-width: 1px 0 0 1px; }
.modal::after  { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(var(--ink), 0.07);
}

.modal__title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #e6edf3;
    opacity: 0;
    animation: tac-flicker 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.modal__body {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: rgba(230, 237, 243, 0.7);
    letter-spacing: 0.03em;
    line-height: 1.65;
    opacity: 0;
    animation: fadeIn 0.3s ease 0.38s both;
}

.modal__footer {
    position: relative;
    margin-top: 24px;
    padding-top: 16px;
}

/* hatch accent strip above footer — mirrors route card fallback segment */
.modal__footer::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(var(--ink), 0.11) 0px, rgba(var(--ink), 0.11) 2px,
        transparent 2px, transparent 6px
    );
}

/* close button override inside modal */
.modal .btn--icon {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.625rem;
    color: rgba(var(--ink), 0.35);
    background: transparent;
    border: 1px solid rgba(var(--ink), 0.12);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    border-radius: 0;
    padding: 0;
}
@media (hover: hover) and (pointer: fine) {
    .modal .btn--icon:hover {
        color: #e6edf3;
        border-color: rgba(var(--ink), 0.35);
    }
}
.modal .btn--icon:active {
    color: #e6edf3;
    border-color: rgba(var(--ink), 0.35);
}

/* Larger tap target on touch, without enlarging the visible icon */
@media (max-width: 900px) {
    .modal .btn--icon {
        width: 44px;
        height: 44px;
    }
}

/* ── Reduced motion ──────────────────────────────────────────
   Toast/modal entrance choreography and the persistent pulse/shimmer
   loops (live-dot, sidebar status dots, skeleton shimmer) all ignore
   prefers-reduced-motion by default — this collapses every animation
   here to an instant state change, same as the marketing pages. */
@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;
    }
}
