/* World Time UI (§9.7b) - Clock, Catch-up, Time Gates */

/* ============================================================================
 * §9.7b.2 World Clock Display
 * ============================================================================ */

/* Clock pill in session header (§9.7b.2.1) */
.world-clock-pill {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.world-clock-pill:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text);
}

.world-clock-pill.hidden {
    display: none;
}

.world-clock-pill-icon {
    font-size: 0.875rem;
    transition: transform 0.3s ease;
}

.world-clock-pill-icon.day {
    color: #fbbf24;
}

.world-clock-pill-icon.night {
    color: #818cf8;
}

.world-clock-pill-label {
    font-weight: 500;
    white-space: nowrap;
}

/* Pulse animation when time advances (§9.7b.3.1) */
.world-clock-pill.pulse {
    animation: clockPulse 0.6s ease-out;
}

@keyframes clockPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(139, 92, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    }
}

/* Clock detail popover (§9.7b.2.3) */
.world-clock-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.world-clock-popover.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.world-clock-popover-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.world-clock-popover-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.world-clock-popover-icon.day {
    color: #fbbf24;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
}

.world-clock-popover-icon.night {
    color: #818cf8;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.15), rgba(99, 102, 241, 0.15));
}

.world-clock-popover-time {
    flex: 1;
}

.world-clock-popover-main {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.world-clock-popover-period {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.world-clock-popover-body {
    padding: 0.75rem 1rem;
}

.world-clock-popover-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    font-size: 0.8rem;
}

.world-clock-popover-row-label {
    color: var(--text-muted);
}

.world-clock-popover-row-value {
    color: var(--text);
    font-weight: 500;
}

.world-clock-popover-row-value.paused {
    color: var(--warning);
}

/* Time scale badge */
.time-scale-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    font-size: 0.7rem;
    color: var(--primary);
}

/* ============================================================================
 * §9.7b.4 Offline Catch-up Flow
 * ============================================================================ */

/* Catch-up card overlay (§9.7b.4.3) - Exceptional UX */
.catchup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.catchup-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.catchup-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 
        0 0 0 1px rgba(139, 92, 246, 0.1),
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(139, 92, 246, 0.1);
    transform: scale(0.9) translateY(30px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.catchup-overlay.visible .catchup-card {
    transform: scale(1) translateY(0);
}

.catchup-header {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.1));
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.catchup-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.25rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
    position: relative;
    animation: catchupIconFloat 3s ease-in-out infinite;
}

.catchup-icon::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    opacity: 0.3;
    animation: catchupIconRing 2s ease-out infinite;
}

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

@keyframes catchupIconRing {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.5); opacity: 0; }
}

.catchup-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.catchup-time-passed {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.catchup-time-value {
    color: var(--primary);
    font-weight: 600;
}

.catchup-body {
    padding: 1.25rem;
    max-height: 280px;
    overflow-y: auto;
}

.catchup-events {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.catchup-event {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.catchup-event-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--primary);
}

.catchup-event.npc_moved .catchup-event-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.catchup-event.time_passed .catchup-event-icon {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.catchup-event.time_gate_unlocked .catchup-event-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.catchup-event-content {
    flex: 1;
    min-width: 0;
}

.catchup-event-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.125rem;
}

.catchup-event-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.catchup-more {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.catchup-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
}

.catchup-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.catchup-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    position: relative;
    overflow: hidden;
}

.catchup-btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.catchup-btn-primary:hover::before {
    opacity: 1;
}

.catchup-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.catchup-btn-primary:active {
    transform: translateY(0);
}

.catchup-btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.catchup-btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

/* Catch-up detail view (§9.7b.4.4) */
.catchup-detail-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 350;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.catchup-detail-modal.visible {
    opacity: 1;
    visibility: visible;
}

.catchup-detail-content {
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.catchup-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.catchup-detail-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.catchup-detail-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.catchup-detail-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.catchup-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.catchup-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.catchup-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.catchup-timeline-item {
    position: relative;
    padding-bottom: 1.25rem;
}

.catchup-timeline-item:last-child {
    padding-bottom: 0;
}

.catchup-timeline-dot {
    position: absolute;
    left: -1.5rem;
    top: 0.125rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--primary);
}

.catchup-timeline-item.npc_moved .catchup-timeline-dot {
    border-color: #3b82f6;
}

.catchup-timeline-item.time_gate_unlocked .catchup-timeline-dot {
    border-color: #10b981;
}

.catchup-timeline-content {
    background: var(--bg);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

.catchup-timeline-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.catchup-timeline-text {
    font-size: 0.8rem;
    color: var(--text);
}

/* ============================================================================
 * §9.7b.5 Time-Gated Content UI
 * ============================================================================ */

/* Time gate display (§9.7b.5.2) */
.time-gate {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-gate:hover {
    background: var(--bg-hover);
    border-color: var(--warning);
}

.time-gate-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--warning);
}

