/* ============================================================================
   Medical Portal — Sign-In  ·  "Calm Clinical"
   ----------------------------------------------------------------------------
   Unbranded (no QRM/QaiS) front door for the medical module at /medical.
   Split canvas: a deep evergreen brand panel with a living vital-sign line +
   a warm ivory sign-in panel. Display: Fraunces · Body: Hanken Grotesk.
   Self-contained tokens (mp-*) — renders outside the app shell. Tenant logo +
   appName carry the branding; one emerald accent, no stacked bars.

   Functional contract (do not rename): .mp-panel + .hidden (panel switching),
   .mp-alert + .show (alert reveal), and every #mp* id the login JS queries.
   ============================================================================ */

:root {
    --mp-ink:        #14221c;
    --mp-ink-soft:   #4d5f56;
    --mp-ink-faint:  #8a9a90;
    --mp-paper:      #f4f1e8;   /* ivory page */
    --mp-surface:    #fffdf8;   /* card */
    --mp-line:       #e5e0d2;
    --mp-line-soft:  #efeadd;
    --mp-field:      #fbfaf4;

    --mp-evergreen:  #0d3b2e;
    --mp-evergreen-2:#0a2a20;
    --mp-mint:       #6ee7b7;   /* glow / line on the dark panel */
    --mp-mint-soft:  rgba(110,231,183,0.16);
    --mp-accent:     #0f766e;   /* links + focus on the ivory side */
    --mp-accent-ring:rgba(15,118,110,0.16);

    --mp-danger:     #b4231f;
    --mp-danger-bg:  #fbeae8;
    --mp-ok:         #0f766e;
    --mp-ok-bg:      #e7f3ee;

    --mp-r:   12px;
    --mp-r-lg:20px;
    --mp-shadow: 0 1px 2px rgba(20,34,28,.05);
    --mp-shadow-card: 0 30px 60px -28px rgba(13,59,46,.30), 0 6px 16px -10px rgba(13,59,46,.18);

    --mp-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --mp-body: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --mp-ink:        #e9f1ec;
        --mp-ink-soft:   #a3b6ac;
        --mp-ink-faint:  #6c8076;
        --mp-paper:      #0a1310;
        --mp-surface:    #0f1c17;
        --mp-line:       #1f2e27;
        --mp-line-soft:  #16231d;
        --mp-field:      #13211b;
        --mp-evergreen:  #0c3528;
        --mp-evergreen-2:#071d16;
        --mp-accent:     #5eead4;
        --mp-accent-ring:rgba(94,234,212,0.18);
        --mp-danger:     #fca5a1;
        --mp-danger-bg:  #2a1413;
        --mp-ok:         #6ee7b7;
        --mp-ok-bg:      #0e261d;
        --mp-shadow-card: 0 30px 60px -28px rgba(0,0,0,.6);
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body.medical-portal {
    font-family: var(--mp-body);
    color: var(--mp-ink);
    background: var(--mp-paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ── Stage ─────────────────────────────────────────────────────────────── */
.mp-stage {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1.02fr 1fr;
}

/* ── Brand canvas (evergreen) ──────────────────────────────────────────── */
.mp-aside {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 18% 8%, #14543f 0%, transparent 55%),
        radial-gradient(120% 100% at 92% 96%, #0c5246 0%, transparent 52%),
        linear-gradient(155deg, var(--mp-evergreen) 0%, var(--mp-evergreen-2) 100%);
    color: #eafaf2;
    isolation: isolate;
}
/* drifting aurora glow */
.mp-aside-glow {
    position: absolute; inset: -25%;
    background:
        radial-gradient(38% 38% at 30% 30%, rgba(110,231,183,.30), transparent 70%),
        radial-gradient(34% 34% at 72% 68%, rgba(45,212,191,.22), transparent 70%);
    filter: blur(14px);
    animation: mp-drift 22s ease-in-out infinite alternate;
    z-index: 0;
}
/* fine grain so the gradient never reads flat */
.mp-aside-grain {
    position: absolute; inset: 0; z-index: 1; opacity: .5; mix-blend-mode: soft-light;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.mp-aside-inner {
    position: relative; z-index: 2;
    height: 100%;
    display: flex; flex-direction: column;
    padding: clamp(34px, 4.4vw, 68px);
}

.mp-aside-brand { display: flex; align-items: center; gap: 13px; }
.mp-aside-brand .mp-logo-img { height: 40px; width: auto; max-width: 230px; object-fit: contain; }
.mp-aside-brand .mp-logo-mark {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px;
    background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18);
    color: var(--mp-mint); font-size: 19px;
    box-shadow: 0 0 26px -6px rgba(110,231,183,.55);
}
.mp-aside-brand .mp-logo-word {
    font-family: var(--mp-display); font-weight: 500; font-size: 1.45rem;
    letter-spacing: -.01em; color: #f3fbf7;
}

/* the living vital-sign line — the memorable element */
.mp-ecg { margin: clamp(28px,5vh,64px) 0 auto; }
.mp-ecg svg { width: 100%; height: clamp(90px, 16vh, 150px); display: block; overflow: visible; }
.mp-ecg-base { fill: none; stroke: rgba(234,250,242,.14); stroke-width: 1.5; }
.mp-ecg-line {
    fill: none; stroke: var(--mp-mint); stroke-width: 2.4;
    stroke-linecap: round; stroke-linejoin: round;
    filter: drop-shadow(0 0 6px rgba(110,231,183,.85));
    stroke-dasharray: 2000; stroke-dashoffset: 2000;
    animation: mp-ecg 5s cubic-bezier(.55,0,.45,1) infinite;
}

.mp-aside-copy { margin-top: auto; max-width: 34ch; }
.mp-aside-title {
    font-family: var(--mp-display); font-weight: 500;
    font-size: clamp(1.9rem, 3.1vw, 2.85rem); line-height: 1.05; letter-spacing: -.02em;
    margin: 0 0 14px; color: #f6fcf9;
}
.mp-aside-tag { margin: 0; font-size: 1rem; line-height: 1.6; color: rgba(220,240,231,.74); }
.mp-aside-foot { margin: 30px 0 0; font-size: .78rem; letter-spacing: .02em; color: rgba(200,224,214,.5); }

/* ── Sign-in canvas (ivory) ────────────────────────────────────────────── */
.mp-main {
    display: flex; align-items: center; justify-content: center;
    padding: clamp(28px, 5vw, 72px);
}
.mp-card-shell { width: 100%; max-width: 408px; }

.mp-card-head { margin-bottom: 26px; }
.mp-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 0 0 16px; font-size: .72rem; font-weight: 600;
    letter-spacing: .16em; text-transform: uppercase; color: var(--mp-accent);
}
.mp-eyebrow-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--mp-accent);
    box-shadow: 0 0 0 4px var(--mp-accent-ring); animation: mp-pulse 2.6s ease-in-out infinite;
}
.mp-card-head h1 {
    font-family: var(--mp-display); font-weight: 500;
    font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1.02; letter-spacing: -.025em;
    margin: 0 0 8px; color: var(--mp-ink);
}
.mp-sub { margin: 0; font-size: 1rem; color: var(--mp-ink-soft); }

.mp-card { position: relative; }

.mp-panel { display: block; }
.mp-panel.hidden { display: none; }

.mp-panel-note {
    margin: 0 0 18px; font-size: .9rem; line-height: 1.55; color: var(--mp-ink-soft);
}

.mp-field { margin-bottom: 16px; }
.mp-field label {
    display: block; font-size: .82rem; font-weight: 600; color: var(--mp-ink);
    margin-bottom: 7px; letter-spacing: -.005em;
}
.mp-field-row { display: flex; justify-content: space-between; align-items: baseline; }

.mp-input {
    width: 100%; padding: 13px 15px; font-family: var(--mp-body); font-size: 1rem;
    color: var(--mp-ink); background: var(--mp-field);
    border: 1px solid var(--mp-line); border-radius: var(--mp-r);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
    outline: none;
}
.mp-input::placeholder { color: var(--mp-ink-faint); }
.mp-input:hover { border-color: #d6d0bf; }
.mp-input:focus {
    border-color: var(--mp-accent); background: var(--mp-surface);
    box-shadow: 0 0 0 4px var(--mp-accent-ring);
}

.mp-link {
    background: none; border: 0; padding: 0; font-family: var(--mp-body);
    font-size: .82rem; font-weight: 600; color: var(--mp-accent); cursor: pointer;
}
.mp-link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.mp-btn {
    position: relative; overflow: hidden;
    width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    margin-top: 6px; padding: 14px 18px;
    font-family: var(--mp-body); font-size: 1rem; font-weight: 600; letter-spacing: -.005em;
    color: #f3fbf7; background: var(--mp-evergreen);
    border: 0; border-radius: var(--mp-r); cursor: pointer;
    box-shadow: 0 10px 22px -12px rgba(13,59,46,.7);
    transition: transform .16s ease, box-shadow .2s ease, background .2s ease;
}
.mp-btn i { font-size: .9em; transition: transform .2s ease; }
.mp-btn::after {     /* mint sheen sweep on hover */
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(110,231,183,.28) 50%, transparent 70%);
    transform: translateX(calc(-120% * var(--dir-sign, 1))); transition: transform .6s ease;
}
.mp-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -14px rgba(13,59,46,.75); }
.mp-btn:hover::after { transform: translateX(calc(120% * var(--dir-sign, 1))); }
.mp-btn:hover i.fa-arrow-right-long { transform: translateX(calc(3px * var(--dir-sign, 1))); }
.mp-btn:active { transform: translateY(0); }
.mp-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.mp-btn-ghost {
    margin-top: 10px; color: var(--mp-ink-soft); background: transparent;
    font-weight: 500; box-shadow: none; border: 1px solid var(--mp-line);
}
.mp-btn-ghost::after { display: none; }
.mp-btn-ghost:hover { background: var(--mp-line-soft); color: var(--mp-ink); transform: none; box-shadow: none; }

