/* ==========================================================================
   Quim Aiguafreda — author site
   Palette lifted from the book covers: warm paper, dense ink, rust, slate.
   Two typefaces only: Fraunces (display) and Newsreader (text).
   ========================================================================== */

:root {
  --paper:        #f6f2e9;
  --paper-deep:   #efe9dc;
  --paper-edge:   #e2d9c6;
  --ink:          #1b1a17;
  --ink-soft:     #4a453c;
  --ink-faint:    #857c6c;
  --rust:         #9a3b2a;
  --rust-deep:    #7d2e1f;
  --slate:        #2c4a5e;

  --shell:        clamp(1rem, 5vw, 4.5rem);
  --measure:      34rem;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --text:    "Newsreader", Georgia, "Times New Roman", serif;

  --shadow-cover: 0 1px 1px rgba(27, 26, 23, .10),
                  0 8px 20px -8px rgba(27, 26, 23, .30);
  --shadow-lift:  0 2px 3px rgba(27, 26, 23, .10),
                  0 22px 40px -14px rgba(27, 26, 23, .38);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #16171a;
    --paper-deep: #1d1f23;
    --paper-edge: #33363c;
    --ink:        #ece7dc;
    --ink-soft:   #b3ac9e;
    --ink-faint:  #837c70;
    --rust:       #d4715a;
    --rust-deep:  #e08a72;
    --slate:      #8fb3c9;
    --shadow-cover: 0 8px 20px -8px rgba(0, 0, 0, .7);
    --shadow-lift:  0 22px 40px -14px rgba(0, 0, 0, .8);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: clamp(1.0625rem, .45vw + .95rem, 1.1875rem);
  line-height: 1.65;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--rust); }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 550;
  line-height: 1.08;
  letter-spacing: -.015em;
  margin: 0;
  font-variation-settings: "SOFT" 0, "WONK" 0;
}

.wrap { max-width: 74rem; margin-inline: auto; padding-inline: var(--shell); }

.eyebrow {
  font-family: var(--text);
  font-size: .78rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1.25rem;
}

/* --- header --------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--paper-edge);
  background: var(--paper);
}
.site-header .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.4rem;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
}
.site-nav { display: flex; gap: 1.75rem; font-size: .95rem; }
.site-nav a { text-decoration: none; color: var(--ink-soft); }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--ink); text-decoration: underline; }

/* --- 404 lede -------------------------------------------------------------- */

.hero-lede {
  font-size: clamp(1.2rem, 1vw + 1rem, 1.45rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 30ch;
  margin: 0 0 2rem;
}
/* --- split header --------------------------------------------------------- */
/* One half is a solid panel of words, the other a wall of covers running off
   the edge, so neither half can read as empty. The catalogue is heading for
   300+ titles, so the cover sample is a fixed size and the TEXT sets the
   header's height - the covers simply crop to fit. */

.hdr-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  min-height: clamp(21rem, 52vh, 27rem);
  background: var(--ink);
  color: var(--paper);
}
.hdr-split-text {
  display: flex;
  flex-direction: column;
  padding: 0 clamp(1.5rem, 4vw, 3.5rem) clamp(1.75rem, 3vw, 2.5rem) var(--shell);
}
.hdr-split-text .brand,
.hdr-split-text .site-nav a { color: var(--paper); }
.hdr-split-text .site-nav a:hover,
.hdr-split-text .site-nav a[aria-current] { color: var(--rust-deep); }

.hdr-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.3rem;
  flex-wrap: wrap;
}
/* the words sit centred in their panel: no tall void above them */
.hdr-split-body { margin-block: auto; padding-block: clamp(1.5rem, 3vw, 2.25rem); }
/* The headline is a sentence rather than a slogan, so it is set at statement
   size on a wider measure - at slogan size it ran to five lines and pushed the
   whole header off the screen. */
.hdr-split-body h1 {
  font-size: clamp(1.55rem, 2.5vw, 2.15rem);
  line-height: 1.16;
  letter-spacing: -.02em;
  max-width: 26ch;
  text-wrap: balance;
}
.hdr-lede {
  color: color-mix(in srgb, var(--paper) 68%, transparent);
  font-size: 1.02rem;
  line-height: 1.55;
  margin: 1.1rem 0 0;
  max-width: 44ch;
}
.hdr-split-body .btn { margin-top: 1.65rem; }
.hdr-split-body .btn-primary { background: var(--rust); border-color: var(--rust); color: #fff; }
.hdr-split-body .btn-primary:hover { background: var(--rust-deep); border-color: var(--rust-deep); }

.hdr-split-covers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0;
  overflow: hidden;
}
.hdr-split-covers img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

/* --- faceted catalogue ---------------------------------------------------- */

