﻿html {
    background-color: #222;
}

main {
    background-color: var(--background-color);
    background-image: var(--main-background-image);
    background-size: var(--main-background-size);
    background-repeat: repeat;
}

/* ビデオコンテナ */
/* センタリング、幅100%、アスペクト比保持 */
#video-container {
    width: 100%;
    margin: 0 auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#video-container.fullscreen {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 100px;
}

#message {
    /* 垂直の中心に配置 */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    font-size: 2rem;
    text-align: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    /* 縁取り */
    filter: url(#outline-filter);
 
}

#video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    aspect-ratio: 16 / 9;
    background-color: #000;
    transition: opacity 0.3s ease;
    z-index: 1;
    touch-action: none;
    transform-origin: center center;
}

div#osd-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    color: var(--text-color);
    /* 縁取り */
    filter: url(#outline-filter);
    text-align: left;
    z-index: 3;
    opacity: 0.7    ;
    transition: opacity 0.3s ease;
}
div#osd-title {
    font-size: 1.0rem;
    font-weight: bold;
    max-width: 83%
}
div#osd-performer {
    font-size: 0.8rem;
    max-width: 83%;
}
div#osd-time {
    font-size: 1.5rem;
    font-weight: bold;
    position: absolute;
    top: 1rem;
    right: 1rem;
}



#invisible-button {
    position: absolute;
    top: 5%;
    left: 5%;
    right: 5%;
    bottom: 5%;
    width: 90%;
    z-index: 10;
    transition: opacity 0.3s ease;

    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
}

#hidden-ui {
    width: 100%;

    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 20;

    display: flex;
    flex-direction: column;
    justify-content: center;

}

#hidden-ui.visible {
    opacity: 1;
    pointer-events: auto;
}

#controls {
    display: flex;
    justify-content: center;
    position: absolute;
    left: 0;
    gap: 10px;
    width: 100%;
    margin-top: 10rem;
    margin-bottom: 0rem;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem;
    z-index: 30;
}

#lower-left-controls {
    flex: 0 0 auto;
    position: absolute;
    left: 0;
    bottom: 0;
}


#upper-controls {
    display: flex;
    justify-content: end;
    align-items: center;
    gap: 10px;

    position: absolute;
    top: 5rem;
    left: 0;
}


#controls button, #upper-controls button, #lower-left-controls button {
    flex: 1;
    max-width: 120px;
    padding: 0.8rem;
    white-space: nowrap;
    background-color: rgba(64, 64, 64, 0.5);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: 500;
    transition: all 0.2s ease;
    z-index: 40;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

/* タッチデバイス以外でのみhoverをセット */
@media (hover: hover) and (pointer: fine) {
    #controls button:hover, #upper-controls button:hover, #lower-left-controls button:hover {
        background-color: var(--secondary-color);
        border-color: var(--accent-color);
    }
}

/* タッチデバイスではactiveをセット */
@media (hover: none) and (pointer: coarse) {
    #controls button:active,
    #upper-controls button:active,
    #lower-left-controls button:active {
      background-color: rgba(255, 255, 255, 0.1); /* ハイライト色（好みで調整） */
      border-color: var(--accent-color);
    }
  }

#controls button.disabled {
    background-color: var(--secondary-color);
    border-color: var(--accent-color);
    opacity: 0.5;
}

#controls button span.narrow {
    letter-spacing: -0.5em;
    margin-right: 0.5em;
}

#lower-left-controls button {
    max-width: none;
}

button#play-pause {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.3em;
}

button#prev, button#next {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0em;
}
div.pause-button {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.3em;
}


div.pause-bar {
    width: 0.25em; /* 棒の太さ */
    height: 1.2rem; /* 棒の高さ */
    background-color: var(--text-color);
}


