/* 記事本文だけで読み込む。楽天creativeは常に300px実寸。 */
.article-body .article-inline-ad {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 24px;
    width: max-content;
    max-width: 100%;
    margin: 24px auto 0;
}
.article-body .article-inline-ad[hidden] { display: none; }
.article-body .article-inline-ad > .ltl-rakuten-widget {
    flex: 0 0 300px;
    width: 300px;
}
.article-body .article-inline-ad[data-variant='extra'][data-viewport='pc'] > .ltl-rakuten-widget {
    flex: 0 0 600px;
    width: 600px;
}
.article-body .article-inline-ad + h2 { margin-top: 1.25em; }
@media (max-width: 1023px) {
    .article-body .article-inline-ad[data-viewport='pc'] { display: none; }
}
@media (min-width: 1024px) {
    .article-body .article-inline-ad[data-viewport='sp']:not([data-initial-viewport]) { display: none; }
}

/* A8: PCは右下固定、SPは3つ目のH2直前へJSで移動する。 */
.a8-article-ad[hidden],
.a8-article-ad__close[hidden] {
    display: none;
}

.a8-article-ad {
    width: 300px;
    max-width: 100%;
}

.a8-article-ad__panel,
.a8-article-ad__text-row,
.a8-article-ad__creative {
    width: 300px;
    max-width: 100%;
}

.a8-article-ad__panel,
.a8-article-ad__text,
.a8-article-ad__creative {
    position: relative;
}

.a8-article-ad__text-row {
    min-height: 36px;
}

.a8-article-ad__text {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.a8-article-ad__text > a {
    display: block;
    color: var(--link);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.45;
    text-decoration: none;
}

.a8-article-ad__text > a:hover {
    color: var(--link-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.a8-article-ad__text > img,
.a8-article-ad__creative > img {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    box-shadow: none;
}

.a8-article-ad__creative {
    height: 250px;
    margin-top: 12px;
    overflow: hidden;
}

.a8-article-ad__creative > a,
.a8-article-ad__creative > a > img {
    display: block;
    width: 300px;
    height: 250px;
    max-width: none;
}

.a8-article-ad__close {
    position: absolute;
    top: -12px;
    right: -12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.a8-article-ad__close:hover {
    background: var(--surface-2);
}

.article-body .a8-article-ad[data-mode='sp'] {
    margin: 24px auto 0;
}

.article-body .a8-article-ad[data-mode='sp'] + h2 {
    margin-top: 1.25em;
}

@media (max-width: 1023px) {
    .a8-article-ad__close {
        display: none;
    }
}

@media (min-width: 1024px) {
    .a8-article-ad[data-mode='pc'] {
        position: fixed;
        right: clamp(24px, 2.5vw, 48px);
        bottom: 24px;
        z-index: 80;
        margin: 0;
    }
}

/* SP専用: 画面下から少し浮かせる常時表示のA8テキスト広告。 */
.a8-sp-floating-text[hidden] {
    display: none;
}

.a8-sp-floating-text {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
    z-index: 85;
    width: min(340px, calc(100vw - 32px));
    transform: translateX(-50%);
}

.a8-sp-floating-text__content {
    position: relative;
    padding: 9px 42px 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.a8-sp-floating-text__content > a {
    display: block;
    color: var(--link);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.45;
    text-decoration: none;
}

.a8-sp-floating-text__content > a:hover {
    color: var(--link-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.a8-sp-floating-text__content > img {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    box-shadow: none;
}

.a8-sp-floating-text__close {
    position: absolute;
    top: 50%;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.a8-sp-floating-text__close:hover {
    background: var(--surface-3);
}

@media (min-width: 1024px) {
    .a8-sp-floating-text {
        display: none;
    }
}
