/* ==========================================================================
   El-B — Authentication screens (layout + animated brief only)
   Shared components (fields, buttons, notices…) live in ui.css.
   ========================================================================== */

:root { --brief-duration: 5.5s; }

.auth-body { margin: 0; min-height: 100dvh; background: var(--soft-linen); color: var(--carbon-black); font-family: var(--bs-body-font-family); line-height: 1.65; -webkit-font-smoothing: antialiased; }
.auth-body::before { display: none; }
.auth-skip { position: absolute; top: -100px; inset-inline-start: 12px; z-index: 50; padding: .6rem 1rem; border-radius: 12px; background: var(--carbon-black); color: var(--soft-linen); font-weight: 700; text-decoration: none; }
.auth-skip:focus { top: 12px; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth { grid-template-columns: minmax(460px, 1fr) minmax(0, 1.08fr); } }

.auth-main { display: flex; flex-direction: column; min-height: 100dvh; padding: 16px clamp(20px, 5vw, 64px) 20px; }
@media (max-width: 991.98px) { .auth-main { min-height: auto; } }

.auth-card { width: 100%; max-width: 420px; margin: auto; padding: 2rem 0 2.5rem; animation: auth-in .7s var(--ease-out) both; }
@keyframes auth-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-head { margin-bottom: 1.75rem; }
.auth-head h1 { font-size: clamp(1.95rem, 3.6vw, 2.55rem); font-weight: 800; line-height: 1.2; letter-spacing: -.02em; }
.auth-head p { margin-top: .6rem; color: var(--text-muted); font-size: 1.02rem; }
.auth-foot { text-align: center; font-size: .8rem; color: var(--text-muted); padding-top: 1rem; }
.auth-foot i { margin-inline-end: .45rem; color: var(--stone); }

/* ── Social sign-in & divider ─────────────────────────────────────────── */
.auth-google {
    display: flex; align-items: center; justify-content: center; gap: .75rem; height: 54px; border-radius: 14px;
    background: #fff; border: 1.5px solid var(--line-strong); color: var(--carbon-black); font-weight: 700; text-decoration: none;
    box-shadow: 0 1px 0 rgba(var(--carbon-black-rgb), .04);
    transition: border-color .2s, box-shadow .25s var(--ease-out), transform .2s var(--ease-out);
}
.auth-google:hover { border-color: rgba(var(--carbon-black-rgb), .32); box-shadow: 0 10px 24px -16px rgba(var(--carbon-black-rgb), .55); transform: translateY(-1px); color: var(--carbon-black); }
.auth-google:focus-visible { outline: none; box-shadow: var(--ring); }
.auth-divider { display: flex; align-items: center; gap: .9rem; margin: 1.4rem 0; color: var(--text-muted); font-size: .84rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }

/* ── Form ─────────────────────────────────────────────────────────────── */
.auth-form { display: grid; gap: 1.15rem; }
.auth-form .check { justify-self: start; }
.auth-form .ui-btn { margin-top: .35rem; }

/* Notices, badge, switch link */
.auth-badge { display: inline-flex; align-items: center; gap: .5rem; margin: -.6rem 0 1.4rem !important; padding: .4rem .9rem; border-radius: 999px; background: rgba(var(--tuscan-sun-rgb), .38); font-weight: 700; font-size: .88rem; }
.auth-switch { margin-top: 1.6rem !important; text-align: center; color: var(--text-muted); }
.auth-switch a { color: var(--carbon-black); font-weight: 800; text-decoration: underline; text-decoration-color: var(--tuscan-sun); text-decoration-thickness: 3px; text-underline-offset: 5px; transition: text-decoration-color .2s; }
.auth-switch a:hover { text-decoration-color: var(--carbon-black); }