/* メタデータ */
#metadata {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
    margin-left: auto;
    margin-right: auto;
    width: 90%;
    padding: 20px;
    border-radius: 10px;
    opacity: 0.9;
}
#metadata.hide {
    display: none;
}
#metadata table {
    border-collapse: none;
    line-height: 1.3;
}
#metadata th.metadata-label {
    font-weight: bold;
    text-align: left;
    vertical-align: top;
    color: var(--accent-color);
    width: 6rem;
}
#metadata td {
    text-align: left;
    vertical-align: top;
}

h1#title {
    font-size: 1rem;
    font-weight: normal;
    margin: 0;
}


/* 購入リンク (ボタン) */   
#link-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}
#buy-link {
    flex: 4;
    display: block;
    padding: 10px;
    background-color: var(--accent-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0.8;
}
#back-link {
    flex: 3;
    text-align: center;
    display: inline-flex;
    align-items: center;
    color: transparent; /* 実際は:afterの内容が表示される */
    position: relative;
    text-decoration: none;
    
}
#back-link:after {
    content: "＜ 一覧に戻る";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--text-color);
}

#buy-link:hover {
    background-color: var(--accent-color-hover);
}

#xpost-link {
    display: flex;
    justify-content: right;
    align-items: center;
    margin: 0 auto;
    flex: 3;
    color: var(--text-color);
    padding: 14px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1rem;
}
.x-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    filter: invert(1); /* 白黒反転 */
}
#xpost-link:hover {
    background-color: #202020;
}


/* 詳細メタデータブロック */
#detail-metadata {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#detail-metadata h2 {
    font-size: 1.0rem;
    font-weight: bold;
    color: var(--accent-color);
    text-align: left;
    margin-top: 1rem;
    margin-bottom: 0;
}



#osd-favorite {
    position: absolute;
    bottom: 0.5rem;
    right: 0;
    z-index: 9999;
    width: 4rem;
    height: 4rem;
}

#osd-svn-container {
    opacity: 0.7;
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    z-index: 9998;
    display: none;
}

#osd-svn-counter {
    font-size: 1rem;
    color: var(--text-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
button#svn-prev, button#svn-next {
    background-color: var(--secondary-color);
    border: 2px solid #7e67c1;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
    z-index: 40;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    margin: 0.2rem
}
button#svn-prev.disabled, button#svn-next.disabled {
    background-color: #aaa;
    border-color: #ccc;
    opacity: 0.5;
}

/* 続きを読むボタン */
.read-more-button {
    margin-top: 0.2rem;
    margin-bottom: 0.5rem;
    background: none;
    border: none;
    color: #7e7ef1;
    text-decoration: underline;
    cursor: pointer;
    font-size: 1em;
}

/* ジャンルタグ */
#genre, #performer, #series {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    flex-wrap: wrap;
}
#genre a, #performer a, #series a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.8rem;
    background-color: var(--secondary-color);
    padding: 0.2rem 0.5rem;
    border-radius: 0.2rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}
#genre a:hover, #performer a:hover, #series a:hover {
    background-color: var(--accent-color);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 価格 */
#sale-info .price{
    color: var(--text-color);
}
#sale-info .original_price{
    color: var(--text-color);
    opacity: 0.3;
    text-decoration: line-through;
}
#sale-info .sale_price{
    font-size: 1.1rem;
    color: var(--sale-color);
    font-weight: bold;
    padding-left: 0.5rem;
}
#sale-info .sale_until{
    color: var(--text-color);
    background-color: var(--sale-color);
    border-radius: 4px;
    padding: 0.2rem;
    margin-left: 0.5rem;
}


/* プレイルリスト・関連動画切り替えタブメニュー */
#tab-menu {
    display: flex;
    justify-content: flex-start; /* 左寄せ */
    border-bottom: 2px solid #666; /* タブの下線 */
    margin-top: 1em;
    gap: 0.2em;
}

.tab-button {
    padding: 0.5em 1em;
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid #666;
    border-bottom: none;
    border-radius: 0.5em 0.5em 0 0;
    font-weight: bold;
    cursor: pointer;
}

