/* share-common.css (完成版) */

/* --- 共有ボタン関連のスタイル --- */

.share-wrapper {
    position: relative;
    max-width: 500px;
    margin: 10px auto 10px; /* 無駄な余白を削減 */
    padding: 0 20px;
    display: flex;
    justify-content: flex-end; /* 右端に配置 */
    align-items: flex-start; /* 下方向に広がるように上揃え */
}

#share-actions-container-inner {
    position: relative;
    background: #d5d9de;
    box-sizing: border-box; /* 枠線の太さ変化によるガタつきを防ぐ */
    overflow: hidden;
    z-index: 10;
    /* ボタンの広がりとスタイルのトランジション */
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                border-radius 0.4s ease, 
                border-width 0.4s ease,
                border-color 0.4s ease,
                box-shadow 0.4s ease,
                opacity 0.6s ease-out, 
                transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- 閉じた状態（初期の角丸正方形ボタン） --- */
#share-actions-container-inner.is-closed {
    width: 110px;
    height: 60px;
    border: 5px solid #fff;
    border-radius: 16px; /* 角丸の正方形 */
    cursor: pointer;
    box-shadow: 0 4px 0px rgba(0, 0, 0, 0.2); /* 押せることを示すドロップシャドウ */
    opacity: 0; /* スクロール検知前は見えない */
    transform: translateY(30px) scale(0.9);
}

/* スクロール検知でふわっと出現 */
.share-wrapper.is-visible #share-actions-container-inner.is-closed {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* --- 展開状態 --- */
#share-actions-container-inner.is-expanded {
    width: 100%;
    border: 6px solid #588ec4; /* 青いライトの色で6pxのボーダー */
    border-radius: 26px;
    cursor: default;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 高さの動的設定（ボタンの数に応じて高さを変更する。テキスト追加のため+15px調整） */
#share-actions-container-inner.is-expanded[data-button-count="2"] { height: 240px; }
#share-actions-container-inner.is-expanded[data-button-count="3"] { height: 325px; }
#share-actions-container-inner.is-expanded[data-button-count="4"] { height: 410px; }
#share-actions-container-inner.is-expanded[data-button-count="5"] { height: 495px; }

/* --- トリガーアイコン --- */
.share-trigger-icon {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('../images/iconShareArea_shareNew.svg') no-repeat center;
    background-size: 75px;
    /* 閉じる時: サイズ変更(約0.4s)が終わってから0.3sかけてフェードイン */
    transition: opacity 0.3s ease 0.4s;
    opacity: 1;
}

/* 展開時はアイコンがすぐに消える */
#share-actions-container-inner.is-expanded .share-trigger-icon {
    /* 開く時: 遅延なしで0.1sでフェードアウト */
    transition: opacity 0.1s ease 0s;
    opacity: 0;
    pointer-events: none;
}

/* --- 閉じる（×）ボタン --- */
.share-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #cc1842; /* 赤い背景色に変更 */
    background-image: url('../images/icon_close.svg'); /* svg画像でばつ印を表示 */
    background-size: 24px;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    cursor: pointer;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* 展開状態になったら表示 */
#share-actions-container-inner.is-expanded .share-close-button {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.3s;
}

/* --- 展開後のコンテンツラッパー --- */
.share-expanded-content {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    box-sizing: border-box;
    padding: 70px 15px 10px; /* テキスト追加のため上部余白を50pxから65pxに変更 */
    display: flex;
    flex-direction: column; /* 縦並び */
    justify-content: flex-start;
    align-items: stretch;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#share-actions-container-inner.is-expanded .share-expanded-content {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.2s; /* コンテナが少し広がってから中身がフェードイン */
}

/* 「共有してみよう」のフレーズ画像 */
.share-expanded-content::before {
    content: '';
    position: absolute;
    top: 13px;
    left: 50%;
    transform: translateX(-50%);
    width: 170px;
    height: 28px;
    background: url(../images/share_phrase.svg) no-repeat center;
    background-size: contain;
}

/* 画像下の説明文を追加 */
.share-expanded-content::after {
    content: 'みんなでこのページを共有しよう！';
    position: absolute;
    top: 44px; /* 画像の下に配置 */
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #888;
    font-weight: bold;
    white-space: nowrap;
}

