/* =================================================================
   LyricLine — main stylesheet
   Design concept: liner notes for a digital age. Editorial type,
   a tracklist-style rhythm for listings, and a three-colour system
   (borrowed from stage lighting) that carries real meaning: pink for
   the original lyric, blue for the romanization, gold for the
   translation. That colour system is the one deliberately bold
   element; everything else stays quiet on purpose.
   ================================================================= */

/* ---------- Design tokens ---------- */
:root {
  --ink: #1b1720;
  --ink-soft: #5a5462;
  --paper: #faf9fb;
  --paper-raised: #f1eef4;
  --line: #e4e0e8;

  --brand: #6b3fa0;
  --brand-ink: #4e2d77;
  --brand-tint: #efe7f7;

  --original: #b0206b;
  --original-bg: #fbeaf3;
  --romanized: #0b6e8c;
  --romanized-bg: #e7f4f8;
  --translation: #96650a;
  --translation-bg: #fbf3e3;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif;

  --max-width: 940px;
  --radius: 10px;
  --radius-sm: 6px;

  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #f1eef4;
    --ink-soft: #b9b2c2;
    --paper: #16131c;
    --paper-raised: #201c28;
    --line: #332c3d;
    --brand: #b48ce0;
    --brand-ink: #d6bff2;
    --brand-tint: #29223a;
    --original: #f172ac;
    --original-bg: #33192a;
    --romanized: #5fc7e8;
    --romanized-bg: #12313b;
    --translation: #e3b24c;
    --translation-bg: #382c11;
    color-scheme: dark;
  }
}

[data-theme='dark'] {
  --ink: #f1eef4;
  --ink-soft: #b9b2c2;
  --paper: #16131c;
  --paper-raised: #201c28;
  --line: #332c3d;
  --brand: #b48ce0;
  --brand-ink: #d6bff2;
  --brand-tint: #29223a;
  --original: #f172ac;
  --original-bg: #33192a;
  --romanized: #5fc7e8;
  --romanized-bg: #12313b;
  --translation: #e3b24c;
  --translation-bg: #382c11;
  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem; top: -3rem;
  background: var(--brand);
  color: #fff;
  padding: 0.6em 1em;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-sm);
}
.container--narrow { max-width: 640px; }
.container--song { max-width: 760px; padding-block: var(--space-md) var(--space-xl); }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 40;
}
.site-header__inner {
  max-width: var(--max-width);
  margin-inline: auto;
  padding: 0.9rem var(--space-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.site-header__actions { display: flex; gap: 0.5rem; order: 2; }
.icon-button, .nav-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  color: var(--ink);
  display: inline-flex;
}

/* On mobile, nav + search collapse into a full-width row that is hidden
   until the menu button is pressed. */
.site-nav, .site-search { flex-basis: 100%; display: none; order: 3; }
.site-nav.is-open, .site-search.is-open { display: flex; }

.site-nav { flex-direction: column; gap: 0.75rem; }
.site-nav a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
  padding: 0.25rem 0;
}
.site-nav a[aria-current='page'] { color: var(--brand); }

