/* =========================================================
   RIDDIM INDEX  v1.1  —  Clean & Organized CSS
   ========================================================= */

/* =========================================================
   1. トークン / ベース設定
   ========================================================= */

:root{
  /* spacing */
  --sp-2: 2px;
  --sp-4: 4px;
  --sp-6: 6px;
  --sp-8: 8px;
  --sp-10: 10px;
  --sp-12: 12px;

  /* control height */
  --ctl-h: 36px;

  /* colors (dark theme) */
  --bg:          #0e0e10;
  --surface:     #18181b;
  --border:      #26262c;
  --border-dash: #26262c;
  --accent:      #9146ff;
  --text-main:   #f7f7f8;
  --text-soft:   #c8c8d0;
  --chip-bg:     #1f1f23;

  /* star color */
  --star-off: #f0c25a;
  --star-on:  #ffd864;

  /* base font size (mobile/tablet) */
  --fs: 14px;

  /* detail page geometry */
  --card-left:      10px;
  --metagrid-left:  10px;
  --metarow-left:   6px;
  --align-left:     calc(var(--metagrid-left) + var(--metarow-left));
  --title-pad-left: calc(var(--align-left) - var(--card-left));
}

*{
  box-sizing: border-box;
}

html, body{
  height: 100%;
}

body{
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  font: var(--fs)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =========================================================
   2. レイアウト
   ========================================================= */

.container{
  width: calc(100% - 24px);
  max-width: 800px;
  margin: 0 auto;
}

/* =========================================================
   3. ヘッダー / タイトル / 検索 / フィルタ
   ========================================================= */

.masthead{
  padding: 16px 0 4px;
  background: transparent;
  border-bottom: none;
}

.title{
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .2px;
}

.title .ver{
  font-size: 11px;
  color: var(--accent);
  margin-left: 6px;
}

.titleline{
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* タイトルのリンク（インデックスに戻る） */
.titleLink{
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.titleLink:visited{
  color: inherit;
}

@media (hover:hover){
  .titleLink:hover{
    text-decoration: none;
  }
}

/* 検索窓 */
.input{
  height: var(--ctl-h);
  width: 100%;
  padding: 0 12px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-soft);
  outline: none;
  font-size: 16px;
}

.masthead .input{
  margin-top: 4px;
}

.input::placeholder{
  color: var(--text-soft);
  opacity: .7;
}

.input:focus{
  border-color: var(--accent);
}

/* フィルタ */
.filters{
  margin-top: 4px;
  display: flex;
  gap: var(--sp-10);
  background: transparent;
}

.filters select{
  height: var(--ctl-h);
  min-width: 120px;
  padding: 0 10px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 13px;
}

.filters select:focus{
  border-color: var(--accent);
}

/* ★ フィルタボタン */
.favFilterBtn{
  height: var(--ctl-h);
  width: 40px;
  flex: 0 0 auto;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  font-size: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

.favFilterBtn::before{
  content: "★";
  font-size: 20px;
  color: var(--star-off);
}

.favFilterBtn:focus{
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

@media (hover:hover){
  .favFilterBtn:hover{
    border-color: var(--accent);
  }
}

.favFilterBtn.is-active{
  background: var(--accent);
  border-color: var(--accent);
}

.favFilterBtn.is-active::before{
  color: var(--star-on);
}

.meta{
  margin-top: var(--sp-8);
  margin-bottom: 0;          /* ← 下の余白を詰める */
  color: var(--text-soft);
  font-size: 12px;           /* ← ソート文を少し小さめに */
}

/* =========================================================
   4. 共通コンポーネント（カード / ソート / フッター）
   ========================================================= */

.card{
  margin: 12px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar{
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar--in{
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

/* ソートボタン */
.sortBtn{
  height: var(--ctl-h);
  min-width: 110px;
  padding: 0 10px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-soft);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sortBtn.active{
  border-color: var(--accent);
  color: var(--accent);
  background: #211f35;
}

.sortBtn .dir{
  opacity: .7;
  width: 1em;
  text-align: center;
}

/* YouTube */
.ytBtn{
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ytBtn:focus{
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.ytIcon{
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 9px;
  border-color: transparent transparent transparent var(--text-soft);
  margin-left: 1px;
}

@media (hover:hover){
  .ytBtn:hover{ border-color: var(--accent); }
}

/* フッター */
.footerNote{
  text-align: center;
  color: var(--text-soft);
  opacity: .6;
  font-size: 10px;
  padding: 15px 0 20px;
}

/* =========================================================
   5. インデックスページ（columns / rows / ★）
   ========================================================= */

.columns{
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
}

.columns .name,
.columns .label{
  flex: 1 1 45%;
  min-width: 120px;
  cursor: pointer;
}

.columns .year{
  flex: 0 0 76px;
  text-align: right;
  white-space: nowrap;
  cursor: pointer;
}

.columns .sorted{
  color: var(--accent);
}

/* rows */
.list{
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  padding: 0 var(--sp-6);
}

.row{
  display: flex;
  gap: 6px;
  align-items: center;
  padding: var(--sp-6);
  border-bottom: 1px dashed var(--border-dash);
  color: var(--text-soft);
}

.row:last-child{
  border-bottom: none;
}

/* name/label/year */
.name,
.label{
  flex: 1 1 45%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.year{
  flex: 0 0 76px;
  text-align: right;
}

/* ★ トグル */
.row .name{
  display: flex;
  align-items: center;
  margin-left: -6px;
}

.favToggle{
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  margin-right: 1px;
  color: var(--star-off);
  width: 1.2em;
  height: 1.2em;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: 1px;
}

.favToggle.is-on{
  color: var(--star-on);
}

@media (hover:hover){
  .favToggle:hover{ transform: translateY(-1px); }
}

.nameText{
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* クリック範囲 */
.row.row--click{
  position: relative;
  cursor: pointer;
}

.row.row--click::before{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.05);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}

@media (hover:hover){
  .row.row--click:hover::before{ opacity: 1; }
}

.row.row--click.touch-hover::before{
  opacity: 1;
}

/* =========================================================
   6. 詳細ページ
   ========================================================= */

.cardHead{
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.cardHead__row{
  display: flex;
  align-items: center;
  gap: 8px;
}

.cardHead__title{
  margin: 0;
  font-size: 18px;
  font-weight: 400;
  padding-left: var(--title-pad-left);
  color: var(--text-main);
}

/* 詳細ページの★ */
.detailPage .cardHead__row .favToggle{
  font-size: 18px;
  margin-right: -10px;
  position: relative;
  top: 1px;
}

/* メタ情報 */
.metaGrid{
  display: grid;
  padding: 0 10px;
}

.metaRow{
  display: grid;
  grid-template-columns: 160px 1fr;
  padding: 7px 6px;
  border-bottom: 1px dashed var(--border-dash);
}

.metaRow:last-child{
  border-bottom: none;
}

.metaKey{
  color: var(--text-soft);
}

.metaVal{
  color: var(--text-soft);
  margin-left: -60px;
}

/* PICKUP リスト */
.songList{
  list-style: none;
  padding: 0 10px;
  margin: 0;
}

.songRow{
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border-dash);
  color: var(--text-soft);
  position: relative;
  overflow: hidden;
}

.songRow:last-child{
  border-bottom: none;
}

/* PICKUP 行内のテキスト */
.songRow .dot{
  position: relative;
  left: -0.1em;
  width: 0.8em;
  display: inline-block;
  color: var(--text-soft);
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  margin-left: 6px;
}

.songRow .artist{
  font-weight: 400;
}

.songRow .title{
  font-weight: 400;
  font-size: inherit;
}

.songRow .sep{
  opacity: .7;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.songRow::before{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.05);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}

@media (hover:hover){
  .songRow:hover::before{ opacity: 1; }
}

.songRow.touch-hover::before{
  opacity: 1;
}

.songLink{
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-soft);
  text-decoration: none;
}

/* =========================================================
   7. ページレイアウト（index / detail）
   ========================================================= */

body.detailPage{
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.detailPage .masthead{
  padding: 16px 0 0;
  margin-bottom: -4px;
}

body.detailPage .card.container:first-of-type{
  flex: 0 0 auto;
  margin-top: 8px;
}

body.detailPage .card.container:nth-of-type(2){
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  margin-top: -3px;
  margin-bottom: 0;
}

body.detailPage .card.container:nth-of-type(2) .songList{
  flex: 1 1 auto;
  max-height: var(--pickup-max-height, 320px);
  overflow-y: auto;
}

body.indexPage{
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

body.indexPage .card.container{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}

body.indexPage .card.container .columns{
  flex: 0 0 auto;
}

body.indexPage .card.container .list{
  flex: 1 1 auto;
  overflow-y: auto;
}

body.indexPage .card .list{
  flex: 1 1 auto;
}

body.indexPage .card .row:last-child{
  padding-bottom: 8px;
}

/* =========================================================
   8. レスポンシブ
   ========================================================= */

@media (max-width:700px){
  .meta{
    margin-bottom: 2px;
  }
}

@media (max-width:900px){
  .columns{
    display: grid;
    grid-template-columns: 1.4fr 0.8fr 76px;
    gap: 4px 8px;
    padding: 10px 10px;
  }

  .columns .label{
    padding-left: 35px;
  }

  .row{
    display: grid;
    grid-template-columns: 1.4fr 0.8fr 76px;
    gap: 4px 8px;
    padding: 6px 8px;
  }

  .row > .name,
  .row > .label{
    min-width: 0;
  }

  .row > .name{
    margin-left: -10px;
    overflow: hidden;
  }

  .row > .label{
    padding-left: 10px;
    overflow: visible;
  }
}

@media (max-width:768px){
  .songRow{
    overflow-x: auto;
  }

  .songLink{
    white-space: nowrap;
    min-width: 100%;
  }
}

@media (max-width:600px){
  .footerNote{
    font-size: 8px;
  }
}

@media (min-width:901px){
  .sticky-head{
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
  }

  :root{
    --fs: 16px;   /* PC base font */
  }

  .metaVal{
    margin-left: -20px;
  }
}

/* モバイル専用フォントサイズ（700px以下） */
@media (max-width:700px){
  :root{
    --fs: 12px;
  }
}

/* =========================================================
   9. リセットボタン
   ========================================================= */

.resetBtn{
  height: var(--ctl-h);
  width: 40px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.resetBtn:focus{
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

@media (hover:hover){
  .resetBtn:hover{
    border-color: var(--accent);
    color: var(--accent);
  }
}

.resetBtn:active,
.resetBtn.pressed{
  background: #211f35;
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(0.96);
}

.footerLogoWrap{
  text-align: center;
  margin-top: 10px;
  margin-bottom: 25px;
}