/* Chord Finder — shared styles. Light theme, no external fonts or assets. */

:root {
  --ink: #1c2333;
  --muted: #5b6478;
  --line: #dde2ee;
  --bg: #f6f7fb;
  --card: #ffffff;
  --accent: #4348d0;
  --accent-soft: #eef0ff;
  --accent-ink: #30369e;
  --ok: #1a7f4f;
  --ok-soft: #e7f6ee;
  --warn: #9a5b00;
  --warn-soft: #fff3dd;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --touch: 44px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- header / footer ---------- */

.site-head { background: var(--card); border-bottom: 1px solid var(--line); }
.site-head .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
}
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 8px 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent-ink); }
.site-nav a[aria-current="page"] { font-weight: 600; }

.site-foot { border-top: 1px solid var(--line); margin-top: 56px; background: var(--card); }
.site-foot .wrap { padding: 26px 20px 34px; color: var(--muted); font-size: 14.5px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; }
.site-foot a { color: var(--accent-ink); }

/* ---------- generic ---------- */

main { padding-bottom: 20px; }

h1 { font-size: 30px; line-height: 1.25; margin: 34px 0 10px; }
h2 { font-size: 22px; margin: 44px 0 12px; }
h3 { font-size: 18px; margin: 24px 0 8px; }
p { margin: 10px 0; }
.lede { color: var(--muted); font-size: 17.5px; max-width: 46em; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin: 16px 0;
}

button {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- tool ---------- */

.tool { padding: 20px; }

.tool-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tool-row input[type="text"] {
  flex: 1 1 260px;
  min-height: var(--touch);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.tool-hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.piano-tools { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; flex-wrap: wrap; }
.piano-tools .label { color: var(--muted); font-size: 14px; }
.octave-btn { padding: 8px 0; width: var(--touch); }

/* piano */

.piano { margin: 6px 0 2px; }
.piano-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  background: #23263a;
  padding: 10px;
}
.piano-keys {
  position: relative;
  display: flex;
  width: max-content; /* black-key % lefts must resolve against real key pitch, not the clipped row */
  min-width: 924px; /* 21 white keys × 44px minimum touch width */
  height: 200px;
}
.key { cursor: pointer; border: 0; padding: 0; }
.key-white {
  flex: 1 1 44px;
  min-width: 44px;
  margin-right: 2px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(#ffffff, #f0f1f7);
  box-shadow: inset 0 -6px 0 rgba(28, 35, 51, 0.08);
}
.key-white[aria-pressed="true"] {
  background: linear-gradient(var(--accent-soft), #dfe3ff);
  box-shadow: inset 0 -6px 0 var(--accent);
}
.key-black {
  position: absolute;
  top: 0;
  width: 34px;
  height: 58%;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(#3a3f57, #14162a);
  z-index: 2;
}
.key-black::before {
  /* invisible hit-area halo: 40px wide — a 44px black hit would reach the white
     keys' centers (22px from each boundary at 46px pitch) and steal their clicks */
  content: "";
  position: absolute;
  inset: 0 -3px;
}
.key-black[aria-pressed="true"] { background: linear-gradient(var(--accent), var(--accent-ink)); }

/* chips */

.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; align-items: center; margin-top: 12px; }
.chips-empty { color: var(--muted); font-size: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}
.chip .oct { color: var(--muted); font-weight: 400; font-size: 13px; }

/* status + results */

.status { min-height: 1.4em; margin: 8px 0 0; color: var(--danger); font-size: 14.5px; }

.results { margin-top: 6px; }
.placeholder { color: var(--muted); }

.result-card { border-color: var(--accent); border-width: 2px; }
.result-badge {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 12px;
  margin: 0 0 4px;
}
.result-badge.exact { background: var(--ok-soft); color: var(--ok); }
.result-badge.incomplete { background: var(--warn-soft); color: var(--warn); }
.result-label { font-size: 44px; line-height: 1.1; margin: 2px 0 2px; }
.result-name { color: var(--muted); font-size: 17px; margin: 0 0 14px; }

.tone-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.tone {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 96px;
  background: #fafbff;
}
.tone-note { display: block; font-size: 21px; font-weight: 700; }
.tone-role { display: block; color: var(--muted); font-size: 13px; }

.why { margin: 8px 0 0; padding-left: 20px; color: var(--ink); }
.why li { margin: 5px 0; }

.missing-note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; }

.play-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.alternates { margin-top: 14px; }
.alternates ul { list-style: none; margin: 8px 0 0; padding: 0; }
.alternates li { border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 10px 14px; margin: 8px 0; }
.alternates .alt-label { font-weight: 700; margin-right: 8px; }
.alternates .alt-note { color: var(--muted); }

/* ---------- content sections ---------- */

.steps { padding-left: 22px; }
.steps li { margin: 8px 0; }

.table-scroll { overflow-x: auto; }
table.chord-types { border-collapse: collapse; width: 100%; background: var(--card); font-size: 15px; }
table.chord-types th, table.chord-types td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
table.chord-types th { background: var(--accent-soft); color: var(--accent-ink); }
table.chord-types td:first-child { white-space: nowrap; font-weight: 600; }

.faq h3 { margin-top: 18px; }
.faq p { color: var(--ink); }

.related { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.related a {
  display: inline-block;
  min-height: var(--touch);
  line-height: var(--touch);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  text-decoration: none;
  font-weight: 600;
}
.related a:hover { border-color: var(--accent); }

/* privacy page */
.prose { max-width: 46em; }
.prose h2 { margin-top: 30px; }

/* responsive */

@media (max-width: 720px) {
  h1 { font-size: 25px; }
  .result-label { font-size: 36px; }
  .tool-row .btn { flex: 1 1 auto; }
  .site-head .wrap { padding-top: 10px; padding-bottom: 10px; }
}
