/* =========================================================================
 * ページトップ／上へ戻るボタン (公開講義テーマ最適化・リッチフェード仕様)
 * ========================================================================= */
.pagetop-btn {
    position: fixed;
    width: 75px;
    height: 75px;
    border: solid 2px #3868c9;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    right: 25px;
    bottom: 25px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(56, 104, 201, 0.15);
    overflow: hidden;
}

/* 内部コンテンツのラッパー */
.pagetop-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px; /* 矢印と文字の隙間 */
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* 矢印アイコン */
.pagetop-arrow {
    width: 10px;
    height: 10px;
    border-left: 2px solid #3868c9;
    border-top: 2px solid #3868c9;
    transform: rotate(45deg);
    margin-top: 2px;
    transition: border-color 0.4s ease;
}

/* テキスト */
.pagetop-text {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.5px;
    color: #3868c9;
    transition: color 0.4s ease;
}

/* --- モード別の初期状態 --- */
/* 通常モードのコンテンツ */
.content-top {
    opacity: 1;
    transform: translateY(0);
}

/* 戻るモードのコンテンツ */
.content-return {
    opacity: 0;
    transform: translateY(15px); /* 少し下からスライドインさせる */
}

.content-return .pagetop-arrow {
    border-left-color: #ffffff;
    border-top-color: #ffffff;
}

.content-return .pagetop-text {
    color: #ffffff;
}

/* --- 表示時・ホバー時の挙動 --- */
.pagetop-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.pagetop-btn:hover {
    background: #f0f4f8;
    box-shadow: 0 6px 20px rgba(56, 104, 201, 0.25);
    transform: translateY(-2px);
}

/* =========================================================================
 * 戻るモード「上へ戻る」時の劇的な変化
 * ========================================================================= */
.pagetop-btn.return-mode {
    background: #7a64d1; /* 背景を鮮やかな紫で塗りつぶし、明確に区別 */
    border-color: #7a64d1;
    box-shadow: 0 4px 15px rgba(122, 100, 209, 0.3);
}

/* コンテンツの切り替えアニメーション */
.pagetop-btn.return-mode .content-top {
    opacity: 0;
    transform: translateY(-15px); /* 上へスライドアウト */
}

.pagetop-btn.return-mode .content-return {
    opacity: 1;
    transform: translateY(0); /* 定位置へスライドイン */
}

/* 戻るモード時のホバー */
.pagetop-btn.return-mode:hover {
    background: #5d48b5;
    border-color: #5d48b5;
    box-shadow: 0 6px 20px rgba(122, 100, 209, 0.4);
    transform: translateY(-2px);
}

/* レスポンシブ対応 */
@media screen and (max-width: 767px) {
    .pagetop-btn {
        width: 65px;
        height: 65px;
        right: 15px;
        bottom: 15px;
    }
    .pagetop-text {
        font-size: 10px;
    }
    .pagetop-arrow {
        width: 8px;
        height: 8px;
    }
}