/*!
 * affilun — front-end card styles.
 *
 * Design goals:
 *
 *   - "溶け込む" with arbitrary WordPress themes: avoid resetting
 *     theme typography or colors at the root; pin everything inside
 *     a single `.affilun-card` boundary, and use CSS custom properties
 *     so a theme can override any token without touching this file.
 *
 *   - Modern affiliate-card layout: horizontal image + body on
 *     desktop (image left, ~140 px wide), stacks vertically below
 *     480 px. Provider buttons sit at the bottom
 *     of the body and pick up the upstream brand color
 *     (Amazon / Rakuten / Yahoo!ショッピング).
 *
 *   - No external font, no SVG icon set, no JS dependency. The
 *     stylesheet is the only asset enqueued for the front-end.
 *
 * CSS custom properties (override at :root or on `.affilun-card`):
 *
 *   --affilun-card-bg              card background
 *   --affilun-card-border          card border (1 px solid)
 *   --affilun-card-radius          card border-radius
 *   --affilun-card-shadow          card box-shadow
 *   --affilun-card-padding         card inner padding
 *   --affilun-card-gap             space between image and body
 *   --affilun-card-image-size      image column width (desktop)
 *   --affilun-text-strong          title color
 *   --affilun-text-muted           brand / footer color
 *   --affilun-text-default         body / description color
 *   --affilun-button-radius        button border-radius
 *   --affilun-color-amazon         Amazon button background
 *   --affilun-color-amazon-text    Amazon button text
 *   --affilun-color-rakuten        Rakuten button background
 *   --affilun-color-rakuten-text   Rakuten button text
 *   --affilun-color-yahoo          Yahoo!ショッピング button background
 *   --affilun-color-yahoo-text     Yahoo!ショッピング button text
 *   --affilun-color-mercari        Mercari button background
 *   --affilun-color-mercari-text   Mercari button text
 *
 * @package Affilun
 */

/* -----------------------------------------------------------------
 * Tokens.
 * Defined on .affilun-card so they cascade into plugin-rendered elements
 * without leaking globally.
 * -------------------------------------------------------------- */

.affilun-card {
	--affilun-card-bg: #ffffff;
	--affilun-card-border: 1px solid #e5e7eb;
	--affilun-card-radius: 8px;
	--affilun-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.04),
		0 1px 3px rgba(0, 0, 0, 0.06);
	--affilun-card-padding: 16px;
	--affilun-card-gap: 16px;
	--affilun-card-image-size: 140px;

	--affilun-text-strong: #111827;
	--affilun-text-muted: #6b7280;
	--affilun-text-default: #374151;

	--affilun-button-radius: 6px;

	--affilun-color-amazon: #f6a306;
	--affilun-color-amazon-text: #000000;
	--affilun-color-rakuten: #cf4944;
	--affilun-color-rakuten-text: #ffffff;
	--affilun-color-yahoo: #51a7e8;
	--affilun-color-yahoo-text: #000000;
	--affilun-color-mercari: #f2a1a1;
	--affilun-color-mercari-text: #000000;
}

/* -----------------------------------------------------------------
 * Card container.
 * -------------------------------------------------------------- */

.affilun-card {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	gap: var(--affilun-card-gap);
	padding: var(--affilun-card-padding);
	margin: 1.5em 0;
	background: var(--affilun-card-bg);
	border: var(--affilun-card-border);
	border-radius: var(--affilun-card-radius);
	box-shadow: var(--affilun-card-shadow);
	box-sizing: border-box;
}

/* Design presets. */
.affilun-card.affilun-design-flat {
	--affilun-card-border: 1px solid #e5e7eb;
	--affilun-card-shadow: none;
}

.affilun-card.affilun-design-outlined {
	--affilun-card-bg: transparent;
	--affilun-card-border: 2px solid #d1d5db;
	--affilun-card-shadow: none;
}

