/* ========================================
   CHRISTIAN HYMN SONGBOOK APP - COMPLETE REDESIGN
   Modern, Clean, Impressive - Mobile First
   ======================================== */

:root {
    --primary: #1a73e8;
    --primary-light: #5b9ef5;
    --primary-dark: #004bb3;
    --accent: #f57c00;
    --success: #00897b;
    --text-dark: #202124;
    --text-light: #5f6368;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e8eaed;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.12);
    --shadow-large: 0 8px 24px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    min-height: 100dvh;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(160deg, #e8f4fc 0%, #ddeef8 40%, #eaf6fb 70%, #f0f8ff 100%);
    background-attachment: fixed;
    color: var(--text-dark);
}

/* ========================================
   LAYOUT
   ======================================== */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Decorative background shapes */
.app-container::before,
.app-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.app-container::before {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(46,139,192,0.08) 0%, transparent 70%);
    top: -100px;
    right: -150px;
}

.app-container::after {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(46,139,192,0.06) 0%, transparent 70%);
    bottom: -80px;
    left: -100px;
}

.app-header {
    background: linear-gradient(135deg, #3a9fd4 0%, #2e8bc0 50%, #1f6f9f 100%);
    color: white;
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-medium);
    flex-shrink: 0;
}

.app-header-home-link {
    cursor: pointer;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.app-title {
    font-size: 1.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}

.app-title i {
    font-size: 1.6rem;
}

.app-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 300;
}

.app-main {
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;
    min-height: 0;
}

/* ========================================
   STEP SECTIONS
   ======================================== */

.step-section {
    display: none;
    height: 100%;
    overflow: hidden;
    flex-direction: column;
    will-change: transform;
    min-height: 0;
}

.step-section.active {
    display: flex;
}

html.songapp-hash-book #step-home,
html.songapp-hash-song #step-home,
html.songapp-hash-song #step-songs {
    display: none;
}

html.songapp-hash-book #step-songs,
html.songapp-hash-song #step-lyrics {
    display: flex;
}

#step-lyrics {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.step-header {
    padding: 20px 16px;
    background: rgba(224,242,251,0.92);
    border-bottom: 1px solid rgba(46,139,192,0.15);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    z-index: 10;
    flex-shrink: 0;
    position: relative;
}

.step-header h2 {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin: 0;
    flex: 1;
    min-width: 200px;
}

.step-header p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0;
    width: 100%;
}

/* ========================================
   HOME LANDING
   ======================================== */

#step-home {
    overflow-y: auto;
}

.home-hero {
    min-height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 420px);
    gap: 32px;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 24px 56px;
}

.home-copy {
    position: relative;
    z-index: 1;
}

.home-kicker {
    font-size: clamp(1.2rem, 2.8vw, 1.9rem);
    line-height: 1.15;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #1f6f9f;
    margin-bottom: 22px;
    font-weight: 700;
}

.home-title {
    font-size: clamp(2.6rem, 6vw, 5.4rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
    color: #14314a;
    max-width: 9ch;
    margin-bottom: 24px;
}

.home-description {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #39566d;
    max-width: 58ch;
    margin-bottom: 32px;
}

.home-feature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 560px;
    padding: 24px 26px;
    border-radius: 24px;
    background: rgba(255,255,255,0.62);
    border: 1px solid rgba(255,255,255,0.78);
    box-shadow: 0 18px 40px rgba(24, 74, 109, 0.08);
    backdrop-filter: blur(18px);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
}

.home-feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 48px rgba(24, 74, 109, 0.12);
}

.home-card-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #5b7b91;
    margin-bottom: 10px;
}

.home-card-subtitle {
    display: block;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    color: #1f6f9f;
    margin-top: -4px;
    margin-bottom: 4px;
    font-weight: 700;
}

.home-card strong {
    font-size: 1.08rem;
    color: #173a56;
}

.home-feature-card strong {
    font-size: 1.45rem;
    line-height: 1.25;
    color: #173a56;
}

.home-feature-meta {
    font-size: 0.96rem;
    color: #4f6a7f;
}

.home-orb {
    position: relative;
    width: min(40vw, 360px);
    aspect-ratio: 1;
    margin: 0 auto;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.25s ease;
}

.home-orb:hover {
    transform: scale(1.02);
}

.home-orb-ring,
.home-orb-core {
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.home-orb-ring {
    background:
        linear-gradient(140deg, rgba(119,191,236,0.34), rgba(56,136,193,0.14));
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.62),
        0 30px 70px rgba(46,139,192,0.22);
    transform: scale(1.08);
}

