/* ============================================
   Virtual Pet Companion - Luma-Inspired Design
   Warm, elderly-friendly interface
   ============================================ */

/* ===== CSS Variables (Luma Design System) ===== */
:root {
    /* Primary Colors */
    --bg-primary: #FAF9F7;
    --bg-accent: rgba(242, 236, 231, 0.3);
    --bg-secondary: #F2ECE7;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #F6C36A 0%, #FF8A65 100%);

    /* Text Colors */
    --text-primary: #5C5550;
    --text-secondary: #7E8A90;
    --text-white: #FFFFFF;

    /* Accent Colors */
    --accent-gold: #F6C36A;
    --accent-coral: #FF8A65;

    /* State Colors */
    --color-listening: #80CBC4;
    --color-thinking: #FFD54F;
    --color-speaking: #FF8A65;
    --color-idle: #F6C36A;

    /* Borders */
    --border-light: rgba(246, 195, 106, 0.1);
    --border-subtle: rgba(126, 138, 144, 0.1);

    /* Shadows */
    --shadow-subtle: 0 4px 20px rgba(92, 85, 80, 0.06);
    --shadow-medium: 0 8px 32px rgba(246, 195, 106, 0.15);
    --shadow-strong: 0 12px 48px rgba(246, 195, 106, 0.35);
    --shadow-accent: 0 4px 16px rgba(246, 195, 106, 0.25);

    /* Typography Scale */
    --font-base: 18px;
    --font-small: 0.85rem;
    --font-body: 1.1rem;
    --font-h3: 1.2rem;
    --font-h2: 1.8rem;
    --font-h1: 2.5rem;
    --font-hero: 5rem;
    --font-hero-mobile: 3.5rem;
    --font-h1-mobile: 2rem;

    /* Line Heights */
    --line-height-base: 1.6;
    --line-height-relaxed: 1.7;
    --line-height-loose: 1.8;

    /* Letter Spacing */
    --letter-spacing-tight: -0.02em;
    --letter-spacing-normal: 0.01em;

    /* Border Radius */
    --radius-small: 12px;
    --radius-medium: 16px;
    --radius-large: 20px;
    --radius-circle: 50%;

    /* Spacing */
    --gap-small: 16px;
    --gap-medium: 32px;
    --gap-large: 48px;
    --gap-xlarge: 80px;

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slower: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Warm Accent Palette (Legacy - keeping for avatar colors) */
    --warm-yellow: #FFD54F;
    --warm-beige: #F5E6D3;
    --warm-peach: #FFAB91;
    --warm-aqua: #80CBC4;
}

/* ===== Reset and Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
}

/* ===== Top Navigation Bar ===== */
.top-nav {
    width: 100%;
    background: var(--warm-beige);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 20px rgba(92, 85, 80, 0.08);
    padding: 12px 30px;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition-smooth);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-medium);
    transition: var(--transition-smooth);
    color: var(--text-secondary);
}

.nav-item:hover {
    background: rgba(246, 195, 106, 0.15);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.nav-item:active {
    transform: translateY(0);
}

.nav-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    transition: var(--transition-smooth);
}

.nav-item:hover .nav-icon {
    transform: scale(1.1);
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    transition: var(--transition-smooth);
}

/* ===== Main Container ===== */
.container {
    max-width: 550px;
    width: 100%;
    background: white;
    border-radius: var(--radius-large);
    border: 1px solid var(--border-light);
    padding: 30px;
    margin: 20px;
    box-shadow: var(--shadow-subtle);
    transition: var(--transition-slower);
}

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

h1 {
    font-size: var(--font-h1-mobile);
    color: var(--text-primary);
    font-weight: 200;
    font-family: 'Nunito', sans-serif;
    letter-spacing: var(--letter-spacing-tight);
    line-height: var(--line-height-base);
}

/* Language Selector */
.language-selector {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--warm-beige);
    border: 2px solid var(--accent-coral);
    border-radius: var(--radius-large);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.language-btn:hover {
    background: var(--accent-coral);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

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

.language-btn .flag {
    font-size: 20px;
    line-height: 1;
}

.language-btn .lang-text {
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* ===== Pet Container ===== */
.pet-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

/* ===== Pet Avatar Container (White Circle) ===== */
.avatar-wrapper {
    width: 220px;
    height: 220px;
    background: white;
    border-radius: var(--radius-circle);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-subtle);
    margin-bottom: 20px;
    transition: var(--transition-slower);
}

/* Pet Avatar - SVG Based */
.pet-avatar {
    width: 190px;
    height: 190px;
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        transform: scale(1) translateY(0px);
    }
    50% {
        transform: scale(1.02) translateY(-8px);
    }
}

