/**
 * YAY Book Gallery — front-end styles.
 * Colors/radius/font are driven by CSS variables injected from settings.
 */

.ybg-gallery,
.ybg-authors,
.ybg-slider,
.ybg-filter,
.ybg-detail,
.ybg-reviews {
	--ybg-primary: #2a6df4;
	--ybg-btn: #f39c12;
	--ybg-btn-text: #fff;
	--ybg-radius: 8px;
	--ybg-font: inherit;
	font-family: var(--ybg-font);
	box-sizing: border-box;
}

.ybg-gallery *,
.ybg-authors *,
.ybg-slider *,
.ybg-detail * { box-sizing: border-box; }

/* ---------- Grid ---------- */
.ybg-gallery {
	display: grid;
	gap: 22px;
	margin: 0 0 24px;
}
.ybg-cols-1 { grid-template-columns: 1fr; }
.ybg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ybg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ybg-cols-4 { grid-template-columns: repeat(4, 1fr); }
.ybg-cols-5 { grid-template-columns: repeat(5, 1fr); }
.ybg-cols-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 900px) {
	.ybg-cols-4, .ybg-cols-5, .ybg-cols-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
	.ybg-cols-3, .ybg-cols-4, .ybg-cols-5, .ybg-cols-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
	.ybg-gallery:not(.ybg-gallery--list) { grid-template-columns: 1fr; }
}

