/* ==============================================================================
 * MSM Auth (Forecast Atelier) - v2.0 login page
 * Aesthetic: Bloomberg Terminal × Linear × Vercel - data-driven sophistication.
 * Local fonts (no Google Fonts CDN per CLAUDE.md правило 3.1).
 * Performance: GPU-accelerated transforms only, will-change hints, paint isolation.
 * ============================================================================== */

/* ─────────────────────────── @font-face declarations ─────────────────────────── */

@font-face {
    font-family: 'Bricolage Grotesque';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('/assets/fonts/bricolage/bricolage-variable.woff2') format('woff2-variations');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('/assets/fonts/jetbrains-mono/jetbrains-mono-variable.woff2') format('woff2-variations');
    unicode-range: U+0400-04FF;
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('/assets/fonts/jetbrains-mono/jetbrains-mono-latin.woff2') format('woff2-variations');
    unicode-range: U+0000-024F;
}

@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('/assets/fonts/manrope/manrope-variable.woff2') format('woff2-variations');
    unicode-range: U+0400-04FF;
}

@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('/assets/fonts/manrope/manrope-latin.woff2') format('woff2-variations');
    unicode-range: U+0000-024F;
}

/* ─────────────────────────── CSS variables ─────────────────────────── */

:root {
    --auth-ink: #0a0e1a;
    --auth-midnight: #0f1729;
    --auth-graphite: #1a2238;
    --auth-line: rgba(148, 163, 184, 0.12);
    --auth-line-strong: rgba(148, 163, 184, 0.22);

    --auth-cyan: #06b6d4;
    --auth-cyan-bright: #22d3ee;
    --auth-amber: #f59e0b;
    --auth-amber-bright: #fbbf24;
    --auth-cream: #fbf3e8;

    --auth-text: #e2e8f0;
    --auth-text-soft: #94a3b8;
    --auth-text-mute: #64748b;

    --auth-error: #f87171;
    --auth-error-bg: rgba(248, 113, 113, 0.08);

    --auth-radius: 14px;
    --auth-radius-sm: 8px;

    --auth-easing: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ─────────────────────────── Reset + body ─────────────────────────── */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body.msm-auth-body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--auth-ink);
    color: var(--auth-text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Mobile: чтобы 100% от viewport се вижда коректно при scroll */
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─────────────────────────── Shell layout ─────────────────────────── */

.msm-auth-shell {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
}

/* Tablet portrait + small landscape (< 980px): stack vertically */
@media (max-width: 980px) {
    .msm-auth-shell {
        grid-template-columns: 1fr;
        grid-template-rows: clamp(180px, 28dvh, 240px) 1fr;
    }
    body.msm-auth-body { overflow-y: auto; }
}

/* Phone (< 640px): по-компактен decorative strip */
@media (max-width: 640px) {
    .msm-auth-shell {
        grid-template-rows: clamp(140px, 22dvh, 180px) 1fr;
    }
}

/* Landscape phone (height < 500px): hide decorative strip изобщо за да се вижда формата */
@media (max-height: 500px) and (orientation: landscape) {
    .msm-auth-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }
    .msm-auth-stage { display: none; }
}

/* ─────────────────────────── LEFT: Stage (decorative) ─────────────────────────── */

.msm-auth-stage {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 30%, rgba(6, 182, 212, 0.08) 0%, transparent 60%),
        radial-gradient(circle at 80% 70%, rgba(245, 158, 11, 0.04) 0%, transparent 50%),
        linear-gradient(135deg, #050810 0%, var(--auth-ink) 50%, var(--auth-midnight) 100%);
    padding: clamp(20px, 3vw, 56px) clamp(20px, 4vw, 64px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    /* GPU layer isolation - изолира animations от main composite layer */
    contain: layout paint;
}

/* Particle network canvas (1:1 със старата система) */
.msm-stage-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    /* Subtle blue tint в overlay - drives "data network" feel */
    opacity: 0.85;
}

