/**
 * UnifiedDeeplinkService Interstitial Page Styles
 *
 * Two layouts:
 * 1. MCA (Copilot) - Features list + Continue button
 * 2. WXP (Word/Excel/PowerPoint) - Simple install prompt with store badge
 */

/* ═══════════════════════════════════════════════════════════════════════════
   CSS VARIABLES - Design Tokens (matching Figma)
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    /* Brand colors - M365 Primary */
    --color-brand-primary: #464FEB;
    --color-brand-primary-hover: #3940d3;

    /* Neutral colors */
    --color-background: #ffffff;
    --color-surface: #ffffff;
    --color-text-primary: #242424;
    --color-text-secondary: #616161;
    --color-border: #E0E0E0;
    --color-border-light: #EBEBEB;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 40px;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Responsive layout + type scale */
    --page-padding-inline: clamp(14px, 4vw, 24px);
    --page-padding-top: clamp(16px, 2.2vh, 24px);
    --page-padding-bottom: clamp(20px, 3vh, 32px);
    --section-gap: clamp(18px, 3.6vh, 28px);
    --content-gap: clamp(18px, 3.2vh, 24px);
    --layout-max-width: 361px;
    --logo-width: clamp(92px, 29vw, 111px);
    --app-icon-size: clamp(78px, 22vw, 86px);
    --app-icon-inner-size: clamp(54px, 16vw, 60px);
    --title-size: clamp(20px, 5.2vw, 22px);
    --title-line: clamp(26px, 6.7vw, 28px);
    --body-size: clamp(14px, 3.9vw, 15px);
    --body-line: clamp(19px, 5vw, 20px);
    --button-size: clamp(16px, 4.4vw, 17px);
    --button-height: clamp(48px, 6.5vh, 52px);
    --feature-size: clamp(14px, 3.9vw, 15px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESET & BASE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    font-family: var(--font-family);
    font-size: clamp(15px, 3.9vw, 16px);
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */
.interstitial-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--section-gap);
    min-height: 100dvh;
    padding: max(var(--page-padding-top), env(safe-area-inset-top)) var(--page-padding-inline) max(var(--page-padding-bottom), env(safe-area-inset-bottom));
}

