@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Source+Sans+3:wght@400;500;600&display=swap');

:root {
    --color-bg-dark: #0d0705;
    --color-bg-mid: #1a0f0a;
    --color-bg-accent: #2c1810;
    --color-cream: #faf6f0;
    --color-cream-mid: #f5efe6;
    --color-cream-warm: #f2ebe0;
    --color-brown: #474026;
    --color-brown-dark: #3a331f;
    --color-text: #3d2e26;
    --color-text-muted: #6b5344;
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Source Sans 3', -apple-system, sans-serif;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--color-bg-accent) 0%, var(--color-bg-mid) 50%, var(--color-bg-dark) 100%);
    margin: 0;
    min-height: 100vh;
    padding: 24px;
    color: var(--color-text);
}

.app-header {
    text-align: center;
    margin-bottom: 24px;
}

.app-header img {
    display: block;
    margin: 0 auto;
    width: 72px;
    height: 72px;
    box-shadow: var(--shadow-card);
}

.app-header .footer,
.app-header .tagline {
    padding: 10px 0 0;
    font-size: 24px;
    color: rgba(250, 246, 240, 0.9);
    margin: 0;
    line-height: 1.4;
    font-family: var(--font-display);
    font-style: italic;
}

.card {
    max-width: 560px;
    margin: 0 auto;
    background: linear-gradient(to right, var(--color-cream) 0%, var(--color-cream-mid) 15%, var(--color-cream-warm) 50%, var(--color-cream-mid) 85%, var(--color-cream) 100%);
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(180, 160, 140, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.card-inner {
    position: relative;
    z-index: 1;
    padding: 40px 36px 48px;
}

.card h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 28px;
    color: var(--color-brown);
    margin: 0 0 12px;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.card h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    color: var(--color-brown);
    margin: 0 0 8px;
}

.card p {
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text-muted);
    margin: 0 0 20px;
}

.btn {
    display: inline-block;
    padding: 12px 26px;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    color: var(--color-cream);
    background: var(--color-brown);
    border: 1px solid var(--color-brown-dark);
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn:hover {
    background: var(--color-brown-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.section {
    text-align: center;
    padding: 24px 0;
}

.section:not(:first-child) {
    border-top: 1px solid rgba(61, 46, 38, 0.12);
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(61, 46, 38, 0.15), transparent);
    margin: 0 24px;
}

.footer {
    text-align: center;
    padding: 20px 0 0;
    font-size: 14px;
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-style: italic;
}

/* Story-specific */
.story-hero {
    position: relative;
    width: 100%;
    height: 200px;
    margin: 0 0 24px;
    overflow: hidden;
    border-radius: 8px;
}

.story-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.story-image-fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent 0%, rgba(250, 246, 240, 0.5) 50%, var(--color-cream-warm) 100%);
    pointer-events: none;
}

.story-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.85rem, 4.5vw, 2.35rem);
    color: var(--color-brown);
    margin: 0 0 16px;
    line-height: 1.25;
    text-align: center;
}

.story-lines .story-line {
    font-family: var(--font-display);
    font-size: 20px;
    line-height: 1.7;
    color: var(--color-text);
    margin: 0 0 12px;
}

.story-actions {
    margin-top: 24px;
    text-align: right;
}

.story-content {
    display: block;
}

.story-lines {
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 88%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 88%, transparent 100%);
}

.loading, .error {
    text-align: center;
    color: var(--color-text-muted);
    padding: 48px 0;
    font-size: 17px;
}

/* ========== Landing Page ========== */
.landing-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(to bottom, var(--color-bg-dark) 0%, transparent 100%);
    transition: background 0.3s ease;
}

.landing-nav.scrolled {
    background: rgba(13, 7, 5, 0.95);
    backdrop-filter: blur(8px);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--color-cream);
    font-weight: 600;
    font-size: 18px;
    font-family: var(--font-display);
}

.nav-logo img {
    width: 40px;
    height: 40px;
}

.nav-cta {
    padding: 10px 20px;
    background: var(--color-brown);
    color: var(--color-cream);
    text-decoration: none;
    font-weight: 600;
    border-radius: 8px;
    transition: background 0.2s, transform 0.15s;
}

.nav-cta:hover {
    background: var(--color-brown-dark);
    transform: translateY(-1px);
}

/* Hero */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 120px 24px 80px;
}

.hero-content {
    max-width: 620px;
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5.5vw, 4rem);
    font-weight: 600;
    color: var(--color-cream);
    margin: 0 0 16px;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.hero-tagline {
    font-size: 18px;
    line-height: 1.6;
    color: rgba(250, 246, 240, 0.85);
    margin: 0 0 32px;
}

.btn-hero {
    font-size: 17px;
    padding: 14px 32px;
}

.hero-image-wrap {
    margin-top: 48px;
    max-width: 340px;
}

.hero-app-image {
    width: 100%;
    height: auto;
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4), 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Feature sections */
.feature {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 80px 24px;
}

