/* ============================================================
   Dourak — install-guide.css
   Shared styles for the in-app Add-to-Home-Screen guide.
   RTL-first, touch-first, safe-area aware, token-driven so the
   sheet inherits the existing dark/light palette of each surface.
   No external assets, no fonts beyond the app's own icons.
   ============================================================ */

.ig-root {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay, 10000);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

.ig-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.66);
    opacity: 0;
    transition: opacity 220ms ease;
}

.ig-root.is-open .ig-backdrop {
    opacity: 1;
}

.ig-sheet {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: 92vh;
    max-height: min(92dvh, 780px);
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--color-card, #171717);
    color: var(--color-text, #F1E4CC);
    border: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    box-shadow: var(--shadow-lg, 0 24px 60px rgba(0, 0, 0, 0.45));
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.25, 0.6, 0.3, 1);
}

.ig-root.is-open .ig-sheet {
    transform: none;
}

.ig-handle {
    width: 36px;
    height: 4px;
    margin: var(--space-3, 12px) auto 0;
    border-radius: var(--radius-pill, 999px);
    background: var(--color-border-strong, rgba(168, 121, 69, 0.30));
    flex: 0 0 auto;
}

.ig-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2, 8px);
    padding: var(--space-2, 8px) var(--space-5, 20px);
}

.ig-title {
    margin: 0;
    font-size: var(--fs-lg, 1.15rem);
    font-weight: var(--fw-extrabold, 800);
    line-height: 1.35;
}