/* ===== SVG Element Animations (Slower) ===== */

/* Ears wiggle - slower and gentler */
#leftEar {
    transform-origin: 60px 50px;
    animation: wiggle-left 3.5s ease-in-out infinite;
}

#rightEar {
    transform-origin: 140px 50px;
    animation: wiggle-right 3.5s ease-in-out infinite;
}

@keyframes wiggle-left {
    0%, 100% {
        transform: rotate(-15deg);
    }
    50% {
        transform: rotate(-22deg);
    }
}

@keyframes wiggle-right {
    0%, 100% {
        transform: rotate(15deg);
    }
    50% {
        transform: rotate(22deg);
    }
}

/* Eyes blink - slower */
.eye {
    animation: blink 5s infinite;
}

@keyframes blink {
    0%, 48%, 54%, 100% {
        opacity: 1;
    }
    50%, 52% {
        opacity: 0;
    }
}

/* Mouth talking animation - only when speaking */
.pet-avatar.speaking #mouthClosed,
.pet-avatar.speaking #mouth path:not([id]) {
    animation: talk 0.6s ease-in-out infinite;
}

@keyframes talk {
    0%, 100% { opacity: 1; }
    25% { opacity: 0.4; }
    50% { opacity: 0.7; }
    75% { opacity: 0.3; }
}

/* ===== Status Indicator ===== */
.status-indicator {
    margin-top: 20px;
    padding: 12px 24px;
    background: var(--warm-beige);
    border-radius: var(--radius-large);
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-slower);
}

.status-text {
    font-size: var(--font-base);
    color: var(--text-secondary);
    font-weight: 500;
    line-height: var(--line-height-base);
    transition: var(--transition-slower);
}

/* Listening State */
.status-indicator.listening {
    background: var(--color-listening);
    animation: pulse-gentle 1.5s ease-in-out infinite;
}

.status-indicator.listening .status-text {
    color: white;
}

@keyframes pulse-gentle {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
}

/* Speaking State */
.status-indicator.speaking {
    background: var(--color-speaking);
}

.status-indicator.speaking .status-text {
    color: white;
}

/* Thinking State (NEW) */
.status-indicator.thinking {
    background: var(--color-thinking);
}

.status-indicator.thinking .status-text {
    color: var(--text-primary);
}

/* ===== Controls ===== */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

/* Button Base Styles */
.btn-large {
    font-family: 'Nunito', sans-serif;
    font-size: var(--font-base);
    font-weight: 600;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-medium);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-slower);
    min-width: 200px;
}

/* Primary Button (Talk to Me) */
.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-white);
    box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-strong);
}

.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

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

/* Secondary Button (Switch Pet) */
.btn-secondary {
    background: linear-gradient(135deg, var(--warm-aqua) 0%, #4DB6AC 100%);
    color: var(--text-white);
    box-shadow: var(--shadow-accent);
}

.btn-secondary:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-strong);
}

.btn-secondary:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Active/Speaking State */
.btn-primary.active {
    background: var(--gradient-primary);
    animation: pulse-button 1.5s ease-in-out infinite;
}

@keyframes pulse-button {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Icons */
.mic-icon, .switch-icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.5px;
}

.btn-text {
    font-weight: 600;
}

/* ===== Prompt Suggestions ===== */
.prompt-suggestions {
    text-align: center;
    margin-top: 24px;
    padding: 0 20px;
    opacity: 1;
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    transform: translateY(0);
}

.prompt-suggestions.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.suggestions-label {
    font-size: var(--font-small);
    color: var(--text-secondary);
    opacity: 0.6;
    margin-bottom: 12px;
    font-weight: 500;
}

