/* ═══════════════════════════════════════════════
   TABVAULT (Bataкко) — MOBILE RESPONSIVE PATCH
   Place at:  static/css/mobile.css
   Link in baseof.html AFTER main.css:
     <link rel="stylesheet" href="/css/mobile.css">
═══════════════════════════════════════════════ */

/* ─────────────────────────────────────────────
   0. ROOT — applied at ALL widths
   These stop overflow-caused fake-zoom on mobile.
───────────────────────────────────────────────*/
html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%; /* stops iOS font inflation */
    text-size-adjust: 100%;
}
*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ─────────────────────────────────────────────
   1. SONG LAYOUT — grid column fix
   main.css collapses .song-layout to 1fr at 860px
   AND hides .song-sidebar at 860px.
   Below that, .song-main (the only visible child)
   defaults to min-width:auto and can grow wider
   than the viewport. Fix: min-width:0 + width:100%.
   We only apply this BELOW 860px so desktop grid
   (1fr + 280px sidebar) is completely untouched.
   EXCLUDE .scroll-panel — it's position:fixed and
   must not have width:100% forced onto it.
───────────────────────────────────────────────*/
@media (max-width: 859px) {
    .song-layout > *:not(.scroll-panel) {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
}

/* ─────────────────────────────────────────────
   2. PAGE WRAP — symmetric padding always
   main.css sets padding: 24px 20px (equal).
   We reinforce equal sides and fix song-layout
   grid so it doesn't create visual asymmetry.
───────────────────────────────────────────────*/

/* Desktop: ensure page-wrap is truly centered with equal padding */
.page-wrap {
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
    width: 100%;
}

/* song-layout grid: stretch to fill page-wrap fully */
.song-layout {
    width: 100%;
}

@media (max-width: 640px) {
    .page-wrap {
        padding: 14px 12px;
        max-width: 100%;
    }
}
@media (max-width: 400px) {
    .page-wrap {
        padding: 12px 10px;
    }
}

/* ─────────────────────────────────────────────
   3. NAV — hamburger on mobile
   Desktop (>640px): logo | search | links — unchanged.
   Mobile (<=640px):  logo + hamburger in bar.
                     Dropdown reveals search + links.
───────────────────────────────────────────────*/

/* Hidden at ALL widths by default */
.nav-menu-toggle {
    display: none;
}
.nav-dropdown {
    display: none;
}

@media (max-width: 640px) {
    .site-nav {
        flex-wrap: nowrap;
        height: 50px;
        padding: 0 14px;
        gap: 0;
        position: relative;
    }

    .logo {
        flex: 1;
        font-size: 1rem;
    }

    /* Hide bar-level search + links */
    .site-nav > .nav-search,
    .site-nav > .nav-links {
        display: none;
    }

    /* Hamburger button */
    .nav-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: 1px solid var(--border);
        color: var(--text);
        width: 34px;
        height: 34px;
        border-radius: var(--radius);
        font-size: 1.1rem;
        line-height: 1;
        cursor: pointer;
        flex-shrink: 0;
        transition:
            border-color 0.15s,
            color 0.15s;
    }
    .nav-menu-toggle:hover,
    .nav-menu-toggle[aria-expanded="true"] {
        border-color: var(--accent);
        color: var(--accent);
    }

    /* Dropdown panel */
    .nav-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 12px 14px;
        flex-direction: column;
        gap: 10px;
        z-index: 200;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
    }
    .nav-dropdown.open {
        display: flex;
    }

    .nav-dropdown .nav-search {
        display: flex;
        max-width: 100%;
        width: 100%;
    }
    .nav-dropdown .nav-search input {
        min-width: 0;
        width: 100%;
    }
    .nav-dropdown .nav-links {
        display: flex;
        margin-left: 0;
        gap: 6px;
        flex-wrap: wrap;
    }
    .nav-btn {
        font-size: 0.78rem;
        padding: 6px 14px;
    }
}

