/* Friendly Folk — one stylesheet for the whole site. */

:root {
    --ink: #1f2a22;
    --muted: #66705f;
    --paper: #f7f3ea;
    --card: #fffdf8;
    --line: #e2dccd;
    --green: #1f3d2b;
    --green-soft: #2f5a40;
    --gold: #f2c46d;
    --accent: #b5651d;
    --danger: #8f2a1d;
    --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.9rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
a { color: var(--green-soft); }
code { font-size: 0.9em; background: rgba(31, 61, 43, 0.07); padding: 0.1em 0.35em; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.inline { display: inline; }
[hidden] { display: none !important; }

/* ---- Top bar ---- */
.top {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1.5rem;
    padding: 0.7rem 1.25rem;
    background: var(--green);
    color: #fff;
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: #fff; text-decoration: none; font-family: Georgia, serif; font-size: 1.2rem; font-weight: 600; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
    background: rgba(255, 255, 255, 0.12); color: var(--gold); font-size: 1.3rem;
}
.top-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem 1rem; }
.top-nav a, .top-nav .linkish { color: #e9efe9; text-decoration: none; font-size: 0.95rem; padding: 0.2rem 0; }
.top-nav a:hover, .top-nav .linkish:hover { color: #fff; }
.top-nav a.on { color: var(--gold); border-bottom: 2px solid var(--gold); }

.page { max-width: 1000px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: 0.25rem 0 0; }

/* ---- Messages ---- */
.flash {
    background: #e8f1e6; border: 1px solid #c7dcc2; color: #234a2c;
    padding: 0.7rem 1rem; border-radius: var(--radius); margin: 0 0 1.25rem;
}
.flash-error { background: #f8e9e5; border-color: #ebcbc3; color: var(--danger); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.6rem 1.1rem; border-radius: 999px; border: 1.5px solid transparent;
    font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-soft); }
.btn-secondary { background: rgba(31, 61, 43, 0.07); color: var(--ink); border-color: rgba(31, 61, 43, 0.15); }
.btn-secondary:hover { background: rgba(31, 61, 43, 0.13); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #f5cf86; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.45; cursor: default; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---- Forms ---- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.field { display: block; margin-bottom: 1rem; }
.field > span:first-child { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.3rem; }
.field-hint { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }
.field-error, .form-errors { color: var(--danger); font-size: 0.9rem; }
.form-errors ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.field-check { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number], select, textarea {
    width: 100%; font: inherit; color: var(--ink);
    padding: 0.6rem 0.75rem; border: 1.5px solid var(--line); border-radius: 9px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-soft); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 14rem; }
.row .field { margin-bottom: 0; }

.narrow { max-width: 440px; margin: 2rem auto; }

/* ---- Tune list ---- */
.searchbar {
    position: sticky; top: 0; z-index: 5;
    display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
    padding: 0.75rem 0; background: var(--paper);
}
.searchbar input[type=search] { flex: 1 1 16rem; font-size: 1.05rem; padding: 0.7rem 1rem; border-radius: 999px; }
.building {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
    background: var(--green); color: #fff; border-radius: var(--radius);
    padding: 0.7rem 1rem; margin-bottom: 0.5rem;
}
.building strong { color: var(--gold); }
.letters { display: flex; flex-wrap: wrap; gap: 0.15rem 0.35rem; margin: 0.25rem 0 1rem; font-size: 0.9rem; }
.letters a { text-decoration: none; padding: 0.1rem 0.35rem; border-radius: 5px; }
.letters a:hover { background: rgba(31, 61, 43, 0.1); }
.letter-head { margin: 1.4rem 0 0.4rem; font-size: 1.05rem; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 0.2rem; }

.tunes { list-style: none; margin: 0; padding: 0; }
.tune {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.25rem; border-bottom: 1px solid var(--line);
}
.tune:last-child { border-bottom: 0; }
.tune-name { flex: 1 1 auto; min-width: 0; text-decoration: none; color: var(--ink); font-weight: 500; }
.tune-name:hover { color: var(--green-soft); text-decoration: underline; }
.tune-meta { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.chip {
    display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px;
    background: rgba(181, 101, 29, 0.12); color: #7b4513; white-space: nowrap;
}
.chip-missing { background: #f3e0dc; color: var(--danger); }
.tune .btn-small { flex: 0 0 auto; }
.btn.added { background: #e8f1e6; color: #234a2c; border-color: #c7dcc2; }
.empty { color: var(--muted); padding: 1.5rem 0; text-align: center; }
.count { color: var(--muted); font-size: 0.9rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #f3eee2; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.num { width: 2.5rem; color: var(--muted); }
table.list td.act { white-space: nowrap; text-align: right; }
table.list td.act form { display: inline; }
.line-text { color: var(--muted); font-style: italic; }
tr.unmatched td { background: #fbf3e4; }

/* ---- Playlist cards ---- */
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.list-card {
    display: flex; flex-direction: column; gap: 0.4rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
}
.list-card h3 { margin: 0; }
.list-card h3 a { color: var(--ink); text-decoration: none; }
.list-card .actions { margin-top: auto; padding-top: 0.5rem; }

/* ---- One tune on a page of its own ---- */
.sheet { display: flex; flex-direction: column; gap: 1rem; align-items: center; }

/* A scan, drawn onto canvases by wwwroot/js/sheet.js. */
.scan { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.scan-pages { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1rem; min-height: 4rem; }
.scan canvas { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12); }
.scan.drawing .scan-pages { opacity: 0.5; }
.scan-tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

/* The bare page the music stand shows in its frame. */
.sheet-body { margin: 0; background: #fff; }
.sheet-body .sheet { gap: 0; }
.sheet-body .scan-pages { gap: 0; }
.sheet-body .scan canvas { box-shadow: none; }

/* ---- The music stand ---- */
.player-body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--green); }
.player-bar {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.45rem 0.6rem; color: #fff;
}
.player-title { font-family: Georgia, serif; font-weight: 600; margin: 0 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14rem; }
.player-tabs { display: flex; gap: 0.3rem; overflow-x: auto; flex: 1 1 auto; min-width: 0; padding-bottom: 0.1rem; scrollbar-width: thin; }
.player-tab {
    flex: 0 0 auto; font: inherit; font-size: 0.85rem; cursor: pointer;
    padding: 0.35rem 0.75rem; border-radius: 999px;
    background: transparent; color: #e9efe9; border: 1.5px solid rgba(255, 255, 255, 0.35);
    white-space: nowrap; max-width: 16rem; overflow: hidden; text-overflow: ellipsis;
}
.player-tab:hover { border-color: #fff; }
.player-tab.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.player-tab.gone { text-decoration: line-through; opacity: 0.6; }
/* Press-and-hold to drag (js/player.js): no text selection or callout menu on a long press. */
.player-tab { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.player-tab.dragging {
    background: #fff; color: var(--ink); border-color: #fff; cursor: grabbing;
    transform: scale(1.08); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); position: relative; z-index: 2;
}
.player-tabs.reordering { scroll-behavior: auto; cursor: grabbing; }
.player-toast {
    position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 20;
    margin: 0; padding: 0.55rem 1rem; border-radius: 999px;
    background: var(--green); color: #fff; font-size: 0.9rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.player-toast.error { background: var(--danger); }
.player-bar .btn { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: transparent; flex: 0 0 auto; }
.player-bar .btn:hover { background: rgba(255, 255, 255, 0.26); }
.player-bar .btn:disabled { opacity: 0.35; }
.player-stage { flex: 1; min-height: 0; background: #fff; }
.player-stage iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 640px) {
    .page { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.55rem; }
    .tune { flex-wrap: wrap; gap: 0.3rem 0.6rem; }
    .tune-name { flex-basis: 100%; }
    .player-title { display: none; }
}
