/* style.css — Mobile-first styles for lyrics pronunciation site */

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Mincho ProN',
               'Noto Serif CJK JP', 'Noto Serif CJK SC', 'Source Han Serif JP',
               'Source Han Serif SC', 'Yu Mincho', 'SimSun', serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #fafaf8;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
}

/* ===== Browse Page (index.html) ===== */
.browse-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.browse-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fafaf8;
  padding: 16px 0 12px;
}

.browse-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  background: #fff;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: #4a90d9;
}

/* Filter row */
.filter-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.lang-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.lang-pill {
  padding: 6px 14px;
  font-size: 0.85rem;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  transition: all 0.15s;
}

.lang-pill.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.tag-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
}

.tag-chips::-webkit-scrollbar {
  display: none;
}

.tag-chip {
  padding: 6px 12px;
  font-size: 0.8rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  transition: all 0.15s;
}

.tag-chip.active {
  background: #e8f0fe;
  border-color: #4a90d9;
  color: #4a90d9;
}

/* Song cards */
.song-list {
  padding: 8px 0 32px;
}

.song-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}

.song-card:active {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-title-en {
  font-size: 0.85rem;
  color: #888;
  margin-top: 2px;
}

.card-artist {
  font-size: 0.85rem;
  color: #666;
  margin-top: 4px;
}

.card-badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.card-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.badge-lang {
  background: #f0f0f0;
  color: #666;
}

.badge-tag {
  background: #f5f0ff;
  color: #7c5cbf;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: #999;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ===== Song Display Page (song.html) ===== */
.song-body {
  max-width: 600px;
  margin: 0 auto;
}

.song-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fafaf8;
  border-bottom: 1px solid #eee;
}

.back-btn {
  font-size: 1.3rem;
  text-decoration: none;
  color: #1a1a1a;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.song-title-header {
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-btn {
  font-size: 0.9rem;
  min-width: 44px;
  min-height: 44px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

/* Line progress indicator (e.g. "3/24") */
.line-progress {
  font-size: 0.78rem;
  color: #aaa;
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Mode selector dropdown */
.mode-selector {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: #fafaf8;
  border-bottom: 1px solid #eee;
  justify-content: center;
}

.mode-pill {
  padding: 6px 16px;
  font-size: 0.85rem;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.15s;
}

.mode-pill.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

/* Song metadata */
.song-meta {
  padding: 10px 16px;
  font-size: 0.85rem;
  color: #888;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meta-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #f5f0ff;
  color: #7c5cbf;
}

/* Song content with lyrics */
.song-content {
  padding: 16px 16px 64px;
}

.loading, .error {
  text-align: center;
  padding: 48px 16px;
  color: #999;
}

.error {
  color: #c0392b;
}

.song-section {
  margin-bottom: 24px;
}

.section-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #aaa;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

/* Lyrics line */
.lyric-line {
  margin-bottom: 6px;
  line-height: 1.5;
  min-height: 2.8em;
  border-left: 3px solid transparent;
  padding-left: 12px;
  border-radius: 0 4px 4px 0;
  transition: background 0.3s, border-color 0.3s, opacity 0.5s ease;
}

/* Current line — spotlight highlight */
.lyric-line.active {
  background: rgba(245, 166, 35, 0.12);
  border-left-color: #f5a623;
  font-weight: 600;
}

/* Past lines — faded out */
.lyric-line.past {
  opacity: 0.35;
}

/* Darker annotation text on active line for readability */
.lyric-line.active .r-rt {
  color: #555;
}

/* Active line in mode-none: slightly larger text since no annotations */
.mode-none .lyric-line.active {
  font-size: 1.05em;
}

/* ===== Ruby Annotation Rendering ===== */

/* Ruby wrapper — inline flex column */
.r {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: top;
  line-height: 1;
  margin: 0 0.08em;
}

/* Annotation container */
.r-annos {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

/* Individual annotation text */
.r-rt {
  font-size: 1em;
  line-height: 1.25;
  white-space: nowrap;
  color: #777;
}

/* Cantonese annotations: tone numbers as superscript */
.r.yue .r-rt {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.3;
}

/* Japanese kana layer inherits from .r-rt */

/* Tone number superscript */
.r-tone {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 0;
  position: relative;
  top: -0.1em;
}

/* Base text */
.r-txt {
  font-size: 1em;
  line-height: 1.4;
}

/* Plain text (no annotation) */
.r-plain {
  white-space: pre-wrap;
  line-height: 1.4;
}

/* ===== Annotation Mode Toggles ===== */

/* Mode: kana-only (hide romaji — the outermost r-rt for JA) */
.mode-kana .r.ja .r-rt:first-child {
  display: none;
}

/* Mode: none (hide all annotations) */
.mode-none .r .r-annos {
  display: none;
}

/* ===== Back to Top Button ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid #ddd;
  background: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ===== Admin Page (admin.html) ===== */
.admin-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fafaf8;
  padding: 14px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eee;
}

.admin-header h1 {
  font-size: 1.2rem;
  font-weight: 600;
}

.admin-header .back-btn {
  font-size: 1.3rem;
  text-decoration: none;
  color: #1a1a1a;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-section {
  margin-top: 16px;
}

.admin-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}

/* File loader area */
.file-loader {
  padding: 20px;
  border: 2px dashed #ddd;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.file-loader:hover {
  border-color: #4a90d9;
}

.file-loader p {
  font-size: 0.85rem;
  color: #888;
}

.file-input {
  display: none;
}

/* Form fields */
.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.95rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: #4a90d9;
}

.form-select {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.95rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  outline: none;
}

/* Section editor */
.section-editor {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.section-editor-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.section-label-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.9rem;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  background: #fff;
  outline: none;
}

.btn-remove {
  min-width: 36px;
  min-height: 36px;
  padding: 4px 10px;
  font-size: 0.85rem;
  border: 1.5px solid #e0c0c0;
  border-radius: 6px;
  background: #fff;
  color: #c0392b;
  cursor: pointer;
}

/* Line editor */
.line-editor {
  margin-bottom: 6px;
}

.line-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-family: 'Source Han Serif JP', 'Noto Serif CJK JP', 'SimSun', serif;
  border: 1.5px solid #eee;
  border-radius: 6px;
  background: #fff;
  outline: none;
}

.line-input:focus {
  border-color: #4a90d9;
}

.line-hint {
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 2px;
  margin-left: 4px;
}

/* Action buttons */
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  padding: 8px 18px;
  font-size: 0.9rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s;
}

.btn-primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.btn-add {
  border-style: dashed;
  width: 100%;
  text-align: center;
}

/* Preview area */
.preview-area {
  margin-top: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  min-height: 60px;
}

/* ===== Responsive: Tablet & Desktop ===== */
@media (min-width: 481px) {
  .song-header, .browse-header, .admin-header {
    padding-left: 0;
    padding-right: 0;
  }

  .song-content {
    padding-left: 0;
    padding-right: 0;
  }

  .song-meta {
    padding-left: 0;
    padding-right: 0;
  }
}
