/* Ebookifi KDP Category Finder (scoped to .ebk-cf); same tokens as the Description Formatter */

.ebk-cf {
	--ebk-green: #2d6a2d;
	--ebk-green-dark: #0d2e0d;
	--ebk-green-soft: #eaf3de;
	--ebk-ink: #1c1f1c;
	--ebk-muted: #555b55;
	--ebk-line: #e1e5e1;
	--ebk-line-strong: #c9cfc9;
	--ebk-surface: #ffffff;
	--ebk-focus: #1d7c82;
	--ebk-radius: 14px;
	--ebk-radius-sm: 8px;
	--ebk-shadow: 0 1px 2px rgba(16, 24, 16, .05), 0 8px 24px rgba(16, 24, 16, .05);
	--ebk-fast: 150ms;
	--ebk-ease: cubic-bezier(.4, 0, .2, 1);
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
	color: var(--ebk-ink);
	font-size: 15px;
	line-height: 1.55;
	margin: 0 0 32px;
}
.ebk-cf *, .ebk-cf *::before, .ebk-cf *::after { box-sizing: border-box; }
.ebk-cf-noscript { grid-column: 1 / -1; background: #fff5dc; padding: 12px 16px; border-radius: var(--ebk-radius-sm); }

.ebk-cf-card { background: var(--ebk-surface); border: 1px solid var(--ebk-line); border-radius: var(--ebk-radius); box-shadow: var(--ebk-shadow); padding: 22px; }
.ebk-cf-card-title { margin: 0 0 6px; font-size: 18px; line-height: 1.3; font-weight: 700; color: var(--ebk-ink); }
.ebk-cf-shortlist-card { position: sticky; top: 100px; }

/* Format switch */
.ebk-cf-store { display: inline-flex; gap: 4px; padding: 4px; background: #f1f4f0; border: 1px solid var(--ebk-line); border-radius: 999px; margin-bottom: 18px; }
.ebk-cf-store-option { position: relative; margin: 0; cursor: pointer; }
.ebk-cf-store-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ebk-cf-store-option span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 18px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--ebk-muted); transition: background var(--ebk-fast) var(--ebk-ease), color var(--ebk-fast) var(--ebk-ease); }
.ebk-cf-store-option input:checked + span { background: var(--ebk-surface); color: var(--ebk-green-dark); box-shadow: 0 1px 3px rgba(16, 24, 16, .15); }
.ebk-cf-store-option input:focus-visible + span { outline: 3px solid var(--ebk-focus); outline-offset: 2px; }