/* ─────────────────────────────────────────────
   4. SONG HEADER — 3-col grid to 2-row stack
───────────────────────────────────────────────*/
@media (max-width: 600px) {
    .song-header {
        grid-template-columns: 44px 1fr;
        grid-template-rows: auto auto;
        gap: 10px 12px;
        padding: 12px 14px;
        width: 100%;
        min-width: 0;
    }
    .album-art {
        grid-row: 1;
        grid-column: 1;
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    .song-info {
        grid-row: 1;
        grid-column: 2;
        min-width: 0;
    }
    .song-title {
        font-size: 1.1rem;
    }
    .song-artist {
        font-size: 0.82rem;
    }
    .rating-block {
        grid-row: 2;
        grid-column: 1 / -1;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }
}

/* ─────────────────────────────────────────────
   5. TOOLBAR
   ┌─────────────────────────────────────────┐
   │ DESKTOP  [Transpose][Size][Simple][Scroll][♡🖨] │
   ├─────────────────────────────────────────┤
   │ MOBILE row 1  [Transpose]  [Size]  [♡🖨]│
   │ MOBILE row 2  [Simple Chord] [Autoscroll]│
   └─────────────────────────────────────────┘
───────────────────────────────────────────────*/

/* ── Desktop: flex row, natural order, polished spacing ── */
.tab-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap; /* single row on desktop */
    gap: 8px;
}

/* Shared group spacing */
.tab-toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Separator */
.toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    opacity: 0.6;
    flex-shrink: 0;
}

/* Simple chord: pill-style toggle */
.tb-simple {
    white-space: nowrap;
}

/* Autoscroll active state */
.autoscroll-btn[aria-pressed="true"],
.tb-scroll[aria-pressed="true"] {
    border-color: var(--green);
    color: var(--green);
    background: rgba(46, 204, 113, 0.07);
}

/* Actions always push to the far right on desktop */
.tb-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Mobile: 2-row grid ── */
@media (max-width: 640px) {
    .tab-toolbar {
        display: grid;
        /*  col A: transpose group
            col B: size group
            col C: actions (fixed width)       */
        grid-template-columns: auto auto 1fr auto;
        grid-template-rows: auto auto;
        grid-template-areas:
            "transpose  size  .        actions"
            "simple     simple  scroll   scroll";
        gap: 7px 8px;
        padding: 8px 10px;
        width: 100%;
        min-width: 0;
        align-items: center;
    }

    /* Hide desktop-only separators */
    .toolbar-sep {
        display: none;
    }

    /* Hide all labels by default on mobile */
    .toolbar-label {
        display: none;
    }

    /* Show ONLY the Transpose label so new users understand −/+ */
    .tb-transpose .toolbar-label {
        display: inline;
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--muted);
        letter-spacing: 0.3px;
        white-space: nowrap;
    }

    /* Place each group into its named area */
    .tb-transpose {
        grid-area: transpose;
        justify-content: center;
        align-items: center;
    }
    .tb-size {
        grid-area: size;
        justify-content: center;
    }
    .tb-actions {
        grid-area: actions;
        margin-left: 0;
        justify-content: flex-end;
    }
    .tb-simple {
        grid-area: simple;
        width: 100%;
        text-align: center;
        justify-content: center;
        font-size: 0.78rem;
        padding: 6px 10px;
    }
    .tb-scroll {
        grid-area: scroll;
        width: 100%;
        text-align: center;
        font-size: 0.78rem;
        padding: 6px 10px;
    }

    /* Compact control buttons */
    .ctrl-btn {
        font-size: 0.78rem;
        padding: 5px 9px;
        min-width: 28px;
    }
    .ctrl-val {
        font-size: 0.82rem;
        min-width: 22px;
        text-align: center;
    }
    .action-btn {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
}

/* Very small phones — tighten further */
@media (max-width: 380px) {
    .tab-toolbar {
        gap: 5px 6px;
        padding: 7px 8px;
    }
    .ctrl-btn {
        font-size: 0.72rem;
        padding: 4px 7px;
        min-width: 24px;
    }
    .tb-simple,
    .tb-scroll {
        font-size: 0.72rem;
        padding: 5px 8px;
    }
}

/* ─────────────────────────────────────────────
   6. CHORD SHEET — contained horizontal scroll
   .song uses min-width:max-content to keep
   chords aligned above lyrics. We contain that
   inside .chord-sheet-wrap so only the card
   scrolls horizontally, never the whole page.
───────────────────────────────────────────────*/

