/* 共有シート（js/core/share.js）：画面下からせり上がる、らくがき帳のシート */
.share-root {
  position: absolute; inset: 0; z-index: 80;
  display: flex; flex-direction: column; justify-content: flex-end;
  font-family: var(--font); color: var(--ink);
}
.share-backdrop { position: absolute; inset: 0; background: rgba(31, 42, 68, .5); opacity: 0; transition: opacity .22s; }
.share-root.share-in .share-backdrop { opacity: 1; }
/* 開く途中・閉じるアニメの間は押せない（✕の直後に下のボタンを誤って押さないように） */
.share-root:not(.share-in) { pointer-events: none; }

.share-sheet {
  position: relative; display: flex; flex-direction: column;
  margin-bottom: var(--share-kb, 0px);
  /* 上はステータスバー・ノッチ（全画面のアプリ）を避ける。.screen と同じ max(10px, safe-area) */
  max-height: calc(100% - max(10px, env(safe-area-inset-top)) - var(--share-kb, 0px));
  background-color: var(--paper);
  /* ノートの赤い余白線＋方眼 */
  background-image:
    linear-gradient(90deg, transparent 22px, rgba(229, 57, 53, .28) 22px, rgba(229, 57, 53, .28) 24px, transparent 24px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px, 22px 22px;
  border: 3px solid var(--ink); border-bottom: 0; border-radius: 24px 24px 0 0;
  box-shadow: 0 -5px 0 rgba(31, 42, 68, .16);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .9, .3, 1.04);
  outline: none;
}
.share-root.share-in .share-sheet { transform: translateY(0); }

/* 見出し（ここを下にドラッグしても閉じられる） */
.share-head { position: relative; flex: none; padding: 10px 56px 6px; text-align: center; touch-action: none; cursor: grab; }
.share-grip { width: 46px; height: 5px; margin: 0 auto 7px; border-radius: 999px; background: var(--ink); opacity: .35; }
.share-title { margin: 0; font-size: 19px; font-weight: 900; transform: rotate(-1.5deg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-close {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; padding: 0;
  border: 2.5px solid var(--ink); border-radius: 50%; background: #fff; box-shadow: 0 2px 0 var(--ink);
  font-size: 16px; font-weight: 900; cursor: pointer;
}
.share-close:active { transform: translateY(2px); box-shadow: none; }
/* 結果の共有シート：けっか／ちょうせんじょう の切りかえ（main.js がシートの見出しに足す） */
.seg.share-kind { width: auto; max-width: none; margin: 8px -40px 0; box-shadow: 0 2px 0 var(--ink); border-width: 2.5px; }
.seg.share-kind button { min-height: 36px; padding: 4px 10px; font-size: 13px; }

/* プレビューと文 */
.share-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 16px 10px 30px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.share-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 8px; flex-shrink: 0; }
.share-frame {
  position: relative; display: grid; place-items: center; min-width: 120px; min-height: 120px;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 6px; padding: 6px;
  box-shadow: 0 4px 0 var(--ink); transform: rotate(-1.5deg);
}
/* マスキングテープ */
.share-frame::before {
  content: ''; position: absolute; top: -11px; left: 50%; width: 72px; height: 20px; margin-left: -36px;
  background: rgba(253, 216, 53, .72); border: 1.5px solid rgba(31, 42, 68, .18); transform: rotate(4deg); z-index: 1;
}
.share-media { display: block; max-width: 100%; width: auto; height: auto; max-height: clamp(110px, 27vh, 300px); border-radius: 3px; background: var(--paper); }
.share-wait {
  width: 150px; height: 188px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 800; color: var(--ink2);
}
.share-wait i { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); animation: share-dot .9s ease-in-out infinite; }
.share-wait i:nth-child(2) { animation-delay: .15s; background: var(--primary); }
.share-wait i:nth-child(3) { animation-delay: .3s; background: var(--accent); }
.share-wait span { width: 100%; text-align: center; margin-top: 4px; }
@keyframes share-dot { 50% { transform: translateY(-8px); } }

.seg.share-seg { width: auto; min-width: 210px; }
.seg.share-seg button { padding: 6px 14px; font-size: 13px; }

