/**
 * Luminous Core v0.5.0 - Hegemony Blocks & Embed Styles
 * Material 3 Expressive / 利用規約準拠埋め込み対応
 */

:root {
    --m3-radius-card: 16px;
    --m3-sanctuary: 24px;
}

/* 24px Sanctuary & Container */
.m3-block-container {
    max-width: 800px;
    margin: 24px auto;
    padding-left: 24px;
    padding-right: var(--m3-sanctuary);
    box-sizing: border-box;
}

/* ==========================================================================
   1. Smart Sort Table
   ========================================================================== */
.m3-sort-table-wrapper,
.m3-table-container {
    overflow-x: auto;
    border-radius: var(--m3-radius-card);
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
    margin-bottom: 24px;
}

.m3-sort-table,
.m3-sortable-table {
    width: 100%;
    border-collapse: collapse;
}

.m3-sort-table th,
.m3-sortable-table th {
    background: var(--md-sys-color-surface-container-high);
    padding: 12px 16px;
    text-align: left;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
    position: relative;
    white-space: nowrap;
    transition: background 0.2s;
}

.m3-sort-table th:hover,
.m3-sortable-table th:hover { background: var(--md-sys-color-surface-container-highest); }
.m3-sort-table th.is-sorting,
.m3-sortable-table th.is-sorting { color: var(--md-sys-color-primary); }

.m3-sort-table th::after,
.m3-sortable-table th::after {
    content: 'expand_more';
    font-family: 'Material Symbols Outlined';
    font-size: 18px;
    vertical-align: middle;
    margin-left: 8px;
    opacity: 0.3;
}

.m3-sort-table th.sort-asc::after,
.m3-sortable-table th.sort-asc::after  { content: 'arrow_upward';   opacity: 1; }
.m3-sort-table th.sort-desc::after,
.m3-sortable-table th.sort-desc::after { content: 'arrow_downward'; opacity: 1; }

.m3-sort-table td,
.m3-sortable-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* ==========================================================================
   2. Media Label (Interactive Image)
   ========================================================================== */
.m3-media-container {
    position: relative;
    border-radius: var(--m3-radius-card);
    overflow: hidden;
    box-shadow: var(--m3-elevation-1);
    transition: transform 0.3s var(--m3-motion-easing);
}

.m3-media-container:hover { transform: scale(1.01); box-shadow: var(--m3-elevation-2); }

.m3-media-checkbox {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--md-sys-color-primary);
}

.m3-media-label {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 8px 16px;
    border-radius: var(--m3-radius-full);
    font-weight: 800;
    box-shadow: var(--m3-elevation-3);
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    z-index: 5;
}

/* ==========================================================================
   3. Voting Block
   ========================================================================== */
.m3-voting-card {
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--m3-radius-card);
    padding: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--m3-elevation-1);
}

.m3-voting-result-container {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: var(--m3-radius-medium);
    padding: 16px;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 900;
}

/* ==========================================================================
   4. Responsive (Device Specific)
   ========================================================================== */
@media (max-width: 359px) {
    :root { --m3-sanctuary: 16px; }
    .m3-block-container { padding-left: 12px; padding-right: 16px; }
    .m3-voting-title { font-size: 1.2rem; }
}

@media (min-width: 360px) and (max-width: 399px) {
    .m3-block-container { padding-left: 20px; padding-right: 24px; }
}

@media (min-width: 400px) {
    .m3-sort-table { font-size: 1rem; }
}

/* ==========================================================================
   9. 商品カード [product_card] / [m3_product]
   Amazon・楽天・Yahoo 同時表示対応
   ========================================================================== */
.m3-product-card {
    display: flex;
    gap: var(--m3-spacing-m, 16px);
    align-items: flex-start;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--m3-radius-medium, 16px);
    padding: var(--m3-spacing-l, 24px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s var(--m3-motion-easing);
}

.m3-product-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* 商品画像 */
.m3-product-card__image {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--md-sys-color-surface-container-high);
}

.m3-product-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* 商品情報エリア */
.m3-product-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.m3-product-card__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.m3-product-card__price {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--md-sys-color-primary);
}

/* ボタン群 */
.m3-product-card__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

/* 購入ボタン共通 */
.m3-product-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--m3-radius-full, 1000px);
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
    transition: transform 0.2s var(--m3-motion-easing), box-shadow 0.2s var(--m3-motion-easing), opacity 0.2s;
}

.m3-product-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.m3-product-btn:active {
    transform: translateY(0);
    opacity: 0.85;
}

/* Amazon */
.m3-product-btn--amazon {
    background: #FF9900;
    color: #111111;
}

.m3-product-btn--amazon:hover { background: #FFB347; }

/* 楽天 */
.m3-product-btn--rakuten {
    background: #BF0000;
    color: #ffffff;
}

.m3-product-btn--rakuten:hover { background: #D40000; }

/* モバイル: 商品カードを縦並びに */
@media (max-width: 599px) {
    .m3-product-card {
        flex-direction: column;
    }

    .m3-product-card__image {
        width: 100%;
        height: 180px;
    }

    .m3-product-card__buttons {
        flex-direction: column;
    }

    .m3-product-btn {
        justify-content: center;
        width: 100%;
    }
}

/* ダークモード */
[data-theme="dark"] .m3-product-card {
    background: var(--md-sys-color-surface-container);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .m3-product-card__image {
    background: var(--md-sys-color-surface-container-high);
}
