/* ==================================================================
   Lyrics & Chords App - shared styles
   Mobile-first. Works as a plain responsive web app (no framework),
   so it can be uploaded as-is to Hostinger.
   ================================================================== */

:root {
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

    /* Day (light) theme */
    --bg: #faf8f4;
    --bg-elevated: #ffffff;
    --text: #201d18;
    --text-muted: #6b6459;
    --border: #e4ddd0;
    --accent: #7a5c3e;
    --accent-contrast: #ffffff;
    --chord-color: #b03a2e;
    --section-color: #7a5c3e;
    --section-bg: #efe6d6;
    --danger: #b03a2e;

    --editor-chord-bg: #dff1fb;
    --editor-lyric-bg: #e3f6e0;
    --editor-section-bg: #f1e7d3;

    --shadow: 0 2px 10px rgba(30, 24, 12, 0.08);
    --radius: 10px;
}

[data-theme="night"] {
    /* Night (stage) theme: dark, high contrast, low glare */
    --bg: #14120f;
    --bg-elevated: #1e1b16;
    --text: #f2ede2;
    --text-muted: #a89f8d;
    --border: #332e26;
    --accent: #d8b876;
    --accent-contrast: #14120f;
    --chord-color: #ff8a70;
    --section-color: #d8b876;
    --section-bg: #2a2419;

    --editor-chord-bg: #17324a;
    --editor-lyric-bg: #1c3320;
    --editor-section-bg: #332c1a;

    --shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); }

button, input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.app-header .brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.app-header .spacer { flex: 1; }

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn:hover { background: var(--section-bg); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}
.btn:hover { background: var(--section-bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

main.container {
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.field { margin-bottom: 1rem; }
.field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text);
}
.field-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.song-list { list-style: none; margin: 0; padding: 0; }
.song-list li {
    border-bottom: 1px solid var(--border);
}
.song-list a {
    display: block;
    padding: 0.85rem 0.25rem;
    text-decoration: none;
    color: var(--text);
}
.song-list .title { font-weight: 700; }
.song-list .meta { font-size: 0.85rem; color: var(--text-muted); }

.search-box { position: relative; margin-bottom: 1rem; }
.search-box input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
}

/* ---------------- Section-tag picker chips ---------------- */
.section-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.section-chip {
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--section-bg);
    color: var(--section-color);
    cursor: pointer;
    font-weight: 600;
}
.section-chip:hover { filter: brightness(1.05); }

/* ---------------- Editor: colored chord/lyric line overlay ---------------- */
.editor-wrap {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-elevated);
}
.editor-backdrop,
.editor-textarea {
    margin: 0;
    padding: 0.7rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    tab-size: 4;
}
.editor-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
    color: transparent;
}
.editor-backdrop .line { display: block; min-height: 1.7em; }
.editor-backdrop .line.role-chord { background: var(--editor-chord-bg); }
.editor-backdrop .line.role-lyric { background: var(--editor-lyric-bg); }
.editor-backdrop .line.role-section { background: var(--editor-section-bg); }

.editor-textarea {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    min-height: 340px;
    resize: vertical;
    border: none;
    background: transparent;
    color: var(--text);
    caret-color: var(--text);
}
.editor-textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.editor-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
    flex-wrap: wrap;
}
.editor-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.swatch {
    width: 0.8rem; height: 0.8rem; border-radius: 3px; display: inline-block;
    border: 1px solid var(--border);
}
.swatch.chord { background: var(--editor-chord-bg); }
.swatch.lyric { background: var(--editor-lyric-bg); }
.swatch.section { background: var(--editor-section-bg); }

/* ---------------- Song viewer ---------------- */
.viewer-toolbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.viewer-toolbar .group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.2rem 0.4rem;
}
.viewer-toolbar select { border: none; background: transparent; color: var(--text); }
.viewer-toolbar .spacer { flex: 1; }

.song-title-block { padding: 1rem 1rem 0.25rem; }
.song-title-block h1 { margin: 0 0 0.15rem; font-size: 1.4rem; }
.song-title-block .sub { color: var(--text-muted); font-size: 0.9rem; }

.song-body {
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    line-height: 1.5;
}
.song-section { margin-bottom: 1.4rem; }
.song-section .section-label {
    display: inline-block;
    font-family: var(--font-ui);
    font-weight: 700;
    color: var(--section-color);
    background: var(--section-bg);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}
.line-pair {
    position: relative;
    white-space: pre;
    overflow-x: auto;
}
.chord-row {
    position: relative;
    height: 1.3em;
}
.chord-row .chord {
    position: absolute;
    top: 0;
    color: var(--chord-color);
    font-weight: 700;
    white-space: pre;
}
.chord-row .chord.not-a-chord {
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}
.lyric-row { white-space: pre-wrap; word-break: break-word; }

@media (min-width: 640px) {
    .song-body { font-size: 1.15rem; }
}

/* ---------------- Auth ---------------- */
.login-wrap {
    max-width: 380px;
    margin: 3rem auto;
    padding: 0 1rem;
}

/* ---------------- Live session ---------------- */
.live-banner {
    background: var(--accent);
    color: var(--accent-contrast);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.live-dot {
    width: 0.55rem; height: 0.55rem; border-radius: 50%;
    background: #e23; display: inline-block;
    animation: pulse 1.4s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(226,34,51,0.6); }
    70% { box-shadow: 0 0 0 8px rgba(226,34,51,0); }
    100% { box-shadow: 0 0 0 0 rgba(226,34,51,0); }
}

.join-code-display {
    font-family: var(--font-mono);
    font-size: 2rem;
    letter-spacing: 0.3rem;
    font-weight: 700;
    text-align: center;
    padding: 1rem;
    background: var(--section-bg);
    color: var(--section-color);
    border-radius: var(--radius);
    margin: 1rem 0;
}

.toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 0.6rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    z-index: 50;
    box-shadow: var(--shadow);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