.tab-button.active {
    color: var(--text-color);
    background-color: var(--accent-color);
    z-index: 1;
}
.tab-pane {
    display: none;
  }
  .tab-pane.active {
    display: block;
  }

/* カルーセルスタイル */
/* カルーセルラッパー */
.carousel-wrapper {
    display: flex;
    gap: 15px;
    width: 100%;
}

.create-playlist-link {
    color: var(--text-color);
    text-decoration: underline;
    cursor: pointer;
}

/* プレイリスト */
#playlist-items, #recommend-items {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    gap: 15px;
    width: 100%;
}

#playlist-items::-webkit-scrollbar, #recommend-items::-webkit-scrollbar {
    height: 6px;
}

#playlist-items::-webkit-scrollbar-track, #recommend-items::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 3px;
}

#playlist-items::-webkit-scrollbar-thumb, #recommend-items::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}

.playlist-item, .recommend-item {
    flex: 0 0 auto;
    width: 200px;
    scroll-snap-align: start;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    position: relative;
}

.playlist-item.current, .recommend-item.current {
    border: 5px solid var(--accent-color);
}

.playlist-item.current::before, .recommend-item.current::before {
    content: "再生中";
    position: absolute;
    top: -1px;
    left: -1px;
    background-color: var(--accent-color);
    color: var(--text-color);
    padding: 3px 6px;
    font-weight: bold;
    font-size: 0.8rem;
    z-index: 2;
    border-radius: 4px;
}

/* ポイントすると少し浮き上がる */
.playlist-item:hover, .recommend-item:hover {
    transform: translateY(-5px);
}
/* リンクのない関連動画1つ目は浮き上がらない */
.recommend-item.current:hover {
    transform: none;
}

.playlist-item a, .recommend-item a {
    text-decoration: none;
    color: var(--text-color);
}

.playlist-item img, .recommend-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
    background-color: var(--secondary-color);
}

.playlist-item-title, .recommend-item-title {
    padding: 8px;
    font-size: 0.9rem;
    background-color: var(--primary-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.4em;
    line-height: 1.2;
    height: 4rem;
}

.sale {
    /* 配色はstyle.cssで定義 */
    position: absolute;
    bottom: 4.4rem;
    left: 0;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
}
.playlist-item.onSale .sale {
    display: inline-block
}

/* 関連動画タブ */
.recommend-item-next-button {
    color: #777;
    background-color: #333;
    text-align: center;
    z-index: 100;
    cursor: pointer;
}
.recommend-item-next-button:hover {
    color: #aaa;
    background-color: #555;
}
.recommend-item-next-button.selected {
    color: var(--text-color);
    background-color: var(--accent-color);
}

.recommend-item.current {
    margin-right: 1rem;
}

.force-load {
    color: var(--text-color);
    text-decoration: underline;
    cursor: pointer;
}

#playlist-items.active {
    cursor: grabbing;
}

/* 次の動画を自動再生チェックボックス */
#auto-go-next-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-left: 0.5rem;
}

/* レビューアイテムのスタイル */
.review-item {
    background-color: var(--secondary-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.review-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.review-item-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.review-item-comment {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-color);
    max-height: 150px;
    overflow-y: auto;
    padding-right: 5px;
    text-align: left;
}

.review-item-comment::-webkit-scrollbar {
    width: 4px;
}

.review-item-comment::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.review-item-comment::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 2px;
}

#review-items {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

#review-items::-webkit-scrollbar {
    width: 6px;
}

#review-items::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 3px;
}

#review-items::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}



footer {
    margin-top: 0.8rem;
}

