/* ============================================================
   DaCLobo-AI — Design System & Core Stylesheet
   Project: AI-powered voice assistant for daclobo.net
   Character: MrRamansey (ostrich-egg-bodied man, SVG logo)
   ============================================================ */

/* ------------------------------------------------------------
   1. DESIGN SYSTEM VARIABLES
   Source: RESEARCH.md Section 2
   ------------------------------------------------------------ */
:root {
    /* Primary palette */
    --primary-color: #7A0042;          /* Deep burgundy */
    --secondary-color: #FF6B35;        /* Vivid orange */
    --accent-green: #2ECC71;
    --accent-blue: #3498DB;

    /* Surfaces */
    --background: #000000;             /* Pure black */
    --surface: #111111;                /* Dark card bg */
    --surface-hover: #1a1a1a;
    --surface-elevated: #1c1c1c;

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);

    /* Borders & dividers */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-hover: rgba(255, 255, 255, 0.2);

    /* Typography */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.5s ease-out;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Glow — defined here, used in Phase 2 */
    --glow-purple-sm: 0 0 12px rgba(122, 0, 66, 0.5);
    --glow-purple-lg: 0 0 24px rgba(122, 0, 66, 0.2);
    --glow-orange-sm: 0 0 12px rgba(255, 107, 53, 0.5);
    --glow-orange-lg: 0 0 24px rgba(255, 107, 53, 0.2);

    /* Layout */
    --header-height: 64px;
    --footer-height: 48px;
    --chat-max-width: 800px;
    --sidebar-width: 280px;
}

/* ------------------------------------------------------------
   2. CSS RESET & BASE
   ------------------------------------------------------------ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Selection color */
::selection {
    background: rgba(122, 0, 66, 0.6);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(122, 0, 66, 0.6);
    color: var(--text-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Links */
a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-color);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-md);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* Images */
img, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Form elements base */
input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* ------------------------------------------------------------
   3. NAVIGATION BAR
   ------------------------------------------------------------ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.navbar-brand .brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary-color);
    box-shadow: 0 0 8px var(--secondary-color);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    list-style: none;
}

.navbar-links a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.navbar-links a:hover,
.navbar-links a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs);
}

/* ------------------------------------------------------------
   4. PAGE LAYOUT UTILITIES
   ------------------------------------------------------------ */
.page-container {
    padding-top: var(--header-height);
    min-height: 100vh;
}

.content-section {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-3xl) var(--space-xl);
}

.content-section.sm { max-width: 600px; }
.content-section.lg { max-width: 1100px; }

/* Hero section */
.hero {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.hero .hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: var(--space-xl);
}

/* Card component */
.card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-color-hover);
    background: var(--surface-hover);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
}

/* Glass card (glassmorphism) */
.glass-card {
    background: rgba(17, 17, 17, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

/* ------------------------------------------------------------
   5. BUTTONS
   ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-primary);
}

.btn-primary:hover {
    background: #8e0052;
    box-shadow: 0 0 20px rgba(122, 0, 66, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: #000;
}

.btn-secondary:hover {
    background: #ff7f52;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ------------------------------------------------------------
   6. FORMS
   ------------------------------------------------------------ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(122, 0, 66, 0.2);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

textarea.form-input {
    min-height: 120px;
    resize: vertical;
}

/* ------------------------------------------------------------
   7. MR RAMANSEY GLOW CLASSES
   Source: RESEARCH.md Section 3
   Applied to the container div wrapping MrRamansey.svg
   ------------------------------------------------------------ */
.mr-ramanse-purple {
    filter: drop-shadow(0 0 12px rgba(122, 0, 66, 0.5))
            drop-shadow(0 0 24px rgba(122, 0, 66, 0.2));
    transition: filter 0.15s ease;
}

.mr-ramanse-orange {
    filter: drop-shadow(0 0 12px rgba(255, 107, 53, 0.5))
            drop-shadow(0 0 24px rgba(255, 107, 53, 0.2));
    transition: filter 0.15s ease;
}

.mr-ramanse-idle {
    filter: drop-shadow(0 0 4px rgba(122, 0, 66, 0.12));
    animation: mr-pulse 3s ease-in-out infinite;
    transition: filter 0.5s ease-out;
}

/* ---- MrRamansey Idle Pulse ---- */
@keyframes mr-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(122, 0, 66, 0.12));
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(122, 0, 66, 0.35))
                drop-shadow(0 0 32px rgba(255, 107, 53, 0.1));
    }
}

/* Container for MrRamansey SVG */
#mr-ramanse-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--space-lg) auto;
    width: 200px;
    height: 200px;
    position: relative;
}

#mr-ramanse-container img,
#mr-ramanse-container svg,
#mr-ramanse-container object {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ------------------------------------------------------------
   8. FOOTER
   ------------------------------------------------------------ */
