/* The public bookshop, not the PDF reader or its print sheets. */
@media screen {
  :is(.home-page, .book-page, .library-page, main:has(> #install-guide)) {
    --shelf-paper: #f1f5f8;
    --shelf-rule: #e2e8f0;
    --shelf-ink: #1f1f1f;
    --shelf-caption: #515a63;
    --shelf-link: #315f89; /* Legible text; the underline carries the original pen blue. */
    --shelf-pen: #478cd0;
    background: var(--shelf-paper);
    color: var(--shelf-ink);
    font-family: var(--font-reading-ui, system-ui, sans-serif);
  }

  :is(.home-page main, .book-page main, .library-page main, main:has(> #install-guide)) :is(h1, h2, h3) {
    font-family: var(--font-editorial, Charter, 'Iowan Old Style', AppleMyungjo, Batang, serif);
    color: var(--shelf-ink);
    letter-spacing: normal;
  }
  .home-page .wrap, .book-page main.wrap, .library-page main.wrap { max-width: 1200px; }
  .home-page :is(.home-hero, .home-band), main:has(> #install-guide) > section { background: var(--shelf-paper); }
  .home-page .home-hero .hero {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
    min-height: 0;
    padding: clamp(20px, 3vw, 40px) 0 28px;
    gap: 20px;
  }
  .home-page .hero > div { min-width: 0; }
  .home-page .hero .hero-kicker { justify-content: center; margin: 0 0 12px; }
  .home-page .hero-kicker::before { content: none; }
  .home-page .hero h1, .viewer-hero h1, .library-page h1 {
    margin: 0 auto 12px;
    max-width: 22em;
    font-size: clamp(34px, 5vw, 50px);
    line-height: 1.1;
    font-weight: 400;
  }
  .home-page .hero .lead {
    margin: 0 auto;
    max-width: 42em;
    font-size: clamp(15px, 1.6vw, 18px);
    line-height: 1.5;
  }
  .home-page .hero .actions { justify-content: center; align-items: center; margin: 16px 0 0; gap: 4px 12px; }
  .home-page .hero .actions .button { flex: none; min-height: 44px; padding: 10px 20px; }
  :is(.home-page .hero, .book-page .split, .viewer-hero) .button:not(.outline):not(.secondary) {
    background: var(--shelf-ink);
    border-color: var(--shelf-ink);
    color: white;
    border-radius: 10px;
    box-shadow: none;
  }
  :is(.home-page .hero, .book-page .split, .viewer-hero) .button:not(.outline):not(.secondary):hover { background: #383838; }
  .home-page .hero .actions .outline, .viewer-hero .actions .outline {
    color: var(--shelf-link);
    background: transparent;
    border: 0;
    box-shadow: none;
    padding-inline: 6px;
    text-decoration: underline;
    text-decoration-color: var(--shelf-pen);
    text-underline-offset: .22em;
  }
  .home-page .hero .muted { margin: 8px 0 0; }
  .home-page .hero-photo-wrap {
    width: min(100%, 420px);
    max-width: none;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--shelf-rule);
    border-radius: 10px;
    background: white;
  }
  .home-page .hero-photo {
    width: 100%; height: clamp(220px, 36vh, 380px); max-height: 380px;
    object-fit: contain; mix-blend-mode: normal;
    background: #f5f5f3;
  }
  .home-page .hero-photo-wrap figcaption { padding: 6px 12px; font-size: 14px; color: var(--shelf-caption); }

  .home-page .home-band, main:has(> #install-guide) .home-band {
    padding: clamp(32px, 5vw, 64px) 0;
    border-top: 1px solid var(--shelf-rule);
  }
  .home-page .home-band .section-head { display: grid; justify-items: center; justify-content: center; gap: 8px; text-align: center; }
  .home-page .home-band h2, #detail .section h2, main:has(> #install-guide) .home-band h2 {
    font-size: clamp(25px, 3vw, 29px); font-weight: 500; line-height: 1.2;
  }
  .home-page .catalog-intro { margin-top: 8px; }
  .home-page main .eyebrow, .book-page main .eyebrow, .library-page .eyebrow, .viewer-hero .eyebrow,
  .home-page .policy-number { color: var(--shelf-caption); }
  .home-page .category-tabs { justify-content: center; gap: 8px; }
  .home-page .category-tab {
    border: 1px solid var(--shelf-rule); border-radius: 10px; color: var(--shelf-ink); background: white;
  }
  .home-page .category-tab:is([aria-current=page], [aria-pressed=true]) {
    color: var(--shelf-ink); background: var(--color-highlighter-yellow, #fff7ca); border-color: #ece4b4;
  }
  .home-page .filters { width: min(100%, 760px); margin-inline: auto; }
  .home-page .filters :is(input, select) { min-width: 0; max-width: 100%; }
  .home-page .catalog-filter-status { text-align: center; color: var(--shelf-caption); }
  .home-page .category-tab:focus-visible { outline: 2px solid var(--shelf-link); outline-offset: 3px; }

  /* Both the static catalogue and the API render the same jacket, then its metadata. */
  #books, .library-page #library {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(16px, 2vw, 28px);
  }
  .home-page main .card, .library-page #library .card, main:has(> #install-guide) .card {
    min-width: 0; border: 1px solid var(--shelf-rule); border-radius: 10px; background: white; box-shadow: none;
  }
  :is(#books, .library-page #library) > .card {
    --shelf-inset: clamp(16px, 1.8vw, 24px);
    padding: 0 var(--shelf-inset) 12px;
    overflow: hidden;
    transition: none;
  }
  :is(#books, .library-page #library) > .card:hover { transform: none; box-shadow: none; }
  :is(#books, .library-page #library) .cover-mini {
    width: auto; height: clamp(200px, 24vw, 250px);
    margin-inline: calc(-1 * var(--shelf-inset));
    border-radius: 0; border-bottom: 1px solid var(--shelf-rule);
    background: #f5f5f3;
  }
  :is(#books, .library-page #library, .book-page .split) .mockup-cover > img {
    display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; transform: none;
  }
  :is(#books, .library-page #library) h3 {
    margin: 16px 0 8px; font-size: 22px; line-height: 1.28; font-weight: 600;
  }
  :is(#books, .library-page #library) h3 a { color: var(--shelf-ink); }
  :is(#books, .library-page #library) .tag { color: #414951; background: var(--shelf-paper); border-radius: 6px; }
  :is(#books, .library-page #library) .card p { margin-block: 10px 6px; }
  :is(#books, .library-page #library) .card > a, .book-page .split > div > a:not(.button) {
    min-height: 44px; display: inline-flex; align-items: center; color: var(--shelf-link); font-weight: 600;
    text-decoration: underline; text-decoration-color: var(--shelf-pen); text-underline-offset: .23em;
  }
  .home-page .viewer-banner, .home-page .faq-list, .library-page #library .empty {
    background: white; border: 1px solid var(--shelf-rule); border-radius: 10px; box-shadow: none;
  }

  .book-page #detail .split {
    grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr);
    align-items: start; gap: clamp(24px, 4vw, 56px); padding: 24px 0 48px;
  }
  .book-page .split > div { min-width: 0; }
  .book-page #detail .split > .cover-mini {
    /* The old component and its runtime both specify a fixed height. */
    height: auto !important; width: 100%; max-width: 360px; justify-self: center; aspect-ratio: 3 / 4;
    border: 1px solid var(--shelf-rule); border-radius: 10px;
  }
  .book-page #detail .split h1 { font-size: clamp(29px, 4vw, 44px); line-height: 1.17; font-weight: 500; }
  .library-page h1 { margin-left: 0; }
  .viewer-hero { gap: clamp(24px, 4vw, 56px); padding-block: 48px; }
  .viewer-hero h1 { margin-left: 0; }
  .viewer-hero .app-portrait { min-height: 240px; background: white; border: 1px solid var(--shelf-rule); border-radius: 10px; }
  .viewer-hero .app-portrait img { width: 108px; height: 108px; border-radius: 18px; box-shadow: none; }
  .viewer-hero .app-portrait strong { color: var(--shelf-ink); }
}

@media screen and (min-width: 1000px) {
  #books, .library-page #library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #books .card .cover-mini { height: 200px; }
  .library-page #library .card .cover-mini { height: 250px; }
}
@media screen and (max-width: 800px) {
  .book-page #detail .split { grid-template-columns: minmax(0, 1fr); }
  .book-page #detail .split > .cover-mini { max-width: 360px; justify-self: center; }
}
@media screen and (max-width: 599px) {
  #books, .library-page #library { grid-template-columns: minmax(0, 1fr); }
  :is(#books, .library-page #library) .cover-mini { height: clamp(200px, 60vw, 250px); }
  .home-page .hero-photo { height: auto; aspect-ratio: 1200 / 943; }
  .home-page .home-hero .hero { gap: 16px; }
  .home-page .category-tab { padding-inline: 12px; }
  .viewer-hero { grid-template-columns: minmax(0, 1fr); padding-block: 28px; }
  .viewer-hero .app-portrait { min-height: 196px; }
}
@media screen and (prefers-reduced-motion: reduce) {
  :is(#books, .library-page #library) > .card, .home-page .hero .button { transition: none; animation: none; }
}

/* Editorial difficulty, separate from examination grades. */
.difficulty-badge{display:inline-block;border:1px solid #d4dfeb;border-radius:8px;background:#edf3f9;color:#234d72;padding:5px 9px;font-weight:650;font-size:13px;line-height:1.5;margin:4px 6px 4px 0;}
.difficulty-description{line-height:1.7;max-width:55em;}
.difficulty-selection{display:flex;flex-wrap:wrap;gap:6px 12px;line-height:1.7;margin:14px 0;color:#515a63;}
.difficulty-guide{margin:16px 0;padding:12px 16px;background:white;border:1px solid #e2e8f0;border-radius:10px;}
.difficulty-levels{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:12px 20px;padding:0;list-style:none;}
.difficulty-levels li{padding:10px 12px;border:1px solid #e2e8f0;border-radius:8px;}
.difficulty-levels p{margin:8px 0 0;font-size:14px;line-height:1.7;}