.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.suggestion-chip {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(242, 236, 231, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    opacity: 0.7;
    transition: var(--transition-smooth);
    cursor: default;
    user-select: none;
}

.suggestion-chip:hover {
    opacity: 0.9;
    background: rgba(242, 236, 231, 0.6);
    transform: translateY(-1px);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 20px;
}

.help-text {
    font-size: var(--font-small);
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ===== Avatar Navigation Indicators ===== */
.avatar-indicators {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding: 0;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-circle);
    background: var(--warm-beige);
    border: 2px solid var(--accent-gold);
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 0;
}

.indicator-dot:hover {
    transform: scale(1.2);
    background: var(--accent-coral);
}

.indicator-dot.active {
    background: var(--accent-gold);
    width: 14px;
    height: 14px;
    border-width: 2.5px;
}

/* Swipe Hint Text */
.swipe-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    margin: 10px 0 0 0;
    font-style: italic;
}

/* Avatar Slide Transition */
.avatar-wrapper {
    transition: none; /* Remove default transition for slide animations */
}

.avatar-wrapper.slide-left {
    animation: slideOutLeft 0.4s ease forwards;
}

.avatar-wrapper.slide-right {
    animation: slideOutRight 0.4s ease forwards;
}

.avatar-wrapper.slide-in-left {
    animation: slideInLeft 0.4s ease forwards;
}

.avatar-wrapper.slide-in-right {
    animation: slideInRight 0.4s ease forwards;
}

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

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100px);
        opacity: 0;
    }
}

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

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

/* ===== Active/Interactive States for Avatar ===== */

/* Listening State */
.pet-avatar.listening {
    animation: listen-tilt 3s ease-in-out infinite;
}

@keyframes listen-tilt {
    0%, 100% {
        transform: scale(1.02) rotate(0deg);
    }
    50% {
        transform: scale(1.02) rotate(-3deg);
    }
}

.pet-avatar.listening #leftEar {
    animation: perk-left 1.2s ease-in-out infinite;
}

.pet-avatar.listening #rightEar {
    animation: perk-right 1.2s ease-in-out infinite;
}

@keyframes perk-left {
    0%, 100% {
        transform: rotate(-18deg);
    }
    50% {
        transform: rotate(-8deg);
    }
}

@keyframes perk-right {
    0%, 100% {
        transform: rotate(18deg);
    }
    50% {
        transform: rotate(8deg);
    }
}

/* Listening - Avatar wrapper glow */
.avatar-wrapper.listening {
    box-shadow: 0 8px 40px rgba(128, 203, 196, 0.3);
}

/* Speaking State */
.pet-avatar.speaking {
    animation: speak-bounce 2s ease-in-out infinite;
}

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

/* Speaking - Avatar wrapper glow */
.avatar-wrapper.speaking {
    box-shadow: 0 8px 40px rgba(255, 138, 101, 0.3);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    /* Top Nav - Tablet */
    .top-nav {
        padding: 15px 30px;
    }

    .nav-container {
        gap: 35px;
    }

    .nav-item {
        padding: 10px 15px;
    }

    .nav-icon {
        width: 26px;
        height: 26px;
    }

    .nav-label {
        font-size: 13px;
    }

    .container {
        padding: 35px;
        margin: 30px 15px;
    }

    h1 {
        font-size: var(--font-hero-mobile);
    }

    .avatar-wrapper {
        width: 240px;
        height: 240px;
    }

    .pet-avatar {
        width: 210px;
        height: 210px;
    }

    .status-text {
        font-size: 20px;
    }

    .message {
        font-size: 18px;
    }

    .btn-large {
        font-size: 20px;
        padding: 18px 40px;
        min-width: 240px;
    }
}

@media (max-width: 480px) {
    /* Top Nav - Mobile */
    .top-nav {
        padding: 12px 15px;
    }

    .nav-container {
        gap: 15px;
        justify-content: space-between;
    }

    .nav-item {
        padding: 8px 10px;
        gap: 6px;
    }

    .nav-icon {
        width: 24px;
        height: 24px;
    }

    .nav-label {
        font-size: 11px;
    }

    .container {
        padding: 25px;
        margin: 20px 10px;
    }

    h1 {
        font-size: var(--font-h1-mobile);
    }

    .avatar-wrapper {
        width: 200px;
        height: 200px;
    }

    .pet-avatar {
        width: 180px;
        height: 180px;
    }

    .status-text {
        font-size: 18px;
    }

    .btn-large {
        font-size: 18px;
        padding: 16px 32px;
        min-width: 200px;
    }

    .help-text {
        font-size: 16px;
    }
}

/* ===== Accessibility: 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;
    }
}
