/* ================================
   SignBridge — Global Styles
   ================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #06060f;
    --bg-secondary: #0c0c1d;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-hover: rgba(255, 255, 255, 0.065);
    --surface-active: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-glow: rgba(124, 58, 237, 0.25);
    --accent: #06b6d4;
    --accent-light: #22d3ee;
    --accent-glow: rgba(6, 182, 212, 0.25);

    --text-primary: #eaeaf2;
    --text-secondary: rgba(234, 234, 242, 0.5);
    --text-muted: rgba(234, 234, 242, 0.25);

    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.25);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.25);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s ease;
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ================================
   Ambient Background
   ================================ */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25;
    animation: float 25s infinite ease-in-out;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -15%;
    left: -8%;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    bottom: -15%;
    right: -8%;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(20px, -30px) scale(1.03); }
    66% { transform: translate(-15px, 15px) scale(0.97); }
}

/* ================================
   Header
   ================================ */
header {
    text-align: center;
    padding: 2.5rem 1.5rem 0.75rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.logo-mark {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-mark svg {
    width: 100%;
    height: 100%;
}

.logo h1 {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.logo h1 .highlight {
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* ================================
   Mode Selector
   ================================ */
.mode-selector-wrapper {
    display: flex;
    justify-content: center;
    padding: 1.25rem 1rem 1.75rem;
}

.mode-selector {
    display: flex;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 4px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.mode-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    border-radius: calc(var(--radius-xl) - 3px);
    transition: transform var(--transition-spring);
    box-shadow: 0 2px 16px var(--primary-glow);
    z-index: 0;
}

.mode-selector.sign-active .mode-slider {
    transform: translateX(100%);
}

.mode-btn {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: calc(var(--radius-xl) - 3px);
    transition: color var(--transition);
    white-space: nowrap;
}

.mode-btn.active { color: #fff; }

.mode-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.mode-arrow {
    display: flex;
    align-items: center;
    opacity: 0.5;
}
.mode-arrow svg {
    width: 14px;
    height: 14px;
}

.mode-label { margin-left: 0.15rem; }

/* ================================
   Panels
   ================================ */
.panel {
    display: none;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
    animation: fadeSlideUp 0.45s ease;
}

.panel.active { display: block; }

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

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* ================================
   Cards
   ================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    transition: border-color var(--transition);
}

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

.card-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.card-icon-wrap {
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.12);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.card-icon-wrap.accent {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-light);
}
.card-icon-wrap svg {
    width: 100%;
    height: 100%;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card-body { min-height: 300px; }
.card-body.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ================================
   Microphone Button
   ================================ */
.mic-btn {
    position: relative;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
    margin: 1.25rem 0 0.75rem;
}

.mic-btn svg { width: 32px; height: 32px; }

.mic-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 32px var(--primary-glow);
}

.mic-btn:active { transform: scale(0.96); }

.mic-btn.listening {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    box-shadow: 0 0 50px var(--danger-glow);
    animation: micPulse 1.5s infinite ease-in-out;
}

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

.pulse-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--primary-light);
    opacity: 0;
    pointer-events: none;
}

.mic-btn.listening .pulse-ring {
    animation: pulseRing 1.8s infinite ease-out;
}
.mic-btn.listening .pulse-ring.delay {
    animation-delay: 0.5s;
}

@keyframes pulseRing {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.7); opacity: 0; }
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 1rem;
    transition: color var(--transition);
}
.status-text.active { color: var(--success); }
.status-text.error { color: var(--danger); }

/* ================================
   Transcript
   ================================ */
.transcript {
    width: 100%;
    min-height: 72px;
    padding: 0.85rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
}

.transcript .interim {
    color: var(--text-secondary);
    font-style: italic;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.88rem;
}

/* ================================
   Sign Output (Voice -> Sign)
   ================================ */
.sign-output {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    align-items: flex-start;
    min-height: 180px;
}

.sign-card {
    width: 68px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.65rem 0.4rem;
    background: linear-gradient(150deg, rgba(124, 58, 237, 0.1), rgba(6, 182, 212, 0.05));
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: var(--radius-md);
    animation: signAppear 0.35s ease backwards;
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: default;
}

.sign-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
}

.sign-card .sign-letter {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.sign-card .sign-desc {
    font-size: 1.6rem;
    text-align: center;
    line-height: 1;
}

.sign-space {
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.6rem;
}

@keyframes signAppear {
    from { opacity: 0; transform: translateY(10px) scale(0.85); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ================================
   Webcam
   ================================ */
.webcam-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border);
    margin: 0.75rem 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.webcam-container.active {
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
}

.webcam-container video,
.webcam-container canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.webcam-container canvas { z-index: 1; }

.webcam-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 6, 15, 0.85);
    backdrop-filter: blur(8px);
    transition: opacity var(--transition);
}
.webcam-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.start-camera-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 2rem;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.start-camera-btn svg {
    width: 36px;
    height: 36px;
    stroke: var(--accent);
}
.start-camera-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(6, 182, 212, 0.04);
}

.detected-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 3;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    font-size: 1.6rem;
    font-weight: 900;
    color: white;
    opacity: 0;
    transform: scale(0.7);
    transition: all var(--transition-spring);
}
.detected-badge.visible {
    opacity: 1;
    transform: scale(1);
}

.confidence-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 3;
}
.confidence-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--primary-light));
    transition: width 0.2s ease;
    border-radius: 0 2px 0 0;
}

/* ================================
   Text Output (Sign -> Voice)
   ================================ */
.text-output {
    min-height: 90px;
    padding: 1.1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 1.1rem;
    position: relative;
}

.recognized-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    word-break: break-all;
}

.text-cursor {
    display: inline-block;
    width: 2px;
    height: 1.5rem;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: middle;
    animation: blink 1s step-end infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.sign-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ctrl-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.ctrl-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.ctrl-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}
.ctrl-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.ctrl-btn.primary {
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    border-color: transparent;
    color: white;
}
.ctrl-btn.primary:hover {
    box-shadow: 0 4px 16px var(--primary-glow);
    transform: translateY(-1px);
}

/* ================================
   Reference Grid
   ================================ */
.reference-section {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 1.5rem 1.5rem 2.5rem;
}

.section-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    color: var(--text-primary);
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.6rem;
}

.ref-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.65rem 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    cursor: default;
}
.ref-card:hover {
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px var(--primary-glow);
}
.ref-card .ref-letter {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}
.ref-card .ref-desc {
    font-size: 1.6rem;
    text-align: center;
    line-height: 1;
}

/* ================================
   Footer
   ================================ */
footer {
    text-align: center;
    padding: 1.75rem 1rem 2.5rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}
footer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.footer-note {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
    margin-top: 0.3rem;
}

/* ================================
   Responsive
   ================================ */
@media (max-width: 768px) {
    .logo h1 { font-size: 1.8rem; }
    .panel-grid { grid-template-columns: 1fr; }
    .mode-btn { padding: 0.65rem 0.9rem; font-size: 0.8rem; }
    .mode-label { display: none; }
    .card { padding: 1.15rem; }
    .card-body { min-height: 220px; }
    .reference-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
}

@media (max-width: 480px) {
    header { padding: 1.75rem 1rem 0.5rem; }
    .logo h1 { font-size: 1.5rem; }
    .mic-btn { width: 72px; height: 72px; }
    .mic-btn svg { width: 26px; height: 26px; }
}

/* ================================
   Scrollbar
   ================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

/* ================================
   Utility
   ================================ */
.shake { animation: shake 0.4s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