/* Search field */
.ebk-cf-label { display: block; font-weight: 700; font-size: 15px; margin: 0 0 8px; }
.ebk-cf-field { position: relative; }
.ebk-cf-field-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ebk-muted); pointer-events: none; }
.ebk-cf .ebk-cf-input { width: 100%; min-height: 52px; padding: 12px 16px 12px 44px; font-size: 17px; border: 1px solid var(--ebk-line-strong); border-radius: 10px; background: #fff; color: var(--ebk-ink); transition: border-color var(--ebk-fast) var(--ebk-ease), box-shadow var(--ebk-fast) var(--ebk-ease); }
.ebk-cf .ebk-cf-input:focus { outline: none; border-color: var(--ebk-focus); box-shadow: 0 0 0 3px rgba(29, 124, 130, .25); }
/* Waiting state */
.ebk-cf-spinner { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border: 2.5px solid #cfe0d6; border-top-color: var(--ebk-focus); border-radius: 50%; opacity: 0; pointer-events: none; transition: opacity var(--ebk-fast) var(--ebk-ease); }
.ebk-cf.is-busy .ebk-cf-spinner { opacity: 1; animation: ebk-cf-spin .7s linear infinite; }
.ebk-cf.is-busy .ebk-cf-field-icon { opacity: 0; }
.ebk-cf.is-busy .ebk-cf-status { display: flex; align-items: center; gap: 8px; color: var(--ebk-focus); }
.ebk-cf.is-busy .ebk-cf-status::before { content: ""; flex: 0 0 14px; height: 14px; border: 2px solid #cfe0d6; border-top-color: var(--ebk-focus); border-radius: 50%; animation: ebk-cf-spin .7s linear infinite; }
.ebk-cf.is-busy .ebk-cf-group { opacity: .45; transition: opacity var(--ebk-fast) var(--ebk-ease); }
.ebk-cf-skeleton { list-style: none; border: 1px solid var(--ebk-line); border-radius: 12px; padding: 16px; margin: 0 0 12px; }
.ebk-cf-sk-line { display: block; height: 12px; width: 45%; border-radius: 6px; margin: 0 0 10px; background: linear-gradient(90deg, #eef2ed 25%, #f7f9f6 50%, #eef2ed 75%); background-size: 200% 100%; animation: ebk-cf-shimmer 1.2s ease-in-out infinite; }
.ebk-cf-sk-line.is-wide { height: 16px; width: 30%; }
.ebk-cf-sk-line.is-row { width: 100%; height: 30px; margin: 10px 0 0; }
@keyframes ebk-cf-spin { to { transform: rotate(360deg); } }
@keyframes ebk-cf-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.ebk-cf-hint { margin: 8px 0 0; font-size: 13px; color: var(--ebk-muted); }
.ebk-cf-status { min-height: 1.4em; margin: 14px 0 8px; font-size: 14px; font-weight: 600; color: var(--ebk-green-dark); }

/* Results */
.ebk-cf-results, .ebk-cf-shortlist { list-style: none; margin: 0; padding: 0; }
.ebk-cf-group { border: 1px solid var(--ebk-line); border-radius: 12px; margin: 0 0 12px; overflow: hidden; }
.ebk-cf-group.is-category-match { border-color: #b9d3a8; }
.ebk-cf-group-head { position: relative; padding: 12px 16px; background: #f6f8f5; border-bottom: 1px solid var(--ebk-line); }
.ebk-cf-group.is-category-match .ebk-cf-group-head { background: var(--ebk-green-soft); }
.ebk-cf-group-name { display: block; font-size: 17px; color: var(--ebk-ink); padding-right: 130px; }
.ebk-cf-crumbs { display: block; font-size: 13px; color: var(--ebk-muted); overflow-wrap: anywhere; }
.ebk-cf-tag { position: absolute; top: 12px; right: 14px; font-size: 12px; font-weight: 700; color: var(--ebk-green-dark); background: #fff; border: 1px solid #b9d3a8; border-radius: 999px; padding: 2px 10px; }
.ebk-cf-places { list-style: none; margin: 0; padding: 4px 0; }
.ebk-cf-places li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 16px; transition: background var(--ebk-fast) var(--ebk-ease); }
.ebk-cf-places li + li { border-top: 1px solid #f0f2ef; }
.ebk-cf-places li:hover { background: #fafcf9; }
.ebk-cf-place { font-size: 15px; font-weight: 600; color: var(--ebk-ink); min-width: 0; }
.ebk-cf mark { background: #fff1b8; color: inherit; padding: 0 1px; border-radius: 2px; }
.ebk-cf-group:focus { outline: none; }
.ebk-cf-group:focus-visible { outline: 3px solid var(--ebk-focus); outline-offset: 2px; }

/* Show more */
.ebk-cf .ebk-cf-more { display: flex; width: 100%; margin: 4px 0 0; }
.ebk-cf .ebk-cf-more[hidden] { display: none; }

/* Related categories */
.ebk-cf-related { margin: 20px 0 0; padding: 16px 0 0; border-top: 1px solid var(--ebk-line); }
.ebk-cf-related[hidden] { display: none; }
.ebk-cf .ebk-cf-related-title { margin: 0 0 10px; font-size: 15px; line-height: 1.3; font-weight: 700; color: var(--ebk-ink); }
.ebk-cf-related-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ebk-cf-related-list li { margin: 0; }
.ebk-cf .ebk-cf-related-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 44px; padding: 8px 12px; text-align: left; font: inherit; background: #fff; border: 1px solid var(--ebk-line-strong); border-radius: 10px; cursor: pointer; transition: background var(--ebk-fast) var(--ebk-ease), border-color var(--ebk-fast) var(--ebk-ease); }
.ebk-cf .ebk-cf-related-item:hover { background: var(--ebk-green-soft); border-color: var(--ebk-green); }
.ebk-cf .ebk-cf-related-item:focus-visible { outline: 3px solid var(--ebk-focus); outline-offset: 2px; }
.ebk-cf-related-name { font-size: 14px; font-weight: 700; color: var(--ebk-green-dark); }
.ebk-cf-related-path { font-size: 12px; color: var(--ebk-muted); overflow-wrap: anywhere; }

/* Buttons */
.ebk-cf-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ebk-ink); background: #fff; border: 1px solid var(--ebk-line-strong); border-radius: 999px; cursor: pointer; transition: background var(--ebk-fast) var(--ebk-ease), border-color var(--ebk-fast) var(--ebk-ease), color var(--ebk-fast) var(--ebk-ease), transform var(--ebk-fast) var(--ebk-ease); }
.ebk-cf-btn:hover:not(:disabled) { border-color: var(--ebk-green); color: var(--ebk-green-dark); background: var(--ebk-green-soft); }
.ebk-cf-btn:active:not(:disabled) { transform: scale(.98); }
.ebk-cf-btn:focus-visible { outline: 3px solid var(--ebk-focus); outline-offset: 2px; }
.ebk-cf-btn:disabled { opacity: .55; cursor: not-allowed; }
.ebk-cf-btn-small { flex: 0 0 auto; min-height: 36px; padding: 0 14px; font-size: 13px; }
.ebk-cf-btn.is-added { opacity: 1; background: var(--ebk-green-soft); border-color: var(--ebk-green); color: var(--ebk-green-dark); }
.ebk-cf-btn-primary { width: 100%; margin-top: 14px; min-height: 46px; background: var(--ebk-green); border-color: var(--ebk-green); color: #fff; }
.ebk-cf-btn-primary:hover:not(:disabled) { background: var(--ebk-green-dark); border-color: var(--ebk-green-dark); color: #fff; }

/* Shortlist */
.ebk-cf-shortlist { counter-reset: ebkcf; margin-top: 12px; }
.ebk-cf-shortlist li { counter-increment: ebkcf; display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--ebk-line); font-size: 14px; }
.ebk-cf-shortlist li::before { content: counter(ebkcf); flex: 0 0 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ebk-green); color: #fff; font-size: 12px; font-weight: 700; }
.ebk-cf-shortlist li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ebk-cf-empty { margin: 12px 0 0; font-size: 14px; color: var(--ebk-muted); }
.ebk-cf-count { display: inline-block; margin-left: 8px; padding: 1px 9px; border-radius: 999px; background: var(--ebk-green-soft); color: var(--ebk-green-dark); font-size: 13px; font-weight: 700; vertical-align: middle; }
.ebk-cf-full { margin: 12px 0 0; padding: 8px 12px; border-radius: var(--ebk-radius-sm); background: #fff5dc; color: #4a3200; font-size: 13px; }
.ebk-cf-full[hidden] { display: none; }
.ebk-cf-copy-status { min-height: 1.2em; margin: 8px 0 0; font-size: 13px; color: var(--ebk-green-dark); text-align: center; }

/* Left column only: the pinned shortlist card slides down the right column and would cover a full-width notice. */
.ebk-cf-notice { grid-column: 1; margin: 0; font-size: 12px; line-height: 1.6; color: var(--ebk-muted); }

@media (max-width: 860px) {
	.ebk-cf { grid-template-columns: 1fr; }
	.ebk-cf-shortlist-card { position: static; }
}
@media (max-width: 480px) {
	.ebk-cf-card { padding: 16px; }
	.ebk-cf-store { display: flex; }
	.ebk-cf-store-option { flex: 1; }
	.ebk-cf-store-option span { justify-content: center; padding: 0 10px; }
	.ebk-cf-group-name { padding-right: 0; }
	.ebk-cf-tag { position: static; display: inline-block; margin-top: 6px; }
	.ebk-cf-places li { padding: 6px 12px; }
}
@media (pointer: coarse) {
	.ebk-cf-btn, .ebk-cf-btn-small, .ebk-cf-store-option span { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
	.ebk-cf *, .ebk-cf *::before, .ebk-cf *::after { transition: none !important; }
	/* No spinning or shimmer: keep a still ring and plain placeholder bars. */
	.ebk-cf.is-busy .ebk-cf-spinner, .ebk-cf.is-busy .ebk-cf-status::before, .ebk-cf-sk-line { animation: none; }
}