.facets {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.25rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
  margin-bottom: clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--paper-edge);
}
.facet-label {
  margin: 0 0 .8rem;
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font-family: var(--text);
  font-size: .9rem;
  line-height: 1;
  padding: .62rem 1.05rem;
  border: 1px solid var(--paper-edge);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.chip-sm { font-size: .84rem; padding: .5rem .85rem; }
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.chip[data-facet="thinker"][aria-pressed="true"] {
  background: var(--rust);
  border-color: var(--rust);
  color: #fff;
}

.thinker-search {
  font-family: var(--text);
  font-size: .92rem;
  padding: .6rem .9rem;
  width: min(22rem, 100%);
  margin-bottom: .85rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
}
.thinker-search:focus { outline: none; border-color: var(--ink-faint); }

.link-btn {
  margin-top: .9rem;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--text);
  font-size: .88rem;
  color: var(--ink-faint);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.link-btn:hover { color: var(--rust); }

.facet-active {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
  font-size: .92rem;
  color: var(--ink-soft);
}
.facet-active > span::before { content: "Showing: "; color: var(--ink-faint); }
.facet-active .link-btn { margin-top: 0; }

.book-card .tag {
  display: block;
  margin: .85rem 0 .3rem;
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.books-grid.tagged .book-card h3 { margin-top: 0; }
.chips-empty { color: var(--ink-faint); }

/* --- section furniture ---------------------------------------------------- */

.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.75rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--paper-edge);
  flex-wrap: wrap;
}
.section-head h2 { font-size: clamp(1.6rem, 2.5vw, 2.25rem); }
.section-head p { margin: 0; color: var(--ink-faint); font-size: .95rem; }

/* --- book grid ------------------------------------------------------------ */

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: clamp(1.75rem, 3vw, 2.75rem) clamp(1.25rem, 2.5vw, 2.25rem);
  list-style: none;
  margin: 0;
  padding: 0;
}
.book-card a { text-decoration: none; display: block; }
.book-card .frame {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--paper-deep);
  box-shadow: var(--shadow-cover);
  overflow: hidden;
  transition: transform .3s cubic-bezier(.2, .7, .3, 1), box-shadow .3s;
}
.book-card img { width: 100%; height: 100%; object-fit: cover; }
.book-card a:hover .frame { transform: translateY(-6px); box-shadow: var(--shadow-lift); }
.book-card h3 {
  font-size: 1.02rem;
  line-height: 1.25;
  margin: 1rem 0 .3rem;
  letter-spacing: -.005em;
}
.book-card a:hover h3 { color: var(--rust); }
.book-card p {
  margin: 0;
  font-size: .87rem;
  line-height: 1.4;
  color: var(--ink-faint);
}

/* placeholder when an epub carries no cover image */
.frame.no-cover {
  display: grid;
  align-content: center;
  gap: .5rem;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--paper-edge);
  background: var(--paper-deep);
}
.frame.no-cover span:first-child {
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.15;
}
.frame.no-cover span:last-child {
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* --- book page ------------------------------------------------------------ */

.crumbs { padding-block: 1.75rem 0; font-size: .85rem; color: var(--ink-faint); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.book-layout {
  display: grid;
  grid-template-columns: minmax(0, 19rem) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem);
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 7vw, 5rem);
  align-items: start;
}
.book-layout.single { grid-template-columns: minmax(0, 1fr); }
.book-aside { position: sticky; top: 2rem; }
.book-aside .frame img { width: 100%; height: auto; }

/* about page: words on the left, portrait filling the space on the right */
.about-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 20rem);
  gap: clamp(2rem, 6vw, 4.5rem);
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 7vw, 5rem);
  align-items: start;
}
.about-page.single { grid-template-columns: minmax(0, 1fr); }
.portrait { position: sticky; top: 2rem; margin: 0; }
.portrait img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  box-shadow: var(--shadow-lift);
}
.portrait figcaption {
  margin-top: .85rem;
  font-size: .78rem;
  line-height: 1.4;
  color: var(--ink-faint);
}
.book-aside .frame {
  aspect-ratio: 2 / 3;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  background: var(--paper-deep);
}
.book-aside .frame img { width: 100%; height: 100%; object-fit: cover; }

.book-title { font-size: clamp(2.1rem, 4.5vw, 3.35rem); letter-spacing: -.025em; }
.book-subtitle {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.15rem, 1.6vw, 1.5rem);
  line-height: 1.3;
  color: var(--ink-soft);
  margin: .85rem 0 0;
  font-variation-settings: "SOFT" 0, "WONK" 1;
  font-style: italic;
}
.book-body { max-width: var(--measure); }
.book-body p { margin: 0 0 1.15em; }

.buy {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 2rem 0 .85rem;
}
.btn {
  display: inline-block;
  padding: .8rem 1.6rem;
  font-family: var(--text);
  font-size: .95rem;
  letter-spacing: .02em;
  text-decoration: none;
  border: 1px solid var(--rust);
  transition: background .2s, color .2s, transform .2s;
}
.btn-primary { background: var(--rust); color: var(--paper); }
.btn-primary:hover { background: var(--rust-deep); border-color: var(--rust-deep); color: var(--paper); transform: translateY(-2px); }
.btn-ghost { color: var(--rust); }
.btn-ghost:hover { background: var(--rust); color: var(--paper); transform: translateY(-2px); }
.buy-note { font-size: .82rem; color: var(--ink-faint); margin: 0; }

