/**
 * TalkStock Login Page - Bold Brand Design (Iteration 10 Final)
 * ==============================================================
 * Deep dark hero with high-contrast brand content + amber glow orbs
 * Inspired by DigitalOcean's unified brand approach
 */

/* ==================== Reset & Base ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--brand-font-family, 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    line-height: 1.6;
}

/* ==================== Container ==================== */
.login-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    animation: loginFadeIn 0.5s ease-out;
}

@keyframes loginFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== Hero Section ==================== */
.login-hero {
    width: 100%;
    height: 32vh;
    min-height: 200px;
    max-height: 300px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #1C1410 0%, #2A180C 30%, #1A0F08 65%, #0C0806 100%);
}

.hero-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Warm ambient gradient overlay */
.hero-content::before {
    content: '';
    position: absolute;
    top: -60%;
    left: -40%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 25% 40%, var(--color-accent-subtle) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 60%, var(--color-accent-muted) 0%, transparent 45%);
    animation: heroGlow 10s ease-in-out infinite alternate;
}

/* Bottom accent line — warm gradient */
.hero-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent 5%, var(--color-accent) 25%, var(--color-accent-hover) 50%, var(--color-accent) 75%, transparent 95%);
    opacity: 0.85;
}

@keyframes heroGlow {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(6%, -2%) scale(1.08);
        opacity: 1;
    }
}

/* Ambient orbs — warm amber/orange glow */
.hero-orbs {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
}

.hero-orb-1 {
    width: 350px;
    height: 350px;
    top: -120px;
    right: -100px;
    background: radial-gradient(circle, var(--color-accent-subtle) 0%, var(--color-accent-muted) 50%, transparent 70%);
    animation: orbFloat1 14s ease-in-out infinite;
}

.hero-orb-2 {
    width: 280px;
    height: 280px;
    bottom: -80px;
    left: 3%;
    background: radial-gradient(circle, var(--color-accent-subtle) 0%, var(--color-accent-muted) 50%, transparent 70%);
    animation: orbFloat2 18s ease-in-out infinite;
}

.hero-orb-3 {
    width: 180px;
    height: 180px;
    top: 15%;
    left: 40%;
    background: radial-gradient(circle, var(--color-accent-subtle) 0%, transparent 65%);
    animation: orbFloat3 12s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, 25px) scale(1.1); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(25px, -30px) scale(1.12); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
    50% { transform: translate(-18px, 15px) scale(1.18); opacity: 0.6; }
}

/* ==================== Hero Brand Content ==================== */
.hero-brand {
    position: relative;
    z-index: 2;
    display: none; /* Hidden on mobile, shown on desktop */
    flex-direction: column;
    align-items: flex-start;
    padding: 0 64px;
    margin: -24px auto 0; /* Visual center correction + horizontal centering */
    width: 100%;
    max-width: 540px;
    animation: heroBrandIn 0.7s ease-out 0.2s both;
}

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

/* Icon container — shows the app icon at original colors */
.hero-brand-icon {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow:
        0 8px 32px var(--color-accent-subtle),
        0 0 0 1px var(--color-accent-muted);
}

.hero-icon-img {
    width: 68px;
    height: 68px;
    display: block;
}