.ms-logo-row {
    position: absolute;
    top: max(22px, calc(env(safe-area-inset-top) + 8px));
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-logo {
    width: var(--logo-width);
    height: auto;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT BASE
   ═══════════════════════════════════════════════════════════════════════════ */
.layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(var(--layout-max-width), calc(100vw - (2 * var(--page-padding-inline))));
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTENT CARD
   ═══════════════════════════════════════════════════════════════════════════ */
.content-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
    gap: var(--content-gap);
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP ICON - 86x86px per Figma
   ═══════════════════════════════════════════════════════════════════════════ */
.app-icon {
    width: var(--app-icon-size);
    height: var(--app-icon-size);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    outline: 1px solid var(--color-border);
    outline-offset: -1px;
}

.app-icon img {
    width: var(--app-icon-inner-size);
    height: var(--app-icon-inner-size);
    object-fit: contain;
}

.app-icon svg {
    width: var(--app-icon-inner-size);
    height: var(--app-icon-inner-size);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════ */
.text-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    width: 100%;
}

.title {
    font-size: var(--title-size);
    font-weight: 590;
    line-height: var(--title-line);
    color: var(--color-text-primary);
    margin: 0;
    text-align: center;
}

.message {
    font-size: var(--body-size);
    font-weight: 400;
    line-height: var(--body-line);
    color: var(--color-text-primary);
    margin: 0;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.button-container {
    width: 100%;
}

.primary-button {
    width: 100%;
    height: var(--button-height);
    padding: 0 var(--spacing-md);
    font-size: var(--button-size);
    font-weight: 590;
    font-family: var(--font-family);
    color: white;
    background: var(--color-brand-primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-button:hover {
    background: var(--color-brand-primary-hover);
}

.primary-button:active {
    transform: scale(0.98);
}

.secondary-button {
    padding: 12px 24px;
    font-size: var(--body-size);
    font-weight: 500;
    font-family: var(--font-family);
    color: var(--color-text-primary);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.secondary-button:hover {
    background: var(--color-border-light);
}

/* ═══════════════════════════════════════════════════════════════════════════
   COPILOT LAYOUT - Features Section
   ═══════════════════════════════════════════════════════════════════════════ */
.copilot-layout {
    gap: var(--spacing-xl);
}

.features-section {
    width: 100%;
    background: var(--color-surface);
    outline: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 0 var(--spacing-md);
}

.feature-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) 2px;
    border-bottom: 1px solid var(--color-border-light);
}

.feature-item:last-child {
    border-bottom: none;
}

.feature-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-brand-primary);
}

.feature-icon svg {
    width: 20px;
    height: 20px;
}

.feature-item span {
    flex: 1;
    padding: 6px var(--spacing-sm);
    font-size: var(--feature-size);
    font-weight: 400;
    line-height: var(--body-line);
    color: var(--color-text-primary);
    text-align: left;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WXP LAYOUT - Simple Install Prompt
   ═══════════════════════════════════════════════════════════════════════════ */
.wxp-layout {
    justify-content: center;
    min-height: 80dvh;
}

.wxp-content {
    gap: clamp(24px, 4vh, 32px);
}

.wxp-icon {
    width: clamp(88px, 25vw, 100px);
    height: clamp(88px, 25vw, 100px);
}

.wxp-icon img {
    width: clamp(68px, 20vw, 80px);
    height: clamp(68px, 20vw, 80px);
}

.wxp-icon svg {
    width: clamp(68px, 20vw, 80px);
    height: clamp(68px, 20vw, 80px);
}

.wxp-title {
    font-size: clamp(21px, 6vw, 24px);
    font-weight: 600;
    line-height: clamp(28px, 7.8vw, 32px);
}

/* Store Badge Link */
.store-badge-link {
    display: inline-block;
    text-decoration: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.store-badge-link:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

.store-badge-link:active {
    transform: scale(0.98);
}

.store-badge-img {
    height: clamp(42px, 6.2vh, 48px);
    width: auto;
}

/* Play Store badge needs specific sizing due to extra padding in the image */
#wxp-playstore-badge {
    height: clamp(62px, 9.5vh, 72px);
    margin: clamp(-12px, -1.8vh, -8px) 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ERROR STATE
   ═══════════════════════════════════════════════════════════════════════════ */
.error-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: clamp(16px, 2.8vh, 24px);
    background: #fde7e9;
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 361px;
}

.error-message {
    font-size: 14px;
    color: #a80000;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DIALOG
   ═══════════════════════════════════════════════════════════════════════════ */
.dialog-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    padding: var(--spacing-md);
}

.dialog-content {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.20);
    max-width: 340px;
    width: 100%;
}

.dialog-title {
    font-size: clamp(18px, 4.8vw, 20px);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--color-text-primary);
}

.dialog-message {
    font-size: var(--body-size);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

/* Side by side, translated labels overflow the dialog. */
.dialog-actions-stacked {
    flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAUNCH PROMPT DIALOG (Fluent 2 surface)
   ═══════════════════════════════════════════════════════════════════════════ */
.launch-prompt {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2), 0 32px 64px rgba(0, 0, 0, 0.24);
}

.launch-prompt-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.launch-prompt-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.launch-prompt .dialog-title {
    flex: 1;
    min-width: 0;
    font-size: 20px;
    line-height: 28px;
    margin-bottom: 0;
    overflow-wrap: break-word;
}

.launch-prompt .dialog-message {
    line-height: 20px;
    margin-bottom: 0;
}

/* 6px of the 32px box is padding, so the negative end margin lines the glyph
   up with the surface padding the way Fluent's offset container does. */
.launch-prompt-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    margin-inline: var(--spacing-xs) -6px;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.launch-prompt-close:hover {
    background: var(--color-border-light);
}

.launch-prompt-close svg {
    width: 20px;
    height: 20px;
}

.launch-prompt .dialog-actions {
    padding-top: var(--spacing-xs);
}

.launch-prompt .primary-button,
.launch-prompt .secondary-button {
    width: 100%;
    min-width: 96px;
    /* Design specifies 32px; iOS HIG needs 44px for a touch target. */
    min-height: 44px;
    height: auto;
    padding: 6px var(--spacing-md);
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    border-radius: var(--radius-md);
}

.launch-prompt .secondary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
    .ms-logo-row {
        top: max(16px, calc(env(safe-area-inset-top) + 6px));
    }

    .wxp-title {
        font-size: clamp(20px, 6.4vw, 21px);
        line-height: clamp(27px, 8.2vw, 30px);
    }

    .title {
        font-size: clamp(19px, 5.6vw, 20px);
        line-height: clamp(25px, 7.2vw, 26px);
    }
}

@media (max-height: 760px) {
    .interstitial-container {
        --section-gap: 20px;
        --content-gap: 18px;
    }

    .wxp-layout {
        min-height: 74dvh;
    }
}

@media (max-height: 680px) {
    .interstitial-container {
        --page-padding-top: 12px;
        --page-padding-bottom: 16px;
        --section-gap: 16px;
        --content-gap: 14px;
    }

    .features-section {
        padding: 0 12px;
    }

    .feature-item {
        padding: 6px 2px;
    }

    .wxp-layout {
        min-height: 70dvh;
    }
}

@media (min-width: 430px) {
    :root {
        --layout-max-width: 410px;
        --logo-width: clamp(108px, 25vw, 132px);
        --app-icon-size: clamp(86px, 20vw, 96px);
        --app-icon-inner-size: clamp(60px, 15vw, 68px);
        --title-size: clamp(22px, 4.8vw, 26px);
        --title-line: clamp(28px, 6vw, 34px);
        --body-size: clamp(15px, 3.2vw, 17px);
        --body-line: clamp(21px, 4.4vw, 24px);
        --button-size: clamp(17px, 3.8vw, 19px);
    }
}

@media (min-width: 768px) {
    :root {
        --layout-max-width: 520px;
        --logo-width: clamp(124px, 16vw, 156px);
        --app-icon-size: clamp(96px, 12vw, 112px);
        --app-icon-inner-size: clamp(68px, 8vw, 78px);
        --title-size: clamp(24px, 3vw, 30px);
        --title-line: clamp(32px, 4vw, 38px);
        --body-size: clamp(16px, 2vw, 18px);
        --body-line: clamp(23px, 2.8vw, 27px);
        --button-size: clamp(18px, 2.4vw, 20px);
        --button-height: clamp(52px, 5.4vh, 58px);
        --feature-size: clamp(15px, 2vw, 17px);
    }

    .wxp-content {
        gap: clamp(30px, 4vh, 40px);
    }
}
