.book-samples {
    width: 100%;
    margin-top: 1rem;
    scroll-margin-top: 6.5rem;
    text-align: center;
}

.book-samples-eyebrow {
    margin: 0 0 0.6rem;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.18em;
}

.book-samples > h1 {
    margin: 0;
    color: #0f172a;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 600;
    letter-spacing: -0.04em;
}

.book-samples-description {
    margin: 0.75rem 0 2.25rem;
    color: #64748b;
    font-size: 0.95rem;
}

.book-samples-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.book-sample-link {
    --book-color: #2563eb;
    display: block;
    min-width: 0;
    color: #0f172a;
    text-decoration: none;
    border-radius: 0.5rem;
    outline-offset: 0.5rem;
}

.book-sample-link--advanced { --book-color: #be3b2b; }
.book-sample-link--etymology { --book-color: #177355; }
.book-sample-link--verbs { --book-color: #8438ac; }

.book-sample-link h2 {
    margin: 0 0 1rem;
    font-size: clamp(0.8rem, 1.3vw, 1rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    overflow-wrap: anywhere;
}

.book-sample-link h2 span {
    display: block;
    margin-top: 0.25rem;
    color: var(--book-color);
    font-weight: 700;
    letter-spacing: 0;
}

/* Crop each cover after the preceding shadow and feather only its outer margins. */
.book-sample-cover {
    display: block;
    aspect-ratio: 500 / 600;
    background-image: url('/assets/images/sample-books-lineup.png');
    background-size: 412% auto;
    background-position: calc(2.564102564% + var(--book-index) * 32.051282051%) bottom;
    background-repeat: no-repeat;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 2%, #000 96%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 2%, #000 96%, transparent);
    transition: transform 180ms ease;
}

.book-sample-link:hover .book-sample-cover {
    transform: translateY(-5px);
}

.book-sample-link:focus-visible {
    outline: 2px solid var(--book-color);
}

.book-sample-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #cbd5e1;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
}

.book-sample-link:hover .book-sample-action {
    color: var(--book-color);
    border-color: currentColor;
}

body[data-sample-page] {
    margin: 0;
    background: #fff;
    color: #0f172a;
    font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body[data-sample-page] *,
body[data-sample-page] *::before,
body[data-sample-page] *::after {
    box-sizing: border-box;
}

body[data-sample-page] [hidden] { display: none !important; }

body[data-sample-view='reader'] {
    min-height: 100svh;
    background: radial-gradient(ellipse at 50% 25%, #fbfaf7, #eeeae3);
}

.sample-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(100, 116, 139, 0.12);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(14px);
}

.sample-toolbar-inner {
    width: min(1180px, 100% - 3rem);
    min-height: 3.75rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sample-brand,
.sample-back-link {
    color: inherit;
    text-decoration: none;
}

.sample-brand {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.sample-back-link {
    color: #475569;
    font-size: 0.85rem;
    padding: 0.75rem 0;
    text-underline-offset: 0.25rem;
}

.sample-content {
    width: min(1180px, 100% - 3rem);
    margin: 0 auto;
    padding: 2.5rem 0 3rem;
}

.sample-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.sample-heading .book-samples-eyebrow {
    color: #64748b;
}

.sample-heading h1 {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 700;
    letter-spacing: -0.05em;
    overflow-wrap: anywhere;
}

.sample-summary {
    margin: 0.6rem 0 0;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.65;
}

.sample-book-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.2rem;
    margin: 0;
}

.sample-book-nav a {
    padding: 0.85rem 0;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.sample-book-nav a[aria-current='page'] {
    border-color: #0f172a;
    color: #0f172a;
}

.sample-status {
    padding: 3rem 1rem;
    color: #64748b;
    line-height: 1.7;
    text-align: center;
}

.sample-status[hidden] { display: none; }

.sample-viewport {
    overflow: auto;
    padding: 2rem 1.25rem;
    margin: 0 -1.25rem;
    touch-action: pan-x pan-y pinch-zoom;
}

.sample-viewport:focus-visible {
    outline: 2px solid #8a7961;
    outline-offset: -2px;
}

.sample-spread {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 1080px, calc((100svh - 260px) * 1.42));
    min-width: 280px;
    margin: 0 auto;
    background: #fffefa;
    border-radius: 2px 5px 5px 2px;
    box-shadow: 0 2px 0 #d9d3c9, 0 5px 0 #f9f7f2, 0 6px 0 #d9d3c9,
        0 18px 35px -12px rgba(57, 45, 29, 0.28);
}

.sample-spread::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 50%;
    width: 3%;
    transform: translateX(-50%);
    background: linear-gradient(to right, transparent, rgba(58, 43, 25, 0.13) 48%, rgba(58, 43, 25, 0.2) 50%, rgba(255, 255, 255, 0.3) 54%, transparent);
    pointer-events: none;
}

.sample-viewport.is-zoomed {
    max-height: 72svh;
    overscroll-behavior: contain;
}

.sample-viewport.is-zoomed .sample-spread {
    width: 180%;
    min-width: 900px;
    max-width: none;
}

.sample-sheet {
    position: relative;
    margin: 0;
    background: #fff;
    min-width: 0;
    overflow: hidden;
    animation: sample-page-in 160ms ease-out;
}

.sample-sheet img {
    display: block;
    width: 100%;
    height: auto;
}

.sample-sheet figcaption {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.sample-sheet--blank {
    display: grid;
    place-content: center;
    padding: 2rem 1rem;
    background: #fffefa;
    color: #958b7b;
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.8;
}

.sample-sheet-loading {
    position: absolute;
    top: 40%;
    left: 1rem;
    right: 1rem;
    color: #64748b;
    font-size: 0.8rem;
    text-align: center;
}

.sample-sheet[data-loaded='true'] .sample-sheet-loading { display: none; }

.sample-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.5rem auto 0;
}

.sample-controls button,
.sample-sheet button {
    min-height: 44px;
    border: 1px solid #d7d0c6;
    border-radius: 999px;
    padding: 0.65rem 1.2rem;
    background: #fffdf9;
    color: #3d382f;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.sample-controls button:hover:not(:disabled) { background: #e9e3d9; }
.sample-controls button:disabled { opacity: 0.35; cursor: default; }
.sample-controls button:focus-visible { outline: 2px solid #796349; outline-offset: 3px; }
.sample-controls .sample-zoom { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }
.sample-controls .sample-zoom[aria-pressed='true'] { background: #e9e3d9; }

.sample-spread-label {
    min-width: 7rem;
    color: #6d665a;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.sample-reading-hint {
    margin: 1rem 0 0;
    color: #8b8275;
    font-size: 0.75rem;
    line-height: 1.7;
    text-align: center;
}

@keyframes sample-page-in {
    from { opacity: 0.5; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 767px) {
    .book-samples-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 2rem 0.75rem;
    }

    .book-samples { margin-top: 0.5rem; }
    .book-samples > h1 { font-size: 1.65rem; }
    .book-sample-link h2 { font-size: 0.85rem; margin-bottom: 0.8rem; }
    .book-samples-description { font-size: 0.85rem; line-height: 1.7; margin-bottom: 2rem; }
    .book-sample-action { margin-top: 0.4rem; font-size: 0.8rem; }
    .sample-toolbar-inner { width: calc(100% - 2rem); flex-wrap: wrap; gap: 0.25rem 1rem; }
    .sample-content { width: calc(100% - 2rem); padding-top: 1.5rem; padding-bottom: 2rem; }
    .sample-heading { align-items: flex-start; flex-wrap: wrap; gap: 0.75rem; }
    .sample-heading > div { min-width: 0; }
    .sample-heading h1 { font-size: 1.4rem; }
    .sample-summary { font-size: 0.8rem; }
    .sample-book-nav { width: 100%; gap: 0.25rem 1rem; justify-content: space-between; }
    .sample-book-nav a { font-size: 0.8rem; }
    .sample-viewport { margin: 0 -0.75rem; padding: 1.5rem 0.75rem 2rem; }
    .sample-spread { width: 100%; min-width: 0; }
    .sample-controls { display: flex; gap: 1rem; margin-top: 0; }
    .sample-controls button { padding: 0.65rem 0.75rem; }
    .sample-viewport.is-zoomed + .sample-controls .sample-zoom {
        position: fixed;
        z-index: 20;
        right: 1rem;
        bottom: max(1rem, env(safe-area-inset-bottom));
        background: #35322d;
        color: #fff;
        padding: 0.75rem 1.2rem;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
        text-decoration: none;
    }
    .sample-reading-hint { margin-top: 0.5rem; padding: 0 0.5rem; }
    .sample-sheet-loading { left: 0.4rem; right: 0.4rem; font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
    .book-sample-cover { transition: none; }
    .book-sample-link:hover .book-sample-cover { transform: none; }
    .sample-sheet { animation: none; }
}
