/* Vineyard — Little Amps design system (see DESIGN.md for the decision ledger) */

:root {
  --bg: #fff9f2;            /* Cream Canvas */
  --surface: #f6ede3;       /* Warm Beige */
  --surface-low: #cbbbb4;   /* Fawn Gray */
  --hairline: #e6dad4;      /* Smoky Ash */
  --text: #522c25;          /* Vinyl Brown */
  --text-muted: #977e77;    /* Muted Taupe — large/secondary only */
  --action: #c03001;        /* Roast Red — primary actions + Exact badge only */
  --accent-2: #a55600;      /* Mellow Ochre (darkened for AA) — secondary/Rotation */
  --accent-cool: #89b4ca;   /* Community Blue — informational */
  --highlight: #febf6f;     /* Sunbeam Yellow — review flags */
  --font-display: 'League Spartan', 'Trebuchet MS', sans-serif;
  --font-body: 'Inclusive Sans', 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', Consolas, monospace;
  --r-card: 8px;
  --r-ctrl: 3px;
  --r-panel: 22px;
  --gap: 6px;
  --section-gap: 40px;
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: 0.05em;
  line-height: 1.6;
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  padding: 10px 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.06em;
  color: var(--bg);
  margin-right: 8px;
  line-height: 1;
}
.brand .brand-amp { color: var(--highlight); }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; }

.tab {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bg);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-ctrl);
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tab:hover { background: rgba(255, 249, 242, 0.14); }
a.tab-link { text-decoration: none; display: inline-block; color: var(--highlight); }
.tab:active { background: rgba(255, 249, 242, 0.25); }
.tab[aria-selected="true"] { background: var(--bg); color: var(--text); }

.topbar-spacer { flex: 1; }

.datachip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--bg);
  opacity: 0.85;
}
.datachip .dirty { color: var(--highlight); }

/* ---------- generic controls ---------- */
button, .btn {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  border-radius: var(--r-ctrl);
  border: 1px solid transparent;
  padding: 7px 14px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
}
button:active { transform: translateY(1px); }

.btn-primary { background: var(--action); color: var(--bg); }
.btn-primary:hover { background: #a82a01; }
.btn-secondary { background: var(--accent-2); color: var(--bg); }
.btn-secondary:hover { background: #8f4a00; }
.btn-cool { background: var(--accent-cool); color: var(--text); }
.btn-cool:hover { background: #7aa8c0; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--text); }
.btn-ghost:hover { background: var(--surface); }

:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
  border-radius: var(--r-ctrl);
}
.topbar :focus-visible { outline-color: var(--highlight); }

input, select {
  font-family: var(--font-body);
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--r-ctrl);
  padding: 7px 10px;
}
input::placeholder { color: var(--text-muted); }

/* ---------- layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 28px 22px 80px; }

.view { display: none; }
.view.active { display: block; }

.view-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 41px;
  letter-spacing: -0.1em;
  line-height: 0.9;
  margin: 6px 0 4px;
}

.view-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 26px;
}

.panel {
  background: var(--surface);
  border-radius: var(--r-panel);
  padding: 36px;
  margin-bottom: var(--section-gap);
}

.hairline-top { border-top: 1px solid var(--hairline); }

/* ---------- badges & chips ---------- */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--r-ctrl);
  padding: 2px 7px;
  white-space: nowrap;
}
.badge-exact { background: var(--action); color: var(--bg); }
.badge-rotation { background: var(--accent-2); color: var(--bg); }
.badge-fuzzy { background: transparent; color: var(--text); border: 1px solid var(--text-muted); }
.badge-info { background: var(--accent-cool); color: var(--text); }
.badge-flag { background: var(--highlight); color: var(--text); }
.badge-section { background: var(--surface); color: var(--text); border: 1px solid var(--hairline); }
.results .badge-section { background: var(--bg); }

.score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  min-width: 2.4em;
  text-align: right;
}

