/* ═══════════════════════════════════════════
   style.css — WebAR «Оживающая книга»
   AuthKit-inspired: frosted glass cathedral at midnight
   ═══════════════════════════════════════════ */

/* ── Токены дизайн-системы ── */
:root {
    /* Surfaces */
    --surface-midnight: #05060f;
    --surface-steel: #2f343e;
    --surface-frosted: rgba(186, 214, 247, 0.03);
    --surface-deep-glass: rgba(5, 6, 15, 0.97);

    /* Text hierarchy: Ice Highlight → Frost Glow → Moon Mist → Fog Veil */
    --text-headline: #d8ecf8;
    --text-body: #d1e4fa;
    --text-muted: #c7d3ea;
    --text-helper: #9da7ba;
    --text-white: #ffffff;

    /* Accent — единственный хроматический цвет */
    --accent: #663af3;
    --accent-hover: #7b5cf7;

    /* Secondary accents (только для decorative swatches) */
    --blueprint-blue: #b6d9fc;
    --ember-glow: #e46d4c;
    --signal-blue: #027dea;
    --deep-teal: #269684;

    /* Borders & fills */
    --hairline: rgba(186, 215, 247, 0.12);
    --frost-wash: rgba(186, 214, 247, 0.06);
    --frost-wash-hover: rgba(186, 214, 247, 0.12);
    --input-fill: rgba(199, 211, 234, 0.06);
    --badge-fill: rgba(199, 211, 234, 0.12);
    --focus-ring: rgba(186, 215, 247, 0.24);

    /* Glass shadows — elevation через inset glow + dark halo */
    --shadow-card: inset 0 1px 1px rgba(199, 211, 234, 0.12),
                   inset 0 24px 48px rgba(199, 211, 234, 0.05),
                   0 24px 32px rgba(6, 6, 14, 0.7);
    --shadow-modal: inset 0 1px 1px rgba(216, 236, 248, 0.2),
                    inset 0 24px 48px rgba(168, 216, 245, 0.06),
                    0 16px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 6px rgba(186, 207, 247, 0.32),
                   0 0 12px rgba(238, 186, 247, 0.24);

    /* Radius — Do: buttons=pills, cards=16px, badges/inputs=6px, icons=circle */
    --radius-card: 16px;
    --radius-input: 6px;
    --radius-badge: 6px;
    --radius-pill: 999px;
    --radius-circle: 9999px;

    /* Typography — substitutes for AuthKit fonts */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    /* Type scale */
    --text-caption: 12px;
    --text-body-sm: 14px;
    --text-body: 16px;
    --text-subheading: 18px;
    --text-heading-sm: 24px;
    --text-heading: 28px;
    --text-display: 44px;

    /* Spacing (4px base unit) */
    --space-4: 4px;
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-20: 20px;
    --space-24: 24px;
    --space-32: 32px;
    --space-40: 40px;
    --space-48: 48px;
    --space-56: 56px;
}

/* ── Сброс и база ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    font-family: var(--font-body);
    font-size: var(--text-body);
    color: var(--text-body);
    background: var(--surface-midnight);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Background atmosphere: blueprint grid + spotlight ── */
body::before {
    content: '';
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(186, 215, 247, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(186, 215, 247, 0.06) 1px, transparent 1px);
    background-size: 80px 80px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 30%, transparent 70%);
}

/* Spotlight halo */
body::after {
    content: '';
    position: fixed; top: 0; left: 50%; transform: translateX(-50%);
    width: 800px; height: 600px; z-index: 0; pointer-events: none;
    background: conic-gradient(
        at 50% -5%,
        transparent 40%,
        rgba(124, 145, 182, 0.15) 48%,
        rgba(124, 145, 182, 0.3) 50%,
        rgba(124, 145, 182, 0.15) 52%,
        transparent 60%
    );
    opacity: 0.6;
}

/* ── Контейнер приложения ── */
#app {
    width: 100%; height: 100%; position: relative; z-index: 1;
}

/* ── Экраны ── */
.screen {
    position: absolute; inset: 0; display: none;
    flex-direction: column; align-items: center; justify-content: center;
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active { display: flex; }

/* ── Стартовый экран: glass card ── */
#start-screen {
    background: var(--surface-midnight);
}

.screen-content {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    max-width: 380px; width: 100%; gap: var(--space-20);
    background: var(--surface-deep-glass);
    border-radius: var(--radius-card);
    padding: var(--space-32) var(--space-24);
    box-shadow: var(--shadow-modal);
    border: none;
    position: relative;
}

/* Hairline inset border via pseudo-element (не нарушает border-radius) */
.screen-content::before {
    content: ''; position: absolute; inset: 0; border-radius: var(--radius-card);
    box-shadow: inset 0 1px 0 rgba(216, 236, 248, 0.15);
    pointer-events: none;
}

.logo-area {
    display: flex; flex-direction: column; align-items: center; gap: var(--space-12);
}

.logo-icon {
    font-size: 56px;
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-circle);
    background: var(--frost-wash);
    box-shadow: var(--shadow-glow);
}

