/* ============================================================
   KMA_AUDIO_UI_AUDIBLE_V1 2026-02-16
   - expanded panel (Audible-like) scaffolding
   ============================================================ */

/* hidden by default (JS will toggle aria-hidden) */
#audio-mini-player,
#global-audio-expanded{
  display: none;
}

#global-audio-expanded[aria-hidden="false"]{
  display: block;
}

/* overlay panel */
#global-audio-expanded{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: rgba(0,0,0,.48);
  padding: 12px;
}

/* panel body */
#global-audio-expanded .audio-expanded-inner{
  position: relative;
  max-width: 860px;
  margin: 0 auto; align-self: start;
  background: #fff;
  border-radius: 16px;
  padding: 12px 12px 16px;
  box-shadow: 0 -16px 40px rgba(0,0,0,.18);
}

/* cover (placeholder) */
#global-audio-expanded .audio-expanded-cover{
  width: 100px;
  height: 100px;
  border-radius: 12px;
  background: rgba(0,0,0,.08);
  float: left;
  margin-right: 12px;
}

/* meta */
#global-audio-expanded .audio-expanded-meta{
  min-height: 100px;
  padding-top: 2px;
}

#global-audio-expanded .audio-expanded-title{
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#global-audio-expanded .audio-expanded-sub{
  font-size: 12px;
  opacity: .7;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* progress */
#global-audio-expanded .audio-expanded-progress{
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

#global-audio-expanded .audio-seek{
  flex: 1;
}

/* controls */
#global-audio-expanded .audio-expanded-controls{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

#global-audio-expanded .audio-expanded-controls button{
  height: 40px;
  min-width: 52px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.12);
  cursor: pointer;
}

#global-audio-expanded .audio-play-large{
  height: 48px;
  min-width: 90px;
  font-size: 20px;
  border-radius: 16px;
}

/* close */
#global-audio-expanded .audio-expanded-close{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.12);
  cursor: pointer;
}

/* mobile: fullscreen-ish */
@media (max-width: 768px){
  #global-audio-expanded{
    padding: 0;
    background: #fff;
  }
  #global-audio-expanded .audio-expanded-inner{
    max-width: 100%;
    margin: 0;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    padding: 16px 16px 22px;
  }
  #global-audio-expanded .audio-expanded-cover{
    width: 46vw;
    height: 46vw;
    max-width: 220px;
    max-height: 220px;
    float: none;
    margin: 10px auto 12px;
  }
  #global-audio-expanded .audio-expanded-meta{
    min-height: 0;
    text-align: center;
  }
}

/* AUDIBLE_BAR_STEP2: injected UIが有効な時はネイティブaudio自体を視界から外す */
#global-audio-player.has-audible-ui #global-audio{
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  inset: auto auto 0 0;
}

/* has-audible-ui時はサブ文言を消して縦スペースを詰める */
#global-audio-player.has-audible-ui .audio-player-sub{
  display: none;
}