/* レスポンシブデザイン */
/* 小さなスクリーン */
@media (max-width: 767px) {
    #metadata {
        width: 100%;
        font-size: 0.8rem;
    }
    h1#title {
        font-size: 0.8rem;
    }

    .recommend-item-title {
        font-size: 0.6rem;
        gap: 0.3rem;
        text-align: left;
    }

    .recommend-item {
        font-size: 0.8rem;
        width: 25%;
    }

    .review-item {
        padding: 12px;
    }

    .review-item-title {
        font-size: 0.8rem;
    }

    .review-item-comment {
        font-size: 0.8rem;
    }
    
    
    #review-items {
        max-height: 300px;
    }
    #osd-svn-counter {
        font-size: 0.7rem;
    }

    /* フルスクリーン時 */
    #video-container.fullscreen {
        display: flex;
        flex-direction: column;
        height: 100dvh;
    }

    #video-container.fullscreen #video {
        height: unset;
        margin-bottom: 10rem;
    }
    #video-container.fullscreen #time-slider {
        /* videoの直下に配置 */
        position: relative;
        bottom: 10rem;
    }
    #video-container.fullscreen #osd-title {
        font-size: 0.8rem;
    }
    #video-container.fullscreen #osd-title {
        font-size: 1.0rem;
        position: absolute;
        top: 2rem;
        left: 0;
        max-width: 100%;
        padding: 0 1rem;
    }
    #video-container.fullscreen #osd-favorite {
        bottom: 3rem;
        right: 2rem;
    }
    #video-container.fullscreen #message {
        top: 30%;
        font-size: 1.5rem;
    }
    #video-container.fullscreen #upper-controls {
        top: 70%;
    }
    #video-container.fullscreen #controls {
        top: 75%;
    }
    #video-container.fullscreen #lower-left-controls {
        top: 95%;
    }
    #video-container.fullscreen #osd-svn-counter {
        font-size: 0.9rem;
    }
    #video-container.fullscreen #osd-svn-container {
        position: relative;
        bottom: 10rem;
        margin-top: 0.5rem
    }
}





@media (max-width: 767px) and (orientation: portrait){
    main {
        padding-top: 0;
    }
    #osd-favorite {
        position: absolute;
        bottom: 0;
        right: 0;
        width: 2.5rem;
        height: 2.5rem;
    }

    div#osd-time {
        font-size: 0.8rem;
        font-weight: bold;
        position: absolute;
        top: 0;
        right: 0.3rem;
    }

    #message {
        font-size: 0.9rem;
        top: 40%;
    }
    #controls {
        margin-top: 3rem;
    }

    #upper-controls {
        top: 0;
    }

    #lower-left-controls {
        bottom: 0;
    }
    #controls button, #upper-controls button, #lower-left-controls button {
        font-size: 0.8rem;
    }
    div#osd-container {
        filter: url(#outline-filter-mobile);
    }
    div#osd-title {
        font-size: 0.5rem;
        font-weight: normal;
        max-width: 78%;
    }
    div#osd-performer {
        display: none;
    }
    div#osd-time {
        font-size: 0.9rem;
    }

    #controls button, #upper-controls button {
        font-size: 0.8em;
    }
 
    #controls button span.narrow {
        letter-spacing: -0.4em;
        margin-right: 0.3em;
    }

    div.pause-bar {
        width: 0.2rem; /* 棒の太さ */
        height: 0.9rem; /* 棒の高さ */
        background-color: var(--text-color);
    }
  
    #buy-link {
        font-size: 0.8rem;
    }
    #xpost-link {
        font-size: 0.8rem;
    }
    #xpost-link span {
        display: none;
    }
    #back-link {
        font-size: 0.8rem;
    }
    #back-link:after {
        content: "＜ 戻る";
        font-size: 1rem;
    }
}

/* モバイル ランドスケープ時のカルーセル表示（新着・履歴両対応） */
@media screen and (orientation: landscape) and (max-width: 1024px) {
    #video-container {
        height: 100vh;
    }
    #metadata {
        padding: 0;
    }
}

#time-slider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.2);
    z-index: 5;
    overflow: hidden;
    cursor: pointer;
}

#time-slider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background-color: #c323a6;
    width: var(--progress, 0%);
    transition: width 0.1s linear;
}

/* モバイル対応 */
@media (max-width: 767px) and (orientation: portrait) {
    #time-slider {
        height: 2px;
    }
}