/* テーマ側（trivinews-theme等）のヘッダーとコンテンツの間に埋め込むバナー形式、
   または専用ページ（repeatモード）に設置する形式のどちらでも使う共通スタイル。
   position:fixedのポップアップにはせず、差し込まれた場所にそのまま表示される。
   スマホ幅を想定した狭いカード（max-width: 400px）にしている。カードを狭くしているのは
   デザイン上の好みだけでなく機能的な理由もある：時間帯の背景画像（横長のワイド1枚絵）を
   background-size:coverで表示したとき、カードが狭いほど画像のごく一部しか見えなくなり、
   ページ読み込み毎にランダムに変える表示位置の違いがはっきり体感できる。
   （最初は画面の端から端まで広げる案を試したが、デスクトップ幅だとワイド画像の
   ほぼ全体が見えてしまい位置替えの意味が薄れることが分かり、ユーザーと相談のうえ
   この「常に狭いカード」方式に変更した。全幅化のために.site-mainのサイドバー付き
   グリッドから要素を追い出す変更もしていたが、不要になったため元に戻している） */
.tnk-widget {
    max-width: 400px;
    /* 横幅に余裕がある場所（サイドバー付きの広いカラム等）に置かれても
       左右中央寄せになるようにする。狭い場所では単に400pxいっぱいになるだけ。 */
    margin: 0 auto;
    /* min-heightで背景画像に十分な高さを確保する（吹き出しの中身が短い
       状態でも、背景の奥行き＝空・丘・草地が一望できる高さを常に確保する）。
       猫・吹き出しはalign-items:flex-endで下辺に寄せ、padding-bottomは
       小さめにして「背景の一番手前（下辺）に猫が立っている」ように見せる。 */
    min-height: 260px;
    padding: 16px 20px 8px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    box-sizing: border-box;
    font-size: 13px;
    background-size: cover;
    background-repeat: no-repeat;
}

.tnk-widget[hidden] {
    display: none;
}

.tnk-mascot-wrap {
    position: relative;
    flex-shrink: 0;
    margin-right: -6px;
    z-index: 1;
}

.tnk-mascot {
    display: block;
    width: 90px;
    height: auto;
}

.tnk-mascot-name {
    position: absolute;
    top: -10px;
    /* 50%（画像全体の中央）ではなく43%にしているのは、trivia-neko.pngの
       しっぽが右側に膨らんでいるぶん画像全体の重心が右に寄っており、
       50%centeringだと顔の真上からずれてしまうため（頭部だけのバウンディング
       ボックス中心で計算し直した値）。マスコット画像を差し替える場合は
       ここも見た目を見ながら再調整すること。 */
    left: 43%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 10px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tnk-bubble {
    position: relative;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex: 1 1 auto;
    min-width: 0;
    box-sizing: border-box;
}

/* 吹き出しの三角（猫側＝左向き）。猫の顔あたりを指すよう、しっぽの位置（画像下部）
   より上に配置している。bottomは.tnk-mascotの高さ（90px幅、縦横比0.73:1）基準で
   決めているため、マスコットの表示サイズを変える場合はここも合わせて調整すること。 */
.tnk-bubble::before {
    content: "";
    position: absolute;
    left: -11px;
    bottom: 66px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 9px 12px 9px 0;
    border-color: transparent #ddd transparent transparent;
}

.tnk-bubble::after {
    content: "";
    position: absolute;
    left: -9px;
    bottom: 67px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 11px 8px 0;
    border-color: transparent #fff transparent transparent;
}

.tnk-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    line-height: 1;
    font-size: 14px;
    padding: 0;
}

.tnk-lead {
    margin: 0 0 4px;
    font-weight: bold;
}