.hero-title {
    font-size: 38px;
    font-weight: 800;
    color: var(--color-text-on-accent);
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

/* Accent highlight in title handled by HTML if needed */
.hero-subtitle {
    font-size: 16px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.75;
    margin-bottom: 36px;
    max-width: 420px;
}

.hero-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hero-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 14.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.hero-feature-item svg {
    flex-shrink: 0;
    color: var(--color-accent);
    opacity: 0.9;
}

/* Mobile hero logo */
.hero-logo-mobile {
    height: 36px;
    width: auto;
    position: relative;
    z-index: 2;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

/* ==================== Form Section ==================== */
.login-form-section {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 24px 48px;
    background: var(--color-bg-secondary);
}

.login-form-wrapper {
    width: 100%;
    max-width: 440px;
    animation: formSlideUp 0.5s ease-out 0.1s both;
}

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

/* ==================== Logo (Desktop) ==================== */
.login-logo {
    display: none;
    height: 36px;
    width: auto;
    margin-bottom: 40px;
}

/* ==================== Typography ==================== */
.login-heading {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 6px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.login-subheading {
    font-size: 15px;
    color: var(--color-text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
}

/* ==================== Google OAuth Button ==================== */
.btn-oauth-google {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 13px 24px;
    background: var(--color-bg-elevated);
    border: 1.5px solid var(--color-border-default);
    border-radius: var(--brand-radius-md, 12px);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-oauth-google:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.btn-oauth-google:focus-visible {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.btn-oauth-google:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-oauth-google svg {
    flex-shrink: 0;
}

/* ==================== Divider ==================== */
.login-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    gap: 16px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border-default);
}

.login-divider span {
    font-size: 13px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ==================== Form ==================== */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==================== Form Fields ==================== */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.form-field input {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 15px;
    color: var(--color-text-primary);
    background: var(--color-bg-elevated);
    border: 1.5px solid var(--color-border-default);
    border-radius: var(--brand-radius-md, 12px);
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-field input:hover {
    border-color: var(--color-border-strong);
}

.form-field input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

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

.form-field input[aria-invalid="true"] {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px var(--color-danger-subtle);
}

/* Password wrapper */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.password-toggle:hover {
    color: var(--color-text-secondary);
}

/* Field error */
.field-error {
    font-size: 13px;
    color: var(--color-danger);
    min-height: 0;
    overflow: hidden;
    transition: all 0.2s ease;
}

.field-error:empty {
    display: none;
}

/* ==================== Form Actions ==================== */
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: -8px;
}

.forgot-password {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    padding: 4px 0;
    transition: color 0.15s;
}

.forgot-password:hover {
    color: var(--color-accent-hover);
}

/* ==================== Login Button ==================== */
.btn-login {
    width: 100%;
    padding: 13px 24px;
    margin-top: 4px;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
    color: var(--color-text-on-accent);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--brand-radius-lg, 20px);
    cursor: pointer;
    outline: none;
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--color-accent-subtle);
}

.btn-login:focus-visible {
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.btn-login:active {
    transform: translateY(0);
    box-shadow: var(--shadow-accent);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: var(--shadow-accent);
}

/* Button loading state */
.btn-login.loading .btn-text {
    opacity: 0;
}

.btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-text-on-accent);
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    position: absolute;
}

.btn-login.loading .btn-spinner {
    display: block;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

/* ==================== Auth View Switching ==================== */
.auth-view {
    display: none;
}

.auth-view.active {
    display: block;
}

.auth-view-enter {
    animation: authViewEnter 0.35s ease-out both;
}

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

/* ==================== Register Prompt ==================== */
.register-prompt {
    text-align: center;
    margin-top: 28px;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.register-prompt a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.register-prompt a:hover {
    color: var(--color-accent-hover);
}

/* ==================== Legal Links ==================== */
.legal-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.legal-links a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.legal-links a:hover {
    color: var(--color-text-secondary);
}

.legal-dot {
    font-size: 10px;
}

/* ==================== Toast v2 (synced with styles.css) ==================== */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 14px 40px 14px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
    min-width: 300px;
    max-width: 420px;
    font-size: 14px;
    color: var(--color-text-primary);
    overflow: hidden;
    pointer-events: auto;
    border: 1px solid rgba(28, 25, 23, 0.08);
}

.toast__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast__content {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-primary);
}

.toast__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--color-text-tertiary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.toast__close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text-primary);
}

.toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left;
    animation: toastProgress linear forwards;
    border-radius: 0 0 12px 12px;
}

