/* pages/share.css */

/* =========================================
   Base / Tokens
========================================= */

.share {
  background: var(--c-gray);

  --share-fz-sm: 14px;
  --share-fz-md: 16px;
  --share-fz-lg: 18px;
  --share-fz-xl: 22px;

  --share-accent-1: #2c3e50;
  --share-accent-2: #4a90e2;

  --share-green: #18a34a;
  --share-green-dark: #14823c;
  --share-dark: #111827;
  --share-dark-2: #374151;
}

.share__header {
  padding-top: 14px;
  padding-bottom: 6px;
}

/* iOS tap highlight */
.share a,
.share button,
.share label {
  -webkit-tap-highlight-color: transparent;
}

/* =========================================
   Main Layout
========================================= */

.share__layout {
  margin-top: 10px;
  display: grid;
  gap: 14px; /* “呼吸” */
  align-items: start;
}

/* PC：左=可変 / 右=固定幅（送るをスリム化） */
@media (min-width: 980px) {
  .share__layout {
    grid-template-columns: minmax(520px, 1fr) 360px;
    gap: 14px 18px;
  }
}

/* =========================================
   Card Common
========================================= */

.share__target,
.share__send,
.share__about {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: var(--radius-xl);
  background: var(--c-card);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Left accent bar（target/send） */
.share__target::before,
.share__send::before {
  content: "";
  position: absolute;
  inset: 0;
  left: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--share-accent-1), var(--share-accent-2));
}

/* Headings */
.share__heading {
  margin: 0 0 12px;
  font-size: var(--share-fz-xl);
  line-height: 1.25;
  color: var(--c-text);
  position: relative;
  padding-left: 14px;
}

.share__heading::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.32em;
  width: 4px;
  height: 1.15em;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--share-accent-1), var(--share-accent-2));
}

/* =========================================
   Target (Left)
========================================= */

.share__targetForm { margin-top: 2px; }
.share__fieldset { border: 0; padding: 0; margin: 0; }

.share__legend {
  font-size: var(--share-fz-sm);
  color: #667085;
  margin-bottom: 10px;
}

/* 上段：現在ページ + トグル（2カラム固定 / 高さ揃え） */
.share__targetTop {
  display: grid;
  grid-template-columns: 1fr auto; /* ← ここを常に2カラム */
  gap: 10px 12px;
  align-items: stretch; /* 高さ揃えの核 */
}

.share__targetTopRight {
  height: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: stretch; /* 高さ揃え */
}

/* Option */
.share__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid #e7edf6;
  background: #fff;
  margin-bottom: 10px;
  cursor: pointer;
  transition:
    box-shadow 0.18s ease,
    transform 0.12s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.share__option:hover {
  background: #f7faff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.share__option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--share-accent-2);
}

/* checked（:has 対応ブラウザだけリッチに） */
.share__option:has(input[type="radio"]:checked) {
  border-color: rgba(74, 144, 226, 0.55);
  box-shadow: 0 8px 18px rgba(74, 144, 226, 0.14);
}

@supports not selector(:has(*)) {}

.share__option--primary {
  margin-bottom: 0; /* 上段内の段差を消す */
  height: 100%;     /* 高さ揃え */
}

/* Toggle input（hidden） */
.share__targetToggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Toggle button（固定幅 / 高さ揃え / 小さく見せて押しやすく） */
.share__targetMoreBtn {
  position: relative;
  width: 112px;           /* PC固定幅（ブレ防止） */
  height: 100%;           /* ラジオ行に高さ合わせ */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 0 10px;        /* 高さは親に任せる */
  border-radius: 12px;
  border: 1px solid #d1d8e6;
  background: #ffffff;
  color: #1d2935;

  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;

  box-shadow: 0 4px 10px rgba(0,0,0,0.10);
  cursor: pointer;
  user-select: none;
}

/* “押しやすさ”は当たり判定を拡張（見た目は小さいまま） */
.share__targetMoreBtn::before {
  content: "";
  position: absolute;
  inset: -8px;
}

/* Arrow */
.share__targetMoreBtn::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid #667085;
  border-bottom: 2px solid #667085;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  flex: 0 0 auto;
}

/* 文言の混合を防ぐ：表示制御をここで確定 */
.share__targetMoreBtn .share__targetMoreText--open { display: inline; }
.share__targetMoreBtn .share__targetMoreText--close { display: none; }

.share__target:has(#targetMoreToggle:checked) .share__targetMoreBtn .share__targetMoreText--open { display: none; }
.share__target:has(#targetMoreToggle:checked) .share__targetMoreBtn .share__targetMoreText--close { display: inline; }
.share__target:has(#targetMoreToggle:checked) .share__targetMoreBtn::after { transform: rotate(225deg); }

/* Expanded area（2カラム固定：スマホでも維持） */
.share__targetMore {
  display: none;
  margin-top: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.share__target:has(#targetMoreToggle:checked) .share__targetMore {
  display: grid;
}

/* :has 非対応：開閉は効かないが選択肢は表示 */
@supports not selector(:has(*)) {
  .share__targetMore { display: grid; }
  .share__targetMoreBtn .share__targetMoreText--open { display: inline; }
  .share__targetMoreBtn .share__targetMoreText--close { display: none; }
}

/* =========================================
   Preview (Left)
========================================= */

.share__preview {
  margin-top: 14px;
  padding: 12px 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #dfe7f3;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
}

.share__previewLabel { display: none; }

.share__previewTitle {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--c-text);
  font-weight: 900;
}

.share__previewMeta {
  margin: 0 0 6px;
  font-size: 12px;
  color: #667085;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.share__previewHelp {
  margin: 0;
  font-size: 13px;
  color: #667085;
  line-height: 1.6;
}

/* =========================================
   Send (Right)
========================================= */

.share__sendTop { margin-top: 6px; }
.share__sendTop .shareBtn { width: 100%; }

.share__sendGrid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.shareBtn {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 54px;

  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;

  cursor: pointer;
  text-decoration: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.20);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.shareBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.26);
}

.shareBtn:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.20);
}

