/* ============================================
   CLARITY EMERGENCE - "Thrives in the Gray"
   Focus effect: blur + desaturation → sharp clarity
   ============================================ */

html {
    background-color: #FFFFFF;
    overflow-x: hidden;
    /* Prevent horizontal scroll on iOS when keyboard appears */
    position: relative;
    width: 100%;
}

.dark html {
    background-color: #000000;
}

/* ============================================
   FOCUS EMERGENCE
   Page starts soft/gray, comes into sharp clarity
   ============================================ */

body {
    background-color: #FFFFFF;
    overflow-x: hidden;
    /* Prevent horizontal scroll on iOS */
    position: relative;
    width: 100%;
    min-height: 100%;
}

.dark body {
    background-color: #000000;
}

/* ============================================
   HEADLINE WORD-BY-WORD EMERGENCE
   ============================================ */

.headline-word {
    display: inline;
    color: #9CA3AF; /* Start as muted gray - visible but unclear */
    transition: color 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.headline-word.emerged {
    color: #000000;
}

.dark .headline-word {
    color: #6B7280;
}

.dark .headline-word.emerged {
    color: #FFFFFF;
}

/* Special treatment for "the gray" - stays gray with shimmer */
.headline-word.the-gray {
    position: relative;
}

.headline-word.the-gray.emerged {
    color: #6B7280 !important; /* Stays gray */
    background: linear-gradient(
        90deg,
        #6B7280 0%,
        #9CA3AF 25%,
        #6B7280 50%,
        #4B5563 75%,
        #6B7280 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 8s ease-in-out infinite;
}

.dark .headline-word.the-gray.emerged {
    background: linear-gradient(
        90deg,
        #9CA3AF 0%,
        #D1D5DB 25%,
        #9CA3AF 50%,
        #6B7280 75%,
        #9CA3AF 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ============================================
   STAGGERED CONTENT EMERGENCE
   ============================================ */

/* Start visible by default - JS will add .animated class to enable transitions */
.emerge {
    opacity: 1;
    transform: translateY(0);
}

/* Only animate when JS has loaded and added the setup class */
.js-ready .emerge {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.js-ready .emerge.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Delay classes for staggered animation */
.emerge-delay-1 { transition-delay: 0.1s; }
.emerge-delay-2 { transition-delay: 0.3s; }
.emerge-delay-3 { transition-delay: 0.5s; }
.emerge-delay-4 { transition-delay: 0.7s; }
.emerge-delay-5 { transition-delay: 0.9s; }
.emerge-delay-6 { transition-delay: 1.1s; }

/* ============================================
   STATUS INDICATOR
   ============================================ */

/* Visible by default, animated only when JS ready */
.status-indicator {
    opacity: 1;
    transform: translateX(0);
}

.js-ready .status-indicator {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.js-ready .status-indicator.visible {
    opacity: 1;
    transform: translateX(0);
}

.status-dot {
    animation: pulse-gray 2s ease-in-out infinite;
}

@keyframes pulse-gray {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(107, 114, 128, 0.4);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 8px rgba(107, 114, 128, 0);
    }
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Name sparkle - subtle periodic color shift */
.name-sparkle {
    background: linear-gradient(
        90deg,
        #6B7280 0%,
        #6B7280 40%,
        #000000 50%,
        #01AAFF 60%,
        #0071D6 70%,
        #000000 80%,
        #6B7280 100%
    );
    background-size: 400% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: nameSparkle 8s ease-in-out infinite;
    animation-delay: 2s; /* Wait for clarity effect to complete */
}

@keyframes nameSparkle {
    0% { background-position: 0% 50%; }
    /* First sparkle ~1s after animation starts (12.5% of 8s) */
    10%, 18% { background-position: 100% 50%; }
    28%, 85% { background-position: 0% 50%; }
    /* Second sparkle near end of cycle */
    90%, 95% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.dark .name-sparkle {
    background: linear-gradient(
        90deg,
        #9CA3AF 0%,
        #9CA3AF 40%,
        #FFFFFF 50%,
        #01AAFF 60%,
        #0071D6 70%,
        #FFFFFF 80%,
        #9CA3AF 100%
    );
    background-size: 400% 100%;
    -webkit-background-clip: text;
    background-clip: text;
}

/* Tag hover effects */
.tag {
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    cursor: default;
}

.tag:hover {
    background-color: #E5E7EB;
    color: #374151;
    transform: translateY(-1px);
}

.dark .tag:hover {
    background-color: #1F2937;
    color: #D1D5DB;
}

/* Social link brand colors */
.social-linkedin {
    transition: color 0.2s ease;
}

.social-linkedin:hover {
    color: #0A66C2 !important;
}

.social-linkedin:hover svg {
    stroke: #0A66C2;
}

/* LinkedIn bordered button variant */
.social-linkedin-btn:hover {
    color: #0A66C2;
    border-color: #0A66C2;
}

.social-linkedin-btn:hover svg {
    stroke: #0A66C2;
}

.social-x {
    transition: color 0.2s ease;
}

.social-x:hover {
    color: #000000 !important;
}

.social-x:hover svg {
    fill: #000000;
    stroke: none;
}

.dark .social-x:hover {
    color: #FFFFFF !important;
}

.dark .social-x:hover svg {
    fill: #FFFFFF;
}

.social-github {
    transition: color 0.2s ease;
}

.social-github:hover {
    color: #8250DF !important;
}

.social-github:hover svg {
    stroke: #8250DF;
}

/* ============================================
   GENERAL STYLES
   ============================================ */

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #9CA3AF;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #6B7280;
}
.dark ::-webkit-scrollbar-thumb {
    background: #4B5563;
}

/* Selection */
::selection {
    background-color: #6B7280;
    color: white;
}

/* Theme toggle icons */
.dark .icon-moon { display: none; }
.dark .icon-sun { display: block; }
.icon-sun { display: none; }

/* Hover line animation */
.hover-line {
    position: relative;
}
.hover-line::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: #6B7280;
    transition: width 0.3s ease;
}
.hover-line:hover::after {
    width: 100%;
}

/* Inline body links */
.body-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: #9CA3AF;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

.body-link:hover {
    color: #000000;
    text-decoration-color: #2563EB;
}

.dark .body-link:hover {
    color: #FFFFFF;
    text-decoration-color: #2563EB;
}

/* Button hover states - gray accent */
.btn-primary {
    background-color: #000000;
    transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn-primary:hover {
    background-color: #374151;
    transform: translateY(-1px);
}
.dark .btn-primary {
    background-color: #FFFFFF;
    color: #000000;
}
.dark .btn-primary:hover {
    background-color: #D1D5DB;
}

/* Sections - no animation, always visible */
.section-emerge {
    opacity: 1;
    transform: none;
}

/* ============================================
   CHAT INTERFACE
   ============================================ */

.chat-container {
    max-width: 600px;
    width: 100%;
    overflow-x: hidden;
}

.chat-messages {
    margin-bottom: 16px;
    padding: 4px 0;
}

.chat-message {
    margin-bottom: 16px;
    animation: chatFadeIn 0.3s ease-out;
}

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

.chat-message.assistant {
    padding-right: 48px;
}

.chat-message.assistant .chat-bubble {
    max-width: calc(100% - 48px);
}

.chat-message.user {
    padding-left: 48px;
    text-align: right;
}

.chat-message.user .chat-bubble {
    max-width: calc(100% - 48px);
}

.chat-bubble {
    display: inline-block;
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 100%;
    text-align: left;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-message.assistant .chat-bubble {
    background-color: #F3F4F6;
    color: #1F2937;
    border-bottom-left-radius: 4px;
}

.dark .chat-message.assistant .chat-bubble {
    background-color: #1F2937;
    color: #E5E7EB;
}

.chat-message.user .chat-bubble {
    background-color: #0071D6;
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}

.dark .chat-message.user .chat-bubble {
    background-color: #0071D6;
    color: #FFFFFF;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background-color: #F3F4F6;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.dark .chat-typing {
    background-color: #1F2937;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #9CA3AF;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chat-typing-dot:nth-child(1) { animation-delay: 0s; }
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input form */
.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    font-size: 16px; /* Must be 16px+ to prevent iOS auto-zoom on focus */
    font-family: inherit;
    background: transparent;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #6B7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.dark .chat-input {
    border-color: #374151;
}

.dark .chat-input:focus {
    border-color: #9CA3AF;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.1);
}

.chat-input::placeholder {
    color: #9CA3AF;
}

.chat-new {
    padding: 12px;
    background-color: transparent;
    color: #9CA3AF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /* iOS touch fixes */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.chat-new:hover {
    background-color: #F3F4F6;
    border-color: #9CA3AF;
    color: #6B7280;
}

.chat-new:active {
    transform: scale(0.95);
}

.dark .chat-new {
    border-color: #374151;
}

.dark .chat-new:hover {
    background-color: #1F2937;
    border-color: #6B7280;
    color: #D1D5DB;
}

.chat-submit {
    padding: 12px;
    background-color: #000000;
    color: #FFFFFF;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-submit:hover {
    background-color: #374151;
}

.chat-submit:active {
    transform: scale(0.95);
}

.chat-submit:disabled {
    background-color: #9CA3AF;
    cursor: not-allowed;
}

.dark .chat-submit {
    background-color: #FFFFFF;
    color: #000000;
}

.dark .chat-submit:hover {
    background-color: #E5E7EB;
}

.chat-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
    color: #9CA3AF;
    font-family: 'JetBrains Mono', monospace;
}

.chat-footer-icon {
    display: flex;
    align-items: center;
}

/* Conversation complete state */
.chat-complete {
    padding: 16px;
    background-color: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: 12px;
    margin-top: 16px;
}

.dark .chat-complete {
    background-color: #052E16;
    border-color: #166534;
}

.chat-complete-text {
    font-size: 14px;
    color: #166534;
}

.dark .chat-complete-text {
    color: #86EFAC;
}