.specs {
  display: grid;
  /* 9rem so a 979-xxxxxxxxxx ISBN keeps its hyphen on one line */
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1.25rem 1.5rem;
  margin: 2.5rem 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--paper-edge);
}
.specs div { font-size: .95rem; }
.specs dd { overflow-wrap: break-word; }
.specs dt {
  font-size: .72rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .3rem;
}
.specs dd { margin: 0; }

/* opening excerpt */
.excerpt {
  margin: 3rem 0 0;
  padding: 1.75rem 0 .25rem 1.75rem;
  border-left: 2px solid var(--rust);
}
.excerpt p { color: var(--ink-soft); }
.excerpt .eyebrow { margin-bottom: 1rem; }
.excerpt .eyebrow + p::first-letter {
  font-family: var(--display);
  float: left;
  font-size: 3.35rem;
  line-height: .84;
  padding: .1em .1em 0 0;
  color: var(--rust);
}

/* table of contents */
.toc { margin-top: 3rem; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: chap; }
.toc > ol > li {
  counter-increment: chap;
  padding: 1.1rem 0;
  border-top: 1px solid var(--paper-edge);
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: .5rem;
}
.toc > ol > li::before {
  content: counter(chap, decimal-leading-zero);
  font-size: .82rem;
  color: var(--ink-faint);
  padding-top: .35rem;
  font-variant-numeric: tabular-nums;
}
.toc h3 { font-size: 1.15rem; font-weight: 500; }
.toc ul {
  margin: .6rem 0 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 2rem;
  font-size: .9rem;
  color: var(--ink-faint);
}
.toc ul li { break-inside: avoid; padding: .18rem 0; }

/* --- thinker pages -------------------------------------------------------- */

.thinker-head { padding-block: clamp(1.5rem, 4vw, 2.5rem) 0; }
.thinker-head .hero-lede { margin-bottom: 0; max-width: 46ch; }

.book-thinkers {
  margin-top: 2.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--paper-edge);
}
.book-thinkers .chip {
  text-decoration: none;
  display: inline-block;
}

.letter-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: clamp(1.75rem, 3vw, 2.5rem);
}
.letter-group h2 {
  font-size: 1.05rem;
  padding-bottom: .5rem;
  margin-bottom: .75rem;
  border-bottom: 1px solid var(--paper-edge);
  color: var(--rust);
}
.letter-group ul { list-style: none; margin: 0; padding: 0; }
.letter-group li { padding: .2rem 0; font-size: .95rem; }
.letter-group a { text-decoration: none; color: var(--ink-soft); }
.letter-group a:hover { color: var(--rust); text-decoration: underline; }

/* --- about ---------------------------------------------------------------- */

.about { background: var(--paper-deep); border-block: 1px solid var(--paper-edge); }
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  padding-block: clamp(3rem, 7vw, 5rem);
}
.about-grid h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); }
.about-grid p { margin: 0 0 1.15em; max-width: var(--measure); }
.about-grid p:last-child { margin-bottom: 0; }

/* --- footer --------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--paper-edge);
  padding-block: 2.75rem 3.5rem;
  font-size: .88rem;
  color: var(--ink-faint);
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.site-footer a { color: var(--ink-soft); }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 64rem) {
  .hdr-split { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .hdr-split-text { padding-inline: var(--shell); }
  /* stacked: the covers become a band under the words */
  .hdr-split-covers { grid-template-columns: repeat(6, 1fr); grid-template-rows: none; }
  .hdr-split-covers img { aspect-ratio: 2 / 3; height: auto; }
  .hdr-split-covers img:nth-child(n + 7) { display: none; }
}

@media (max-width: 60rem) {
  .book-layout, .about-grid { grid-template-columns: minmax(0, 1fr); }
  .book-aside { position: static; max-width: 15rem; }
  .toc ul { columns: 1; }

  .about-page { grid-template-columns: minmax(0, 1fr); }
  .portrait { position: static; max-width: 18rem; order: -1; }
}

@media (max-width: 40rem) {
  .books-grid { grid-template-columns: repeat(2, 1fr); }
  .thinker-search { width: 100%; }

  /* A phone header must not eat the whole screen: tighter bar, a denser cover
     band, and the standfirst cut to three lines (it repeats in full on /about). */
  .hdr-bar { padding-block: .95rem; gap: .6rem 1rem; }
  .hdr-bar .site-nav { gap: 1.1rem; font-size: .9rem; }
  .hdr-split-body h1 { font-size: clamp(1.5rem, 6.4vw, 1.9rem); }
  /* the headline is a full sentence, so the standfirst under it is redundant on
     a phone - it survives in full on /about */
  .hdr-split-body .hdr-lede { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
