/*
 * First-launch introduction cards on the /app sign-in screen.
 *
 * Every rule that affects existing elements is scoped under
 * html.sc-intro-active, which only auth-intro.js sets. Without that class the
 * sign-in screen renders exactly as auth-entrance.css draws it.
 *
 * While the cards are up the entrance turns navy and gold to match the
 * introduction artwork. The existing Google and Email buttons stay where they
 * are (outside the swipeable track) and are only restyled. Opening the email
 * panel adds .is-form to the card, which drops back to the light form layout
 * that the panel was designed for.
 *
 * The carousel is a native CSS scroll-snap track: swipe is the platform's own
 * scroll, so there is no gesture library and nothing to load.
 */

/* New elements: inert unless the introduction is active. */
.sc-intro-taster { display: none; }

html.sc-intro-active {
    --sc-intro-bg: #081530;
    --sc-intro-bg-deep: #050d20;
    --sc-intro-gold: #ecc66a;
    --sc-intro-gold-deep: #d9a63a;
    --sc-intro-text: #f4f6fb;
    --sc-intro-muted: #a3b0c9;
    --sc-intro-tile: rgba(23, 45, 86, 0.55);
    --sc-intro-tile-line: rgba(120, 152, 206, 0.16);
    --sc-intro-dot: #263a60;
    --sc-intro-email: #0b5cc2;
    --sc-intro-email-hover: #0d68d8;
}

/* ── Page surface ────────────────────────────────────────────────────── */