.ig-close {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: var(--radius-pill, 999px);
    background: var(--color-overlay, rgba(241, 228, 204, 0.14));
    color: var(--color-text-secondary, #CDBFA7);
    font-size: 1.15rem;
    cursor: pointer;
}

.ig-close:active {
    transform: scale(0.94);
}

.ig-body {
    padding: 0 var(--space-5, 20px) var(--space-4, 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    gap: var(--space-4, 16px);
}

.ig-intro {
    margin: 0;
    color: var(--color-text-secondary, #CDBFA7);
    font-size: var(--fs-sm, 0.9rem);
    line-height: 1.7;
    overflow-wrap: anywhere;
}

/* ---- Local, dependency-free Safari illustration ---- */
.ig-browser {
    position: relative;
    border: 1px solid var(--color-border-strong, rgba(168, 121, 69, 0.30));
    border-radius: 16px;
    background: var(--color-bg, #0B0B0B);
    overflow: hidden;
    padding-bottom: 6px;
}

.ig-browser-bar {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-inline: 12px;
    background: var(--color-surface, #171717);
    border-bottom: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
}

.ig-browser-dots {
    width: 34px;
    height: 8px;
    border-radius: 999px;
    background: radial-gradient(circle at 3px 4px, var(--color-text-muted, #7d7466) 2px, transparent 2.5px),
                radial-gradient(circle at 17px 4px, var(--color-text-muted, #7d7466) 2px, transparent 2.5px),
                radial-gradient(circle at 31px 4px, var(--color-text-muted, #7d7466) 2px, transparent 2.5px);
}

.ig-browser-url {
    flex: 1;
    max-width: 150px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--color-text-muted, #9b9182);
    border: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
    border-radius: 999px;
    padding: 2px 8px;
}

.ig-browser-page {
    min-height: 108px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px 30px;
}

.ig-browser-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, #18507E 0%, #0B2B45 100%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.ig-browser-line {
    width: 72%;
    height: 7px;
    border-radius: 999px;
    background: var(--color-overlay, rgba(241, 228, 204, 0.14));
}

.ig-browser-line-short {
    width: 46%;
}

.ig-share {
    /* Deliberately centered: the illustration is a symbol legend, not a map
       of the real toolbar. Real Share position varies by browser/orientation. */
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    max-width: calc(100% - 24px);
    min-width: 88px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--color-primary, #5A1118);
    border: 2px solid var(--color-accent, #A87945);
    color: var(--color-text-inverse, #F1E4CC);
    font-size: 0.82rem;
    font-weight: var(--fw-bold, 700);
    box-shadow: 0 0 0 5px rgba(168, 121, 69, 0.18);
    animation: ig-pulse 1.8s ease-in-out infinite;
}

.ig-share .bi {
    font-size: 1.15rem;
}

@keyframes ig-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(168, 121, 69, 0.14); }
    50% { box-shadow: 0 0 0 9px rgba(168, 121, 69, 0.04); }
}

/* ---- Steps ---- */
.ig-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 12px);
}

.ig-step {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3, 12px);
    padding: var(--space-3, 12px);
    border: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
    border-radius: 14px;
    background: var(--color-surface, #171717);
}

.ig-step-num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--color-primary, #5A1118);
    color: var(--color-text-inverse, #F1E4CC);
    font-size: var(--fs-xs, 0.78rem);
    font-weight: var(--fw-bold, 700);
}

.ig-step-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--color-primary-light, rgba(117, 28, 36, 0.26));
    color: var(--color-primary-tint-text, #E8B4B8);
    font-size: 1.1rem;
}

.ig-step-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ig-step-title {
    font-size: var(--fs-sm, 0.9rem);
    font-weight: var(--fw-bold, 700);
    line-height: 1.5;
}

.ig-step-text {
    color: var(--color-text-secondary, #CDBFA7);
    font-size: var(--fs-xs, 0.78rem);
    line-height: 1.6;
}

.ig-note {
    margin: 0;
    padding: var(--space-2, 8px) var(--space-3, 12px);
    border-radius: 12px;
    background: var(--color-warning-light, rgba(232, 163, 61, 0.14));
    color: var(--color-warning-text, #F0B75C);
    font-size: var(--fs-xs, 0.78rem);
    line-height: 1.6;
}

.ig-actions {
    padding: var(--space-3, 12px) var(--space-5, 20px) calc(var(--space-5, 20px) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
    background: var(--color-card, #171717);
}

.ig-done {
    width: 100%;
    min-height: 48px;
    border: none;
    border-radius: var(--radius-md, 12px);
    background: var(--color-primary, #5A1118);
    color: var(--color-text-inverse, #F1E4CC);
    font-family: inherit;
    font-size: var(--fs-base, 1rem);
    font-weight: var(--fw-bold, 700);
    cursor: pointer;
}

.ig-done:active {
    transform: scale(0.99);
}

.ig-close:focus-visible,
.ig-done:focus-visible {
    outline: 2px solid var(--color-accent, #A87945);
    outline-offset: 2px;
}

/* Small iPhones (SE / 12 mini): tighten spacing, keep touch targets intact. */
@media (max-width: 360px) {
    .ig-head { padding-inline: var(--space-4, 16px); }
    .ig-body { padding-inline: var(--space-4, 16px); gap: var(--space-3, 12px); }
    .ig-actions { padding-inline: var(--space-4, 16px); }
    .ig-step { gap: var(--space-2, 8px); padding: var(--space-2, 8px); }
}

/* iPad: center the sheet as a card so it does not stretch across the screen. */
@media (min-width: 600px) {
    .ig-root { align-items: center; padding-block: 24px; }
    .ig-sheet {
        max-width: 480px;
        max-height: 86vh;
        max-height: min(86dvh, 720px);
        border-radius: 24px;
        border-bottom: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
    }
    .ig-handle { display: none; }
}

/* Landscape / short viewport: keep the sheet usable without hiding content.
   The body remains the only scroll container; touch targets stay >= 44px. */
@media (orientation: landscape) and (max-height: 560px) {
    .ig-root {
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .ig-sheet {
        max-width: 720px;
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
        border-radius: 20px;
        border-bottom: 1px solid var(--color-border, rgba(168, 121, 69, 0.18));
    }
    .ig-handle { display: none; }
    .ig-head { padding-block: 6px; }
    .ig-body {
        gap: var(--space-2, 8px);
        padding-bottom: var(--space-2, 8px);
    }
    .ig-browser-page { min-height: 64px; padding: 8px 16px 24px; }
    .ig-browser-logo { width: 34px; height: 34px; border-radius: 10px; }
    .ig-browser-line { height: 5px; }
    .ig-share { bottom: 6px; min-height: 44px; }
    .ig-steps {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    .ig-step { padding: var(--space-2, 8px); }
    .ig-actions {
        padding-top: var(--space-2, 8px);
        padding-bottom: calc(var(--space-2, 8px) + env(safe-area-inset-bottom, 0px));
    }
    .ig-done { min-height: 44px; }
}

/* Long translated strings must wrap at any system font scale. */
.ig-step-title,
.ig-step-text,
.ig-note {
    overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
    .ig-root .ig-backdrop,
    .ig-root .ig-sheet,
    .ig-share { transition: none; animation: none; }
}