.affilun-card.affilun-design-soft {
	--affilun-card-bg: #f8fafc;
	--affilun-card-border: 1px solid #e2e8f0;
	--affilun-card-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.affilun-card.affilun-design-soft .affilun-button {
	--affilun-button-radius: 999px;
}

.affilun-card.affilun-button-shape-square {
	--affilun-button-radius: 0;
}

.affilun-card.affilun-button-shape-pill {
	--affilun-button-radius: 999px;
}

.affilun-card.affilun-buttons-stacked .affilun-card__buttons,
.affilun-card.affilun-buttons-full .affilun-card__buttons {
	flex-direction: column;
	align-items: stretch;
}

.affilun-card.affilun-buttons-full .affilun-button {
	width: 100%;
}

.affilun-card.affilun-button-tone-muted {
	--affilun-color-amazon: #f3f4f6;
	--affilun-color-amazon-text: #374151;
	--affilun-color-rakuten: #f3f4f6;
	--affilun-color-rakuten-text: #374151;
	--affilun-color-yahoo: #f3f4f6;
	--affilun-color-yahoo-text: #374151;
	--affilun-color-mercari: #f3f4f6;
	--affilun-color-mercari-text: #374151;
}

.affilun-card.affilun-button-tone-monochrome {
	--affilun-color-amazon: #111827;
	--affilun-color-amazon-text: #ffffff;
	--affilun-color-rakuten: #111827;
	--affilun-color-rakuten-text: #ffffff;
	--affilun-color-yahoo: #111827;
	--affilun-color-yahoo-text: #ffffff;
	--affilun-color-mercari: #111827;
	--affilun-color-mercari-text: #ffffff;
}

/* Variant: compact card narrows the image. */
.affilun-card.affilun-card-single-compact-card {
	--affilun-card-image-size: 100px;
	--affilun-card-padding: 12px;
	--affilun-card-gap: 12px;
}

/* Variant: minimal CTA stacks everything and emphasizes buttons. */
.affilun-card.affilun-card-single-minimal-cta {
	--affilun-card-image-size: 80px;
	--affilun-card-padding: 12px;
	--affilun-card-gap: 12px;
}

/* Image column. */
.affilun-card__image {
	flex: 0 0 var(--affilun-card-image-size);
	margin: 0;
	align-self: flex-start;
}

.affilun-card__image a {
	display: block;
	line-height: 0;
}

.affilun-card__image img {
	display: block;
	width: 100%;
	height: auto;
	max-width: var(--affilun-card-image-size);
	border-radius: calc(var(--affilun-card-radius) - 2px);
	background: #f3f4f6;
	object-fit: contain;
}

/* Body column. */
.affilun-card__body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.affilun-card__header {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.affilun-card__provider {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	padding: 2px 8px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.01em;
	color: var(--affilun-text-muted);
	background: #f3f4f6;
	border-radius: 999px;
}

/* Provider-specific provider-badge tints (subtle). */
.affilun-card__provider.affilun-provider-amazon {
	color: #b35a00;
	background: #fff3e0;
}
.affilun-card__provider.affilun-provider-rakuten {
	color: #8a0000;
	background: #ffe7e7;
}
.affilun-card__provider.affilun-provider-yahoo_shopping {
	color: #a00021;
	background: #ffe5ea;
}
.affilun-card__provider.affilun-provider-mercari {
	color: #8f1d1d;
	background: #ffe8e8;
}

.affilun-card__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.5;
	color: var(--affilun-text-strong);
	word-break: break-word;
}

.affilun-card__title a {
	color: inherit;
	text-decoration: none;
}

.affilun-card__title a:hover,
.affilun-card__title a:focus-visible {
	text-decoration: underline;
}

.affilun-card__brand {
	margin: 0;
	font-size: 12px;
	color: var(--affilun-text-muted);
}

.affilun-card__description {
	margin: 0;
	font-size: 13px;
	line-height: 1.55;
	color: var(--affilun-text-default);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.affilun-card__price {
	margin: 0;
	font-size: 14px;
	color: var(--affilun-text-strong);
}

.affilun-card__price-amount {
	font-weight: 700;
}

.affilun-card__price-observed-at {
	margin-left: 6px;
	font-size: 11px;
	font-weight: 400;
	color: var(--affilun-text-muted);
}

.affilun-card__availability {
	margin: 0;
	font-size: 12px;
	color: var(--affilun-text-muted);
}

.affilun-card__availability--out_of_stock,
.affilun-card__availability--unavailable {
	color: #b91c1c;
}

/* Buttons row. */
.affilun-card__buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

.affilun-button {
	--affilun-button-bg: var(--affilun-text-strong, #111827);
	--affilun-button-fg: #fff;

	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 16px;
	min-width: 120px;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.4;
	text-decoration: none;
	text-align: center;
	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
	border-radius: var(--affilun-button-radius);
	border: 0;
	cursor: pointer;
	transition:
		filter 120ms ease,
		transform 120ms ease;
}

.affilun-card .affilun-button {
	padding: 8px 16px !important;
	min-width: 120px !important;
	min-height: 0 !important;
	font-size: 13px !important;
	line-height: 1.4 !important;
	text-decoration: none !important;
	background: var(--affilun-button-bg) !important;
	color: var(--affilun-button-fg) !important;
	-webkit-text-fill-color: var(--affilun-button-fg) !important;
	border-radius: var(--affilun-button-radius) !important;
	box-shadow: none !important;
}

.affilun-button[hidden],
.affilun-card .affilun-button[hidden] {
	display: none !important;
}

.affilun-button:hover,
.affilun-button:focus-visible {
	filter: brightness(0.92);
	text-decoration: none;
}

.affilun-card .affilun-button:visited,
.affilun-card .affilun-button:hover,
.affilun-card .affilun-button:focus,
.affilun-card .affilun-button:focus-visible,
.affilun-card .affilun-button:active {
	text-decoration: none !important;
	background: var(--affilun-button-bg) !important;
	color: var(--affilun-button-fg) !important;
	-webkit-text-fill-color: var(--affilun-button-fg) !important;
}

.affilun-button:active {
	transform: translateY(1px);
}

.affilun-button:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

/* Provider-specific button colors. */
.affilun-button.affilun-button-amazon {
	--affilun-button-bg: var(--affilun-color-amazon);
	--affilun-button-fg: var(--affilun-color-amazon-text);

	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
}
.affilun-button.affilun-button-rakuten {
	--affilun-button-bg: var(--affilun-color-rakuten);
	--affilun-button-fg: var(--affilun-color-rakuten-text);

	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
}
.affilun-button.affilun-button-yahoo_shopping {
	--affilun-button-bg: var(--affilun-color-yahoo);
	--affilun-button-fg: var(--affilun-color-yahoo-text);

	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
}
.affilun-button.affilun-button-mercari {
	--affilun-button-bg: var(--affilun-color-mercari);
	--affilun-button-fg: var(--affilun-color-mercari-text);

	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
}
.affilun-button.affilun-button-custom {
	--affilun-button-bg: var(--affilun-text-strong);
	--affilun-button-fg: #fff;

	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
}

/* Footer. */
.affilun-card__disclaimers {
	margin-top: 10px;
	border-top: 1px solid #f3f4f6;
	padding-top: 8px;
}

.affilun-card__disclaimers-list {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 11px;
	color: var(--affilun-text-muted);
	line-height: 1.5;
}

.affilun-card__disclaimer + .affilun-card__disclaimer {
	margin-top: 2px;
}

.affilun-card__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 8px;
}

.affilun-badge {
	display: inline-flex;
	align-items: center;
	padding: 1px 8px;
	font-size: 11px;
	color: var(--affilun-text-muted);
	background: #f3f4f6;
	border-radius: 999px;
}

.affilun-badge-sale,
.affilun-badge--sale {
	color: #7c2d12;
	background: #ffedd5;
	font-weight: 700;
}

/* Link-only / degraded fallback cards. */
.affilun-card.affilun-card--fallback {
	display: block;
	border-color: #fde68a;
	background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
}

.affilun-card.affilun-card--fallback .affilun-card__title {
	margin-bottom: 8px;
}

.affilun-card__fallback-copy {
	margin: 0;
	font-size: 13px;
	line-height: 1.55;
	color: var(--affilun-text-default);
}

.affilun-card.affilun-card--fallback .affilun-card__buttons {
	margin-top: 12px;
}

.affilun-card.affilun-card--fallback .affilun-button-amazon {
	min-width: 180px;
	padding: 10px 20px;
	box-shadow: 0 2px 6px rgba(255, 153, 0, 0.24);
}

.affilun-card__fallback-disclosure {
	margin-top: 8px;
	font-size: 11px;
	line-height: 1.5;
	color: var(--affilun-text-muted);
}

/* Admin-only fallback warning emitted by ProductCardBlockRenderer. */
.affilun-card.affilun-card--admin-warning {
	display: block;
	border-color: #fecaca;
	background: #fef2f2;
	color: #991b1b;
	font-size: 13px;
	padding: 12px 14px;
}

/* -----------------------------------------------------------------
 * Color schemes.
 * -------------------------------------------------------------- */

.affilun-card.affilun-color-scheme-light {
	color-scheme: light;
}

.affilun-card.affilun-color-scheme-system {
	color-scheme: light dark;
}

.affilun-card.affilun-color-scheme-dark {
	--affilun-card-bg: #111827;
	--affilun-card-border: 1px solid #374151;
	--affilun-card-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
	--affilun-text-strong: #f9fafb;
	--affilun-text-muted: #9ca3af;
	--affilun-text-default: #d1d5db;

	color-scheme: dark;
}

.affilun-amazon-discounts__category + .affilun-amazon-discounts__category {
	margin-top: 2rem;
}

.affilun-amazon-discounts__heading {
	margin-bottom: 1rem;
}

.affilun-amazon-discounts__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1rem;
}

.affilun-amazon-discounts__grid .affilun-card {
	box-sizing: border-box;
}

.affilun-amazon-discount-badge {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	width: fit-content;
	margin: 0 0 0.5rem;
	padding: 0.25rem 0.625rem;
	border: 0 !important;
	border-radius: 0 !important;
	background: #d63638 !important;
	color: #ffffff !important;
	font-weight: 700 !important;
	line-height: 1.2;
}

.affilun-card.affilun-color-scheme-dark.affilun-design-flat {
	--affilun-card-border: 1px solid #374151;
}

.affilun-card.affilun-color-scheme-dark.affilun-design-outlined {
	--affilun-card-bg: transparent;
	--affilun-card-border: 2px solid #4b5563;
}

.affilun-card.affilun-color-scheme-dark.affilun-design-soft {
	--affilun-card-bg: #172033;
	--affilun-card-border: 1px solid #263449;
	--affilun-card-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
}

.affilun-card.affilun-color-scheme-dark.affilun-button-tone-muted {
	--affilun-color-amazon: #374151;
	--affilun-color-amazon-text: #e5e7eb;
	--affilun-color-rakuten: #374151;
	--affilun-color-rakuten-text: #e5e7eb;
	--affilun-color-yahoo: #374151;
	--affilun-color-yahoo-text: #e5e7eb;
	--affilun-color-mercari: #374151;
	--affilun-color-mercari-text: #e5e7eb;
}

.affilun-card.affilun-color-scheme-dark .affilun-card__image img,
.affilun-card.affilun-color-scheme-dark .affilun-card__provider,
.affilun-card.affilun-color-scheme-dark .affilun-badge {
	background: #1f2937;
}

.affilun-card.affilun-color-scheme-dark .affilun-card__provider.affilun-provider-amazon {
	color: #fbbf24;
	background: rgba(251, 191, 36, 0.14);
}

.affilun-card.affilun-color-scheme-dark .affilun-card__provider.affilun-provider-rakuten {
	color: #fca5a5;
	background: rgba(248, 113, 113, 0.14);
}

.affilun-card.affilun-color-scheme-dark .affilun-card__provider.affilun-provider-yahoo_shopping {
	color: #93c5fd;
	background: rgba(96, 165, 250, 0.14);
}

.affilun-card.affilun-color-scheme-dark .affilun-card__provider.affilun-provider-mercari {
	color: #fca5a5;
	background: rgba(248, 113, 113, 0.14);
}

.affilun-card.affilun-color-scheme-dark .affilun-card__availability--out_of_stock,
.affilun-card.affilun-color-scheme-dark .affilun-card__availability--unavailable {
	color: #fca5a5;
}

.affilun-card.affilun-color-scheme-dark .affilun-card__disclaimers {
	border-top-color: #374151;
}

.affilun-card.affilun-color-scheme-dark .affilun-badge-sale,
.affilun-card.affilun-color-scheme-dark .affilun-badge--sale {
	color: #fed7aa;
	background: rgba(249, 115, 22, 0.18);
}

.affilun-card.affilun-color-scheme-dark .affilun-button.affilun-button-custom {
	--affilun-button-bg: #e5e7eb;
	--affilun-button-fg: #111827;

	background: var(--affilun-button-bg);
	color: var(--affilun-button-fg);
}

.affilun-card.affilun-color-scheme-dark.affilun-card--fallback {
	border-color: #92400e;
	background: linear-gradient(180deg, #292012 0%, #111827 100%);
}

.affilun-card.affilun-color-scheme-dark.affilun-card--admin-warning {
	border-color: #7f1d1d;
	background: #2a1216;
	color: #fecaca;
}

@media (prefers-color-scheme: dark) {

	.affilun-card.affilun-color-scheme-system {
		--affilun-card-bg: #111827;
		--affilun-card-border: 1px solid #374151;
		--affilun-card-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
		--affilun-text-strong: #f9fafb;
		--affilun-text-muted: #9ca3af;
		--affilun-text-default: #d1d5db;
	}

	.affilun-card.affilun-color-scheme-system.affilun-design-flat {
		--affilun-card-border: 1px solid #374151;
	}

	.affilun-card.affilun-color-scheme-system.affilun-design-outlined {
		--affilun-card-bg: transparent;
		--affilun-card-border: 2px solid #4b5563;
	}

	.affilun-card.affilun-color-scheme-system.affilun-design-soft {
		--affilun-card-bg: #172033;
		--affilun-card-border: 1px solid #263449;
		--affilun-card-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
	}

	.affilun-card.affilun-color-scheme-system.affilun-button-tone-muted {
		--affilun-color-amazon: #374151;
		--affilun-color-amazon-text: #e5e7eb;
		--affilun-color-rakuten: #374151;
		--affilun-color-rakuten-text: #e5e7eb;
		--affilun-color-yahoo: #374151;
		--affilun-color-yahoo-text: #e5e7eb;
		--affilun-color-mercari: #374151;
		--affilun-color-mercari-text: #e5e7eb;
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__image img,
	.affilun-card.affilun-color-scheme-system .affilun-card__provider,
	.affilun-card.affilun-color-scheme-system .affilun-badge {
		background: #1f2937;
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__provider.affilun-provider-amazon {
		color: #fbbf24;
		background: rgba(251, 191, 36, 0.14);
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__provider.affilun-provider-rakuten {
		color: #fca5a5;
		background: rgba(248, 113, 113, 0.14);
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__provider.affilun-provider-yahoo_shopping {
		color: #93c5fd;
		background: rgba(96, 165, 250, 0.14);
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__provider.affilun-provider-mercari {
		color: #fca5a5;
		background: rgba(248, 113, 113, 0.14);
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__availability--out_of_stock,
	.affilun-card.affilun-color-scheme-system .affilun-card__availability--unavailable {
		color: #fca5a5;
	}

	.affilun-card.affilun-color-scheme-system .affilun-card__disclaimers {
		border-top-color: #374151;
	}

	.affilun-card.affilun-color-scheme-system .affilun-badge-sale,
	.affilun-card.affilun-color-scheme-system .affilun-badge--sale {
		color: #fed7aa;
		background: rgba(249, 115, 22, 0.18);
	}

	.affilun-card.affilun-color-scheme-system .affilun-button.affilun-button-custom {
		--affilun-button-bg: #e5e7eb;
		--affilun-button-fg: #111827;

		background: var(--affilun-button-bg);
		color: var(--affilun-button-fg);
	}

	.affilun-card.affilun-color-scheme-system.affilun-card--fallback {
		border-color: #92400e;
		background: linear-gradient(180deg, #292012 0%, #111827 100%);
	}

	.affilun-card.affilun-color-scheme-system.affilun-card--admin-warning {
		border-color: #7f1d1d;
		background: #2a1216;
		color: #fecaca;
	}
}

/* -----------------------------------------------------------------
 * Responsive: stack image above body below 480 px.
 * -------------------------------------------------------------- */

@media (max-width: 480px) {

	.affilun-card {
		flex-direction: column;
	}

	.affilun-card__image {
		flex: 0 0 auto;
		align-self: center;
	}

	.affilun-card__image img {
		max-width: 200px;
	}
}