/* Floating glow blobs - GPU promoted via filter + transform */
.msm-stage-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    opacity: 0;
    z-index: 2;
    will-change: transform, opacity;
    transform: translateZ(0);
}
.msm-stage-glow-1 {
    width: 380px;
    height: 380px;
    top: -80px;
    right: -80px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.35) 0%, transparent 70%);
    animation: glowFadeIn 1.2s var(--auth-easing) 0.4s forwards, glowDrift 14s ease-in-out 1.6s infinite alternate;
}
.msm-stage-glow-2 {
    width: 300px;
    height: 300px;
    bottom: 80px;
    left: -50px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.18) 0%, transparent 70%);
    animation: glowFadeIn 1.2s var(--auth-easing) 0.6s forwards, glowDrift2 18s ease-in-out 1.8s infinite alternate;
}

@keyframes glowFadeIn { to { opacity: 1; } }
@keyframes glowDrift {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50%      { transform: translate3d(-30px, 40px, 0); }
}
@keyframes glowDrift2 {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50%      { transform: translate3d(40px, -30px, 0); }
}

/* Animated forecast SVG - layered above canvas */
.msm-stage-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.msm-curve {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: drawCurve 1.8s var(--auth-easing) forwards;
}
.msm-curve-subtle  { animation-delay: 0.4s; }
.msm-curve-primary { animation-delay: 0.7s; }
.msm-curve-accent  {
    animation-delay: 1.0s;
    animation-duration: 2.0s;
}
@keyframes drawCurve {
    to { stroke-dashoffset: 0; }
}

.msm-curve-band {
    opacity: 0;
    animation: bandFadeIn 1.4s var(--auth-easing) 1.2s forwards;
    transform-origin: center;
    will-change: opacity, transform;
}
@keyframes bandFadeIn {
    from { opacity: 0; transform: scaleY(0.85); }
    to   { opacity: 1; transform: scaleY(1); }
}

/* Pulsing data points - transform-only (GPU composite) */
.msm-curve-point {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation: pointAppear 0.4s var(--auth-easing) 1.8s forwards, pointPulse 2.5s ease-in-out 2.2s infinite;
    filter: drop-shadow(0 0 8px currentColor);
    will-change: transform, opacity;
}
.msm-curve-point--delayed {
    animation-delay: 2.0s, 2.4s;
}
@keyframes pointAppear {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes pointPulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%      { transform: scale(1.4); opacity: 0.7; }
}

/* Brand mark (top of stage) */
.msm-stage-brand {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0;
    animation: slideInLeft 0.8s var(--auth-easing) 0.2s forwards;
    will-change: opacity, transform;
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translate3d(-20px, 0, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.msm-stage-brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(15, 23, 41, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--auth-line);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}
.msm-stage-brand-mark img { width: 100%; height: 100%; display: block; }
.msm-stage-brand-name {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--auth-cream);
    letter-spacing: -0.02em;
    line-height: 1;
}
.msm-stage-brand-sub {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    font-weight: 500;
    color: var(--auth-text-soft);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 4px;
}
.msm-stage-brand-version {
    color: var(--auth-cyan);
    margin-left: 6px;
}

/* Stage caption (bottom) */
.msm-stage-caption {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 480px;
    opacity: 0;
    animation: slideInUp 0.8s var(--auth-easing) 1.0s forwards;
    will-change: opacity, transform;
}
@keyframes slideInUp {
    from { opacity: 0; transform: translate3d(0, 20px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.msm-stage-caption-label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.32em;
    color: var(--auth-cyan);
    text-transform: uppercase;
}
.msm-stage-caption-label::before {
    content: '- ';
    opacity: 0.6;
}
.msm-stage-caption-text {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: clamp(20px, 2.4vw, 32px);
    font-weight: 400;
    line-height: 1.2;
    color: var(--auth-cream);
    letter-spacing: -0.02em;
}

/* Tablet/mobile stage adjustments */
@media (max-width: 980px) {
    .msm-stage-glow-1 { width: clamp(160px, 30vw, 220px); height: clamp(160px, 30vw, 220px); }
    .msm-stage-glow-2 { display: none; }
    .msm-stage-caption { display: none; }
}

/* Phone: smaller brand mark */
@media (max-width: 640px) {
    .msm-stage-brand-mark { width: 36px; height: 36px; padding: 6px; border-radius: 10px; }
    .msm-stage-brand-name { font-size: 18px; }
    .msm-stage-brand-sub  { font-size: 9px; }
}

/* ─────────────────────────── RIGHT: Form panel ─────────────────────────── */

.msm-auth-panel {
    background: var(--auth-midnight);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 4vw, 48px);
    position: relative;
    border-left: 1px solid var(--auth-line);
}
.msm-auth-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--auth-cyan) 35%,
        var(--auth-cyan) 65%,
        transparent 100%);
    opacity: 0.4;
}