/* ── Alerts (JS toggles .show) ─────────────────────────────────────────── */
.mp-alert {
    display: none; align-items: flex-start; gap: 9px;
    padding: 11px 13px; margin-bottom: 16px; border-radius: var(--mp-r);
    font-size: .88rem; line-height: 1.45;
}
.mp-alert.show { display: flex; }
.mp-alert i { margin-top: 2px; }
.mp-alert-error { background: var(--mp-danger-bg); color: var(--mp-danger); }
.mp-alert-ok    { background: var(--mp-ok-bg); color: var(--mp-ok); }

/* ── Verifying (magic-link landing) ────────────────────────────────────── */
.mp-verifying { text-align: center; padding: 14px 0 6px; }
.mp-verifying-text { margin: 14px 0 0; }
.mp-spinner {
    display: inline-block; width: 30px; height: 30px; border-radius: 50%;
    border: 2.5px solid var(--mp-accent-ring); border-top-color: var(--mp-accent);
    animation: mp-spin .8s linear infinite;
}

.mp-foot-note { margin: 22px 0 0; text-align: center; font-size: .82rem; color: var(--mp-ink-faint); }

/* ── Motion ────────────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(12px); animation: mp-reveal .75s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: var(--d, 0s); }
@keyframes mp-reveal { to { opacity: 1; transform: none; } }
@keyframes mp-spin { to { transform: rotate(360deg); } }
@keyframes mp-pulse { 0%,100% { box-shadow: 0 0 0 4px var(--mp-accent-ring); } 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes mp-drift { from { transform: translate(-3%, -2%) scale(1); } to { transform: translate(4%, 3%) scale(1.08); } }
@keyframes mp-ecg {
    0%   { stroke-dashoffset: 2000; opacity: .15; }
    8%   { opacity: 1; }
    62%  { stroke-dashoffset: 0; opacity: 1; }
    86%  { opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: .15; }
}

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; animation: none; }
    .mp-aside-glow, .mp-ecg-line, .mp-eyebrow-dot { animation: none; }
    .mp-ecg-line { stroke-dashoffset: 0; }
    .mp-btn, .mp-input, .mp-btn::after { transition: none; }
}

/* ── Responsive: stack, brand becomes a slim top band ──────────────────── */
@media (max-width: 880px) {
    .mp-stage { grid-template-columns: 1fr; }
    .mp-aside { min-height: auto; }
    .mp-aside-inner { padding: 26px clamp(22px,6vw,40px) 22px; }
    .mp-ecg { margin: 18px 0; }
    .mp-ecg svg { height: 60px; }
    .mp-aside-copy { display: none; }
    .mp-aside-foot { display: none; }
    .mp-main { padding: 34px clamp(22px,6vw,40px) 56px; align-items: flex-start; }
    .mp-card-head { margin-top: 8px; }
}
@media (max-width: 880px) and (min-width: 521px) {
    .mp-aside-inner { flex-direction: row; align-items: center; justify-content: space-between; gap: 24px; }
    .mp-ecg { flex: 1; margin: 0; max-width: 360px; }
    .mp-ecg svg { height: 52px; }
}