/* ── Brief panel ──────────────────────────────────────────────────────── */
.auth-brief {
    position: relative; isolation: isolate; overflow: hidden; order: -1;
    display: flex; flex-direction: column; padding: 16px 20px;
    background:
        radial-gradient(70% 55% at 50% 42%, rgba(255, 238, 196, .09), transparent 70%),
        radial-gradient(60% 50% at 100% 110%, rgba(var(--tuscan-sun-rgb), .1), transparent 70%),
        #1a1a19;
    color: var(--soft-linen);
}
.brief-grain {
    position: absolute; inset: 0; z-index: -1; opacity: .16; mix-blend-mode: overlay; pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
.brief-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brief-logo { text-decoration: none; display: inline-flex; border-radius: 12px; transition: opacity .2s, transform .25s var(--ease-out); }
.brief-logo:hover { opacity: .85; transform: translateY(-1px); }
.brief-logo:focus-visible { outline: none; box-shadow: var(--ring); }
.brief-logo .logo-word { color: var(--soft-linen); }
.brief-tagline { font-size: .82rem; color: var(--on-dark); max-width: 60%; text-align: end; }
.brief-stage, .brief-caption, .brief-controls, .brief-trust { display: none; }

@media (min-width: 992px) {
    .auth-brief { order: 0; position: sticky; top: 16px; height: calc(100dvh - 32px); margin: 16px; margin-inline-start: 0; padding: 2.5rem 3rem 2.25rem; border-radius: 32px; }
    .brief-top { flex-direction: column; align-items: flex-start; gap: 1.1rem; }
    .brief-tagline { font-size: 1.02rem; max-width: 26rem; text-align: start; line-height: 1.8; }
    /* The stage absorbs whatever height is left; artwork scales by tier below */
    .brief-stage { display: block; position: relative; flex: 1 1 auto; min-height: 0; margin: 1rem 0; }
    .brief-caption { display: block; min-height: 132px; }
    .brief-controls { display: flex; }
    .brief-trust { display: flex; }
}

/* Frames */
.brief-frame { position: absolute; inset: 0; display: grid; place-items: center; scale: var(--art-scale, 1); opacity: 0; visibility: hidden; transition: opacity .55s var(--ease-out), visibility 0s linear .55s; filter: drop-shadow(0 30px 34px rgba(0, 0, 0, .5)); }
.brief-frame.is-active { opacity: 1; visibility: visible; transition: opacity .6s var(--ease-out) .15s, visibility 0s; }

/* Shared paper */
.art-receipt, .mini-receipt {
    --z: 14px;
    position: relative; width: min(330px, 74%); padding: 28px 24px 30px; color: var(--carbon-black); background: var(--paper);
    -webkit-mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--z) 51% repeat-x, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--z) 51% repeat-x;
            mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--z) 51% repeat-x, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--z) 51% repeat-x;
}
.r-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: .86rem; }
.r-k { color: var(--stone); font-size: .78rem; }
.r-v { font-weight: 700; font-size: .82rem; }
.r-amount { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 12px 0; padding: 12px 0; border-block: 1.5px dashed rgba(var(--carbon-black-rgb), .3); }
.r-amount .mono { font-size: 1.55rem; font-weight: 800; }
.r-amount small { font-weight: 700; }
.r-barcode { height: 30px; width: 80%; margin: 14px auto 0; opacity: .85; background: repeating-linear-gradient(90deg, var(--carbon-black) 0 2px, transparent 2px 4px, var(--carbon-black) 4px 5px, transparent 5px 8px, var(--carbon-black) 8px 11px, transparent 11px 13px, var(--carbon-black) 13px 14px, transparent 14px 18px); }

/* Frame 1: blank sender, circled in red pen */
.art-receipt { transform: rotate(-3deg); }
.r-blank { position: relative; flex: 1; max-width: 60%; height: 18px; border-bottom: 2px dotted rgba(var(--carbon-black-rgb), .35); }
.r-blank svg { position: absolute; inset: -13px -16px -11px -14px; width: calc(100% + 30px); height: calc(100% + 24px); overflow: visible; }
.r-blank path { fill: none; stroke: var(--pen); stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; }
.art-receipt-wrap { position: relative; width: min(330px, 74%); }
.art-receipt-wrap .art-receipt { width: 100%; }
.r-note { position: absolute; top: -48px; left: -10px; z-index: 2; font-family: "Aref Ruqaa", serif; font-size: 2.1rem; line-height: 1; color: var(--pen); transform: rotate(-9deg); clip-path: inset(0 0 0 100%); }
.brief-frame.is-active .art-receipt-wrap { animation: paper-drop .8s var(--ease-out) both; }
.brief-frame.is-active .r-blank path { animation: draw .9s cubic-bezier(.55, 0, .35, 1) .7s forwards; }
.brief-frame.is-active .r-note { animation: write .7s steps(8, end) 1.6s forwards; }