/* --- 各種シェアボタンのスタイル --- */
.share-button {
    display: flex;
    flex-direction: row; /* 横並び（アイコン＋テキスト） */
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: auto;
    padding: 12px 15px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 18px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 0px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    /* 展開されるときに下からふわっと出るように */
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: left;
}

/* 展開状態になったらボタンを浮上表示させる */
#share-actions-container-inner.is-expanded .share-button {
    opacity: 1;
    transform: translateY(0);
}

/* 順番にふわっと出るように時間差を設定 */
#share-actions-container-inner.is-expanded .share-button:nth-child(1) { transition-delay: 0.2s; }
#share-actions-container-inner.is-expanded .share-button:nth-child(2) { transition-delay: 0.3s; }
#share-actions-container-inner.is-expanded .share-button:nth-child(3) { transition-delay: 0.4s; }
#share-actions-container-inner.is-expanded .share-button:nth-child(4) { transition-delay: 0.5s; }
#share-actions-container-inner.is-expanded .share-button:nth-child(5) { transition-delay: 0.6s; }

.share-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.share-button-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin-right: 15px; /* テキストとの余白 */
    border-radius: 12px; /* 正方形の角丸に変更 */
    background-size: 26px; /* アイコンを枠内に収めるサイズ */
    background-repeat: no-repeat;
    background-position: center;
}

/* 各アイコン個別の背景色と画像設定 */
.share-button-icon--native { 
    background-image: url('../images/iconShareArea_shareW.svg'); 
    background-color: #133545; 
}
.share-button-icon--line { 
    background-image: url('../images/icon-SNS-line.svg'); 
    background-color: #06C755; 
}
.share-button-icon--x { 
    background-image: url('../images/icon-SNS-X.svg'); 
    background-color: #000; 
}
.share-button-icon--classroom { 
    background-image: url('../images/iconShareArea_classroom-color.svg'); 
    background-color: #0C7947; 
}
.share-button-icon--qr { 
    background-image: url('../images/iconShareArea_QRcode.svg'); 
    background-color: #c2cbcf; 
}

/* --- ボタン内のテキストエリア --- */
.share-button-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.share-button-label {
    font-size: 17px;
    font-weight: bold;
    color: #222;
    line-height: 1.2;
    margin-bottom: 3px;
}

.share-button-desc {
    font-size: 11px;
    font-weight: normal;
    color: #888;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 文字がはみ出た場合は「...」にする */
}

/* ===============================================
 * ▼▼▼ モーダル関連のスタイル ▼▼▼
 * =============================================== */

/* QRコードモーダル展開時の暗幕の色を濃くする */
#modal-overlay.has-custom-title {
    background-color: rgba(0, 0, 0, 0.85) !important;
}

#qr-code-display {
	padding: 0 0px 10px; 
}
.qr-code-description { 
	font-size: 14px; 
	color: #555; 
	line-height: 1.6; 
	margin-bottom: 10px;
}

#qrcode-container {
    display: block;
    width: 75%;
    max-width: 280px;
    margin: 20px auto;
    padding: 12px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

#qrcode-container canvas {
    display: block !important;
    width: 100% !important;
    height: auto !important;
}

.qr-code-url-display { margin-top: 20px; font-size: 12px; color: #888; word-break: break-all; background: #f0f0f0; padding: 8px 12px; border-radius: 6px; }

.qr-modal-actions {
    display: flex;
    flex-direction: column; /* 縦並びに変更 */
    align-items: stretch; /* 横幅いっぱいに広げる */
    gap: 12px;
    margin-top: 25px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.qr-action-button {
    padding: 15px 20px;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    background-color: #111; /* ボタンの色を黒に変更 */
    border: none;
    border-radius: 12px; /* 角丸を少し緩やかに */
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.qr-action-button:hover {
    background-color: #333;
    transform: translateY(-2px);
}

.qr-action-button:active {
    transform: translateY(1px);
}

.qr-action-button:disabled {
    background-color: #28a745;
    cursor: not-allowed;
    transform: none;
}

.qr-modal-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    padding-bottom: 15px;
    margin: 0 0 20px 0;
    border-bottom: 2px solid #eee;
}

/* QRコードモーダル（.has-custom-title）内の共通ヘッダー(.modal-header)を非表示にする */
#modal-overlay.has-custom-title .modal-header {
    display: none;
}
#modal-content {
    padding: 40px 35px 20px;
}