/* PC: footerを「左メタ（タイトル＋操作） / 右操作（progress＋controls）」へ */
@media (min-width: 769px){

  #global-audio-player.has-audible-ui{
    min-height: 108px;
  }

  #global-audio-player.has-audible-ui.audible-ready .audio-player-inner{
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(504px, 612px);
    grid-template-rows: auto auto;
    grid-template-areas:
      "meta progress"
      "meta controls";
    align-items: center;
    column-gap: 16px;
    row-gap: 6px;
  }

  /* 左: タイトル＋（ブクマ→目次→再生速度） */
  #global-audio-player.has-audible-ui.audible-ready .audio-player-meta{
    grid-area: meta;
    min-width: 0;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 10px;
    align-items: start;
  }

  #global-audio-player.has-audible-ui.audible-ready .audio-player-thumb{
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: rgba(0,0,0,.08);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
  }

  #global-audio-player.has-audible-ui .audio-player-title{
    grid-column: 2;
    grid-row: 1;
    font-weight: 700;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    line-height: 1.22;
    max-width: 34ch;
  }

  #global-audio-player.has-audible-ui.audible-ready .audio-player-meta .ab-actions{
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 22px;
    margin-top: 0;
    flex-wrap: nowrap;
  }

  /* audible-barは右側へ（progress/controlsだけ使う） */
  #global-audio-player.has-audible-ui.audible-ready .audible-bar{
    width: 100%;
    display: contents; /* 子要素をグリッド領域へ */
  }

  /* 上: progress */
  #global-audio-player.has-audible-ui.audible-ready .audible-bar .ab-progress{
    grid-area: progress;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  #global-audio-player.has-audible-ui.audible-ready .audible-bar .ab-cur,
  #global-audio-player.has-audible-ui.audible-ready .audible-bar .ab-dur{
    width: 50px;
    text-align: center;
    font-size: 12px;
    opacity: .75;
    white-space: nowrap;
  }

  #global-audio-player.has-audible-ui.audible-ready .audible-bar .ab-seek{
    flex: 1;
    min-width: 320px;
  }

  /* 下: controls（左右に広げる） */
  #global-audio-player.has-audible-ui.audible-ready .audible-bar .ab-controls{
    grid-area: controls;
    width: 360px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin: 0 auto; align-self: start;
  }

  /* navはcontrols内に移動済み前提 */
  #global-audio-player.has-audible-ui .audio-player-nav{
    display: contents;
  }

  /* 順序: prev / -30 / play / +30 / next */
  #global-audio-player.has-audible-ui .audio-prev{ order: 1; }
  #global-audio-player.has-audible-ui .ab-back{   order: 2; }
  #global-audio-player.has-audible-ui .ab-play{   order: 3; }
  #global-audio-player.has-audible-ui .ab-fwd{    order: 4; transform: translateY(-2px); }
  #global-audio-player.has-audible-ui .audio-next{ order: 5; }

  /* ===== Audible-like button visuals (SVG + black play circle) ===== */

  /* base */
  #global-audio-player.has-audible-ui .ab-controls button,
  #global-audio-player.has-audible-ui .audio-player-nav button{
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s;
    outline: none;
    color: rgba(255,255,255,0.94);
  }
  #global-audio-player.has-audible-ui .ab-controls button:hover,
  #global-audio-player.has-audible-ui .audio-player-nav button:hover{
    opacity: .7;
  }
  #global-audio-player.has-audible-ui .ab-controls button:focus-visible,
  #global-audio-player.has-audible-ui .audio-player-nav button:focus-visible{
    outline: none;
  }

  /* svg stroke style（共通） */
  #global-audio-player.has-audible-ui .ab-controls svg,
  #global-audio-player.has-audible-ui .audio-player-nav svg{
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
  }

  /* play = white circle + dark glyph (PC) */
  #global-audio-player.has-audible-ui .ab-controls .play-btn{
    background-color: #ffffff;
    border-radius: 9999px;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* play/pause svg inside circle */
  #global-audio-player.has-audible-ui .ab-controls .play-btn svg,
  #global-audio-player.has-audible-ui .ab-controls .play-btn svg path{
    fill: #111827;
    stroke: none;
  }

  #global-audio-player.has-audible-ui .ab-controls .play-btn svg{
    width: 46px;
    height:  46px;
    margin-left: 0; /* ここで全体をズラさない */
  }

  /* visual centering: triangle only */
  #global-audio-player.has-audible-ui .ab-controls .play-btn .play-svg{
    margin-left: 1px;
  }
  #global-audio-player.has-audible-ui .ab-controls .play-btn .pause-svg{
    margin-left: 0;
  }

  /* seek buttons (現状の100点サイズ維持) */
  #global-audio-player.has-audible-ui .ab-controls .seek-btn{
    position: relative;
    width: 50px;
    height: 50px;
    color: rgba(255,255,255,0.94);
  }
  #global-audio-player.has-audible-ui .ab-controls .seek-btn svg{
    width: 40px;
    height: 40px;
  }
  #global-audio-player.has-audible-ui .ab-controls .seek-btn svg polygon{
    fill: currentColor;
  }
  #global-audio-player.has-audible-ui .ab-controls .seek-btn .seek-text{
    position: absolute;
    font-size: 8px;
    font-weight: 700;
    top: 54%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.94);
    user-select: none;
    pointer-events: none;
  }

  /* left meta actions (speed / favorite / timer) */
  #global-audio-player.has-audible-ui .ab-actions button{
    min-width: 74px;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    line-height: 1;
    color: rgba(255,255,255,0.94);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    text-align: center;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-speed{
    order: 1;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-bookmark{
    order: 2;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-timer{
    order: 3;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-toc{
    display: none;
  }

  #global-audio-player.has-audible-ui .ab-actions button .ab-ico{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-height: 32px;
    font-size: 24px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-speed .ab-ico{
    font-size: 22px;
    font-weight: 700;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-bookmark .ab-ico{
    font-size: 32px;
  }

  #global-audio-player.has-audible-ui .ab-actions .ab-timer .ab-ico{
    font-size: 28px;
  }

  #global-audio-player.has-audible-ui .ab-actions button .ab-lbl{
    display: block;
    font-size: 12px;
    line-height: 1;
    color: rgba(255,255,255,0.72);
    white-space: nowrap;
  }
}

@media (max-width: 768px){
  #global-audio-player.has-audible-ui{
    min-height: 0;
  }
}


/* 再生ボタンのレスポンス向上：クラス切り替え制御（SIZE SINGLE SOURCE） */
#global-audio-player.has-audible-ui .ab-play svg{
  pointer-events: none;
  display: none;
  width: 46px;
  height: 46px;
}

/* 停止中：再生（三角） */
#global-audio-player.has-audible-ui .ab-play:not(.is-playing) .play-svg{
  display: block;
  margin-left: 1px;
}

/* 再生中：一時停止 */
#global-audio-player.has-audible-ui .ab-play.is-playing .pause-svg{
  display: block;
  margin-left: 0;
}







