@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

/* --- BASE & LAYOUT --- */
body, html {
    height: 100%; 
    height: 100dvh; 
    margin: 0;
    overflow: hidden;
    touch-action: none; 
    font-family: 'Inter', sans-serif;
    background-color: #0f172a;
}

.app-container {
    height: 100dvh;
    overflow: hidden;
}

.split-zone {
    height: 50vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.rotated-180 {
    transform: rotate(180deg);
}

.top-zone {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
}

.bottom-zone {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    color: #0f172a;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    z-index: 2;
    position: relative;
    border-top: none;
}

/* --- DUAL-LAYER PARALLAX WAVE --- */
/* * Complex dual-layer wave animation using pseudo-elements.
 * Hardware acceleration is forced via translate3d for 60fps rendering on mobile.
 */
.bottom-zone::before,
.bottom-zone::after {
    content: "";
    position: absolute;
    left: 0;
    width: 200%;
    background-repeat: repeat-x;
    transform-origin: bottom;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    transform: translate3d(0, 0, 0) scaleY(0.3); /* Flattened state when idle */
    opacity: 0.5;
    pointer-events: none;
}

/* Background wave (semi-transparent, taller) */
.bottom-zone::before {
    top: -40px;
    height: 45px;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1200 120" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><path d="M0,60 C300,120 300,0 600,60 C900,120 900,0 1200,60 L1200,120 L0,120 Z" fill="%23ffffff" opacity="0.5"></path></svg>');
    background-size: 50% 100%;
    z-index: 10;
}

/* Foreground wave (opaque, shorter) */
.bottom-zone::after {
    top: -25px;
    height: 30px;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1200 120" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><path d="M0,60 C300,0 300,120 600,60 C900,0 900,120 1200,60 L1200,120 L0,120 Z" fill="%23ffffff"></path></svg>');
    background-size: 50% 100%;
    z-index: 11;
}

/* Active recording state triggers the amplitude increase and parallax sliding */
.wave-animated .bottom-zone::before {
    opacity: 1;
    animation: wave-slide-bg 2s linear infinite;
}

.wave-animated .bottom-zone::after {
    opacity: 1;
    animation: wave-slide-fg 1.2s linear infinite;
}

@keyframes wave-slide-bg {
    0% { transform: translate3d(0, 0, 0) scaleY(1.2); }
    100% { transform: translate3d(-50%, 0, 0) scaleY(1.2); }
}

@keyframes wave-slide-fg {
    0% { transform: translate3d(0, 0, 0) scaleY(1.4); }
    100% { transform: translate3d(-50%, 0, 0) scaleY(1.4); }
}

/* --- TYPOGRAPHY & SCROLLING --- */
.text-scroll-container {
    overflow-y: auto;
    max-height: calc(50vh - 180px); 
    margin-top: 60px;
    margin-bottom: 20px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    /* Forces scroll to start at the top */
    justify-content: flex-start;
}

.text-scroll-container::-webkit-scrollbar {
    display: none;
}

/* * Safe Centering Hack:
 * Using pseudo-elements with auto margins inside a flex column 
 * centers the content when it's small, but allows proper top-to-bottom 
 * scrolling without clipping the top when it overflows.
 */
.text-scroll-container::before,
.text-scroll-container::after {
    content: '';
    margin: auto;
}

.main-text {
    /* Reduced from 2.2rem to handle long sentences properly */
    font-size: 1.6rem; 
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
    word-wrap: break-word;
    word-break: break-word;
}

.sub-text {
    /* Slightly reduced and opacity adjusted for better hierarchy */
    font-size: 0.95rem; 
    font-weight: 400;
    opacity: 0.6;
    word-wrap: break-word;
    word-break: break-word;
}

/* --- HEADERS & BADGES --- */
.header-bar {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
}

.lang-badge {
    font-size: 0.9rem;
    padding: 0.6em 1.2em;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.bottom-zone .lang-badge {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.lang-badge:active {
    opacity: 0.7;
}

.status-badge {
    font-size: 0.85rem;
    padding: 0.6em 1.2em;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-badge.translating {
    background-color: #f59e0b;
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.status-badge.ready {
    background-color: #10b981;
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.dots {
    animation: pulse 1.5s infinite;
}

/* --- PUSH-TO-TALK BUTTONS --- */
.ptt-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    border: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    z-index: 20;
}

.top-btn {
    background: #3b82f6;
    color: white;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4), inset 0 -4px 0 rgba(0,0,0,0.15);
}

.bottom-btn {
    background: #2563eb;
    color: white;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3), inset 0 -4px 0 rgba(0,0,0,0.2);
}

.ptt-btn:active {
    transform: scale(0.92) translateY(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2), inset 0 2px 6px rgba(0,0,0,0.2);
}

/* --- LANGUAGE SELECTION OVERLAYS --- */
.lang-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 50;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

.lang-overlay.active {
    transform: translateY(0);
    visibility: visible;
}

.top-zone .lang-overlay {
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(10px);
}

.bottom-zone .lang-overlay {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
}

.lang-item {
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-zone .lang-item {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.bottom-zone .lang-item {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.lang-item:active {
    background-color: rgba(128, 128, 128, 0.2);
}

/* --- LANDSCAPE BLOCKER --- */
#landscape-warning {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #0f172a;
    color: white;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

@media (orientation: landscape) and (max-height: 600px) {
    #landscape-warning {
        display: flex;
    }
    .app-container {
        display: none !important;
    }
}