.shareBtn__icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;

  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
  font-size: 16px;
  line-height: 1;
}

/* LINE */
.shareBtn--line {
  background: linear-gradient(135deg, var(--share-green), var(--share-green-dark));
  color: #fff;
}

/* COPY */
.shareBtn--copy {
  background: linear-gradient(135deg, var(--share-dark), var(--share-dark-2));
  color: #fff;
}

/* MAIL */
.shareBtn--mail {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.shareBtn--mail .shareBtn__icon {
  background: rgba(17, 24, 39, 0.06);
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.10);
}

.share__copied {
  margin: 12px 0 0;
  padding: 12px 12px;
  border-radius: 12px;
  background: #f3f7ff;
  border: 1px solid #d7e6ff;
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.6;
}

.share__soft {
  margin: 12px 0 0;
  padding: 12px 12px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px dashed #c7d0e0;
  font-size: 14px;
  line-height: 1.8;
  color: #666;
}

/* PC：送るカードは少し締める */
@media (min-width: 980px) {
  .share__send {
    padding: 16px 16px 14px;
  }
  .share__sendGrid { gap: 10px; }
  .shareBtn { min-height: 52px; }
}

/* =========================================
   About (Bottom)
========================================= */

.share__about { margin-top: 12px; }

.share__aboutTitle {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--c-text);
}

.share__aboutBody {
  font-size: var(--share-fz-md);
  line-height: 1.85;
  color: #444;
}

.share__aboutBody--fade {
  position: relative;
  max-height: 138px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
          mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
}

.share__aboutToggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.share__aboutMore {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;

  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid #d1d8e6;
  background: #ffffff;
  color: #1d2935;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.10);
}

.share__aboutMore::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #667085;
  border-bottom: 2px solid #667085;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.share__about:has(#aboutToggle:checked) .share__aboutBody--fade {
  max-height: none;
  overflow: visible;
  -webkit-mask-image: none;
          mask-image: none;
}

.share__about:has(#aboutToggle:checked) .share__aboutMore::after {
  transform: rotate(225deg);
}

.share__aboutMoreText--close { display: none; }
.share__about:has(#aboutToggle:checked) .share__aboutMoreText--open { display: none; }
.share__about:has(#aboutToggle:checked) .share__aboutMoreText--close { display: inline; }

/* about inner text helpers（現状維持） */
.share__leadInCard { margin: 0 0 8px; color: var(--c-text); }
.share__subLead { margin: 0 0 8px; color: #444; }
.share__whoIntro { margin: 10px 0 8px; font-size: 13px; color: #667085; }
.share__list { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.share__note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e0e6f0;
  color: #555;
}
.share__support { margin: 10px 0 0; color: #56606b; }

/* =========================================
   Mobile Responsive (Enhanced)
   - 上段：2カラム維持（現在ページ + トグル）
   - トグル展開内：1カラム
   - 送る：押しやすさ優先で縦
========================================= */

@media (max-width: 768px) {

  .share__layout { gap: 14px; }

  .share__target,
  .share__send,
  .share__about {
    padding: 18px 14px 16px;
    border-radius: 16px;
  }

  .share__heading {
    font-size: 18px;
    margin-bottom: 12px;
  }

  /* 上段はスマホでも2カラム維持 */
  .share__targetTop {
    grid-template-columns: 1fr auto;
    gap: 10px 12px;
    align-items: stretch;
  }

  /* トグル固定幅（端末幅で微調整） */
  .share__targetMoreBtn {
    width: 104px;
  }
  .share__targetMoreBtn::before {
    inset: -10px; /* 当たり判定 */
  }

  /* トグル展開内：1カラム（ここが要望反映） */
  .share__targetMore {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* 送る：下段は縦（確実に押せる） */
  .share__sendGrid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .shareBtn {
    width: 100%;
    min-height: 58px;
    font-size: 16px;
  }

  .shareBtn__icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 18px;
  }

  .share__aboutBody {
    font-size: 15px;
    line-height: 1.9;
  }

  .share__aboutBody--fade { max-height: 128px; }

  .share__aboutMore {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 390px) {

  .share__layout { gap: 12px; }

  .share__target,
  .share__send,
  .share__about {
    padding: 16px 12px 14px;
  }

  .share__heading { margin-bottom: 10px; }

  .share__targetMoreBtn { width: 96px; }

  .share__previewTitle { font-size: 16px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .shareBtn,
  .share__option,
  .share__targetMoreBtn,
  .share__aboutMore {
    transition: none !important;
  }
}
