/* ==========================================================================
   പാട്ടുകൾ — Songs (js/views/songs.js)
   Uses Muttam tokens: gold ↔ Thinnai zari, teal ↔ peacock, red ↔ kumkum.
   Helper classes Thinnai shared from its palli.css (pp-*, chip--gold, btn--good) are scoped here.
   ========================================================================== */
:is(.songs-home, .songs-section, .song-page) .chip--gold { background: var(--gold-soft); color: var(--gold-deep); }
.song-page .btn--good, .song-page .btn--good:disabled { background: var(--leaf); color: var(--on-leaf, #fff); opacity: 1; }

/* Home */
.song-group { margin-top: 26px; }
.song-group-note { margin: 4px 0 0; font-size: .92rem; }
.song-group .song-sections { margin-top: 12px; }
.song-sections { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.song-sec-card { display: flex; align-items: center; gap: 16px; padding: 18px 20px; min-height: 110px; border-radius: var(--r-lg); text-decoration: none; color: var(--ink);
  background: linear-gradient(150deg, var(--h1, var(--gold-soft)), var(--surface) 75%); border: 1px solid var(--line); box-shadow: var(--shadow-1); transition: transform .15s, border-color .15s; }
.song-sec-card:hover { border-color: var(--hi, var(--teal)); transform: translateY(-2px); }
.song-sec-emoji { font-size: 2.6rem; line-height: 1; }
.song-sec-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.song-sec-text .ml { font: 700 1.35rem/1.4 var(--f-display); color: var(--hi, var(--teal-deep)); }
.song-sec-text .en { font-weight: 600; color: var(--ink-2); }
.song-sec-meta { font-size: .82rem; color: var(--ink-3); }
.song-staff { margin: 14px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.song-more { margin: 28px 0 0; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.song-more .icon { width: 18px; height: 18px; color: var(--gold-deep); }
.song-more a { font-weight: 700; color: var(--teal-deep); }

/* Section list */
.song-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.song-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.song-row:hover { border-color: var(--teal); }
.song-row.is-learned { background: linear-gradient(90deg, var(--leaf-soft), var(--surface) 60%); }
.song-row-emoji { font-size: 1.8rem; }
.song-row-text { flex: 1; display: grid; min-width: 0; }
.song-row-text .ml { font: 700 1.15rem/1.5 var(--f-display); }
.song-row-text .en { font-size: .9rem; color: var(--ink-2); }
.song-when { font-size: .8rem; color: var(--ink-3); }
@media (max-width: 480px) { .song-row .chip { display: none; } }

/* One song */
.song-source { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: .88rem; color: var(--ink-2); position: relative; }
.song-source .icon { width: 16px; height: 16px; }
.song-tune { margin: 14px 0 0; padding: 10px 14px; border-radius: 14px; background: var(--gold-soft); color: var(--ink); font-size: .95rem; }
.song-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; align-items: center; }
.song-page .pp-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: var(--r-pill); border: 2px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 .88rem var(--f-ui); cursor: pointer; }
.song-page .pp-toggle .icon { width: 18px; height: 18px; }
.song-page .pp-toggle[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-deep); }
@media (max-width: 560px) { .song-tools .pp-toggle { flex: 1 1 auto; justify-content: center; } }
.song-note { min-height: 1.5em; margin: 0 0 8px; font-weight: 700; color: var(--teal-deep); }

.song-sheet { padding: clamp(16px, 3vw, 32px); border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.song-sheet.is-verse { background: linear-gradient(160deg, var(--gold-soft), var(--surface) 70%); border: 2px solid var(--gold); }
.song-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.song-line { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 6px 8px; border-radius: 14px; transition: background .2s; }
.song-line.is-singing { background: var(--gold-soft); box-shadow: inset 4px 0 0 var(--gold); }
.song-line.is-your-turn { background: var(--leaf-soft); box-shadow: inset 4px 0 0 var(--leaf); }
.song-line-say { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--teal-soft); color: var(--teal-deep); cursor: pointer; }
.song-line-say .icon { width: 20px; height: 20px; }
.song-line-body { min-width: 0; }
.song-line .rt-line { font-family: var(--f-display); font-weight: 700; font-size: clamp(1.15rem, 1rem + .7vw, 1.45rem); line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.song-sheet.is-verse .rt-line { color: var(--teal-deep); }
.song-tr, .song-en { margin: 2px 0 0; font-size: .9rem; }
.song-tr { color: var(--ink-3); font-family: var(--f-ui); display: none; }
.song-en { color: var(--teal-deep); font-style: italic; display: none; }
.song-lines.show-tr .song-tr, .song-lines.show-en .song-en { display: block; }
.song-page .rt-word.is-hidden-word { color: transparent !important; background: repeating-linear-gradient(90deg, var(--line-2) 0 6px, transparent 6px 9px) left 78% / 100% 3px no-repeat; }

.song-meaning { margin-top: 20px; display: grid; gap: 8px; padding: 16px 18px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); }
.song-meaning .sec-title { margin-bottom: 4px; }
.song-meaning p { margin: 0; }
.song-meaning .rt-line { font-family: var(--f-ml); font-weight: 500; font-size: 1.05rem; }
.song-page .pp-word-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.song-page .pp-word { width: 100%; height: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 8px; padding: 10px 12px; min-height: 58px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.song-page .pp-word:hover { border-color: var(--teal); }
.song-page .pp-word .icon { grid-row: 1 / span 2; grid-column: 2; width: 18px; height: 18px; color: var(--teal); }
.song-page .pp-word-ml { font-family: var(--f-display); font-weight: 700; font-size: 1.12rem; line-height: 1.4; }
.song-page .pp-word-en { font-size: .8rem; color: var(--ink-2); }
.song-done { display: flex; justify-content: center; margin: 22px 0 6px; }
.song-page .pp-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
@media (max-width: 560px) { .song-page .pp-nav { display: grid; grid-template-columns: 1fr 1fr; } .song-page .pp-nav .btn { width: 100%; padding-inline: .6em; } }

/* Watch & sing */
.song-video { display: grid; gap: 10px; margin: 0 0 16px; }
.song-video:empty { display: none; }
.song-video-btn { position: relative; display: block; width: min(560px, 100%); aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: 18px; overflow: hidden; cursor: pointer; background: #000; }
.song-video-btn img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.song-video-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 999px; background: #C4302B; color: #fff; font-weight: 800; font-size: 1.05rem; }
.song-video-frame { width: min(720px, 100%); aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: #000; }
.song-video-frame iframe { width: 100%; height: 100%; border: 0; }
.song-video-edit { padding: 10px 14px; border-radius: 14px; border: 1px dashed var(--line-2); background: var(--surface); }
.song-video-edit summary { cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.song-video-edit .muted { font-size: .88rem; }
.song-video-row { display: flex; gap: 8px; flex-wrap: wrap; }
.song-video-input { flex: 1 1 260px; min-width: 0; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; }

/* Teacher: add a class song */
.song-form { display: grid; gap: 12px; padding: 16px 20px 20px; }
.song-form .field { display: grid; gap: 4px; font-weight: 600; }
.song-form input:not([type=checkbox]), .song-form textarea { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 400; }
.song-form textarea.ml, .song-form input.ml { font-family: var(--f-ml); font-size: 1.1rem; }
.song-form .check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.song-form .check input { margin-top: 4px; width: 20px; height: 20px; flex: none; }

:root[data-contrast="high"] .song-sec-card, :root[data-contrast="high"] .song-row, :root[data-contrast="high"] .song-sheet { border-color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) { .song-sec-card { transition: none; } .song-sec-card:hover { transform: none; } }
@media print {
  .song-tools, .song-note, .song-video, .song-done, .song-staff, .song-line-say, .pp-nav { display: none !important; }
  .song-lines .song-en { display: block; }
}