.share-text { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.share-label { font-size: 12px; font-weight: 800; color: var(--ink2); }
.share-safety { margin: 0 0 4px; padding: 5px 8px; font-size: 11.5px; font-weight: 800; line-height: 1.4; color: #b23a2e; background: #fff4f2; border: 2px dashed #f0b4ab; border-radius: 10px; word-break: keep-all; overflow-wrap: anywhere; }
.share-text textarea {
  width: 100%; resize: none; display: block;
  font: 700 16px/1.5 var(--font); color: var(--ink);
  background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; padding: 8px 10px;
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
.share-text textarea:focus { outline: none; box-shadow: 0 0 0 3px rgba(30, 136, 229, .35); }
.share-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 800; color: var(--ink2); }
.share-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-count { flex-shrink: 0; margin-left: auto; }
.share-count.over { color: var(--primary); }
/* コピーできない端末用：リンクまで入った全文（長押しでコピー） */
.share-text textarea.share-copybox { font-size: 13px; font-weight: 700; background: #fffbe6; border-style: dashed; -webkit-touch-callout: default; }
.share-text textarea.share-copybox[hidden] { display: none; }

/* ボタン（下ほど大事：いちばん下に「投稿する」） */
.share-actions { flex: none; display: flex; flex-direction: column; gap: 9px; padding: 9px 16px 0; border-top: 2px dashed var(--line); }
.share-hint { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.share-note { margin: 0; font-size: 11px; font-weight: 700; color: var(--ink2); text-align: center; line-height: 1.35; }
.share-auto { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; cursor: pointer; }
.share-auto input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }

/* 出ているボタンの数で等分（開けるリンクがないときは Facebook を隠す） */
.share-sns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.share-sns button[hidden] { display: none; }
.share-sns button {
  border: 0; background: none; padding: 2px 0; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font: 800 11px var(--font);
}
.share-ico {
  width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 21px; line-height: 1;
  transition: transform .06s, box-shadow .06s;
}
.share-sns button:active .share-ico { transform: translateY(3px); box-shadow: none; }
.share-ico-x { background: #111; }
.share-ico-line { background: #06c755; font-size: 11px; letter-spacing: -.02em; }
.share-ico-threads { background: #111; font-size: 23px; padding-bottom: 2px; }
.share-ico-fb { background: #1877f2; font-size: 27px; font-family: Georgia, "Times New Roman", serif; padding-top: 3px; }
.share-sns.share-attn .share-ico { animation: share-wiggle .45s ease-in-out 2; }
@keyframes share-wiggle { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

.share-util { display: flex; gap: 8px; }
.share-util .btn { flex: 1; font-size: 14px; padding: 9px 8px; }

.share-post { min-height: 58px; font-size: 20px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.share-post-sub:empty { display: none; }
.share-post-sub { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .25); border: 1.5px solid rgba(255, 255, 255, .7); }
.share-post.is-wait { background: var(--ink2); }
.share-root.share-in .share-post:not(:disabled) { animation: share-nudge .5s .35s ease-out both; }
@keyframes share-nudge { 40% { transform: scale(1.04) rotate(-1deg); } 70% { transform: scale(.99); } }

.share-toast {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: var(--ink); color: #fff; font-weight: 900; font-size: 14px; padding: 7px 16px; border-radius: 999px;
  white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; animation: share-pop .2s ease-out;
}
@keyframes share-pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

/* 文を書いているあいだはプレビューを小さく */
.share-root.share-typing .share-media { max-height: 72px; }
.share-root.share-typing .share-wait { width: 72px; height: 72px; }
.share-root.share-typing .share-seg,
.share-root.share-typing .share-hint { display: none; }

/* 背の低い画面 */
@media (max-height: 640px) {
  .share-media { max-height: clamp(96px, 22vh, 200px); }
  .share-wait { width: 110px; height: 138px; }
  .share-note { display: none; }
  .share-ico { width: 40px; height: 40px; font-size: 18px; }
  .share-ico-fb { font-size: 23px; }
  .share-ico-line { font-size: 10px; } /* 上の .share-ico の文字サイズで「LINE」がはみ出さないように */
  .share-post { min-height: 52px; font-size: 18px; }
  .share-actions { gap: 7px; }
}

/* 全画面表示（ダウンロードできない環境で「長押しで保存」） */
.share-viewer {
  position: absolute; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(20, 26, 40, .93);
  font-family: var(--font);
}
.share-viewer-media {
  display: block; max-width: 100%; max-height: calc(100% - 150px); min-height: 0;
  border: 3px solid #fff; border-radius: 8px; background: #fff;
  /* style.css で全体の長押しメニューを止めているので、ここだけ戻す */
  -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto;
}
.share-viewer-tip {
  margin: 0; max-width: 100%; text-align: center; color: #fff; background: var(--primary);
  font-size: 15px; font-weight: 900; padding: 8px 16px; border-radius: 999px; line-height: 1.4;
  animation: share-bob 1.2s ease-in-out infinite alternate;
}
@keyframes share-bob { to { transform: translateY(-4px); } }
.share-viewer-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .share-sheet, .share-backdrop { transition: none; }
  .share-wait i, .share-viewer-tip, .share-sns.share-attn .share-ico, .share-root.share-in .share-post:not(:disabled) { animation: none; }
}
