/* /assets/css/app.css
   Global styles for myStoryVault
   Uses Bootstrap 5.3 palette only - no custom colors */

/* Sticky footer: push footer to bottom on short pages */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

/* App links: no underline until hover (story text keeps underlines - see .prose a) */
main :where(a:not(.btn, .badge, .list-group-item, .dropdown-item, .page-link, .nav-link)) {
    text-decoration: none;
}

main :where(a:not(.btn, .badge, .list-group-item, .dropdown-item, .page-link, .nav-link)):hover {
    text-decoration: underline;
}

a.badge {
    text-decoration: none;
}

/* ---------- Page scaffolding ---------- */

/* Page heading - hidden on phones, where the top bar already shows the page title */
.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

@media (max-width: 991.98px) {
    .page-title { display: none; }
}

/* Readable single-column pages (feed, forms) */
.page-narrow {
    max-width: 44rem;
    margin: 0 auto;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.section-title .bi {
    color: var(--bs-primary-text-emphasis);
    margin-right: 0.25rem;
}

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--bs-secondary-color);
    background: var(--bs-tertiary-bg);
    border-radius: var(--bs-border-radius-lg);
}

.empty-state > .bi {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--bs-tertiary-color);
}

/* ---------- Book tiles (BookCard) ---------- */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.75rem 1.25rem;
}

@media (max-width: 575.98px) {
    .book-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem 0.875rem;
    }
}