@media (max-width: 768px) {
    .feature {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 56px 24px;
    }
    .feature-right .feature-image-wrap { order: -1; }
}

.feature-left .feature-image-wrap {
    order: 2;
}

.feature-right .feature-content {
    order: 2;
}

.feature-label {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-cream-mid);
    margin-bottom: 8px;
}

.feature h2 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 600;
    color: var(--color-cream);
    margin: 0 0 16px;
    line-height: 1.3;
}

.feature p {
    font-size: 17px;
    line-height: 1.65;
    color: rgba(250, 246, 240, 0.8);
    margin: 0;
}

.feature-image-wrap {
    position: relative;
}

.feature-image-wrap img {
    width: 100%;
    max-width: 380px;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.feature-image-wrap img {
    display: block;
    margin: 0 auto;
}

/* Download section */
.download-section {
    padding: 80px 24px 100px;
}

.download-inner {
    max-width: 900px;
    margin: 0 auto;
    background: linear-gradient(to right, var(--color-cream) 0%, var(--color-cream-mid) 15%, var(--color-cream-warm) 50%, var(--color-cream-mid) 85%, var(--color-cream) 100%);
    border-radius: 24px;
    padding: 48px 40px 56px;
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.download-inner h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-brown);
    text-align: center;
    margin: 0 0 8px;
}

.download-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 16px;
    margin: 0 0 40px;
}

.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .download-grid {
        grid-template-columns: 1fr;
    }
}

.download-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 28px 20px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    transition: transform 0.25s, box-shadow 0.25s;
    opacity: 0;
}

.download-inner.animate-visible .download-card {
    animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.download-inner.animate-visible .download-card:nth-child(1) { animation-delay: 0.1s; }
.download-inner.animate-visible .download-card:nth-child(2) { animation-delay: 0.2s; }
.download-inner.animate-visible .download-card:nth-child(3) { animation-delay: 0.3s; }

.download-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.download-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.download-card h3 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-brown);
    margin: 0 0 8px;
}

.download-card p {
    flex: 1 1 auto;
    font-size: 14px;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.5;
    width: 100%;
}