.home-orb-core {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
    background: linear-gradient(145deg, #8fb3e6 0%, #497dcb 46%, #2f5ea7 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.22),
        inset 0 -22px 60px rgba(18, 83, 123, 0.24);
    color: #fff;
}

.home-orb-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.home-orb-icon {
    font-size: 2.2rem;
    line-height: 1;
    color: #ffffff;
}

.home-orb-core::before,
.home-orb-core::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.home-orb-core::before {
    inset: 12%;
    border: 1px solid rgba(255,255,255,0.28);
}

.home-orb-core::after {
    inset: 22%;
    border: 1px solid rgba(255,255,255,0.18);
}

.home-orb-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
    color: #f5fcff;
    text-shadow: 0 1px 2px rgba(21, 95, 140, 0.28);
}

.home-orb-core > span {
    position: relative;
    z-index: 1;
    text-align: center;
}

/* ========================================
   BOOK SELECTOR DROPDOWN
   ======================================== */

.book-selector {
    flex: 1;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-dark);
    border: none;
    background: transparent;
    cursor: pointer;
    outline: none;
    padding: 4px 0;
    appearance: auto;
    min-width: 0;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn-back,
.btn-control,
.btn-close,
.btn-book,
.btn-song {
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    white-space: nowrap;
}

.btn-back:hover,
.btn-control:hover,
.btn-close:hover {
    background: var(--bg-light);
    color: var(--primary-dark);
}

.btn-book,
.btn-song {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 16px;
}

.btn-book:hover,
.btn-song:hover {
    background: var(--bg-light);
}

.song-controls {
    display: flex;
    gap: 8px;
}

/* ========================================
   BOOKS GRID
   ======================================== */

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    width: 100%;
}

.book-card {
    background: rgba(255,255,255,0.7);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-light);
}

.book-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-medium);
    transform: translateY(-4px);
}

.book-card:active {
    transform: translateY(-2px);
}

.book-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.book-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.3;
}

.book-count {
    font-size: 0.8rem;
    color: var(--text-light);
    display: none;
}

.skeleton-card {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 12px;
    height: 160px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   SEARCH BOX
   ======================================== */

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(224,242,251,0.92);
    border-bottom: 1px solid rgba(46,139,192,0.15);
    z-index: 9;
    flex-shrink: 0;
}

.search-box i {
    color: var(--text-light);
    font-size: 1.1rem;
}

.search-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.95rem;
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-input::placeholder {
    color: var(--text-light);
}

.btn-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

.btn-search-clear:hover {
    color: var(--text-dark);
}

/* ========================================
   SONGS LIST
   ======================================== */

.songs-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.songs-list.fade-in {
    animation: song-list-fade-in 140ms ease-out;
}

@keyframes song-list-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.song-item {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: transparent;
}

.song-item:hover {
    background: rgba(46,139,192,0.06);
}

.song-item:active {
    background: rgba(46,139,192,0.12);
}

.song-item-info {
    flex: 1;
    min-width: 0;
}

.song-number {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text-light);
    display: inline;
}