.toast--success {
    border-left: 4px solid #22c55e;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.06) 0%, #fff 100%);
}
.toast--success .toast__icon { color: #22c55e; }
.toast--success .toast__progress { background: #22c55e; }

.toast--error {
    border-left: 4px solid #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, #fff 100%);
}
.toast--error .toast__icon { color: #ef4444; }
.toast--error .toast__progress { background: #ef4444; }

.toast--warning {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.06) 0%, #fff 100%);
}
.toast--warning .toast__icon { color: #f59e0b; }
.toast--warning .toast__progress { background: #f59e0b; }

.toast--info {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.06) 0%, #fff 100%);
}
.toast--info .toast__icon { color: #3b82f6; }
.toast--info .toast__progress { background: #3b82f6; }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ==================== Dark Theme ==================== */
[data-theme="dark"] .login-form-section {
    background: var(--color-bg-page);
}

[data-theme="dark"] .toast {
    background: var(--color-bg-tertiary);
    border-color: var(--color-border-default);
}
[data-theme="dark"] .toast__close:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .toast--success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, var(--color-bg-tertiary) 100%);
}

[data-theme="dark"] .toast--error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, var(--color-bg-tertiary) 100%);
}

[data-theme="dark"] .toast--warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, var(--color-bg-tertiary) 100%);
}

[data-theme="dark"] .toast--info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, var(--color-bg-tertiary) 100%);
}

/* ==================== Desktop Layout (>=768px) ==================== */
@media (min-width: 768px) {
    .login-container {
        flex-direction: row;
    }

    .login-hero {
        width: 50%;
        height: 100vh;
        max-height: none;
        position: fixed;
        top: 0;
        left: 0;
    }

    .hero-content {
        align-items: center;
        justify-content: flex-start;
    }

    .hero-brand {
        display: flex;
        padding: 0 20px;
        max-width: 800px;
    }

    .hero-logo-mobile {
        display: none;
    }

    .login-form-section {
        width: 50%;
        margin-left: 50%;
        align-items: center;
        padding: 48px 40px;
        min-height: 100vh;
    }

    .login-logo {
        display: block;
    }

    .login-heading {
        font-size: 30px;
    }

    .login-form-wrapper {
        max-width: 420px;
    }
}

/* ==================== Large Desktop (>=1200px) ==================== */
@media (min-width: 1200px) {
    .login-hero {
        width: 55%;
    }

    .hero-brand {
        padding: 0 24px;
        max-width: 1000px;
    }

    .hero-brand-icon {
        width: 76px;
        height: 76px;
        border-radius: 20px;
    }

    .hero-icon-img {
        width: 76px;
        height: 76px;
    }

    .hero-title {
        font-size: 44px;
        margin-bottom: 18px;
    }

    .hero-subtitle {
        font-size: 17px;
        max-width: 460px;
    }

    .hero-features {
        gap: 16px;
    }

    .hero-feature-item {
        font-size: 15px;
    }

    .login-form-section {
        width: 45%;
        margin-left: 55%;
        padding: 48px 64px;
    }

    .login-heading {
        font-size: 34px;
    }

    .login-form-wrapper {
        max-width: 440px;
    }

    .hero-orb-1 {
        width: 550px;
        height: 550px;
        filter: blur(60px);
    }

    .hero-orb-2 {
        width: 420px;
        height: 420px;
        filter: blur(55px);
    }

    .hero-orb-3 {
        width: 280px;
        height: 280px;
        filter: blur(45px);
    }
}