.book-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.book-cover {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 0.5rem;
    background: var(--bs-secondary-bg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.10);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-card:hover .book-cover {
    transform: translateY(-3px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 12px 24px rgba(0, 0, 0, 0.16);
}

/* Cover placeholder when the author hasn't uploaded one */
.book-cover-blank {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 100%;
    padding: 1rem;
    background: linear-gradient(160deg, var(--bs-primary-bg-subtle), var(--bs-secondary-bg));
    color: var(--bs-emphasis-color);
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.2;
}

.book-flag {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
}

.book-parts {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-weight: 500;
}

.book-meta {
    padding-top: 0.6rem;
    min-width: 0;
}

.book-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 600;
    line-height: 1.3;
    color: var(--bs-emphasis-color);
}

.book-author {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-blurb {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0.35rem 0 0;
    font-size: 0.825rem;
    color: var(--bs-secondary-color);
}

.book-stats {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-size: 0.775rem;
    color: var(--bs-tertiary-color);
}

@media (max-width: 575.98px) {
    .book-blurb { display: none; }
}

/* ---------- Shelves (BookShelf): horizontal scrolling rows ---------- */
.shelf {
    margin-bottom: 2.25rem;
}

.shelf-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.875rem;
}

.shelf-more {
    font-size: 0.9rem;
    font-weight: 500;
}

.book-shelf {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 140px;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 0.25rem 0.25rem 0.75rem;
    margin: -0.25rem -0.25rem 0;
    scrollbar-width: thin;
}

.book-shelf > .book-card {
    scroll-snap-align: start;
}

@media (min-width: 992px) {
    .book-shelf { grid-auto-columns: 168px; gap: 1.25rem; }
}

/* ---------- Home ---------- */
.home-hello {
    margin-bottom: 1.75rem;
}

.home-hero {
    margin-bottom: 2.25rem;
    padding: 3rem 2.5rem;
    border-radius: var(--bs-border-radius-xl);
    background: linear-gradient(135deg, var(--bs-primary-bg-subtle), var(--bs-tertiary-bg) 70%);
    border: 1px solid var(--bs-border-color-translucent);
}

@media (max-width: 575.98px) {
    .home-hero { padding: 2rem 1.25rem; }
    .home-hero .display-6 { font-size: 1.75rem; }
}

.home-hero-text {
    max-width: 40rem;
}

.resume-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

@media (max-width: 575.98px) {
    .resume-grid { grid-template-columns: minmax(0, 1fr); }
}

.resume-grid > * {
    min-width: 0;   /* let long titles ellipsize instead of widening the page */
}

.resume-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.resume-card:hover {
    border-color: var(--bs-primary-border-subtle);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

main a.resume-card:hover {
    text-decoration: none;
}

.resume-cover {
    flex-shrink: 0;
    width: 52px;
    aspect-ratio: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.375rem;
    background: var(--bs-secondary-bg);
    color: var(--bs-tertiary-color);
}

.resume-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.resume-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.resume-title {
    font-weight: 600;
    color: var(--bs-emphasis-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resume-sub {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resume-progress {
    height: 4px;
    margin: 0.2rem 0;
}

.resume-go {
    font-size: 1.75rem;
    color: var(--bs-primary);
    flex-shrink: 0;
}

.write-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    margin-top: 0.5rem;
    border-radius: var(--bs-border-radius-lg);
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color-translucent);
}

/* ---------- Story / chapter pages ---------- */
.reader-page {
    max-width: 46rem;
    margin: 0 auto;
}

.reader-topline {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.chapter-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.story-hero {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1.75rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.story-hero-cover {
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 12px 28px rgba(0, 0, 0, 0.18);
}

.story-hero-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 0.5rem;
}

.story-tagline {
    font-size: 1.1rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.75rem;
}

.story-author {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.story-badges,
.story-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.story-tags {
    margin-bottom: 1.5rem;
}

.story-synopsis {
    font-size: 1.05rem;
    line-height: 1.65;
    padding-left: 1rem;
    border-left: 3px solid var(--bs-primary-border-subtle);
    margin-bottom: 1rem;
}

@media (max-width: 575.98px) {
    .story-hero {
        grid-template-columns: 112px 1fr;
        gap: 1rem;
        align-items: start;
    }
    .story-title { font-size: 1.4rem; }
    .story-tagline { font-size: 0.95rem; }
    .chapter-title { font-size: 1.5rem; }
}

.engagement-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    margin: 1.5rem 0;
    border-top: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
}

.engagement-actions {
    display: flex;
    gap: 0.25rem;
}

/* ---------- Activity feed ---------- */
.feed-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.feed-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--bs-secondary-color);
}

.feed-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feed-body {
    flex: 1;
    min-width: 0;
}

.feed-text a {
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

.feed-time {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

.feed-time .bi {
    margin-right: 0.15rem;
}

.feed-cover {
    flex-shrink: 0;
    width: 40px;
    aspect-ratio: 2 / 3;
    border-radius: 0.25rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.feed-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Profile ---------- */
.profile-card .rounded-circle {
    box-shadow: 0 0 0 4px var(--bs-body-bg), 0 0 0 5px var(--bs-border-color);
}

/* Active theme option indicator (segmented buttons in the More sheet use Bootstrap's .btn.active) */
.dropdown-item.theme-option.active {
    font-weight: 600;
}

.dropdown-item.theme-option.active::before {
    content: '\2713 ';
}

/* ---------- App shell: top bar, phone tab bar, More sheet ---------- */
:root {
    --app-topbar-h: 56px;
    --app-tabbar-h: 64px;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    padding-top: env(safe-area-inset-top);
}

.app-topbar-in {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--app-topbar-h);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    font-size: 1.35rem;
    color: var(--bs-body-color);
    text-decoration: none;
}

.app-brand-name {
    display: none;
    font-size: 1.25rem;
}

.app-page-title {
    min-width: 0;
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-desk-nav {
    align-self: stretch;
    gap: 0.25rem;
    margin-left: 1rem;
}

.app-desk-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.75rem;
    color: var(--bs-secondary-color);
}

.app-desk-nav .nav-link:hover {
    color: var(--bs-body-color);
}

.app-desk-nav .nav-link.active {
    color: var(--bs-primary-text-emphasis);
    box-shadow: inset 0 -3px 0 var(--bs-primary);
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
}

@media (min-width: 992px) {
    :root { --app-topbar-h: 64px; }
    .app-brand-name { display: inline; }
}

/* Phone bottom tab bar */
.app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    height: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
}

.app-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.app-tab-ico {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 32px;
    border-radius: 16px;
    font-size: 1.375rem;
    transition: background-color 0.15s ease;
}

.app-tab.active {
    color: var(--bs-primary-text-emphasis);
}

.app-tab.active .app-tab-ico {
    background: var(--bs-primary-bg-subtle);
}

@media (max-width: 991.98px) {
    body {
        padding-bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom));
    }
}

/* More sheet: Bootstrap modal that slides up from the bottom on phones */
.app-sheet-label {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
}

@media (max-width: 991.98px) {
    .modal.app-sheet .modal-dialog {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        max-width: none;
        margin: 0;
        transform: translateY(100%);
        transition: transform 0.25s ease-out;
    }

    .modal.app-sheet.show .modal-dialog {
        transform: none;
    }

    .modal.app-sheet .modal-content {
        max-height: 92dvh;
        border: 0;
        border-radius: 1.25rem 1.25rem 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .modal.app-sheet .modal-content::before {
        content: '';
        align-self: center;
        width: 40px;
        height: 4px;
        margin-top: 0.5rem;
        border-radius: 2px;
        background: var(--bs-border-color);
    }

    .modal.app-sheet .modal-body {
        overflow-y: auto;
    }
}

/* Toasts (ui.js msvToast) - kept above the phone tab bar */
.msv-toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(360px, calc(100vw - 2rem));
}

@media (max-width: 991.98px) {
    .msv-toast-container {
        bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom) + 1rem);
    }
}