/* ---------- Card ---------- */
.ybg-card {
	background: #fff;
	border: 1px solid #e7e7ee;
	border-radius: var(--ybg-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: box-shadow .18s ease, transform .18s ease;
}
.ybg-card:hover { box-shadow: 0 8px 26px rgba(20, 30, 60, .12); transform: translateY(-3px); }

.ybg-card__cover { position: relative; background: #f4f5f9; aspect-ratio: 2 / 3; }
.ybg-card__cover a { display: block; height: 100%; }
.ybg-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ybg-card__nocover {
	display: flex; align-items: center; justify-content: center;
	height: 100%; padding: 14px; text-align: center; color: #8a8fa3; font-size: 14px;
}
.ybg-badge {
	position: absolute; top: 8px; left: 8px;
	background: var(--ybg-primary); color: #fff;
	font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px;
	text-transform: uppercase; letter-spacing: .04em;
}

.ybg-card__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ybg-card__title { font-size: 15px; line-height: 1.3; margin: 0; font-weight: 700; }
.ybg-card__title a { color: inherit; text-decoration: none; }
.ybg-card__title a:hover { color: var(--ybg-primary); }
.ybg-card__author { margin: 0; font-size: 13px; color: #5b6072; }
.ybg-card__author a { color: inherit; text-decoration: none; }
.ybg-card__author a:hover { text-decoration: underline; }
.ybg-card__genre { margin: 0; font-size: 12px; color: #9095a6; }
.ybg-card__excerpt { font-size: 13px; color: #4a4f61; line-height: 1.5; }
.ybg-card__meta { margin-top: auto; }
.ybg-card__price { font-weight: 700; color: var(--ybg-primary); font-size: 15px; }

.ybg-card__buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Buttons */
.ybg-btn {
	display: inline-block;
	background: var(--ybg-btn); color: var(--ybg-btn-text) !important;
	border: 0; border-radius: 6px;
	padding: 7px 12px; font-size: 13px; font-weight: 600;
	text-decoration: none; cursor: pointer; line-height: 1.2;
	transition: filter .15s ease;
}
.ybg-btn:hover { filter: brightness(.92); color: var(--ybg-btn-text); }
.ybg-btn--cart { background: var(--ybg-primary); }
.ybg-btn--login { background: #6b7280; }
.ybg-btn--amazon { background: #ff9900; color: #111 !important; }

/* ---------- List layout ---------- */
.ybg-gallery--list .ybg-card { flex-direction: row; }
.ybg-gallery--list .ybg-card__cover { width: 130px; min-width: 130px; aspect-ratio: 2 / 3; }
.ybg-gallery--list .ybg-card__body { flex: 1; }

/* ---------- Minimal / Image ---------- */
.ybg-gallery--minimal .ybg-card { border: none; background: transparent; }
.ybg-gallery--minimal .ybg-card:hover { transform: none; box-shadow: none; }
.ybg-gallery--minimal .ybg-card__body { padding: 8px 2px; }
.ybg-gallery--image .ybg-card__cover { aspect-ratio: 2 / 3; }

/* ---------- Stars ---------- */
.ybg-stars { display: inline-flex; gap: 1px; color: #f5b301; font-size: 15px; line-height: 1; }
.ybg-star-empty { color: #d5d8e0; }
.ybg-star-half { position: relative; color: #d5d8e0; }
.ybg-star-half::before { content: "\2605"; position: absolute; left: 0; width: 50%; overflow: hidden; color: #f5b301; }
.ybg-card__rating, .ybg-detail__rating { display: flex; align-items: center; gap: 6px; }
.ybg-card__rating small, .ybg-detail__rating small { color: #9095a6; }

.ybg-stars--input { cursor: pointer; font-size: 26px; direction: ltr; }
.ybg-stars--input .ybg-star { color: #d5d8e0; transition: color .1s; }
.ybg-stars--input .ybg-star input { position: absolute; opacity: 0; width: 0; height: 0; }
.ybg-stars--input.is-hover .ybg-star.is-lit,
.ybg-stars--input .ybg-star.is-selected { color: #f5b301; }

/* ---------- Slider ---------- */
.ybg-slider { position: relative; margin: 0 0 24px; }
.ybg-slider__track {
	display: flex; gap: 18px; overflow-x: auto; scroll-behavior: smooth;
	scroll-snap-type: x mandatory; padding: 4px 2px 14px; -webkit-overflow-scrolling: touch;
}
.ybg-slider__track::-webkit-scrollbar { height: 8px; }
.ybg-slider__track::-webkit-scrollbar-thumb { background: #d5d8e0; border-radius: 8px; }
.ybg-slider__slide { scroll-snap-align: start; flex: 0 0 calc((100% - 18px * 3) / 4); }
@media (max-width: 900px) { .ybg-slider__slide { flex-basis: calc((100% - 18px * 2) / 3); } }
@media (max-width: 640px) { .ybg-slider__slide { flex-basis: calc((100% - 18px) / 2); } }
@media (max-width: 420px) { .ybg-slider__slide { flex-basis: 80%; } }

.ybg-slider__nav {
	position: absolute; top: 40%; transform: translateY(-50%);
	width: 40px; height: 40px; border-radius: 50%;
	border: none; background: var(--ybg-primary); color: #fff;
	font-size: 22px; line-height: 1; cursor: pointer; z-index: 2;
	box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.ybg-slider__prev { left: -8px; }
.ybg-slider__next { right: -8px; }
.ybg-slider__nav:disabled { opacity: .35; cursor: default; }

/* ---------- Filter panel ---------- */
.ybg-filter {
	display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
	background: #f7f8fc; border: 1px solid #e7e7ee; border-radius: var(--ybg-radius);
	padding: 14px; margin: 0 0 20px;
}
.ybg-filter__field {
	padding: 8px 10px; border: 1px solid #d5d8e0; border-radius: 6px;
	font-size: 14px; background: #fff; min-width: 140px;
}
.ybg-filter__keyword { flex: 1 1 220px; }
.ybg-filter__submit { padding: 9px 18px; }

/* ---------- Authors ---------- */
.ybg-author { text-align: center; }
.ybg-author__avatar {
	display: inline-flex; align-items: center; justify-content: center;
	width: 120px; height: 120px; border-radius: 50%; overflow: hidden;
	background: var(--ybg-primary); color: #fff; text-decoration: none;
	margin-bottom: 10px; border: 4px solid #fff; box-shadow: 0 4px 16px rgba(20,30,60,.12);
}
.ybg-author__avatar img { width: 100%; height: 100%; object-fit: cover; }
.ybg-author__initials { font-size: 46px; font-weight: 700; }
.ybg-author__name { font-size: 16px; margin: 0 0 4px; }
.ybg-author__name a { color: inherit; text-decoration: none; }
.ybg-author__bio { font-size: 13px; color: #5b6072; margin: 0 0 6px; }
.ybg-author__count { font-size: 12px; color: #9095a6; margin: 0; }

/* ---------- Detail ---------- */
.ybg-detail { display: grid; grid-template-columns: 300px 1fr; gap: 32px; }
@media (max-width: 720px) { .ybg-detail { grid-template-columns: 1fr; } }
.ybg-detail__cover img { width: 100%; border-radius: var(--ybg-radius); box-shadow: 0 10px 30px rgba(20,30,60,.15); }
.ybg-detail__title { margin: 0 0 8px; font-size: 28px; line-height: 1.2; }
.ybg-detail__author { font-size: 16px; color: #5b6072; margin: 0 0 10px; }
.ybg-detail__author a { color: var(--ybg-primary); text-decoration: none; }
.ybg-detail__rating { margin: 0 0 12px; font-size: 18px; }
.ybg-detail__price { font-size: 22px; font-weight: 700; color: var(--ybg-primary); margin: 0 0 14px; }
.ybg-detail__desc { line-height: 1.65; margin-bottom: 18px; }
.ybg-detail__meta { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 14px; }
.ybg-detail__meta th, .ybg-detail__meta td { text-align: left; padding: 7px 10px; border-bottom: 1px solid #eee; vertical-align: top; }
.ybg-detail__meta th { width: 130px; color: #5b6072; font-weight: 600; }
.ybg-detail__buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.ybg-detail__buttons .ybg-btn { padding: 10px 18px; font-size: 14px; }
.ybg-detail__permalink a { color: var(--ybg-primary); text-decoration: none; }

/* ---------- Reviews ---------- */
.ybg-reviews { margin-top: 40px; border-top: 1px solid #eee; padding-top: 24px; }
.ybg-reviews__list { list-style: none; margin: 0 0 24px; padding: 0; }
.ybg-review { padding: 14px 0; border-bottom: 1px solid #f0f0f4; }
.ybg-review__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.ybg-review__author { font-size: 15px; }
.ybg-review__date { color: #9095a6; font-size: 12px; }
.ybg-review-form { background: #f7f8fc; border-radius: var(--ybg-radius); padding: 18px; max-width: 560px; }
.ybg-review-form h3 { margin-top: 0; }
.ybg-review-form input[type=text], .ybg-review-form input[type=email], .ybg-review-form textarea {
	width: 100%; padding: 9px 11px; border: 1px solid #d5d8e0; border-radius: 6px; font-size: 14px;
}
.ybg-review-form__rating { margin-bottom: 12px; }
.ybg-review-form__rating label { display: block; font-weight: 600; margin-bottom: 4px; }
.ybg-review-form__msg { margin-left: 10px; font-size: 14px; }
.ybg-review-form__msg.is-ok { color: #1a8917; }
.ybg-review-form__msg.is-err { color: #c0392b; }

/* ---------- Modal ---------- */
.ybg-modal { position: fixed; inset: 0; z-index: 99999; display: none; }
.ybg-modal.is-open { display: block; }
.ybg-modal__overlay { position: absolute; inset: 0; background: rgba(15, 20, 40, .6); }
.ybg-modal__dialog {
	position: relative; margin: 4vh auto; max-width: 860px; width: calc(100% - 32px);
	max-height: 92vh; overflow-y: auto; background: #fff;
	border-radius: var(--ybg-radius); padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.ybg-modal__close {
	position: absolute; top: 10px; right: 12px; border: none; background: none;
	font-size: 30px; line-height: 1; cursor: pointer; color: #6b7280;
}
.ybg-empty { color: #6b7280; padding: 20px 0; }

/* ---------- Pagination ---------- */
.ybg-pagination { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 8px 0 24px; }
.ybg-pagination .page-numbers {
	display: inline-block; padding: 7px 12px; border: 1px solid #e0e0e8;
	border-radius: 6px; text-decoration: none; color: #333; font-size: 14px;
}
.ybg-pagination .page-numbers.current { background: var(--ybg-primary); color: #fff; border-color: var(--ybg-primary); }

/* ---------- Author profile form ---------- */
.ybg-profile { max-width: 560px; }
.ybg-profile__title { margin: 0 0 14px; }
.ybg-profile__notice { padding: 10px 14px; border-radius: var(--ybg-radius); margin: 0 0 16px; font-size: 14px; }
.ybg-profile__notice--ok { background: #e7f6e9; color: #1a6b23; }
.ybg-profile__notice--err { background: #fdecea; color: #c0392b; }
.ybg-profile__notice--pending { background: #fff6e5; color: #8a6100; }
.ybg-profile__form { background: #f7f8fc; border: 1px solid #e7e7ee; border-radius: var(--ybg-radius); padding: 20px; }
.ybg-profile__field { margin: 0 0 16px; }
.ybg-profile__field label,
.ybg-profile__photo label { display: block; font-weight: 600; margin-bottom: 5px; }
.ybg-profile__form input[type=text],
.ybg-profile__form textarea { width: 100%; padding: 10px 12px; border: 1px solid #d5d8e0; border-radius: 6px; font-size: 14px; }
.ybg-profile__photo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.ybg-profile__avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(20,30,60,.12); }
.ybg-profile__hint { font-size: 12px; color: #8a8fa3; margin: 2px 0 0; }
.ybg-profile__submit { padding: 10px 22px; }

/* ---------- RTL ---------- */
.ybg-rtl .ybg-detail__meta th,
.ybg-rtl .ybg-detail__author,
.ybg-rtl .ybg-card__body { text-align: right; }
.ybg-rtl .ybg-slider__prev { left: auto; right: -8px; }
.ybg-rtl .ybg-slider__next { right: auto; left: -8px; }
.ybg-rtl .ybg-modal__close { right: auto; left: 12px; }