/* ==================== Small Mobile (<=380px) ==================== */
@media (max-width: 380px) {
    .login-form-section {
        padding: 24px 20px 40px;
    }

    .login-heading {
        font-size: 22px;
    }

    .btn-oauth-google,
    .btn-login {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* ==================== Hero Ticker (Background floating stock prices) ==================== */
.hero-ticker {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.hero-ticker-item {
    position: absolute;
    white-space: nowrap;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    animation: tickerFloat linear infinite;
    will-change: transform;
}

.hero-ticker-item.up { color: rgba(239, 68, 68, var(--ticker-opacity)); }
.hero-ticker-item.down { color: rgba(34, 197, 94, var(--ticker-opacity)); }

@keyframes tickerFloat {
    from { transform: translateX(110vw); }
    to { transform: translateX(-120%); }
}

/* ==================== Flash Intro Animation ==================== */
.hd-flash-enter {
    animation: hdFlashReveal 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes hdFlashReveal {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* ==================== Hero Demo Animation ==================== */
.hero-demo {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

/* When demo is active, hide static content */
.hero-brand.hd-active .hero-static-content {
    display: none;
}

.hero-brand:not(.hd-active) .hero-demo {
    display: none;
}

.hero-demo-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
}

.hero-brand-icon--sm {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    margin-bottom: 0;
}

.hero-icon-img--sm {
    width: 44px;
    height: 44px;
}

.hero-demo-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text-on-accent);
    letter-spacing: -0.02em;
}

/* Level indicator tabs */
.hero-demo-levels {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.hd-level-tab {
    position: relative;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.25);
    padding: 2px 4px 3px;
    border-bottom: 2px solid transparent;
    transition: all 0.4s ease;
    letter-spacing: 0;
    white-space: nowrap;
    cursor: default;
}

.hd-level-tab.active {
    color: var(--color-accent);
    font-weight: 700;
    border-bottom-color: var(--color-accent);
    text-shadow: 0 0 8px rgba(var(--color-accent-rgb, 255, 152, 0), 0.4);
}

/* Active tab pulse dot */
.hd-level-tab.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: hdTabPulseDot 1.5s ease-in-out infinite;
}

@keyframes hdTabPulseDot {
    0%, 100% { opacity: 0.4; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.4); }
}

.hd-level-sep {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.12);
}

/* Legacy dot glow keyframe — kept for compat */
@keyframes hdDotGlow {
    from {
        width: 8px;
        box-shadow: 0 0 0px rgba(var(--color-accent-rgb, 255, 152, 0), 0);
    }
    to {
        width: 24px;
        box-shadow: 0 0 8px rgba(var(--color-accent-rgb, 255, 152, 0), 0.5);
    }
}

/* Dual-panel body */
.hero-demo-body {
    display: flex;
    flex-direction: row;
    gap: 16px;
    height: 380px;
    position: relative;
}

/* Left panel: chat */
.hero-demo-left {
    flex: 0 0 50%;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.hero-demo-left::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50px;
    background: linear-gradient(to bottom, transparent, rgba(26, 15, 8, 0.95));
    pointer-events: none;
    z-index: 1;
}

/* Right panel: results */
.hero-demo-right {
    flex: 0 0 50%;
    min-width: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    padding-left: 16px;
    opacity: 0;
}

.hero-demo-right::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(26, 15, 8, 0.95));
    pointer-events: none;
    z-index: 1;
}

/* Right panel content container (JS-generated) */
.hd-right-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    overflow: hidden;
    animation: hdRightReveal 0.5s ease-out both;
}

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

/* Skip all animations during flash intro */
.hd-no-anim,
.hd-no-anim * {
    animation: none !important;
}

/* Right panel — scene exit */
.hd-right-fade-out {
    animation: hdRightFadeOut 0.5s ease-in both;
}

@keyframes hdRightFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; transform: translateX(-8px); filter: blur(2px); }
}

/* Right panel empty state placeholder */
.hd-right-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    opacity: 0.15;
}

/* Chat area */
.hero-demo-chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* User message bubble (right-aligned, orange gradient) */
.hd-msg-user {
    align-self: flex-end;
    max-width: 88%;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
    color: #fff;
    padding: 10px 16px;
    border-radius: 16px 16px 4px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    animation: hdMsgEnter 0.3s ease-out both;
    white-space: nowrap;
    overflow: hidden;
}

.hd-msg-user .hd-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: rgba(255, 255, 255, 0.8);
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: hdCursorBlink 0.6s step-end infinite;
}

/* AI message bubble (left-aligned, glass morphism + orange left border) */
.hd-msg-ai {
    align-self: flex-start;
    max-width: 92%;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--color-accent);
    padding: 12px 16px;
    border-radius: 4px 16px 16px 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    animation: hdMsgEnter 0.35s ease-out both;
}

/* AI result top-down reveal + border glow pulse (overrides hdMsgEnter for result blocks) */
.hd-msg-ai.hd-result {
    animation: hdResultReveal 0.6s ease-out both, hdBorderGlow 1.2s ease-out 0.3s both;
}