.msm-panel-content {
    width: 100%;
    max-width: 380px;
}

/* Header */
.msm-panel-header {
    margin-bottom: 36px;
    opacity: 0;
    animation: slideInUp 0.7s var(--auth-easing) 0.4s forwards;
    will-change: opacity, transform;
}
.msm-panel-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    color: var(--auth-text-soft);
    text-transform: uppercase;
    padding: 5px 12px;
    background: rgba(6, 182, 212, 0.06);
    border: 1px solid rgba(6, 182, 212, 0.18);
    border-radius: 100px;
    margin-bottom: 20px;
}
.msm-panel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--auth-cyan);
    box-shadow: 0 0 8px var(--auth-cyan);
    animation: dotBlink 2s ease-in-out infinite;
}
@keyframes dotBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
.msm-panel-title {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: clamp(22px, 3.5vw, 32px);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.025em;
    color: var(--auth-cream);
    margin: 0 0 10px;
}
.msm-panel-subtitle {
    font-family: 'Manrope', sans-serif;
    font-size: clamp(13px, 1.2vw, 14px);
    line-height: 1.55;
    color: var(--auth-text-soft);
    margin: 0;
}

/* Alert */
.msm-panel-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--auth-error-bg);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: var(--auth-radius-sm);
    color: var(--auth-error);
    font-size: 13px;
    margin-bottom: 20px;
    animation: shake 0.5s ease-in-out, slideInUp 0.4s var(--auth-easing);
}
.msm-panel-alert i { font-size: 15px; flex-shrink: 0; }

@keyframes shake {
    0%, 100%             { transform: translate3d(0, 0, 0); }
    20%, 60%             { transform: translate3d(-4px, 0, 0); }
    40%, 80%             { transform: translate3d(4px, 0, 0); }
}

/* Form */
.msm-panel-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 36px;
}

.msm-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    animation: slideInUp 0.6s var(--auth-easing) forwards;
    will-change: opacity, transform;
}
.msm-field:nth-of-type(1) { animation-delay: 0.6s; }
.msm-field:nth-of-type(2) { animation-delay: 0.7s; }

.msm-field-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--auth-text-soft);
    text-transform: uppercase;
}
.msm-field-hint {
    font-size: 9px;
    color: var(--auth-text-mute);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.msm-field-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.msm-field-icon {
    position: absolute;
    left: 16px;
    color: var(--auth-text-mute);
    font-size: 14px;
    transition: color 0.2s var(--auth-easing);
    pointer-events: none;
    z-index: 1;
}
.msm-field-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: var(--auth-graphite);
    border: 1px solid var(--auth-line);
    border-radius: var(--auth-radius-sm);
    color: var(--auth-cream);
    font-family: 'Manrope', sans-serif;
    /* iOS Safari auto-zoom kicks in при font-size < 16px на focus.
       Mobile-first: 16px по default; desktop може да слезе на 14px. */
    font-size: 16px;
    font-weight: 500;
    transition: border-color 0.2s var(--auth-easing), background 0.2s var(--auth-easing), box-shadow 0.2s var(--auth-easing);
    outline: none;
    /* iOS: премахни default rounded styling */
    -webkit-appearance: none;
    appearance: none;
}
@media (min-width: 768px) {
    .msm-field-input { font-size: 14px; }
}
.msm-field-input::placeholder {
    color: var(--auth-text-mute);
    font-weight: 400;
}
.msm-field-input:focus {
    border-color: var(--auth-cyan);
    background: rgba(6, 182, 212, 0.04);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}