/* Frame 2: two sealed documents */
.art-docs, .art-arbiter { position: relative; width: min(420px, 88%); aspect-ratio: 16 / 10; }
.doc { position: absolute; width: 46%; padding: 18px 16px 16px; border-radius: 16px; background: var(--paper); color: var(--carbon-black); display: flex; flex-direction: column; gap: 9px; }
.doc small { font-weight: 800; font-size: .86rem; }
.doc .ln { display: block; height: 8px; border-radius: 9px; background: rgba(var(--carbon-black-rgb), .2); filter: blur(2px); }
.doc .ln.short { width: 62%; }
.doc-lock { position: absolute; top: -12px; inset-inline-end: -12px; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--tuscan-sun); color: var(--carbon-black); font-size: .8rem; box-shadow: 0 10px 18px -10px rgba(0, 0, 0, .8); }
.doc-tag { align-self: flex-start; margin-top: 4px; padding: .12rem .55rem; border-radius: 999px; background: rgba(var(--carbon-black-rgb), .08); font-size: .72rem; font-weight: 800; }
.art-docs .doc-seller { top: 4%; right: 2%; transform: rotate(4deg); }
.art-docs .doc-buyer { bottom: 4%; left: 2%; transform: rotate(-5deg); }
.brief-frame.is-active .art-docs .doc-seller { animation: from-right .8s var(--ease-out) .15s both; }
.brief-frame.is-active .art-docs .doc-buyer { animation: from-left .8s var(--ease-out) .45s both; }
.brief-frame.is-active .doc-lock { animation: pop .45s var(--ease-spring) 1.1s both; }

/* Frame 3: converge, scan, match */
.art-arbiter .doc { top: 50%; width: 40%; padding: 20px 16px; }
.art-arbiter .doc-seller { right: 3%; transform: translateY(-50%) rotate(3deg); }
.art-arbiter .doc-buyer { left: 3%; transform: translateY(-50%) rotate(-3deg); }
.art-arbiter .scan { position: absolute; top: 8%; bottom: 8%; left: 8%; width: 3px; border-radius: 3px; background: var(--tuscan-sun); box-shadow: 0 0 18px 4px rgba(var(--tuscan-sun-rgb), .55); opacity: 0; }
.art-arbiter .match { position: absolute; left: 50%; bottom: -2%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: .45rem; padding: .45rem 1rem; border-radius: 999px; background: var(--success-soft); color: var(--success-ink); font-weight: 800; font-size: .9rem; opacity: 0; white-space: nowrap; }
.art-arbiter .match i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--success); color: #fff; font-size: .62rem; }
.brief-frame.is-active .art-arbiter .doc-seller { animation: converge-r 1.2s var(--ease-out) .3s both; }
.brief-frame.is-active .art-arbiter .doc-buyer { animation: converge-l 1.2s var(--ease-out) .3s both; }
.brief-frame.is-active .art-arbiter .scan { animation: scan 1.1s ease-in-out 1.45s both; }
.brief-frame.is-active .art-arbiter .match { animation: match-pop .5s var(--ease-spring) 2.55s both; }