html.sc-intro-active:not(:has(#app-login.is-form)),
html.sc-intro-active:not(:has(#app-login.is-form)) body {
    background: var(--sc-intro-bg-deep);
}

html.sc-intro-active .sc-entrance:not(.is-form) {
    align-items: stretch;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    background:
        radial-gradient(120% 70% at 50% 0%, #0f2147 0%, rgba(15, 33, 71, 0) 70%),
        linear-gradient(180deg, var(--sc-intro-bg) 0%, var(--sc-intro-bg-deep) 100%);
    color: var(--sc-intro-text);
}

html.sc-intro-active .sc-entrance-card:not(.is-form) {
    max-width: 420px;
    justify-content: center;
}

/* The existing brand block gives way to the cards; the SC mark stays. */
html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-title,
html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-tagline,
html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-offer,
html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-copy,
html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-nocard {
    display: none;
}

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-logo {
    --sc-logo: 76px;
    margin: 18px auto 14px;
}

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-logo img {
    filter: drop-shadow(0 6px 18px rgba(236, 198, 106, 0.16));
}

/* The email form keeps its own layout; the cards step aside for it. */
html.sc-intro-active .sc-entrance-card.is-form .sc-intro { display: none !important; }

/* ── Carousel ────────────────────────────────────────────────────────── */

html.sc-intro-active .sc-intro {
    width: 100%;
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
}

.sc-intro-skip {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    z-index: 2;
    min-height: 44px;
    min-width: 56px;
    padding: 0 14px;
    background: none;
    border: 0;
    border-radius: 22px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--sc-intro-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sc-intro-skip:hover { color: var(--sc-intro-text); }

.sc-intro-track {
    display: flex;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
}

.sc-intro-track::-webkit-scrollbar { display: none; }

.sc-intro-slide {
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
}

.sc-intro-title {
    font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    font-weight: 700;
    font-size: clamp(1.85rem, 8.6vw, 2.5rem);
    line-height: 1.05;
    letter-spacing: 0.005em;
    margin: 0 0 12px;
    color: var(--sc-intro-gold);
    background: linear-gradient(180deg, #f6d886 0%, var(--sc-intro-gold) 55%, var(--sc-intro-gold-deep) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sc-intro-features {
    margin: 0 0 14px;
    font-size: clamp(0.95rem, 4.3vw, 1.12rem);
    font-weight: 500;
    line-height: 1.4;
    color: var(--sc-intro-text);
}

.sc-intro-features span { white-space: nowrap; }
/* The separators are where a long feature list wraps. */
.sc-intro-features span[aria-hidden] { white-space: normal; }

.sc-intro-desc {
    margin: 0 auto 18px;
    max-width: 360px;
    font-size: clamp(0.88rem, 3.8vw, 0.98rem);
    line-height: 1.5;
    color: var(--sc-intro-muted);
}

.sc-intro-including {
    margin: -4px 0 12px;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--sc-intro-gold);
}

.sc-intro-tiles {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.sc-intro-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 118px;
    padding: 14px 3px 12px;
    background: var(--sc-intro-tile);
    border: 1px solid var(--sc-intro-tile-line);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    font-size: clamp(0.72rem, 3.3vw, 0.86rem);
    line-height: 1.25;
    color: var(--sc-intro-text);
    overflow-wrap: break-word;
}

.sc-intro-icon {
    width: 40px;
    height: 40px;
    color: var(--sc-intro-gold);
    flex-shrink: 0;
}

.sc-intro-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 16px 0 14px;
}

.sc-intro-dot {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sc-intro-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: var(--sc-intro-dot);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.sc-intro-dot.is-active::after {
    background: var(--sc-intro-gold);
    transform: scale(1.15);
}

.sc-intro-skip:focus-visible,
.sc-intro-dot:focus-visible,
.sc-intro-track:focus-visible {
    outline: 2px solid var(--sc-intro-gold);
    outline-offset: 2px;
}

/* ── The existing auth controls, restyled for the navy surface ───────── */

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-actions {
    max-width: none;
    gap: 12px;
    flex-shrink: 0;
}

html.sc-intro-active .sc-entrance:not(.is-form) .sc-entrance-google.google-signin-btn {
    min-height: 54px;
    border: 0;
    border-radius: 14px;
    font-weight: 600;
    color: #111827;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

html.sc-intro-active .sc-entrance:not(.is-form) #app-email-btn {
    min-height: 54px;
    color: #ffffff;
    background: var(--sc-intro-email);
    border-color: var(--sc-intro-email);
    box-shadow: 0 6px 18px rgba(3, 30, 80, 0.45);
}

html.sc-intro-active .sc-entrance:not(.is-form) #app-email-btn:hover {
    background: var(--sc-intro-email-hover);
}

html.sc-intro-active .sc-entrance:not(.is-form) #app-email-btn svg { color: #ffffff; }

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-intro-taster {
    display: block;
    margin: 4px 0 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--sc-intro-muted);
}

html.sc-intro-active .sc-entrance:not(.is-form) .app-launch-status { color: var(--sc-intro-muted); }
html.sc-intro-active .sc-entrance:not(.is-form) .app-launch-status.auth-error { color: #ff9b9b; }

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-switch {
    margin-top: 2px;
    font-size: 0.86rem;
    color: var(--sc-intro-muted);
}

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-switch .sc-link {
    color: var(--sc-intro-text);
}

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-legal {
    margin-top: 10px;
    font-size: 0.78rem;
}

html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-legal,
html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-legal a {
    color: #7f8ca6;
    text-decoration-color: rgba(127, 140, 166, 0.4);
}

html.sc-intro-active .sc-entrance:not(.is-form) .sc-btn:focus-visible,
html.sc-intro-active .sc-entrance:not(.is-form) .sc-link:focus-visible,
html.sc-intro-active .sc-entrance:not(.is-form) .google-signin-btn:focus-visible,
html.sc-intro-active .sc-entrance:not(.is-form) .sc-entrance-legal a:focus-visible {
    outline-color: var(--sc-intro-gold);
}

/* ── Smaller Android screens ─────────────────────────────────────────── */

@media (max-height: 760px) {
    html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-logo { --sc-logo: 60px; margin: 10px auto 10px; }
    .sc-intro-title { margin-bottom: 8px; }
    .sc-intro-features { margin-bottom: 10px; }
    .sc-intro-desc { margin-bottom: 12px; line-height: 1.42; }
    .sc-intro-tile { min-height: 100px; padding: 10px 4px; gap: 8px; }
    .sc-intro-icon { width: 34px; height: 34px; }
    .sc-intro-dots { margin: 10px 0 10px; }
    html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-actions { gap: 10px; }
    html.sc-intro-active .sc-entrance:not(.is-form) .sc-entrance-google.google-signin-btn,
    html.sc-intro-active .sc-entrance:not(.is-form) #app-email-btn { min-height: 50px; }
}

@media (max-height: 660px) {
    html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-logo { --sc-logo: 48px; margin: 4px auto 8px; }
    .sc-intro-title { font-size: clamp(1.6rem, 7.6vw, 2rem); }
    .sc-intro-desc { font-size: 0.84rem; }
    .sc-intro-tile { min-height: 84px; }
    .sc-intro-icon { width: 28px; height: 28px; }
    html.sc-intro-active .sc-entrance-card:not(.is-form) .sc-entrance-legal { margin-top: 4px; }
}

/* Very short screens: the description is the one piece that can go — the
   title, feature list and tiles still say everything. Nothing is clipped. */
@media (max-height: 640px) {
    .sc-intro-desc { display: none; }
}

@media (max-width: 340px) {
    .sc-intro-tiles { gap: 6px; }
    .sc-intro-tile { font-size: 0.74rem; }
}

@media (prefers-reduced-motion: reduce) {
    .sc-intro-track { scroll-behavior: auto; }
    .sc-intro-dot::after { transition: none; }
}