.mono { font-family: var(--font-mono); }
.prog {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

/* ---------- import panel ---------- */
.dropzone {
  border: 2px dashed var(--surface-low);
  border-radius: var(--r-card);
  padding: 48px 24px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
}
.dropzone.dragover { border-color: var(--action); background: var(--bg); }
.dropzone p { margin: 8px 0; }
.dropzone .hint { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.toolbar input[type="search"] { min-width: 220px; flex: 1; max-width: 340px; }
.toolbar .count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* ---------- table ---------- */
.tablewrap { overflow-x: auto; border-top: 1px solid var(--hairline); }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
th {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: var(--topbar-h, 0px);
  background: var(--bg);
}
th .arrow { color: var(--action); }
td.num { font-family: var(--font-mono); font-weight: 700; text-align: center; }
td.words { max-width: 320px; font-size: 13px; color: var(--text); }
td .cellbtn {
  all: unset;
  cursor: pointer;
  display: block;
  min-width: 1.6em;
  min-height: 1.2em;
  text-align: inherit;
  border-radius: var(--r-ctrl);
  padding: 0 3px;
}
td .cellbtn:hover { background: var(--surface); }
td .cellbtn:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }
td .cellbtn.empty { color: var(--surface-low); }
td input { padding: 2px 5px; font-family: var(--font-mono); width: 5em; }
tr.editing { background: var(--surface); }

/* ---------- autocomplete ---------- */
.combo { position: relative; max-width: 480px; }
.combo input { width: 100%; font-size: 16px; padding: 12px 14px; }
.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--r-card);
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
}
.combo-list li {
  padding: 8px 10px;
  border-radius: var(--r-ctrl);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.combo-list li .t { flex: 1; }
.combo-list li .a { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--surface); }
.combo-list li.uncoded .t { color: var(--text-muted); }

/* ---------- match results ---------- */
.songhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin: 26px 0 6px; }
.songhead h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: -0.08em;
  margin: 0;
}
.songhead .meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

.sectiontabs { display: flex; gap: 6px; margin: 12px 0 22px; flex-wrap: wrap; }
.sectiontabs button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--hairline);
}
.sectiontabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.group-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.06em;
  margin: 34px 0 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.group-title .n { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); letter-spacing: 0; }

.results { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hairline); }
.results li {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 4px 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--hairline);
}
.results .r-main { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.results .r-song { font-weight: 400; font-size: 16px; }
.results .r-artist { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.results .r-notes { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.results .r-words { grid-column: 2; font-size: 13px; color: var(--text-muted); }
.empty-note { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); padding: 14px 4px; }

/* ---------- groups view ---------- */
.family { margin-bottom: var(--section-gap); }
.family-head { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.family-head .famprog {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 51px;
  letter-spacing: -0.1em;
  line-height: 0.8;
}
.family-head .famcount { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.family .variant { margin: 16px 0 0 4px; }
.variant-title { font-family: var(--font-mono); font-size: 13px; font-weight: 700; margin-bottom: 4px; display: flex; gap: 10px; align-items: baseline; }
.variant ul { list-style: none; margin: 0; padding: 0; }
.variant li { padding: 6px 4px; border-bottom: 1px solid var(--hairline); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.songlink {
  all: unset; cursor: pointer; font-size: 15px;
}
.songlink:hover { color: var(--action); text-decoration: underline; }
.songlink:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: var(--r-ctrl); }

/* ---------- tag finder ---------- */
.tagform { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 10px; }
.tagform label { display: flex; flex-direction: column; gap: 4px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.tagform select, .tagform input { font-family: var(--font-mono); font-weight: 700; font-size: 16px; width: 5.5em; }

/* ---------- keys view ---------- */
.keysgrid { border-top: 1px solid var(--hairline); }
.keysgrid .keyrow { display: grid; grid-template-columns: 60px 1fr; gap: 14px; padding: 9px 4px; border-bottom: 1px solid var(--hairline); align-items: baseline; }
.keysgrid .keyname { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.06em; }
.keysgrid .chords { font-family: var(--font-mono); font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }

/* ---------- legend / footer ---------- */
.legend {
  margin-top: var(--section-gap);
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  border-radius: var(--r-card);
  padding: 10px 18px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.toast.show { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .view-title { font-size: 32px; }
  .family-head .famprog { font-size: 38px; }
  .panel { padding: 20px; border-radius: var(--r-card); }
  main { padding: 18px 12px 60px; }
  .results li { grid-template-columns: 44px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