/* Prose — reader typography for content body */
.prose {
    line-height: 1.8;
    font-size: 1.05rem;
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.prose p {
    margin-bottom: 1em;
}

main .prose a {
    text-decoration: underline;
}

.prose ul, .prose ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

.prose blockquote {
    border-left: 3px solid var(--bs-border-color);
    margin-left: 0;
    padding-left: 1em;
    color: var(--bs-secondary-color);
}

.prose pre {
    background: var(--bs-tertiary-bg);
    padding: 1em;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin-bottom: 1em;
}

.prose code {
    background: var(--bs-tertiary-bg);
    padding: 0.15em 0.35em;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.prose pre code {
    background: none;
    padding: 0;
}

.prose hr {
    margin: 2em 0;
}

/* Reader font size classes */
.prose.reader-fs-small { font-size: 0.9rem; }
.prose.reader-fs-medium { font-size: 1.05rem; }
.prose.reader-fs-large { font-size: 1.2rem; }
.prose.reader-fs-xlarge { font-size: 1.4rem; }

/* Reader line height classes */
.prose.reader-lh-compact { line-height: 1.4; }
.prose.reader-lh-normal { line-height: 1.8; }
.prose.reader-lh-relaxed { line-height: 2.2; }

/* Reader font family classes */
.prose.reader-ff-serif { font-family: Georgia, 'Times New Roman', serif; }
.prose.reader-ff-sans { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* Focus mode — dim everything except content */
body.reader-focus > .app-topbar,
body.reader-focus > .app-tabbar,
body.reader-focus > footer {
    opacity: 0.15;
    transition: opacity 0.3s ease;
}

body.reader-focus > .app-topbar:hover,
body.reader-focus > .app-tabbar:hover,
body.reader-focus > footer:hover {
    opacity: 1;
}

body.reader-focus > main {
    max-width: 750px;
    margin-left: auto;
    margin-right: auto;
}

/* Reader toolbar — responsive hide on mobile */
@media (max-width: 575.98px) {
    .reader-toolbar .btn-group {
        display: none;
    }
    .reader-toolbar #readerFocusBtn {
        display: none;
    }
}

/* Quill editor container */
#quillEditor {
    min-height: 300px;
}

/* Profile page */
.profile-avatar img {
    width: 120px;
    height: 120px;
    object-fit: cover;
}

/* Utility classes referenced in markup but not provided by Bootstrap (finding U21) */
.min-width-0 {
    min-width: 0;
}

.form-label-sm {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}