/* Frame 4: stamped receipt */
.art-stamped { position: relative; width: min(330px, 74%); display: grid; place-items: center; }
.mini-receipt { width: 100%; transform: rotate(2deg); padding-bottom: 34px; }
/* Sits entirely on the paper so the multiply-blended ink stays visible */
.art-stamp { position: absolute; left: 3%; top: 47%; width: 37%; height: auto; aspect-ratio: 1; overflow: visible; color: #1b1b1a; mix-blend-mode: multiply; opacity: .92; transform: rotate(-14deg); pointer-events: none; }
.brief-frame.is-active .mini-receipt { animation: paper-drop .8s var(--ease-out) both; }
.brief-frame.is-active .art-stamp { animation: stamp .5s cubic-bezier(.2, .8, .3, 1.15) .9s both; }

/* Captions */
.brief-text[hidden] { display: none; }
.brief-text.is-active { animation: caption-in .6s var(--ease-out) both; }
.brief-count { font-family: var(--mono); font-size: .82rem; font-weight: 700; letter-spacing: .12em; color: var(--tuscan-sun); direction: ltr; unicode-bidi: isolate; }
.brief-count span { color: var(--on-dark-soft); }
.brief-title { margin: .45rem 0 .4rem !important; font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 800; color: #fff; line-height: 1.35; }
.brief-body { max-width: 30rem; color: var(--on-dark); line-height: 1.85; }

/* Controls */
.brief-controls { align-items: center; gap: 1rem; margin-top: 1.4rem; }
.brief-progress { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.brief-dot { height: 32px; padding: 0; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; }
.brief-dot span { position: relative; display: block; width: 100%; height: 4px; border-radius: 9px; background: rgba(var(--soft-linen-rgb), .16); overflow: hidden; }
.brief-dot span::after { content: ""; position: absolute; inset: 0; background: var(--tuscan-sun); transform: scaleX(0); transform-origin: right; }
[dir="ltr"] .brief-dot span::after { transform-origin: left; }
.brief-dot.is-done span::after { transform: scaleX(1); }
.brief-dot.is-active span::after { animation: fill var(--brief-duration) linear forwards; }
.brief-dot:hover span { background: rgba(var(--soft-linen-rgb), .3); }
.brief-dot:focus-visible { outline: none; }
.brief-dot:focus-visible span { box-shadow: 0 0 0 3px rgba(var(--tuscan-sun-rgb), .6); }
.auth-brief:hover .brief-dot.is-active span::after,
.auth-brief:has(:focus-visible) .brief-dot.is-active span::after,
.auth-brief.is-paused .brief-dot.is-active span::after { animation-play-state: paused; }
.brief-toggle { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--soft-linen); background: rgba(255, 255, 255, .05); border: 1px solid rgba(var(--soft-linen-rgb), .2); font-size: .78rem; transition: background-color .2s; }
.brief-toggle:hover { background: rgba(255, 255, 255, .12); }
.brief-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
.brief-trust { list-style: none; padding: 0; margin: 1.5rem 0 0; flex-wrap: wrap; gap: .5rem 1.4rem; font-size: .82rem; color: var(--on-dark-soft); }
.brief-trust li { display: inline-flex; align-items: center; gap: .5rem; }
.brief-trust li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--tuscan-sun); }

/* ── Short viewports (e.g. 1366×768 laptops ≈ 630px of browser viewport) ─ */
@media (min-width: 992px) and (max-height: 860px) {
    .auth-brief { --art-scale: .92; padding: 2rem 2.5rem 1.75rem; }
    .brief-top { gap: .8rem; }
    .brief-tagline { font-size: .95rem; line-height: 1.7; }
    .brief-caption { min-height: 112px; }
    .brief-title { font-size: 1.35rem; }
    .brief-controls { margin-top: .9rem; }
    .brief-trust { margin-top: 1rem; }
}
@media (min-width: 992px) and (max-height: 740px) {
    .auth-brief { --art-scale: .84; padding: 1.6rem 2.25rem 1.4rem; }
    .brief-top { flex-direction: row; align-items: center; justify-content: space-between; }
    .brief-tagline { max-width: 15rem; font-size: .85rem; line-height: 1.6; text-align: end; }
    .brief-stage { margin: .5rem 0; }
    .brief-caption { min-height: 96px; }
    .brief-title { font-size: 1.2rem; margin: .3rem 0 .25rem !important; }
    .brief-body { font-size: .9rem; line-height: 1.7; }
    .brief-dot { height: 26px; }
    .brief-trust { display: none; }
}
@media (min-width: 992px) and (max-height: 640px) {
    .auth-brief { --art-scale: .76; }
    .brief-caption { min-height: 88px; }
}