.footer {
    text-align: center;
    padding: var(--space-lg) var(--space-xl);
    color: var(--text-tertiary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

/* ------------------------------------------------------------
   9. RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 768px) {
    .navbar-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        flex-direction: column;
        padding: var(--space-md);
        border-bottom: 1px solid var(--border-color);
    }

    .navbar-links.open {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero .hero-subtitle {
        font-size: 1rem;
    }

    .content-section {
        padding: var(--space-xl) var(--space-md);
    }
}

/* ---- Phase 1.1: Mobile Portrait Typography ---- */
@media (max-width: 480px), (orientation: portrait) {
    h1 { font-size: 1.85rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .hero h1 {
        font-size: 1.85rem;
    }

    .hero .hero-subtitle {
        font-size: 0.95rem;
    }
}

@media (max-width: 360px) {
    body {
        font-size: 14px;
    }

    h1 { font-size: 1.65rem; }
    h2 { font-size: 1.3rem; }
}

/* ---- Phase 1.2: Mobile Nav Refinement ---- */
@media (max-width: 768px) {
    .navbar-links.open {
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        background: rgba(0, 0, 0, 0.98);
        animation: navSlideIn 0.3s ease;
    }

    .navbar-links {
        transform: translateY(-10px);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .navbar-links.open {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes navSlideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ---- Phase 1.3: Hero & MrRamansey Container ---- */
@media (max-width: 480px), (orientation: portrait) {
    .hero {
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        padding: var(--space-xl) var(--space-md);
    }

    #mr-ramanse-container {
        width: 140px;
        height: 140px;
    }
}

/* ---- Phase 1.4: Chat Interface Mobile ---- */
@media (max-width: 480px), (orientation: portrait) {
    .input-area {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .chat-history {
        flex: 1;
        margin-bottom: 100px;
    }

    .quick-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: var(--space-xs);
    }

    .quick-chips::-webkit-scrollbar {
        display: none;
    }
}

/* ---- Phase 1.5: Grid, Cards & Touch Targets ---- */
@media (max-width: 400px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* Minimum touch target for all interactive elements */
.chip, .btn, .nav-toggle, .mic-btn, .send-btn,
.navbar-links a, .form-input, select.form-input {
    min-height: 44px;
    min-width: 44px;
}

/* Tactile button press feedback */
.btn:active {
    transform: scale(0.95);
}

.chip:active {
    transform: scale(0.95);
}


/* ============================================================
   10. CHAT HISTORY (Phase 2.2)
   Glassmorphism chat bubbles, scrollable history.
   ============================================================ */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-width: var(--chat-max-width);
    width: 100%;
    margin: 0 auto;
    scroll-behavior: smooth;
}

/* Message wrapper */
.chat-msg {
    display: flex;
    max-width: 85%;
}

/* AI messages — left-aligned */
.chat-msg.ai-msg {
    align-self: flex-start;
}

/* User messages — right-aligned */
.chat-msg.user-msg {
    align-self: flex-end;
}

/* Glassmorphism bubble */
.msg-bubble {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* AI bubble — semi-transparent surface, glass effect */
.ai-msg .msg-bubble {
    background: rgba(17, 17, 17, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 107, 53, 0.15);
    border-bottom-left-radius: var(--radius-sm);
}

/* User bubble — subtle burgundy tint */
.user-msg .msg-bubble {
    background: rgba(122, 0, 66, 0.2);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(122, 0, 66, 0.3);
    border-bottom-right-radius: var(--radius-sm);
}

/* Sender label */
.msg-sender {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.ai-msg .msg-sender {
    color: var(--secondary-color);
}

.user-msg .msg-sender {
    color: var(--primary-color);
    text-align: right;
}

/* Message text */
.msg-text {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-primary);
}

/* Timestamp */
.msg-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.ai-msg .msg-time {
    text-align: left;
}

.user-msg .msg-time {
    text-align: right;
}

/* Typing indicator (future use) */
.msg-bubble.typing {
    opacity: 0.6;
}

.msg-bubble.typing::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--secondary-color);
    border-radius: 50%;
    margin-left: 4px;
    animation: typing-dot 0.8s infinite;
}

@keyframes typing-dot {
    0%, 60% { opacity: 0.2; }
    100% { opacity: 1; }
}

/* ============================================================
   11. INPUT AREA (Phase 2.4)
   Text input, mic toggle, send button, quick-command chips.
   ============================================================ */
.input-area {
    max-width: var(--chat-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--space-md) var(--space-md);
}

/* Quick-command chips */
.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    justify-content: center;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(17, 17, 17, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.chip:hover {
    background: rgba(122, 0, 66, 0.25);
    border-color: var(--primary-color);
    color: var(--text-primary);
    box-shadow: 0 0 12px rgba(122, 0, 66, 0.15);
}

.chip:active {
    background: rgba(255, 107, 53, 0.2);
    border-color: var(--secondary-color);
    transform: scale(0.97);
}

/* Input row */
.input-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(17, 17, 17, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    transition: border-color var(--transition-fast);
}

.input-row:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(122, 0, 66, 0.15);
}

/* Text input */
.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: var(--space-sm) var(--space-md);
    outline: none;
    min-width: 0;
}

.chat-input::placeholder {
    color: var(--text-tertiary);
}

/* Mic button */
.mic-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.mic-btn:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.2);
}

.mic-btn[aria-pressed="true"] {
    background: rgba(255, 107, 53, 0.2);
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 16px rgba(255, 107, 53, 0.35);
    animation: mic-pulse 1.5s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 107, 53, 0.25); }
    50% { box-shadow: 0 0 20px rgba(255, 107, 53, 0.5); }
}

/* Send button */
.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:hover {
    background: #8e0052;
    box-shadow: 0 0 16px rgba(122, 0, 66, 0.4);
}

.send-btn:active {
    transform: scale(0.93);
}

/* ============================================================
   12. MR RAMANSEY STATUS BAR
   ============================================================ */
#mr-ramanse-status {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    text-align: center;
    margin-bottom: var(--space-md);
    min-height: 20px;
    transition: color var(--transition-fast);
}

#mr-ramanse-status.speaking {
    color: var(--secondary-color);
}

#mr-ramanse-status.listening {
    color: var(--accent-blue);
}