/* Wrap: stays in column, clips at card edge */
.chord-sheet-wrap {
    width: 100%;
    min-width: 0;
    overflow: hidden; /* clip — inner .chord-sheet scrolls */
}

/* Inner: touch-scrollable horizontally */
.chord-sheet {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Song content: natural (wide) width, scroll handled by parent */
.song {
    min-width: max-content;
    display: block;
}

/* Verse shortcode: keep pre spacing for chord alignment */
.verse-lines,
.verse-lines p {
    white-space: pre;
}

/* Tab blocks: self-scrolling */
.tab-block {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .chord-sheet {
        padding: 14px 12px;
        font-size: 0.88rem;
    }
    .sheet-meta {
        padding: 8px 12px;
        gap: 8px;
        font-size: 0.7rem;
        flex-wrap: wrap;
    }
}

/* ─────────────────────────────────────────────
   7. GRIDS — single column on phones
───────────────────────────────────────────────*/
@media (max-width: 500px) {
    .song-grid {
        grid-template-columns: 1fr;
    }
    .artist-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 480px) {
    .song-card {
        padding: 10px;
        gap: 10px;
    }
    .song-card-art {
        font-size: 1.3rem;
    }
    .song-card-title {
        font-size: 0.85rem;
    }
}

/* ─────────────────────────────────────────────
   8. HERO
───────────────────────────────────────────────*/
@media (max-width: 480px) {
    .hero {
        padding: 28px 0 14px;
    }
    .hero-title {
        font-size: clamp(1.5rem, 8vw, 2.2rem);
    }
    .hero-sub {
        font-size: 0.9rem;
    }
    .hero-search {
        max-width: 100%;
    }
    .hero-search button {
        padding: 0 14px;
        font-size: 0.8rem;
    }
}

/* ─────────────────────────────────────────────
   9. FLOATING AUTOSCROLL PANEL
   position:fixed — always relative to viewport.
   Mobile: anchor bottom-right (not center-right)
   so it doesn't cover chord content mid-screen.
───────────────────────────────────────────────*/

/* Ensure fixed panel is never affected by any parent layout rule */
.scroll-panel {
    position: fixed !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
}

@media (max-width: 640px) {
    .scroll-panel {
        right: 10px !important; /* match desktop right value */
        left: auto !important;
        top: auto !important;
        bottom: 16px !important;
        transform: none !important;
    }
    .scroll-box {
        width: 36px;
        padding: 8px 4px;
        gap: 7px;
    }
    .speed-btn {
        width: 18px;
        height: 13px;
    }
    .speed-label,
    .stop-btn,
    .font-controls span {
        font-size: 8px;
    }
    .font-controls button {
        width: 20px;
        height: 20px;
        font-size: 0.75rem;
    }
}

/* ─────────────────────────────────────────────
   10. FOOTER
───────────────────────────────────────────────*/
@media (max-width: 480px) {
    .site-footer {
        margin-top: 40px;
        padding: 20px 14px;
    }
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .footer-copy {
        margin-left: 0;
    }
    .footer-links {
        gap: 12px;
        flex-wrap: wrap;
    }
}

/* ─────────────────────────────────────────────
   11. MISC
───────────────────────────────────────────────*/
.breadcrumb {
    flex-wrap: wrap;
    line-height: 1.8;
}

@media (max-width: 380px) {
    .pill {
        font-size: 0.6rem;
        padding: 2px 5px;
    }
    .meta-pills {
        gap: 4px;
    }
    .artist-page-hero {
        flex-direction: column;
        gap: 10px;
    }
}
@media (max-width: 480px) {
    .list-header h1 {
        font-size: 1.4rem;
    }
}

/* Chord popup: allow clicks inside without dismissing */
.chord-popup {
    max-width: calc(100vw - 24px);
    pointer-events: auto;
}

/* Chord spans in sheet: clear tap target on mobile */
.ch {
    cursor: pointer;
    /* Larger touch target on mobile without affecting layout */
    padding-bottom: 2px;
}

/* Strip items: pointer cursor (already set by JS, belt-and-suspenders) */
.chord-strip-item {
    cursor: pointer;
}
/* Highlight on hover/focus for accessibility */
.chord-strip-item:hover,
.chord-strip-item:focus-within {
    border-color: var(--chord);
    background: rgba(93, 173, 226, 0.06);
}