/* Form rhythm tightens on short screens; targets stay ≥ 44px */
@media (max-height: 820px) {
    :root { --field-h: 48px; }
    .auth-main { padding-top: 10px; padding-bottom: 12px; }
    .auth-card { padding: .75rem 0 1.25rem; }
    .auth-head { margin-bottom: 1.2rem; }
    .auth-head h1 { font-size: clamp(1.7rem, 3vw, 2.1rem); }
    .auth-head p { margin-top: .35rem; font-size: .95rem; }
    .auth-form { gap: .85rem; }
    .auth-google { height: 48px; }
    .auth-divider { margin: 1rem 0; }
    .field-label { margin-bottom: .3rem; }
    .auth-form .ui-btn--lg { --h: 50px; }
    .auth-switch { margin-top: 1.1rem !important; }
    .auth-badge { margin-bottom: 1rem !important; }
    .auth-foot { padding-top: .5rem; }
}
@media (max-height: 680px) {
    .auth-head { margin-bottom: .9rem; }
    .auth-head h1 { font-size: 1.6rem; }
    .auth-form { gap: .7rem; }
    .auth-divider { margin: .75rem 0; }
    .auth-foot { display: none; }
}

/* ── Keyframes ────────────────────────────────────────────────────────── */
@keyframes fill { to { transform: scaleX(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes write { to { clip-path: inset(0 0 0 0); } }
@keyframes paper-drop { from { opacity: 0; transform: translateY(-26px) rotate(-8deg); } }
@keyframes from-right { from { opacity: 0; transform: translateX(60px) rotate(10deg); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-60px) rotate(-10deg); } }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }
@keyframes converge-r { from { transform: translateY(-50%) rotate(3deg); } to { transform: translate(-22%, -50%) rotate(1.5deg); } }
@keyframes converge-l { from { transform: translateY(-50%) rotate(-3deg); } to { transform: translate(22%, -50%) rotate(-1.5deg); } }
@keyframes scan { 0% { opacity: 0; left: 8%; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; left: 92%; } }
@keyframes match-pop { from { opacity: 0; transform: translateX(-50%) scale(.6); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes stamp { 0% { opacity: 0; transform: scale(1.9) rotate(-28deg); } 60% { opacity: .95; transform: scale(.93) rotate(-13deg); } 100% { opacity: .92; transform: scale(1) rotate(-14deg); } }
@keyframes caption-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Reduced motion: final states, no auto-advance ────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .auth-card, .brief-text.is-active { animation: none; }
    .brief-frame, .brief-frame.is-active { transition: none; }
    .brief-frame.is-active * { animation: none !important; }
    .r-blank path { stroke-dashoffset: 0; }
    .r-note { clip-path: none; }
    .art-arbiter .doc-seller { transform: translate(-22%, -50%) rotate(1.5deg); }
    .art-arbiter .doc-buyer { transform: translate(22%, -50%) rotate(-1.5deg); }
    .art-arbiter .match { opacity: 1; }
    .brief-dot.is-active span::after { animation: none; transform: scaleX(1); }
    .brief-toggle { display: none; }
}

/* ── Room join (guest buyer) ──────────────────────────────────────────── */
.join-steps { display: grid; gap: .6rem; margin: 0 0 1.1rem; padding: 0; list-style: none; counter-reset: j; }
.join-steps li { counter-increment: j; display: flex; gap: .75rem; align-items: flex-start; color: var(--text-muted); font-size: .92rem; line-height: 1.65; }
.join-steps li::before { content: counter(j); width: 26px; height: 26px; flex-shrink: 0; border-radius: 9px; display: grid; place-items: center; background: var(--carbon-black); color: var(--tuscan-sun); font-weight: 800; font-size: .8rem; }
.join-warn { margin-bottom: 1.2rem; }

.join-verified { margin-bottom: 1rem; }