.time-gate-content {
    flex: 1;
    min-width: 0;
}

.time-gate-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.time-gate-availability {
    font-size: 0.75rem;
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.time-gate-countdown {
    font-weight: 600;
}

.time-gate-chevron {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Time gate in transcript */
.message-time-gate {
    margin: 1rem 0;
    padding: 0;
}

/* Time gate unlocked state (§9.7b.5.2) */
.time-gate.unlocked {
    border-color: var(--success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
}

.time-gate.unlocked .time-gate-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.time-gate.unlocked .time-gate-availability {
    color: var(--success);
}

.time-gate.unlocked .time-gate-countdown {
    animation: unlockPulse 0.6s ease-out;
}

@keyframes unlockPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Time gate explanation modal (§9.7b.5.4) */
.time-gate-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.time-gate-modal.visible {
    opacity: 1;
    visibility: visible;
}

.time-gate-modal-content {
    width: 100%;
    max-width: 360px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.time-gate-modal-header {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(234, 88, 12, 0.1));
    padding: 1.25rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.time-gate-modal-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.875rem;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--warning);
}

.time-gate-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.time-gate-modal-body {
    padding: 1.25rem;
}

.time-gate-info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.time-gate-info-row:last-child {
    border-bottom: none;
}

.time-gate-info-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.time-gate-info-text {
    flex: 1;
}

.time-gate-info-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.125rem;
}

.time-gate-info-value {
    font-size: 0.875rem;
    color: var(--text);
    font-weight: 500;
}

.time-gate-alternative {
    margin-top: 1rem;
    padding: 0.875rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.05));
    border-radius: var(--radius-sm);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.time-gate-alternative-label {
    font-size: 0.7rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.375rem;
}

.time-gate-alternative-text {
    font-size: 0.8rem;
    color: var(--text);
    line-height: 1.4;
}

.time-gate-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.time-gate-modal-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: var(--bg);
    color: var(--text);
}

.time-gate-modal-btn:hover {
    background: var(--bg-hover);
}

/* ============================================================================
 * §9.7b.6 Session List Integration
 * ============================================================================ */

/* World time chip on session cards */
.session-card-world-time {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 10px;
    font-size: 0.7rem;
    color: var(--primary);
}

.session-card-world-time-icon {
    font-size: 0.75rem;
}

.session-card-world-time-icon.day {
    color: #fbbf24;
}

.session-card-world-time-icon.night {
    color: #818cf8;
}

/* Offline events pending badge */
.session-card-offline-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    animation: offlineBadgePulse 2s ease-in-out infinite;
}

@keyframes offlineBadgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.session-card-offline-badge i {
    font-size: 0.6rem;
}

/* ============================================================================
 * §9.7b.3 Time Passage System Note - Exceptional UX
 * ============================================================================ */

.time-passage-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 0.625rem 1.25rem;
    margin: 1.25rem auto;
    max-width: 280px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(236, 72, 153, 0.06));
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 24px;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-muted);
    animation: timePassageFade 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes timePassageFade {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.time-passage-note i {
    color: var(--primary);
    font-size: 0.9rem;
    animation: hourglassTurn 2s ease-in-out infinite;
}

@keyframes hourglassTurn {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

/* NPC movement notification (§9.7b.3.2) */
.npc-movement-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.npc-movement-note i {
    color: #3b82f6;
}

/* ============================================================================
 * Responsive / Mobile
 * ============================================================================ */

@media (max-width: 768px) {
    .world-clock-popover {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
    }

    .world-clock-popover.visible {
        transform: translateY(0);
    }

    .catchup-card {
        max-width: 100%;
        border-radius: var(--radius);
    }

    .time-gate-modal-content {
        max-width: 100%;
    }
}

/* ============================================================================
 * Accessibility / Reduced Motion
 * ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .world-clock-pill.pulse {
        animation: none;
    }

    .catchup-icon {
        animation: none;
    }

    .session-card-offline-badge {
        animation: none;
    }

    .time-passage-note {
        animation: none;
    }
}

/* Focus states */
.world-clock-pill:focus-visible,
.time-gate:focus-visible,
.catchup-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================================================
 * Light Theme Overrides
 * ============================================================================ */

body.theme-light .world-clock-popover {
    background: #ffffff;
    border-color: #e5e7eb;
}

body.theme-light .catchup-card {
    background: #ffffff;
}

body.theme-light .catchup-event {
    background: #f9fafb;
}

body.theme-light .time-gate {
    background: #f9fafb;
}

body.theme-light .time-gate:hover {
    background: #f3f4f6;
}

body.theme-light .time-gate-modal-content {
    background: #ffffff;
}