@keyframes hdResultReveal {
    from {
        clip-path: inset(0 0 100% 0);
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    to {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
}

@keyframes hdBorderGlow {
    0% {
        box-shadow: 0 0 0 rgba(var(--color-accent-rgb, 255, 152, 0), 0);
    }
    30% {
        box-shadow: 0 0 12px rgba(var(--color-accent-rgb, 255, 152, 0), 0.3),
                    inset 0 0 8px rgba(var(--color-accent-rgb, 255, 152, 0), 0.05);
    }
    100% {
        box-shadow: 0 0 0 rgba(var(--color-accent-rgb, 255, 152, 0), 0);
    }
}

/* Typing indicator (3 bouncing dots) */
.hd-typing-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.hd-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-accent);
    opacity: 0.6;
    animation: hdDotBounce 1.2s ease-in-out infinite;
}

.hd-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.hd-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Result count badge */
.hd-result-count {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    animation: hdMsgEnter 0.3s ease-out both;
}

.hd-result-num {
    color: var(--color-accent);
    font-weight: 700;
    font-size: 13px;
}

/* Table bottom fade + "more results" hint */
.hd-table-fade {
    position: relative;
    height: 22px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hd-more-hint {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.25);
    letter-spacing: 0.5px;
    animation: hdMsgEnter 0.4s ease-out 0.5s both;
}

/* Mini stock table */
.hd-stock-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}

.hd-stock-table th {
    font-size: 10.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 4px 6px 6px;
    border-bottom: 2px solid rgba(var(--color-accent-rgb, 255, 152, 0), 0.3);
    white-space: nowrap;
}

/* Numeric columns right-align (all except first th/td) */
.hd-stock-table th:not(:first-child),
.hd-stock-table td:not(:first-child) {
    text-align: right;
}

