/*
 * CW Store — bài hướng dẫn vẽ ("Cómo Dibujar"): trình xem từng bước, thẻ "Tutorial", khu "Aprende a dibujar".
 * Cùng hướng thiết kế với form tài khoản và bảng gói: nền giấy, viền mực, bóng lệch cứng, vàng header + xanh nút của theme.
 * Không có JavaScript: mọi bước hiện thành danh sách dọc. Có JavaScript: lớp .is-player chỉ hiện bước đang xem.
 */
.cwh,
.cwh-band {
    --cwh-ink: #1d2433;
    --cwh-muted: #5b6474;
    --cwh-text: #3a4252;
    --cwh-sun: #ffe79f;
    --cwh-sun-deep: #ffd24a;
    --cwh-go: #01875f;
    --cwh-go-deep: #016a4b;
    --cwh-paper: #fffdf6;
    --cwh-line: #d9d2bf;
    --cwh-radius: 20px;
    --cwh-ease: cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--cwh-ink);
}
.cwh *,
.cwh-band * { box-sizing: border-box; }
.cwh-crumb { margin-bottom: 14px; font-size: 0.9rem; font-weight: 700; }

/* ---------- Đầu bài ---------- */
.cwh-head { display: grid; grid-template-columns: minmax(0, 1fr) 230px; grid-template-areas: "main result" "lead result" "more result"; column-gap: 28px; align-items: start; margin-bottom: 22px; }
.cwh-head__main { grid-area: main; }
.cwh-result { grid-area: result; }
.cwh-lead { grid-area: lead; }
.cwh-lead__more { grid-area: more; justify-self: start; margin-top: 6px; padding: 0; font: inherit; font-size: 0.9rem; font-weight: 800; color: var(--cwh-go-deep); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.cwh-lead__more[hidden] { display: none; }
.cwh-eyebrow { display: block; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cwh-go-deep); }
.cwh-title { margin: 8px 0 12px; font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.4rem); font-weight: 800; line-height: 1.12; letter-spacing: -0.01em; color: var(--cwh-ink); }
.cwh-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cwh-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 13px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    color: var(--cwh-ink);
    text-decoration: none;
    white-space: nowrap;
    background: #fff;
    border: 2px solid var(--cwh-ink);
    border-radius: 999px;
}
.cwh-chip--sun { background: var(--cwh-sun); }
a.cwh-chip:hover,
.cwh-chip--btn:hover { color: var(--cwh-ink); background: var(--cwh-sun); }
.cwh-chip--btn { cursor: pointer; }
.cwh-chip--btn[hidden] { display: none; }
.cwh-chip:focus-visible,
.cwh-btn:focus-visible,
.cwh-bar__mode:focus-visible,
.cwh-film__item:focus-visible,
.cwh-card:focus-visible,
.cwh-acc summary:focus-visible { outline: 3px solid var(--cwh-go); outline-offset: 3px; }
.cwh-lead { max-width: 68ch; margin-top: 14px; color: var(--cwh-text); }
.cwh-lead p { margin: 0 0 10px; }
.cwh-lead p:last-child { margin-bottom: 0; }
.cwh-result { margin: 0; text-align: center; }
.cwh-result img { display: block; width: 100%; height: auto; background: #fff; border: 3px solid var(--cwh-ink); border-radius: 16px; box-shadow: 5px 5px 0 var(--cwh-ink); }
.cwh-result figcaption { margin-top: 12px; font-size: 0.85rem; font-weight: 700; color: var(--cwh-muted); }

/* ---------- Thanh tiến độ ---------- */
.cwh-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 8px 8px 8px 16px; font-size: 0.9rem; font-weight: 800; background: #fff; border: 2px solid var(--cwh-ink); border-radius: 999px; }
.cwh-bar[hidden] { display: none; }
.cwh-bar__count { white-space: nowrap; }
.cwh-bar__track { flex: 1 1 auto; height: 10px; overflow: hidden; background: #ece7d8; border-radius: 999px; }
.cwh-bar__track i { display: block; width: 100%; height: 100%; background: var(--cwh-go); border-radius: 999px; transform-origin: left center; transform: scaleX(0); transition: transform 300ms var(--cwh-ease); }
.cwh-bar__mode { padding: 8px 14px; font: inherit; font-size: 0.82rem; font-weight: 800; color: var(--cwh-ink); white-space: nowrap; background: var(--cwh-sun); border: 2px solid var(--cwh-ink); border-radius: 999px; cursor: pointer; }
.cwh-bar__mode:hover { background: var(--cwh-sun-deep); }

/* ---------- Các bước ---------- */
.cwh-steps { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.cwh-step { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: 28px; align-items: start; padding: 22px; background: var(--cwh-paper); border: 2px solid var(--cwh-ink); border-radius: var(--cwh-radius); scroll-margin-top: 90px; }
.cwh-step__pic { margin: 0; line-height: 0; background: #fff; border: 3px solid var(--cwh-ink); border-radius: 14px; overflow: hidden; }
.cwh-step__pic img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain; }
.cwh-step__body { display: flex; flex-direction: column; min-width: 0; }
.cwh-step__count { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cwh-go-deep); }
.cwh-step__title { margin: 10px 0; font-size: clamp(1.3rem, 1.05rem + 1vw, 1.75rem); font-weight: 800; line-height: 1.15; color: var(--cwh-ink); }
.cwh-step__text { font-size: 1.06rem; color: var(--cwh-text); }
.cwh-step__text p { margin: 0 0 10px; }

/* Chế độ xem từng bước: chỉ bước hiện tại, trong một khung nổi. */
.cwh.is-player .cwh-step { display: none; box-shadow: 6px 6px 0 var(--cwh-ink); }
.cwh.is-player .cwh-step.is-current { display: grid; animation: cwh-in 260ms var(--cwh-ease); }
.cwh.is-player .cwh-step__body { min-height: 100%; }
@keyframes cwh-in { from { opacity: 0; transform: translateX(var(--cwh-dir, 14px)); } to { opacity: 1; transform: none; } }

.cwh-nav { display: flex; gap: 12px; margin-top: auto; padding-top: 22px; }
.cwh-nav[hidden] { display: none; }
.cwh-btn { flex: 1 1 0; min-height: 52px; padding: 12px 16px; font: inherit; font-size: 1.02rem; font-weight: 800; color: #fff; text-align: center; background: var(--cwh-go); border: 2px solid var(--cwh-ink); border-radius: 12px; box-shadow: 4px 4px 0 var(--cwh-ink); cursor: pointer; transition: transform 160ms var(--cwh-ease), box-shadow 160ms var(--cwh-ease); }
.cwh-btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--cwh-ink); }
.cwh-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--cwh-ink); }
.cwh-btn--ghost { color: var(--cwh-ink); background: #fff; }
.cwh-btn[disabled] { opacity: 0.4; cursor: default; transform: none; box-shadow: 4px 4px 0 var(--cwh-ink); }

/* ---------- Dải ảnh nhỏ ---------- */
.cwh-film { display: flex; gap: 8px; margin-top: 18px; padding: 4px 4px 10px; overflow-x: auto; scrollbar-width: thin; }
.cwh-film[hidden] { display: none; }
.cwh-film__item { position: relative; flex: none; width: 76px; padding: 0; line-height: 0; background: #fff; border: 2px solid var(--cwh-line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.cwh-film__item img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain; }
.cwh-film__item b { position: absolute; left: 4px; top: 4px; padding: 3px 6px; font-size: 0.68rem; font-weight: 800; line-height: 1; color: var(--cwh-ink); background: #fff; border: 1.5px solid var(--cwh-ink); border-radius: 999px; }
.cwh-film__item.is-done { opacity: 0.55; }
.cwh-film__item.is-current { opacity: 1; border: 3px solid var(--cwh-go); box-shadow: 0 0 0 3px #bfe9d9; }

/* ---------- Mục gập ---------- */
.cwh-acc { margin-top: 14px; background: #fff; border: 2px solid var(--cwh-ink); border-radius: 14px; }
.cwh-player + .cwh-acc { margin-top: 26px; }
.cwh-acc summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; font-size: 1.02rem; font-weight: 800; color: var(--cwh-ink); cursor: pointer; list-style: none; }
.cwh-acc summary::-webkit-details-marker { display: none; }
.cwh-acc summary::after { content: "▾"; transition: transform 200ms var(--cwh-ease); }
.cwh-acc[open] summary::after { transform: rotate(180deg); }
.cwh-acc__body { padding: 0 18px 16px; color: var(--cwh-text); }
.cwh-acc__body img { display: block; max-width: min(100%, 420px); height: auto; margin: 10px 0; border: 2px solid var(--cwh-ink); border-radius: 12px; }
.cwh-acc__body p:last-child { margin-bottom: 0; }

/* ---------- Thẻ "Tutorial", lưới, khu trang chủ ---------- */
.cwh-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.cwh-card { position: relative; display: flex; flex-direction: column; color: var(--cwh-ink); text-decoration: none; background: #fff; border: 2px solid var(--cwh-ink); border-radius: 14px; overflow: hidden; transition: transform 160ms var(--cwh-ease), box-shadow 160ms var(--cwh-ease); }
.cwh-card:hover { color: var(--cwh-ink); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--cwh-ink); }
.cwh-card__pic { display: block; aspect-ratio: 1 / 1; line-height: 0; background: var(--cwh-sun); }
.cwh-card__img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; }
.cwh-card__title { display: block; padding: 10px 12px 12px; font-size: 0.98rem; font-weight: 700; line-height: 1.25; border-top: 2px solid var(--cwh-ink); }
.cwh-card__ribbon { position: absolute; left: -2px; top: 12px; z-index: 1; padding: 6px 10px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; line-height: 1; text-transform: uppercase; color: #fff; background: var(--cwh-go); border: 2px solid var(--cwh-ink); border-radius: 0 999px 999px 0; }
.cwh-card__steps { position: absolute; right: 8px; top: 10px; z-index: 1; padding: 5px 9px; font-size: 0.75rem; font-weight: 800; line-height: 1; background: #fff; border: 2px solid var(--cwh-ink); border-radius: 999px; }
.cwh-card--cta { align-items: center; justify-content: center; min-height: 160px; padding: 16px; font-size: 1.05rem; font-weight: 800; text-align: center; background: var(--cwh-sun); }
.cwh-band { margin: 4px 0 18px; padding: 18px 18px 20px; background: var(--cwh-paper); border: 2px solid var(--cwh-ink); border-radius: 18px; box-shadow: 5px 5px 0 var(--cwh-ink); }
.cwh-band__head,
.cwh-more__title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.cwh-band__title,
.cwh-more__title { margin-bottom: 14px; font-size: 1.5rem; font-weight: 800; line-height: 1.1; color: var(--cwh-ink); }
.cwh-band__title { margin: 0; }
.cwh-band__all { font-size: 0.9rem; font-weight: 700; color: var(--cwh-ink); white-space: nowrap; }
.cwh-more { margin-top: 34px; }
.cwh-archive-head { margin-bottom: 22px; }
.cwh-archive-head__lead { max-width: 60ch; margin: 0; color: var(--cwh-text); }
.cwh-pages { margin-top: 22px; }
.cwh-archive-text { margin-top: 26px; }

/* ---------- Màn hẹp ---------- */
@media (max-width: 900px) {
    .cwh-step { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 14px; }
    .cwh-step__pic { max-width: 520px; width: 100%; margin: 0 auto; }
    .cwh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .cwh-card--cta { grid-column: 1 / -1; min-height: 64px; }
}
@media (max-width: 720px) {
    .cwh-head { grid-template-columns: minmax(0, 1fr) 104px; grid-template-areas: "main result" "lead lead" "more more"; column-gap: 12px; margin-bottom: 16px; }
    .cwh-result figcaption { display: none; }
    .cwh-result img { border-width: 2px; border-radius: 12px; box-shadow: 3px 3px 0 var(--cwh-ink); }
    .cwh-chip { min-height: 30px; padding: 5px 10px; font-size: 0.78rem; }
    /* Lời giới thiệu thu gọn 3 dòng (JS thêm .is-clamped) để trình xem nằm ngay màn hình đầu. */
    .cwh-lead.is-clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
    .cwh-bar { gap: 10px; padding-left: 12px; font-size: 0.82rem; }
    .cwh-bar__mode { padding: 7px 10px; font-size: 0.75rem; }
    .cwh.is-player .cwh-step { box-shadow: 4px 4px 0 var(--cwh-ink); }
    /* Nút Trước / Sau bám đáy màn hình để không phải cuộn tìm sau mỗi bước. */
    .cwh.is-player .cwh-nav { position: sticky; bottom: 10px; z-index: 5; margin: 6px -4px 0; padding: 8px; background: var(--cwh-paper); border: 2px solid var(--cwh-ink); border-radius: 16px; }
    .cwh-film__item { width: 62px; }
    .cwh-band { padding: 14px; box-shadow: 4px 4px 0 var(--cwh-ink); }
    .cwh-band__title,
    .cwh-more__title { font-size: 1.25rem; }
    .cwh-card__title { padding: 8px 9px 10px; font-size: 0.85rem; }
    .cwh-card__ribbon { top: 8px; padding: 5px 8px; font-size: 0.6rem; }
    .cwh-card__steps { right: 6px; top: 34px; font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cwh.is-player .cwh-step.is-current { animation: none; }
    .cwh-bar__track i,
    .cwh-btn,
    .cwh-card,
    .cwh-acc summary::after { transition: none; }
}

/* ---------- In: mọi bước trên giấy, bỏ khung site ---------- */
@media print {
    body.cwh-page > *:not(.cwh),
    body.cwh-page header,
    body.cwh-page footer,
    .cwh-crumb, .cwh-bar, .cwh-nav, .cwh-film, .cwh-more, .cwh-chips, .cwh-acc:not([open]) { display: none !important; }
    .cwh { max-width: none; padding: 0 !important; }
    .cwh-head { grid-template-columns: 1fr 150px; margin-bottom: 12px; }
    .cwh-result img, .cwh-step, .cwh-card { box-shadow: none !important; }
    .cwh-steps { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .cwh.is-player .cwh-step,
    .cwh-step { display: block !important; padding: 8px; break-inside: avoid; animation: none !important; }
    .cwh-step__title { margin: 6px 0 4px; font-size: 11pt; }
    .cwh-step__text { font-size: 8.5pt; }
    .cwh-step__count { font-size: 7pt; }
}