/* Skywash gradient heading */
h1 {
    font-family: var(--font-display);
    font-size: var(--text-display);
    font-weight: 500;
    line-height: 1.16;
    letter-spacing: -0.5px;
    background: linear-gradient(0deg, #d8ecf8 0%, #98c0ef 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.description {
    font-size: var(--text-body);
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 300px;
}

/* ── Pill buttons ── */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 200px; padding: 12px 32px;
    border: none; border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--text-white);
    font-family: var(--font-body);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    box-shadow: 0 0 0 1px rgba(186, 215, 247, 0.12) inset,
                0 4px 16px rgba(102, 58, 243, 0.3);
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 0 0 1px rgba(186, 215, 247, 0.12) inset,
                0 2px 8px rgba(102, 58, 243, 0.2);
}

.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 160px; padding: 12px 28px;
    border-radius: var(--radius-pill);
    background: var(--frost-wash);
    color: var(--text-white);
    font-family: var(--font-body);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: inset 0 0 0 1px var(--hairline);
    min-height: 44px;
    border: none;
}

.btn-secondary:hover { background: var(--frost-wash-hover); }
.btn-secondary:active { background: rgba(186, 214, 247, 0.08); }

/* ── Инструкции ── */
.instructions {
    display: flex; flex-direction: column; gap: var(--space-4);
    width: 100%;
    padding: var(--space-12) 0;
}

.instruction-text {
    font-size: var(--text-body-sm);
    color: var(--text-body);
}

.instruction-sub {
    font-size: var(--text-caption);
    color: var(--text-helper);
}

/* ── Приватность ── */
.privacy-note {
    font-size: 11px;
    color: var(--text-helper);
    line-height: 1.5;
    margin-top: var(--space-8);
}

.privacy-link {
    font-size: var(--text-caption);
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--frost-wash);
    box-shadow: inset 0 0 0 1px var(--hairline);
    transition: background 0.15s;
}

.privacy-link:hover { background: var(--frost-wash-hover); }

/* ── Экран загрузки ── */
#loading-screen { background: var(--surface-midnight); }

.spinner {
    width: 48px; height: 48px;
    border: 3px solid var(--hairline);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
    font-size: var(--text-body);
    color: var(--text-muted);
}

.progress-bar {
    width: 100%; max-width: 260px; height: 4px;
    background: var(--frost-wash);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    width: 0%; height: 100%;
    background: var(--accent);
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: var(--text-body-sm);
    color: var(--text-helper);
}

/* ── Экран ошибки ── */
#camera-error-screen,
#webgl-error-screen {
    background: var(--surface-midnight);
}

.error-icon {
    font-size: 56px; margin-bottom: var(--space-8);
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-circle);
    background: var(--frost-wash);
}

#camera-error-screen h2,
#webgl-error-screen h2 {
    font-family: var(--font-display);
    font-size: var(--text-heading-sm);
    font-weight: 500;
    color: var(--text-headline);
}

#camera-error-screen p,
#webgl-error-screen p {
    font-size: var(--text-body-sm);
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 300px;
}

.error-actions {
    display: flex; gap: var(--space-12); margin-top: var(--space-8);
}

/* ── Справка ── */
.help-details {
    margin-top: var(--space-12);
    width: 100%; max-width: 300px; text-align: left;
}

.help-details summary {
    font-size: var(--text-body-sm);
    color: var(--text-helper);
    cursor: pointer;
    padding: var(--space-8) 0;
}

.help-content {
    font-size: var(--text-caption);
    color: var(--text-muted);
    padding: var(--space-8) 0;
    line-height: 1.6;
}

.help-content p { margin: 4px 0; }

/* ── AR-экран ── */
#ar-screen { background: #000; padding: 0; }

#ar-iframe { width: 100%; height: 100%; border: none; }

/* ── Адаптивность ── */

@media (orientation: landscape) {
    .screen-content { max-width: 480px; gap: var(--space-12); }
    h1 { font-size: 36px; }
    .logo-icon { font-size: 40px; width: 56px; height: 56px; }
    .btn-primary { padding: 10px 24px; font-size: 14px; }
}

@media (max-width: 374px) {
    .screen { padding: 12px 10px; }
    .screen-content { padding: var(--space-20) var(--space-16); }
    h1 { font-size: 24px; }
    .description { font-size: 13px; }
    .btn-primary { min-width: 140px; padding: 10px 20px; font-size: 14px; min-height: 44px; }
    .btn-secondary { min-height: 44px; padding: 10px 18px; font-size: 13px; }
    .logo-icon { font-size: 40px; width: 56px; height: 56px; }
    .instruction-text { font-size: var(--text-caption); }
    .instruction-sub { font-size: 10px; }
    .screen-content { gap: var(--space-12); }
    .privacy-note { font-size: 10px; }
}

@media (min-width: 375px) and (max-width: 428px) {
    .screen { padding: 20px 16px; }
    .btn-primary { min-height: 44px; }
    .btn-secondary { min-height: 44px; }
}

@media (min-width: 768px) {
    .screen-content { max-width: 440px; }
    h1 { font-size: 48px; }
    .description { font-size: var(--text-subheading); }
}

/* ── Анимации ── */
.screen.active { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Доступность ── */
@media (prefers-reduced-motion: reduce) {
    .screen.active { animation: none; }
    .spinner { animation: none; border-top-color: rgba(255,255,255,0.3); }
    .btn-primary { transition: none; }
}