.tnk-body {
    margin: 0 0 10px;
    /* スペースを含まない長い単語（外国の地名等）が吹き出しの外にはみ出さないよう、
       単語の途中でも折り返す。管理画面の一覧（admin-style.cssの.tnk-col-body）と
       同じ対策。 */
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ユーザー投稿由来のトリビアにだけ付く「〇〇さんが教えてくれたんよ」の一言。
   本文と見た目の重みを分けるため、.tnk-bodyより控えめな色・小さめの文字にしている。 */
.tnk-submission-note {
    margin: 0 0 10px;
    color: #666;
    font-size: 12px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.tnk-reactions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* [hidden]のデフォルト非表示は、同じ要素に明示的なdisplay指定があると
   author CSSがUAスタイルより優先されて上書きされてしまう（実際にreact直後も
   ボタンが消えず表示され続けるバグとして発現した）。明示的に上書きし直す。 */
.tnk-reactions[hidden] {
    display: none;
}

.tnk-reaction-btn {
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f7f7f7;
    border-radius: 6px;
    padding: 6px 12px;
    text-align: center;
}

.tnk-reaction-btn:hover {
    background: #eee;
}

.tnk-result-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.tnk-result-row:last-child {
    border-bottom: none;
}

.tnk-followup {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.tnk-followup-lead {
    margin: 10px 0 8px;
}

/* .tnk-followupに包まれるonceモードでは既にborder-topで区切られているため、
   直前の要素との二重の余白にならないよう相殺する */
.tnk-followup > .tnk-followup-lead:first-child {
    margin-top: 0;
}

.tnk-followup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tnk-followup-btn {
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f7f7f7;
    border-radius: 6px;
    padding: 6px 12px;
}

.tnk-followup-btn:hover {
    background: #eee;
}

.tnk-submit-textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font: inherit;
}

.tnk-submit-count {
    margin: 4px 0 8px;
    text-align: right;
    color: #888;
    font-size: 12px;
}

.tnk-submit-error {
    margin: 0 0 8px;
    color: #c0392b;
}

.tnk-submit-send-btn {
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f7f7f7;
    border-radius: 6px;
    padding: 6px 14px;
}

.tnk-submit-send-btn:hover {
    background: #eee;
}

.tnk-submit-thanks {
    margin: 0;
}

/* repeatモード（トリビアネコ専用ページ）専用の要素。.tnk-widgetとは別要素として
   前後に置かれるため、幅の揃え方（max-width/margin/padding）を独立して合わせている
   （こちらはページの通常のコンテンツ幅のまま。狭くするのは.tnk-widget＝猫の表示部分のみ）。 */
.tnk-repeat-intro {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px 0;
    box-sizing: border-box;
}

.tnk-repeat-intro p {
    margin: 0;
    line-height: 1.7;
}

.tnk-history {
    max-width: 1280px;
    margin: 0 auto;
    padding: 8px 24px 16px;
    box-sizing: border-box;
}

.tnk-history-section {
    margin-top: 16px;
}

.tnk-history-title {
    font-size: 15px;
    margin: 0 0 8px;
}

.tnk-history-list {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 4px 16px;
}

.tnk-history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.tnk-history-row:last-child {
    border-bottom: none;
}

.tnk-history-tag {
    flex-shrink: 0;
    font-size: 12px;
    color: #666;
    background: #f7f7f7;
    border-radius: 999px;
    padding: 2px 10px;
}

.tnk-history-empty {
    margin: 0;
    padding: 12px 0;
    color: #888;
}

.tnk-history-login-prompt {
    margin: 0;
}

@media (max-width: 480px) {
    .tnk-repeat-intro {
        padding: 12px 16px 0;
    }

    .tnk-history {
        padding: 4px 16px 12px;
    }

    /* .tnk-widgetの親（trivinews-themeの.single-content、実体は.site-main）が
       持つ左右padding（モバイル幅では16px固定、trivinews-theme/assets/style.css
       の@media(max-width:1024px) .site-mainを参照）を打ち消して、画面端まで
       広げる。width:100vw + calc(50% - 50vw)によるフルブリードを最初に試したが、
       モバイルブラウザでは100vwがスクロールバー分だけ実際の表示幅より大きく
       計算される既知の不具合があり、左右非対称な余白とページ全体の横スクロールを
       引き起こすことを確認したため採用しない。既知の固定値（16px）を直接打ち消す
       方式に変更した。
       セレクタを`.single-content .tnk-widget`に絞っているのは、header.phpから
       直接呼ばれるonceモードのバナー（.site-mainの外＝paddingの影響を受けない
       場所に置かれる）にまで適用されると、打ち消す対象のpaddingが無いのに
       -16pxがかかって逆にはみ出してしまうため。repeatモード・固定ページ/
       カスタムURL版（templates/custom-page.php、.single-content配下）にのみ効く。
       trivinews-theme側で.site-mainのモバイルpaddingの値を変更した場合は、
       この-16pxも合わせて調整すること。 */
    .single-content .tnk-widget {
        max-width: none;
        margin-left: -16px;
        margin-right: -16px;
        margin-top: 12px;
        margin-bottom: 12px;
    }
}
