/*
 * components.css
 * 再利用可能なUIコンポーネントのスタイル定義。
 * 新しい共通スタイルはここに追加する。
 * テンプレート内インラインスタイルの移行先。
 */

/* ── Glassmorphism ユーティリティ ───────────────────────────────── */

/* blur(10px) 標準カード */
.glass-blur-sm {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* blur(16px) フォーム・モーダル向け */
.glass-blur-md {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* blur(20px) ヒーロー・大型パネル向け */
.glass-blur-lg {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ── ユーザーアバター ─────────────────────────────────────────── */

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

/* ── スケルトンローダー ───────────────────────────────────────── */

.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.04) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── 用語集自動リンク (.glossary-link) ─────────────────────────────── */
.glossary-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: rgba(197, 160, 89, 0.6);
    text-underline-offset: 3px;
    cursor: help;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.glossary-link:hover {
    color: #e2c585;
    text-decoration-color: #e2c585;
    text-decoration-style: solid;
}

/* ── アフィリエイト商品カード (.gear-product-card) ──────────────────────
 * [[GEAR:]]マーカー / render_gear_card / spot_gear_recommend / gear_card.html 共通。
 * 各寸法・フォントサイズは CSS カスタムプロパティで制御し、スコープ別バリアント
 * (.spot-gear-cards 等) やページ別の詰め幅は「変数の再代入」だけで行う。
 * モバイル(≤480px)の詰め値も末尾の media query で変数を再代入して一括適用する。
 * クラス名は utils/affiliate.py・gear_card.html と一致させること（変更禁止）。
 */
.gear-product-card {
    --gc-thumb: 100px;
    --gc-thumb-radius: 10px;
    --gc-pad-y: 1rem;
    --gc-pad-x: 1.15rem;
    --gc-gap: 1rem;
    --gc-margin-y: 1.5rem;
    --gc-radius: 12px;
    --gc-name-fs: 1.05rem;
    --gc-note-fs: 0.88rem;
    --gc-note-lh: 1.55;
    --gc-price-fs: 1.15rem;
    --gc-pr-fs: 0.64rem;
    --gc-rating-fs: 0.9rem;
    --gc-score-fs: 0.85rem;
    --gc-review-fs: 0.8rem;
    --gc-btn-fs: 0.92rem;
    --gc-btn-minh: 0;
    --gc-btn-pad: 0.55rem 1.3rem;
    --gc-btn-flex: 0 1 auto;
    --gc-btn-radius: 50px;
    --gc-actions-gap: 0.6rem;
    --gc-actions-mt: 0.9rem;
    --gc-align: center;
    --gc-accent: #ff9900;
    --gc-bg: linear-gradient(135deg, rgba(255,153,0,0.06), rgba(255,153,0,0.015));
    --gc-border-color: rgba(255,153,0,0.22);

    position: relative;
    display: flex;
    gap: var(--gc-gap);
    align-items: var(--gc-align);
    flex-wrap: wrap;
    background: var(--gc-bg);
    border: 1px solid var(--gc-border-color);
    border-radius: var(--gc-radius);
    padding: var(--gc-pad-y) var(--gc-pad-x);
    margin: var(--gc-margin-y) 0;
    /* 記事本文(.ql-editor)が white-space: pre-wrap を継承させるため、
     * Jinjaの{% if %}が偽の時に残る空行がそのまま縦の空白として表示されてしまう。
     * カードは地の文ではないウィジェットなので明示的にリセットする。 */
    white-space: normal;
}
/* 任意の「イチオシ」バッジ（[[GEAR:...|バッジ文言]]で指定時のみ表示）。
 * Pochip/Rinker系の商品カードに見られるコーナーラベルを踏襲し、
 * 既存の gear-compare-rank--gold と同系色で統一する。 */
.gear-product-badge {
    position: absolute;
    top: -0.6rem;
    left: 1rem;
    background: linear-gradient(135deg,#d4af37,#f3d57a);
    color: #1a1206;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.35);
    letter-spacing: 0.02em;
    z-index: 1;
}
.gear-product-thumb {
    flex: 0 0 var(--gc-thumb);
    width: var(--gc-thumb);
    height: var(--gc-thumb);
    border-radius: var(--gc-thumb-radius);
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gear-product-thumb img { width: 100%; height: 100%; object-fit: contain; }
.gear-product-thumb--empty {
    background: rgba(255,255,255,0.04);
    color: rgba(255,153,0,0.5);
    font-size: 2rem;
}
.gear-product-body { flex: 1 1 220px; min-width: 0; }
.gear-product-pr {
    font-size: var(--gc-pr-fs);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--gc-accent);
    margin-bottom: 0.3rem;
}
.gear-product-name {
    font-weight: 700;
    color: #fff;
    font-size: var(--gc-name-fs);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gear-product-rating { display: flex; align-items: center; gap: 0.35rem; }
.gear-product-review-count { color: #8a8f98; font-size: var(--gc-review-fs); }
/* 星評価は render_stars() が .gear-compare-stars/.gear-compare-score を吐くため、
 * カード内スコープに限定して比較表(.gear-compare-row)側と干渉させない。 */
.gear-product-card .gear-compare-stars {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    color: #ffc107;
    font-size: var(--gc-rating-fs);
    margin-top: 0.3rem;
}
.gear-product-card .gear-compare-stars .far { color: rgba(255,193,7,0.35); }
.gear-product-card .gear-compare-score {
    color: #ffc107;
    font-weight: 700;
    font-size: var(--gc-score-fs);
    margin-left: 0.25rem;
}
.gear-product-price {
    display: inline-block;
    color: var(--gc-accent);
    font-weight: 800;
    font-size: var(--gc-price-fs);
    margin-top: 0.35rem;
    padding: 0.15rem 0.6rem;
    background: rgba(255,153,0,0.12);
    border-radius: 6px;
}
.gear-product-note {
    color: #b9bdc4;
    font-size: var(--gc-note-fs);
    margin-top: 0.3rem;
    line-height: var(--gc-note-lh);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gear-product-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gc-actions-gap);
    margin-top: var(--gc-actions-mt);
}
.gear-product-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    flex: var(--gc-btn-flex);
    min-height: var(--gc-btn-minh);
    font-weight: 800;
    text-decoration: none;
    border-radius: var(--gc-btn-radius);
    padding: var(--gc-btn-pad);
    font-size: var(--gc-btn-fs);
    white-space: nowrap;
    /* 常時ごく薄い影を落として押せる要素であることを主張し、hoverでさらに強める */
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gear-product-btn:hover { transform: translateY(-2px); }
.gear-product-btn--amazon { background: linear-gradient(135deg,#ff9900,#ffb84d); color: #1a1206; }
.gear-product-btn--amazon:hover { box-shadow: 0 6px 18px rgba(255,153,0,0.35); color:#1a1206; }
.gear-product-btn--rakuten { background: linear-gradient(135deg,#bf0000,#e60000); color: #fff; }
.gear-product-btn--rakuten:hover { box-shadow: 0 6px 18px rgba(191,0,0,0.4); color:#fff; }
.gear-product-btn--mapcamera { background: linear-gradient(135deg,#2c3e50,#34495e); color: #fff; }
.gear-product-btn--mapcamera:hover { box-shadow: 0 6px 18px rgba(44,62,80,0.4); color:#fff; }
.gear-product-btn--yahoo { background: linear-gradient(135deg,#258bf7,#4169E1); color: #fff; }
.gear-product-btn--yahoo:hover { box-shadow: 0 6px 18px rgba(37,139,247,0.4); color:#fff; }

/* コンパクトバリアント: スポット詳細のBortle連動レコメンド（.spot-gear-cards）。
 * 変数の再代入のみ。プロパティは基底定義を再利用する。 */
.spot-gear-cards .gear-product-card {
    --gc-thumb: 72px;
    --gc-thumb-radius: 8px;
    --gc-pad-y: 0.9rem;
    --gc-pad-x: 1.1rem;
    --gc-margin-y: 0.6rem;
    --gc-radius: 14px;
    --gc-name-fs: 0.95rem;
    --gc-note-fs: 0.8rem;
    --gc-note-lh: 1.5;
    --gc-price-fs: 0.88rem;
    --gc-pr-fs: 0.6rem;
    --gc-rating-fs: 0.78rem;
    --gc-score-fs: 0.74rem;
    --gc-review-fs: 0.72rem;
    --gc-btn-fs: 0.8rem;
    --gc-btn-pad: 0.4rem 1rem;
    --gc-actions-gap: 0.45rem;
    --gc-actions-mt: 0.65rem;
}

/* モバイル詰め値（≤480px）。変数の再代入で一括適用。
 * .spot-gear-cards 等の高詳細度バリアントが宣言済みの変数はそちら（既にコンパクト）が
 * 優先されるが、buttons の tap ターゲット化 (--gc-btn-flex / --gc-btn-minh) は
 * バリアント未宣言のため全カードに効く。 */
@media (max-width: 480px) {
    .gear-product-card {
        --gc-thumb: 84px;
        --gc-thumb-radius: 8px;
        --gc-pad-y: 0.75rem;
        --gc-pad-x: 0.8rem;
        --gc-gap: 0.7rem;
        --gc-margin-y: 1rem;
        --gc-name-fs: 0.95rem;
        --gc-note-fs: 0.8rem;
        --gc-note-lh: 1.5;
        --gc-price-fs: 1.05rem;
        --gc-pr-fs: 0.6rem;
        --gc-rating-fs: 0.8rem;
        --gc-score-fs: 0.74rem;
        --gc-review-fs: 0.72rem;
        --gc-btn-fs: 0.84rem;
        --gc-btn-minh: 42px;
        --gc-btn-pad: 0.55rem 0.25rem;
        --gc-btn-flex: 1 1 0;
        --gc-actions-gap: 0.5rem;
        --gc-actions-mt: 0.6rem;
    }
}

/* 画像フォールバック(static/js/ui/img-fallback.js)がプレースホルダーに差し替えた際の見た目。
 * object-fit:cover等の既存指定でアイコンが引き伸ばされないよう contain で上書きする。
 * padding は%指定だと親要素の幅基準になり小さいアバター等で破綻するため使わない。
 * SVG自体の余白で十分なので、既存クラス(.author-avatar等)のgradient背景が透けないよう
 * background だけ明示的に上書きする。 */
.img-fallback {
    object-fit: contain !important;
    background: #2a2f3a !important;
}

.img-fallback-bg {
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-color: #2a2f3a;
}
