/* Keep slot-variable diagrams compact and readable beside their code. */
pre#modal-value-memory.mermaid > svg,
pre#sticky-value-memory.mermaid > svg,
pre#stack-value-memory.mermaid > svg,
pre#macro-value-memory.mermaid > svg {
    width: 520px;
    max-width: 100%;
    height: auto;
}

/* Keep short flow diagrams at their natural aspect ratio. */
pre#pie-selection-distance.mermaid > svg {
    height: auto;
}

/* The four-part Getter/Setter cycle uses fixed geometry at any screen size. */
.pme-get-set-flow {
    width: 520px;
    max-width: 100%;
    margin: 1.5rem auto;
}
.pme-get-set-flow > svg {
    display: block;
    width: 100%;
    height: auto;
}
.pme-get-set-flow__endpoint {
    fill: var(--color-background-secondary, #303743);
    stroke: var(--color-foreground-border, #788593);
    stroke-width: 1.5;
}

/* Feature card styling for sphinx-design */
.feature-card {
    transition: all 0.3s ease;
    border: 1px solid var(--color-card-border);
    background: var(--color-card-background);
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    border-color: var(--color-brand-primary);
}

.feature-card .card-header {
    background: var(--color-brand-primary);
    color: white;
    font-weight: bold;
}

.feature-card .card-body {
    padding: 1.5rem;
}

.feature-card img {
    transition: transform 0.3s ease;
    cursor: pointer;
}

.feature-card img:hover {
    transform: scale(1.05);
}

.sd-card.feature-card-compact {
    height: 100%;
}

.sd-card.feature-card-compact .card-body {
    padding: 1rem 1.1rem;
}

.sd-card.feature-card-compact .sd-card-title {
    font-size: 1rem;
    line-height: 1.35;
}

.sd-card.feature-card-compact img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.sd-card.feature-card-compact p:last-child {
    margin-bottom: 0;
    font-size: 0.95rem;
    line-height: 1.55;
}

/* Grid adjustments for better responsive behavior */
.sd-container-fluid .sd-row {
    --sd-gutter-x: 1.5rem;
    --sd-gutter-y: 1.5rem;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    height: 0;
    max-width: 100%;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- card-carousel 用カスタムサイズ調整 --------------- */
.sd-card-carousel {
    --sd-gap: 1.5rem;
    /* カード間隔 */
}

.sd-card-carousel .sd-card {
    flex: 0 0 clamp(400px, 60vw, 600px);
    /* カード幅。GIF画像を大きく表示するため調整 */
    scroll-snap-align: start;
}

/* モバイル用の調整 */
@media (max-width: 768px) {
    .sd-card-carousel .sd-card {
        flex: 0 0 clamp(280px, 80vw, 320px);
        /* モバイルでは画面幅の80%まで使用 */
    }

    .sd-card-carousel {
        --sd-gap: 1rem;
        /* モバイルでは間隔を少し狭く */
    }
}

/* --- 解説用 色付きカード ------------------------------------------------- */

/* ベーススタイル：モダンなカードデザイン */
.sd-card.ex-card {
    position: relative !important;
    border: 1px solid var(--ex-card-border, #e5e7eb) !important;
    border-radius: 2px 2px 12px 12px !important;
    /* 上部を角張らせ、下部のみ丸く */
    background: var(--ex-card-bg, var(--color-card-background, #ffffff)) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.02) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow: hidden !important;
}

/* アクセントバー（上部色付きライン） */
.sd-card.ex-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 4px;
    background: var(--ex-card-accent, transparent);
    border-radius: 2px 2px 0 0;
    /* 上部を微妙に丸く */
    z-index: 1;
}

/* ホバー効果 */
.sd-card.ex-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08) !important;
    border-color: var(--ex-card-accent, #e5e7eb) !important;
}

/* カードタイトルの調整 */
.sd-card.ex-card .sd-card-title {
    margin-top: 8px !important;
    color: var(--ex-card-accent, var(--color-foreground-primary, #1f2937)) !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}

/* バリアント（色） */
.sd-card.ex-card-keymap {
    --ex-card-accent: #3b82f6;
    /* blue-500 */
    --ex-card-border: rgba(59, 130, 246, 0.2);
}

.sd-card.ex-card-hotkey {
    --ex-card-accent: #10b981;
    /* emerald-500 */
    --ex-card-border: rgba(16, 185, 129, 0.2);
}

.sd-card.ex-card-modifier {
    --ex-card-accent: #f59e0b;
    /* amber-500 */
    --ex-card-border: rgba(245, 158, 11, 0.2);
}

/* ダークテーマ調整 */
[data-theme="dark"] .sd-card.ex-card {
    --ex-card-bg: var(--color-card-background, #1f2937);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

[data-theme="dark"] .sd-card.ex-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .sd-card.ex-card .sd-card-title {
    color: var(--ex-card-accent, var(--color-foreground-primary, #f9fafb)) !important;
}

/* --- 画像・Figure汎用効果 ------------------------------------------------- */

/* ホバーズーム効果 */
.img-hover-zoom {
    transition: transform 0.3s ease;
    cursor: pointer;
}

.img-hover-zoom:hover {
    transform: scale(1.05);
}

/* 影付き画像 */
.img-shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
}

/* 角丸画像 */
.img-rounded {
    border-radius: 12px;
    overflow: hidden;
}

/* フローティング効果（微妙な浮遊感） */
.img-float {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.img-float:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* 組み合わせ用：モダンな画像スタイル */
.img-modern {
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.img-modern:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* ダークテーマ調整 */
[data-theme="dark"] .img-bordered {
    border-color: var(--color-border, #374151);
}

[data-theme="dark"] .img-polaroid {
    background: #f9fafb;
}

.support-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.support-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1rem;
    border: 1px solid var(--color-brand-primary);
    border-radius: 999px;
    color: var(--color-brand-primary);
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.support-button:hover,
.support-button:focus-visible {
    background: color-mix(in srgb, var(--color-brand-primary) 10%, transparent);
    text-decoration: none;
}

.support-button-primary {
    background: var(--color-brand-primary);
    color: var(--color-background-primary);
}

.support-button-primary:hover,
.support-button-primary:focus-visible {
    background: var(--color-brand-content);
    border-color: var(--color-brand-content);
    color: var(--color-background-primary);
}

/* Reference video previews reuse the existing responsive video wrapper. */
.video-container.pme-reference-video {
    padding-bottom: 0;
    height: auto;
    aspect-ratio: 16 / 9;
    min-height: 200px;
}
.pme-reference-video iframe { border: 0; }

/* Language navigation shares the deployment's root / ja layout. */
.documentation-languages {
    display: flex;
    flex-shrink: 0;
    justify-content: center;
    gap: .5rem;
    padding: .4rem 1rem;
    border-top: 1px solid var(--color-foreground-border);
}
.documentation-languages a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 1.125rem;
    text-decoration: none;
}
.documentation-languages a:hover,
.documentation-languages a[aria-current] {
    background: var(--color-background-secondary);
    border-color: var(--color-foreground-border);
}
.documentation-languages a:focus-visible {
    outline: 2px solid var(--color-brand-primary);
    outline-offset: 2px;
}