.msm-field:has(.msm-field-input:focus) .msm-field-icon {
    color: var(--auth-cyan);
}

/* Autofill default style fix (Chrome) */
.msm-field-input:-webkit-autofill,
.msm-field-input:-webkit-autofill:hover,
.msm-field-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-cream);
    -webkit-box-shadow: 0 0 0 1000px var(--auth-graphite) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* Submit button */
.msm-panel-submit {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--auth-cyan) 0%, #0891b2 100%);
    border: none;
    border-radius: var(--auth-radius-sm);
    color: #0a0e1a;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.25s var(--auth-easing), box-shadow 0.25s var(--auth-easing);
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 20px -4px rgba(6, 182, 212, 0.4),
                0 0 0 1px rgba(6, 182, 212, 0.1);
    opacity: 0;
    animation: slideInUp 0.6s var(--auth-easing) 0.85s forwards;
    margin-top: 8px;
    will-change: transform, box-shadow, opacity;
}
.msm-panel-submit::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--auth-cyan-bright) 0%, var(--auth-cyan) 100%);
    opacity: 0;
    transition: opacity 0.25s var(--auth-easing);
}
.msm-panel-submit > * {
    position: relative;
    z-index: 1;
}
.msm-panel-submit:hover {
    transform: translate3d(0, -1px, 0);
    box-shadow: 0 10px 28px -4px rgba(6, 182, 212, 0.55),
                0 0 0 1px rgba(34, 211, 238, 0.2);
}
.msm-panel-submit:hover::before { opacity: 1; }
.msm-panel-submit:active {
    transform: translate3d(0, 0, 0);
    box-shadow: 0 4px 12px -2px rgba(6, 182, 212, 0.35);
}
.msm-panel-submit-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(10, 14, 26, 0.18);
    border-radius: 50%;
    transition: transform 0.25s var(--auth-easing);
}
.msm-panel-submit:hover .msm-panel-submit-arrow {
    transform: translate3d(4px, 0, 0);
}

/* Footer */
.msm-panel-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 24px;
    border-top: 1px solid var(--auth-line);
    opacity: 0;
    animation: slideInUp 0.6s var(--auth-easing) 1.0s forwards;
}
.msm-panel-footer-row {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
}
.msm-panel-footer-key {
    color: var(--auth-text-mute);
    text-transform: uppercase;
}
.msm-panel-footer-val {
    color: var(--auth-text-soft);
    font-weight: 500;
}
.msm-panel-footer-tag {
    color: var(--auth-cyan);
    font-weight: 600;
    margin-left: 4px;
    padding: 1px 6px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 4px;
}

/* Mobile panel adjustments */
@media (max-width: 980px) {
    .msm-auth-panel {
        border-left: none;
        border-top: 1px solid var(--auth-line);
    }
    .msm-panel-content { max-width: none; }
    .msm-panel-header { margin-bottom: 24px; }
}

/* Phone: tighter spacing + по-малки декоративни bits */
@media (max-width: 640px) {
    .msm-panel-eyebrow {
        font-size: 9px;
        padding: 4px 10px;
        margin-bottom: 14px;
    }
    .msm-panel-form { gap: 14px; margin-bottom: 24px; }
    .msm-panel-footer-row { font-size: 9px; }
    .msm-panel-footer { padding-top: 18px; gap: 4px; }
}

/* Touch target safety: submit button >= 48px height на phones */
@media (max-width: 640px) {
    .msm-panel-submit { padding: 15px 18px; }
}

/* ─────────────────────────── Reduced motion ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .msm-curve { stroke-dashoffset: 0; }
    .msm-curve-band,
    .msm-stage-glow,
    .msm-stage-brand,
    .msm-stage-caption,
    .msm-panel-header,
    .msm-field,
    .msm-panel-submit,
    .msm-panel-footer {
        opacity: 1 !important;
    }
    .msm-stage-canvas { display: none; }
}