.song-name {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-related {
    color: var(--accent);
    font-size: 0.75rem;
    margin-left: auto;
    padding: 2px 8px;
    background: rgba(245, 124, 0, 0.1);
    border-radius: 4px;
    display: none;
}

.song-item[data-related="true"] .song-related {
    display: block;
}

.skeleton-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-item::before {
    content: '';
    display: block;
    height: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-item::after {
    content: '';
    display: block;
    height: 10px;
    width: 60%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

/* ========================================
   LYRICS DISPLAY
   ======================================== */

.lyrics-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    width: 100%;
    min-height: 0;
    align-items: stretch;
    background: transparent;
}

.lyrics-main {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: max-content;
}

.lyrics-container {
    padding: 40px 32px;
    background: transparent;
    color: var(--text-dark);
    width: 100%;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.lyrics-song-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 24px;
    line-height: 1.2;
}

.lyrics-text {
    font-size: 1.7rem;
    line-height: 2;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-text:nth-child(odd) {
    width: 90%;
}

.skeleton-text:nth-child(even) {
    width: 75%;
}

/* ========================================
   AUDIO PLAYER
   ======================================== */

.audio-player {
    padding: 16px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    margin-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

#audio-element {
    width: 100%;
    height: 40px;
}

/* ========================================
   RELATED SONG PANEL
   ======================================== */

.related-panel {
    background: transparent;
    display: none;
    flex-direction: column;
    border-top: 1px solid #d8d0c0;
    border-left: none;
    overflow: visible;
    width: 100%;
    max-height: 40vh;
}

.btn-related-toggle {
    display: none;
}

.related-panel.active {
    display: flex;
}

.related-content {
    padding: 40px 32px;
    word-wrap: break-word;
}

.related-song-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 24px;
    line-height: 1.2;
}

.related-song-text {
    font-size: 1.5rem;
    line-height: 2;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-dark);
}

/* ========================================
   MOBILE OPTIMIZATION (< 600px)
   ======================================== */

@media (max-width: 600px) {
    .app-title {
        font-size: 1.5rem;
    }

    .app-subtitle {
        font-size: 0.8rem;
    }

    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px;
    }

    .book-card {
        padding: 16px 12px;
    }

    .book-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .book-name {
        font-size: 0.9rem;
    }

    .step-header {
        padding: 16px 12px;
    }

    .step-header h2 {
        font-size: 1.3rem;
    }

    .step-header p {
        font-size: 0.8rem;
    }

    .home-hero {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 28px 16px 36px;
        text-align: center;
    }

    .home-title {
        max-width: none;
        font-size: 2.5rem;
    }

    .home-kicker {
        font-size: 1.2rem;
        letter-spacing: 0.14em;
    }

    .home-description {
        max-width: none;
        font-size: 1rem;
    }

    .home-orb {
        width: min(56vw, 220px);
    }

    .home-feature-card {
        max-width: none;
        padding: 20px 18px;
    }

    .search-box {
        padding: 10px 12px;
        gap: 8px;
    }

    .search-input {
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .song-item {
        padding: 12px;
    }

    .song-number {
        font-size: 0.75rem;
    }

    .song-name {
        font-size: 1.1rem;
    }

    .lyrics-wrapper {
        flex-direction: column;
    }

    .lyrics-container {
        padding: 24px 20px;
    }

    .lyrics-song-title,
    .related-song-title {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }

    .lyrics-text,
    .related-song-text {
        font-size: 1.2rem;
    }

    .related-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #d8d0c0;
        max-height: 40vh;
        display: none;
    }

    .related-panel.active {
        display: flex;
    }

    .related-content {
        padding: 20px;
    }
}

/* ========================================
   TABLET OPTIMIZATION (600px - 900px)
   ======================================== */

@media (min-width: 600px) and (max-width: 900px) {
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .home-hero {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .lyrics-container {
        font-size: 1.3rem;
        padding: 32px 24px;
    }
}

/* ========================================
   DESKTOP OPTIMIZATION (> 900px)
   ======================================== */

@media (min-width: 900px) {
    .books-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
        padding: 24px;
    }

    .book-card {
        padding: 24px;
    }

    .step-header {
        padding: 24px;
    }

    .step-header h2 {
        font-size: 1.8rem;
    }

    .search-box {
        padding: 16px 24px;
    }

    .lyrics-container {
        max-width: 800px;
        margin: 0 auto;
        padding: 40px 32px;
        font-size: 1.5rem;
    }

    #step-lyrics {
        flex-direction: column;
    }

    #step-lyrics > .step-header {
        width: 100%;
    }
}

@media (min-width: 980px) {
    .lyrics-wrapper {
        flex-direction: row;
        align-items: flex-start;
    }

    .lyrics-main {
        flex: 1 1 50%;
        width: 50%;
        max-width: 50%;
        min-width: 0;
    }

    .lyrics-wrapper:not(.has-related) .lyrics-main {
        flex-basis: 100%;
        width: min(100%, 920px);
        max-width: 920px;
        margin: 0 auto;
    }

    .related-panel {
        flex: 1 1 50%;
        width: 50%;
        max-width: 50%;
        min-width: 0;
        border-left: 1px solid #d8d0c0;
        border-top: none;
        max-height: none;
        position: sticky;
        top: 0;
        display: none;
    }

    .lyrics-wrapper.related-collapsed .lyrics-main {
        flex-basis: 100%;
        width: min(100%, 920px);
        max-width: 920px;
        margin: 0 auto;
    }

    .lyrics-wrapper.related-collapsed .related-panel.active {
        display: none;
    }

    .related-panel.active {
        display: flex;
    }

    .btn-related-toggle.has-related {
        display: inline-flex !important;
    }
}

@media (min-width: 900px) and (max-width: 979px) {
    .lyrics-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .related-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #d8d0c0;
        max-height: 40vh;
        position: static;
        display: none;
    }

    .related-panel.active {
        display: flex;
    }
}

@media (max-width: 979px) {
    .btn-related-toggle {
        display: none !important;
    }
}


/* ========================================
   SCROLLBAR STYLING
   ======================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ========================================
   UTILITIES
   ======================================== */

.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.text-muted {
    color: var(--text-light);
}