.hd-stock-table td {
    font-size: 12.5px;
    padding: 5px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hd-stock-table tbody tr {
    animation: hdRowEnter 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hd-stock-table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.hd-stock-table tbody tr:nth-child(2) { animation-delay: 0.12s; }
.hd-stock-table tbody tr:nth-child(3) { animation-delay: 0.19s; }
.hd-stock-table tbody tr:nth-child(4) { animation-delay: 0.26s; }
.hd-stock-table tbody tr:nth-child(5) { animation-delay: 0.33s; }
.hd-stock-table tbody tr:nth-child(6) { animation-delay: 0.40s; }

/* First row subtle highlight — hints interactivity */
.hd-stock-table tbody tr:first-child {
    background: rgba(var(--color-accent-rgb, 255, 152, 0), 0.06);
    border-radius: 4px;
}

/* Auto-scan row highlight */
.hd-row-scan {
    background: rgba(var(--color-accent-rgb, 255, 152, 0), 0.1) !important;
    transform: scale(1.01);
    transition: background 0.15s ease, transform 0.15s ease;
}

.hd-stock-table tbody tr:not(.hd-row-scan) {
    transition: background 0.2s ease, transform 0.2s ease;
}

/* Rank badge (#1, #2...) */
.hd-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(var(--color-accent-rgb, 255, 152, 0), 0.2);
    color: var(--color-accent);
    font-size: 9px;
    font-weight: 700;
    margin-right: 5px;
    vertical-align: middle;
}

.hd-stock-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.hd-stock-code {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin-left: 4px;
}

.hd-up { color: #ef4444; }
.hd-down { color: #22c55e; }

/* Stats pills row */
.hd-stats-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 6px 0 2px;
    animation: hdMsgEnter 0.3s ease-out 0.3s both;
}

.hd-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 2px 8px;
    white-space: nowrap;
}

.hd-pill-icon {
    color: var(--color-accent);
    font-size: 8px;
}

/* K-line candlestick chart */
.hd-kline-wrap {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    animation: hdChartEnter 0.5s ease-out both;
    animation-delay: 0.3s;
}

.hd-kline-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* K-line area fill under close prices */
.hd-kline-area {
    opacity: 0;
    animation: hdAreaFadeIn 0.8s ease-out 0.5s both;
}

@keyframes hdAreaFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* MA5 moving average line */
.hd-kline-ma-line {
    fill: none;
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hd-kline-label {
    font-size: 8px;
    font-weight: 600;
    fill: rgba(255, 255, 255, 0.45);
    font-family: inherit;
}

/* RSI overlay line */
.hd-kline-rsi-line {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* RSI threshold dashed line (RSI=30) */
.hd-kline-threshold {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 0.7;
    stroke-dasharray: 4 3;
}

/* RSI / overlay label */
.hd-kline-overlay-label {
    font-size: 7px;
    font-weight: 500;
    fill: rgba(255, 255, 255, 0.4);
    font-family: inherit;
}

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

/* Candle stagger grow-in */
.hd-candle {
    animation: hdCandleGrow 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Last candle pulse — emphasize latest data */
.hd-candle-last {
    animation: hdCandleGrow 0.35s cubic-bezier(0.22, 1, 0.36, 1) both,
               hdCandlePulse 1.5s ease-in-out 1s both;
}

@keyframes hdCandlePulse {
    0%, 100% { opacity: 1; filter: brightness(1); }
    50% { opacity: 1; filter: brightness(1.5); }
}

@keyframes hdCandleGrow {
    from {
        opacity: 0;
        transform: scaleY(0.3);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

/* RSI line draw animation */
.hd-line-draw {
    transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.4s;
}

/* Shimmer "AI 分析中..." text */
.hd-shimmer-text {
    display: inline-block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0.4) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: hdShimmer 1.5s ease-in-out infinite;
}

@keyframes hdShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Highlight pulse for key numbers/phrases in summary */
.hd-highlight-pulse {
    color: var(--color-accent);
    font-weight: 600;
    animation: hdHighlightPop 0.4s ease-out both;
}

@keyframes hdHighlightPop {
    0% {
        color: rgba(255, 255, 255, 0.65);
        text-shadow: none;
    }
    50% {
        color: var(--color-accent);
        text-shadow: 0 0 8px rgba(var(--color-accent-rgb, 255, 152, 0), 0.6);
    }
    100% {
        color: var(--color-accent);
        text-shadow: none;
    }
}

/* AI summary text */
.hd-ai-summary {
    margin-top: 8px;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.6;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 8px;
}

.hd-ai-summary .hd-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--color-accent);
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: hdCursorBlink 0.6s step-end infinite;
}

/* Scene entrance shimmer */
.hd-scene-enter {
    position: relative;
}

.hd-scene-enter::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.04) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: hdSceneShimmer 0.6s ease-out both;
    pointer-events: none;
    border-radius: 12px;
}

@keyframes hdSceneShimmer {
    from { background-position: 200% 0; opacity: 1; }
    to { background-position: -200% 0; opacity: 0; }
}

/* Fade out animation class — slide up + blur */
.hd-fade-out {
    animation: hdSceneExit 0.6s cubic-bezier(0.4, 0, 1, 1) both;
}

/* ===== Keyframes ===== */
@keyframes hdMsgEnter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes hdSceneExit {
    from {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
    to {
        opacity: 0;
        transform: translateY(-16px);
        filter: blur(4px);
    }
}

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

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

@keyframes hdRowEnter {
    from {
        opacity: 0;
        transform: translateX(-12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* ===== Responsive: <1024px — right panel hidden ===== */
@media (max-width: 1023px) {
    .hero-demo-right { display: none; }
    .hero-demo-left  { flex: none; width: 100%; }
    .hero-demo-chat  { height: 380px; }
}

/* ===== Responsive: 1200px+ enlarge ===== */
@media (min-width: 1200px) {
    .hero-demo-body {
        height: 460px;
    }

    .hero-demo-title {
        font-size: 26px;
    }

    .hd-msg-user {
        font-size: 15px;
    }

    .hd-msg-ai {
        font-size: 14px;
    }
}

/* ==================== Accessibility ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Hide demo + ticker, show static fallback */
    .hero-demo { display: none !important; }
    .hero-ticker { display: none !important; }
    .hero-brand.hd-active .hero-static-content { display: flex !important; }
}

/* High contrast focus */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}