.download-card .btn {
    margin-top: 20px;
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.btn-outline {
    background: transparent;
    color: var(--color-brown);
    border: 2px solid var(--color-brown);
}

.btn-outline:hover {
    background: var(--color-brown);
    color: var(--color-cream);
}

/* Footer */
.landing-footer {
    text-align: center;
    padding: 40px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.footer-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.9;
}

.landing-footer p {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 15px;
    color: rgba(250, 246, 240, 0.7);
    margin: 0;
}

.footer-credit {
    margin-top: 12px !important;
    font-size: 13px !important;
    font-style: normal !important;
}

.footer-credit a {
    color: rgba(250, 246, 240, 0.6);
    text-decoration: none;
}

.footer-credit a:hover {
    color: rgba(250, 246, 240, 0.9);
    text-decoration: underline;
}

/* Story page: flex layout to push footer to bottom */
.story-page {
    display: flex;
    flex-direction: column;
}

.story-page .card {
    flex: 1;
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.animate-delay-1 {
    animation-delay: 0.2s;
    opacity: 0;
}

.animate-on-scroll {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.animate-on-scroll.animate-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children for feature sections */
.feature-left .feature-content { transition-delay: 0s; }
.feature-left .feature-image-wrap { transition-delay: 0.15s; }
.feature-right .feature-image-wrap { transition-delay: 0s; }
.feature-right .feature-content { transition-delay: 0.15s; }

/* Mobile: Главная + Каталог (hidden on wider viewports) */
.nav-mobile-primary {
    display: none;
}

/* Book catalog */
.nav-books {
    display: flex;
    align-items: center;
    gap: 8px 20px;
    flex-wrap: wrap;
}

.nav-books a {
    color: rgba(250, 246, 240, 0.75);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-books a:hover {
    color: var(--color-cream);
}

@media (max-width: 768px) {
    .landing-nav {
        flex-wrap: wrap;
        gap: 12px;
    }

    .nav-mobile-primary {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px 20px;
        order: 3;
        width: 100%;
    }

    .nav-books {
        display: none;
    }
}

.books-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.books-main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 100px 24px 64px;
    width: 100%;
}

.books-page h1 {
    font-family: var(--font-display);
    font-size: clamp(2.65rem, 7vw, 4rem);
    font-weight: 600;
    color: var(--color-cream);
    margin: 0 0 12px;
    text-align: center;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

.books-subtitle {
    text-align: center;
    color: rgba(250, 246, 240, 0.65);
    font-size: 16px;
    margin: 0 0 40px;
    line-height: 1.5;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

.book-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: linear-gradient(145deg, var(--color-cream-mid) 0%, var(--color-cream-warm) 100%);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.book-card-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    background: var(--color-bg-accent);
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.book-card-level {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(13, 7, 5, 0.82);
    color: var(--color-cream);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
}

.book-card-body {
    padding: 16px 16px 18px;
}

.book-card-title {
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 2.6vw, 1.35rem);
    font-weight: 600;
    color: var(--color-brown);
    margin: 0;
    line-height: 1.35;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.books-empty {
    text-align: center;
    color: rgba(250, 246, 240, 0.65);
    font-size: 17px;
    padding: 48px 24px;
}

/* Promo video block — full-bleed background; .pal-container constrains content */
.promo-video-section {
    padding: 48px 0 64px;
}

.promo-video-inner {
    text-align: center;
}

.promo-video-heading {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 600;
    color: var(--color-cream);
    margin: 0 0 12px;
    line-height: 1.3;
}

.promo-video-lead {
    font-size: 17px;
    line-height: 1.65;
    color: rgba(250, 246, 240, 0.82);
    margin: 0 0 28px;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.promo-video-frame {
    max-width: 576px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 56px rgba(0, 0, 0, 0.45);
    background: #000;
}

/* Intrinsic 576×1280 (9:20) phone screen capture */
.promo-video {
    display: block;
    width: 100%;
    height: auto;
    max-width: 576px;
    max-height: min(90vh, 1280px);
    margin: 0 auto;
    aspect-ratio: 576 / 1280;
    object-fit: contain;
    background: #000;
}

.promo-video-fallback {
    border-radius: 20px;
    overflow: hidden;
    background: var(--color-bg-accent);
    box-shadow: 0 20px 56px rgba(0, 0, 0, 0.45);
}

.promo-video-fallback-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 576px;
    max-height: min(90vh, 1280px);
    margin: 0 auto;
    aspect-ratio: 576 / 1280;
    object-fit: contain;
    vertical-align: middle;
}

.promo-video-fallback-note {
    margin: 0;
    padding: 16px 20px 20px;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(250, 246, 240, 0.75);
    text-align: center;
}

.promo-video-fallback-note code {
    font-size: 12px;
    color: rgba(250, 246, 240, 0.9);
    word-break: break-all;
}

/* Two-image feature row */
.feature-grid-2 {
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
}

.feature-grid-2 .feature-span-full {
    grid-column: 1 / -1;
    text-align: center;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.feature-grid-2 .feature-span-full p {
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .feature-grid-2 {
        grid-template-columns: 1fr;
    }
    .feature-grid-2 .feature-image-wrap {
        order: 0;
    }
}

/* Home library strip */
.home-library {
    padding: 72px 24px 56px;
}

.home-library-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.home-library-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 600;
    color: var(--color-cream);
    text-align: center;
    margin: 0 0 12px;
    letter-spacing: 0.02em;
}

.home-library-sub {
    text-align: center;
    color: rgba(250, 246, 240, 0.7);
    font-size: 17px;
    line-height: 1.6;
    margin: 0 auto 36px;
    max-width: 560px;
}

.book-grid.home-library-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
    justify-content: center;
    margin-bottom: 8px;
}

.home-library-empty {
    text-align: center;
    color: rgba(250, 246, 240, 0.72);
    font-size: 17px;
    line-height: 1.6;
    padding: 24px 16px 8px;
}

.home-library-empty a {
    color: var(--color-cream-mid);
    font-weight: 600;
}

.home-library-empty a:hover {
    color: var(--color-cream);
}

.home-library-cta {
    text-align: center;
    padding-top: 28px;
}

.book-card-lang {
    display: block;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-top: 8px;
    text-align: center;
}

/* Books hub (/books) */
.books-hub-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.books-hub-main {
    flex: 1;
    max-width: 920px;
    margin: 0 auto;
    padding: 120px 24px 72px;
    width: 100%;
}

.books-hub-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 600;
    color: var(--color-cream);
    text-align: center;
    margin: 0 0 16px;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

.books-hub-lead {
    text-align: center;
    color: rgba(250, 246, 240, 0.72);
    font-size: 18px;
    line-height: 1.65;
    margin: 0 auto 48px;
    max-width: 520px;
}

.books-hub-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
}

@media (max-width: 640px) {
    .books-hub-grid {
        grid-template-columns: 1fr;
    }
}

.books-hub-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 36px 32px 32px;
    border-radius: 20px;
    background: linear-gradient(145deg, var(--color-cream-mid) 0%, var(--color-cream-warm) 100%);
    box-shadow: var(--shadow-card);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    position: relative;
    overflow: hidden;
}

.books-hub-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 80% 0%, rgba(180, 140, 100, 0.12) 0%, transparent 55%);
    pointer-events: none;
}

.books-hub-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.books-hub-card-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.books-hub-card-lang {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 600;
    color: var(--color-brown);
    display: block;
    margin-bottom: 12px;
}

.books-hub-card-desc {
    font-size: 16px;
    line-height: 1.55;
    color: var(--color-text-muted);
    margin: 0 0 24px;
}

.books-hub-card-cta {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-brown);
}
