/* Swift To The Lyric — searcher styling. Self-contained: it mirrors the game's
   notebook tokens (paper / ink / rule / margin) and fonts (Caveat for creative text,
   Courier Prime for functional UI) without inheriting the whole game stylesheet. */
:root {
  --paper: #f5efe1;
  --paper-edge: #efe7d4;
  --ink: #2b2722;
  --ink-soft: #6f675a;
  --ink-faint: #a39c8e;
  --rule-line: #d6e1ea;          /* faint blue rule under a lyric line */
  --margin: rgba(178, 58, 58, 0.5);
  --pen: #b9402f;                /* red pen — the matched word */
  --desk: #b9a988;
  --hand: "Caveat", cursive;
  --type: "Courier Prime", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

/* Era wash: the desk subtly takes on the dominant album's colour for the current search,
   a faint ambient tint behind the notebook (never over it). Sits below the static page
   content (z-index:-1) so it only shows on the desk margins. */
.sx-era {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(135% 105% at 50% -6%,
    color-mix(in srgb, var(--era, transparent) 42%, transparent), transparent 58%);
  transition: background 0.6s ease;
}
body {
  background: var(--desk);
  background-image: radial-gradient(140% 120% at 50% 0%, #c7b794 0%, #b09e7c 100%);
  color: var(--ink);
  font-family: var(--hand);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* top bar */
.sx-top {
  max-width: 820px; margin: 0 auto; padding: 14px 18px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.sx-back {
  font-family: var(--type); font-size: 12px; letter-spacing: .04em;
  color: #efe7d4; text-decoration: none; opacity: .85;
}
.sx-back:hover { opacity: 1; text-decoration: underline; }
.sx-mark { font-family: var(--type); font-size: 12px; letter-spacing: .18em; color: #efe7d4; opacity: .8; }

/* the page */
.sx-page {
  max-width: 820px; margin: 14px auto 90px; padding: 26px 34px 54px 62px;
  background-color: var(--paper);
  background-image: linear-gradient(to right, transparent 46px, var(--margin) 46px, var(--margin) 47px,
    rgba(178,58,58,.28) 47px, rgba(178,58,58,.28) 49px, transparent 49px);
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 14px 40px rgba(0,0,0,.32);
}

/* search field */
.sx-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; border-bottom: 2px solid #e0d6bf; padding-bottom: 6px; }
.sx-search svg { width: 22px; height: 22px; color: var(--pen); flex: none; }
#q {
  flex: 1; min-width: 140px; border: 0; background: transparent; outline: none;
  font-family: var(--hand); font-size: 36px; color: var(--ink); line-height: 1.1; padding: 2px 0;
}
#q::placeholder { color: var(--ink-faint); }

/* committed search-term chips (AND-ed together) */
.sx-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sx-chips:empty { display: none; }
.sx-chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-family: var(--type); font-size: 14px; color: #7a2f24;
  background: #f3e2dc; border: 1px solid #c08274; border-radius: 4px; padding: 3px 5px 3px 9px;
}
.sx-chip-x { font-family: var(--type); font-size: 15px; line-height: 1; color: #b9402f; background: none; border: 0; cursor: pointer; padding: 0 2px; }
.sx-chip-x:hover { color: #8f2e20; }

/* controls */
.sx-controls { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; align-items: center; }
.sx-seg { display: inline-flex; gap: 4px; }
.sx-seg button {
  font-family: var(--type); font-size: 11px; letter-spacing: .03em; color: var(--ink-soft);
  background: #f1ead9; border: 1px solid #cbbfa8; border-radius: 4px; padding: 4px 11px; cursor: pointer;
}
.sx-seg button:hover { border-color: var(--ink-soft); }
.sx-seg button.on { color: #7a2f24; border-color: #c08274; background: #f3e2dc; }
.sx-filter { font-family: var(--type); font-size: 11px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.sx-filter select {
  font-family: var(--type); font-size: 11px; color: var(--ink-soft);
  background: #f1ead9; border: 1px solid #cbbfa8; border-radius: 4px; padding: 4px 8px; cursor: pointer;
}
.sx-filter select:hover { border-color: var(--ink-soft); }
.sx-filter select.active { color: #7a2f24; border-color: #c08274; background: #f3e2dc; }

/* counter + album bar */
.sx-counter { font-family: var(--type); font-size: 13px; color: var(--ink-soft); margin-top: 18px; min-height: 17px; }
.sx-counter b { color: var(--ink); font-weight: 700; }
.sx-none b { color: var(--pen); }
.sx-bar { display: flex; height: 7px; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.sx-bar:empty { display: none; }
.sx-bar span { min-width: 2px; }

/* concordance — the readable counterpart to the rainbow bar: where the word lives most,
   how rare it is, and a labeled breakdown of the top albums */
.sx-concord { margin-top: 9px; }
.sx-concord:empty { display: none; }
.sx-concord-line { font-family: var(--type); font-size: 12px; color: var(--ink-soft); }
.sx-concord-line b { font-weight: 700; }
.sx-rarity { color: var(--ink-faint); font-style: italic; }
.sx-concord-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 6px; }
.sx-leg { font-family: var(--type); font-size: 11px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.sx-leg-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sx-leg b { color: var(--ink); font-weight: 700; }
.sx-leg-more { font-family: var(--type); font-size: 11px; color: var(--ink-faint); font-style: italic; }

/* "play this word in the game" — a red-pen invitation tucked beside the counter */
.sx-play {
  font-family: var(--type); font-size: 11px; letter-spacing: .02em;
  color: var(--pen); text-decoration: none; white-space: nowrap;
  border-bottom: 1px dashed rgba(185, 64, 47, .45); padding-bottom: 1px; margin-left: 10px;
}
.sx-play:hover { color: #8f2e20; border-bottom-color: rgba(185, 64, 47, .9); }

.sx-hint { font-family: var(--hand); font-size: 21px; color: var(--ink-faint); margin-top: 22px; }

/* recent searches — a little jotted list shown before you start typing */
.sx-recent { margin-top: 26px; max-width: 460px; }
.sx-recent-head {
  font-family: var(--type); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); display: flex; align-items: baseline; gap: 10px;
  border-bottom: 1px solid #e6dcc6; padding-bottom: 5px;
}
.sx-recent-clear {
  font-family: var(--type); font-size: 10px; color: var(--ink-faint);
  background: none; border: 0; cursor: pointer; padding: 0; margin-left: auto; text-transform: none;
}
.sx-recent-clear:hover { color: var(--pen); text-decoration: underline; }
.sx-recent-list { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.sx-recent-item {
  font-family: var(--hand); font-size: 20px; line-height: 1; color: var(--ink-soft);
  background: none; border: 0; cursor: pointer; padding: 2px 0;
  border-bottom: 1.5px solid transparent;
}
.sx-recent-item:hover { color: var(--ink); border-bottom-color: var(--pen); }

/* results — a binder divider per album, songs within */
.sx-results { margin-top: 14px; }
.sx-album {
  position: relative; margin-top: 30px; padding: 2px 8px 12px;
  background: color-mix(in srgb, var(--album) 5%, var(--paper));
  border-radius: 0 4px 4px 0;
}
.sx-album-tab {
  display: inline-flex; align-items: center;
  margin: 0 0 6px -56px; padding: 3px 15px 4px 11px;
  background: var(--paper-edge); border: 1px solid #ddd2bb; border-left: 5px solid var(--album);
  border-radius: 0 6px 6px 0;
}
.sx-album-era { font-family: var(--hand); font-size: 22px; line-height: 1.05; color: color-mix(in srgb, var(--album) 78%, #2b2722); }
.sx-song { margin-top: 16px; }
.sx-song:first-of-type { margin-top: 4px; }
.sx-song-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--album) 24%, #e3d9c2); }
.sx-song-title { font-family: var(--hand); font-size: 23px; line-height: 1.1;
  color: color-mix(in srgb, var(--album) 68%, var(--ink)); }
.sx-song-count { font-family: var(--type); font-size: 10px; color: var(--ink-faint); margin-left: auto; }

/* a single hit — section jotted in the margin (hand), line number in typewriter */
.sx-hit { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 6px 0; }
.sx-ann { text-align: right; padding-top: 4px; }
.sx-sec { display: block; font-family: var(--hand); font-size: 14px; color: var(--ink-soft); line-height: 1.15; }
.sx-ln { display: block; font-family: var(--type); font-size: 10px; color: var(--pen); margin-top: 1px; }
.sx-lines { padding-bottom: 4px; }
.sx-main { font-family: var(--hand); font-size: 21px; color: var(--ink); line-height: 1.55; }
.sx-ctx { font-family: var(--hand); font-size: 16px; color: var(--ink-faint); line-height: 1.45; }
/* the matched word, circled in red pen (a hand-drawn ellipse stretched over the word) */
.sx-main mark {
  background: transparent; color: #1c1813; padding: 2px 7px; margin: 0 -2px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none'%3E%3Cpath d='M50 5 C78 4 95 12 93 21 C91 31 64 36 40 35 C16 34 4 26 6 17 C8 8 31 4 55 5 C77 6 92 12 88 19' fill='none' stroke='%23b9402f' stroke-width='2.4' stroke-linecap='round' opacity='0.85'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 100% 100%; background-position: center;
}

/* flat view */
.sx-flat .sx-hit-flat { grid-template-columns: 1fr; gap: 4px; padding: 10px 0; border-bottom: 1px solid #ece3cd; }
.sx-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--album); flex: none; }
.sx-ann-flat { text-align: left; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 0; }
.sx-ann-flat .sx-dot { align-self: center; }
.sx-flat-title { font-family: var(--hand); font-size: 19px; color: var(--ink); }
.sx-flat-album { font-family: var(--type); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.sx-flat-loc { font-family: var(--type); font-size: 10px; color: var(--ink-faint); margin-left: auto; }
.sx-hit-flat .sx-lines { border-bottom: 0; }

/* right-edge album rail — binder index tabs out in the desk margin that jump to each
   album's results block. Wide desktops only (needs the margin); grouped view only. */
.sx-rail {
  position: fixed; top: 50%; right: 12px; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; z-index: 5; max-height: 84vh; overflow-y: auto;
}
.sx-rail:empty { display: none; }
.sx-rail button {
  font-family: var(--type); font-size: 10px; letter-spacing: .02em; text-align: right;
  color: var(--ink-soft); background: var(--paper-edge);
  border: 1px solid #ddd2bb; border-right: 4px solid var(--al); border-radius: 6px 0 0 6px;
  padding: 4px 9px 4px 11px; cursor: pointer; white-space: nowrap;
  max-width: 156px; overflow: hidden; text-overflow: ellipsis; opacity: .82;
  transition: opacity .15s ease, background .15s ease;
}
.sx-rail button:hover { opacity: 1; background: #fff8ec; }
@media (max-width: 1180px) { .sx-rail { display: none; } }

/* honest footer — copyright/about note, no tracking, offline */
.sx-foot {
  max-width: 820px; margin: 0 auto 60px; padding: 0 34px 0 62px;
  font-family: var(--type); font-size: 11px; line-height: 1.7; color: #cdbf9f;
}
.sx-foot p { margin: 6px 0; max-width: 60ch; }
.sx-foot a { color: #e6dcc1; text-decoration: none; border-bottom: 1px dashed rgba(230,220,193,.4); }
.sx-foot a:hover { border-bottom-color: rgba(230,220,193,.85); }

@media (max-width: 560px) {
  .sx-page { padding: 22px 18px 40px 42px; background-image: linear-gradient(to right, transparent 28px, var(--margin) 28px, var(--margin) 29px, transparent 29px); }
  #q { font-size: 28px; }
  .sx-hit { grid-template-columns: 42px 1fr; gap: 7px; }
  .sx-foot { padding: 0 18px 0 42px; }
}