.site-search { position: relative; }
.site-search input[type='search'] {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.55em 1.1em;
  background: var(--paper-raised);
  color: var(--ink);
}
.search-results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0,0,0,0.14);
  z-index: 50;
  max-height: 60vh;
  overflow-y: auto;
}
.search-results a {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  padding: 0.6em 0.9em;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a:focus-visible { background: var(--paper-raised); }
.search-results .result-title { font-weight: 600; }
.search-results .result-artist { font-size: 0.875rem; color: var(--ink-soft); }
.search-results__empty { padding: 0.9em; color: var(--ink-soft); }

@media (min-width: 860px) {
  .site-header__inner { padding-block: 1.1rem; flex-wrap: nowrap; }
  .nav-toggle { display: none; }
  .site-nav, .site-search {
    display: flex !important;
    flex-basis: auto;
    order: initial;
  }
  .site-nav { flex-direction: row; gap: var(--space-md); }
  .site-search { width: 220px; flex-shrink: 0; }
  .site-header__actions { order: initial; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: var(--space-xl); }
.site-footer__inner {
  max-width: var(--max-width);
  margin-inline: auto;
  padding: var(--space-lg) var(--space-sm);
  color: var(--ink-soft);
  font-size: 0.925rem;
}
.site-footer__inner nav { display: flex; gap: var(--space-md); margin: var(--space-sm) 0; flex-wrap: wrap; }
.site-footer__inner nav a { color: var(--ink-soft); }
.site-footer__legal { margin: 0; font-size: 0.85rem; }

/* ---------- Hero ---------- */
.hero { padding-block: var(--space-xl) var(--space-lg); }
.hero__title {
  font-size: clamp(2rem, 4.6vw + 1rem, 3.4rem);
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.4em;
  margin-bottom: 0.4em;
}
.hero__word--original { color: var(--original); }
.hero__word--romanized { color: var(--romanized); font-style: italic; }
.hero__word--translation { color: var(--translation); }
.hero__sub { max-width: 46ch; font-size: 1.1rem; color: var(--ink-soft); }
.hero__search { display: flex; gap: 0.6em; max-width: 480px; margin-block: var(--space-md); }
.hero__search input {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.7em 1.2em;
  background: var(--paper-raised);
}

.hero__demo {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--paper-raised);
  border-radius: var(--radius);
  max-width: 520px;
  border-left: 4px solid var(--brand);
}
.hero__demo-line { margin: 0 0 0.35em; font-size: 1.05rem; }
.hero__demo-line--original { color: var(--original); font-weight: 600; }
.hero__demo-line--romanized { color: var(--romanized); font-style: italic; }
.hero__demo-line--translation { color: var(--ink); margin-bottom: 0.6em; }
.hero__demo-credit { font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; }
.hero__demo-credit:hover { color: var(--brand); }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.5em;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background 0.15s ease, transform 0.1s ease;
}
.button--primary { background: var(--brand); color: #fff; }
.button--primary:hover { background: var(--brand-ink); }
.button--primary:active { transform: scale(0.98); }

/* ---------- Sections & tracklist ---------- */
.section { margin-block: var(--space-xl); }
.section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.section__header h2 { margin: 0; }
.section__header a { font-size: 0.9rem; text-decoration: none; }

.page-title { font-size: clamp(1.75rem, 3vw + 1rem, 2.5rem); margin-top: var(--space-md); }
.page-intro { color: var(--ink-soft); max-width: 60ch; }

.tracklist { border-top: 1px solid var(--line); }
.tracklist__row {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.85em 0.1em;
  border-bottom: 1px solid var(--line);
}
.tracklist__row--placeholder { color: var(--ink-soft); grid-template-columns: 1fr; }
.tracklist__index {
  font-family: var(--font-display);
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.tracklist__info { display: flex; flex-direction: column; min-width: 0; }
.tracklist__title {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tracklist__title:hover { color: var(--brand); }
.tracklist__artist { color: var(--ink-soft); text-decoration: none; font-size: 0.9rem; }
.tracklist__artist:hover { color: var(--brand); }
.tracklist__tag {
  font-size: 0.8rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25em 0.75em;
  white-space: nowrap;
}
.tracklist__tag--kpop { color: var(--original); border-color: var(--original-bg); background: var(--original-bg); }
.tracklist__tag--jpop { color: var(--romanized); border-color: var(--romanized-bg); background: var(--romanized-bg); }

.back-link { display: inline-block; text-decoration: none; color: var(--ink-soft); margin-top: var(--space-md); }
.back-link:hover { color: var(--brand); }

.empty-state { padding: var(--space-lg) 0; color: var(--ink-soft); }

.stat-strip {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.stat-strip > div { display: flex; flex-direction: column; }
.stat-strip strong { font-family: var(--font-display); font-size: 1.8rem; }
.stat-strip span { color: var(--ink-soft); font-size: 0.875rem; }

.cta-band {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  background: var(--brand-tint);
  border-radius: var(--radius);
  margin-block: var(--space-xl);
}
.cta-band h2 { margin-bottom: 0.2em; }
.cta-band p { color: var(--ink-soft); }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
}
.pager a, .pager span { text-decoration: none; color: var(--ink); }
.pager a { color: var(--brand); }
.pager span[aria-disabled] { color: var(--ink-soft); }
.pager__status { font-size: 0.875rem; color: var(--ink-soft); }

/* ---------- Liner notes (song metadata) ---------- */
.song-title { margin-top: 0.3em; }
.liner-notes {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4em 1.2em;
  margin: var(--space-md) 0 var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--paper-raised);
  border-radius: var(--radius);
  font-size: 0.925rem;
}
.liner-notes__row { display: contents; }
.liner-notes dt { color: var(--ink-soft); }
.liner-notes dd { margin: 0; }
.liner-notes dd a { color: var(--ink); text-decoration: none; font-weight: 600; }
.liner-notes dd a:hover { color: var(--brand); }

/* ---------- Lyrics: the core feature ---------- */
.lyrics-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-block: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.lyric-legend { display: flex; gap: var(--space-sm); flex-wrap: wrap; font-size: 0.875rem; color: var(--ink-soft); }
.lyric-legend__item { display: inline-flex; align-items: center; gap: 0.4em; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot--original { background: var(--original); }
.dot--romanized { background: var(--romanized); }
.dot--translation { background: var(--translation); }

.view-switch {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}
.view-switch__btn {
  background: none;
  border: none;
  border-radius: 999px;
  padding: 0.35em 0.9em;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.view-switch__btn.is-active { background: var(--brand); color: #fff; }

.lyrics-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.lyric-section { margin-bottom: var(--space-lg); }
.lyric-section__label {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: var(--space-sm);
}

.lyric-columns-header { display: none; }

/* Stacked mode (default): each line is original -> romanized -> translation,
   one under another, each tinted so the three roles stay easy to tell apart
   without relying on colour alone (romanized text is also italic). */
.lyric-block { display: flex; flex-direction: column; gap: var(--space-sm); }
.lyric-line { display: flex; flex-direction: column; border-radius: var(--radius-sm); overflow: hidden; }
.lyric-line p { margin: 0; padding: 0.5em 0.8em; }
.lyric-line__original { background: var(--original-bg); color: var(--ink); font-size: 1.08rem; border-left: 3px solid var(--original); }
.lyric-line__romanized { background: var(--romanized-bg); color: var(--ink); font-style: italic; border-left: 3px solid var(--romanized); }
.lyric-line__translation { background: var(--translation-bg); color: var(--ink); border-left: 3px solid var(--translation); }

/* Columns mode: same markup, reflowed with CSS Grid. Each .lyric-line
   becomes `display: contents`, so its three <p> children become direct
   grid items of .lyric-block and fall into column 1 / 2 / 3 in order. */
[data-view='columns'] .lyric-block {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  column-gap: var(--space-sm);
  row-gap: var(--space-2xs);
  min-width: 680px;
}
[data-view='columns'] .lyric-line { display: contents; }
[data-view='columns'] .lyric-line p { border-radius: var(--radius-sm); height: 100%; }
[data-view='columns'] .lyric-columns-header {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  column-gap: var(--space-sm);
  min-width: 680px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
  padding-bottom: 0.4em;
  margin-bottom: 0.6em;
  border-bottom: 1px solid var(--line);
}

/* ---------- Forms (request page) ---------- */
.request-form { display: flex; flex-direction: column; gap: var(--space-md); margin-block: var(--space-md); }
.field { display: flex; flex-direction: column; gap: 0.4em; }
.field label { font-weight: 600; font-size: 0.925rem; }
.field__optional { font-weight: 400; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65em 0.8em;
  background: var(--paper-raised);
  color: var(--ink);
}
.field--hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.request-form__status { min-height: 1.4em; font-weight: 600; }
.request-form__status.is-success { color: var(--romanized); }
.request-form__status.is-error { color: var(--original); }
.fine-print { font-size: 0.825rem; color: var(--ink-soft); margin-top: var(--space-md); }

/* ---------- Search page ---------- */
.search-page__form input {
  width: 100%;
  font-size: 1.1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8em 1.1em;
  background: var(--paper-raised);
  margin-block: var(--space-sm);
}
.search-page__filters { display: flex; gap: 0.5em; margin-bottom: var(--space-sm); }
.chip {
  border: 1.5px solid var(--line);
  background: none;
  border-radius: 999px;
  padding: 0.4em 1em;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.search-page__status { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Misc ---------- */
@media (min-width: 640px) {
  .hero__search { flex-wrap: nowrap; }
}
