/*
 * The Personal Archive: shared frame (running head, back flap, colophon) and
 * the homepage. The archive is set like a paperback imprint: each subject is
 * a colour-banded series, and colour only ever fills bands, never sets text.
 *
 * Everything is scoped to .pa-frame so the posts' own styles and these never
 * meet: the reset below reverts any post rule that reaches into the frame.
 */

.pa-frame {
  --paper: #FBFAF7;
  --ink: #1C1A17;
  --ink-2: #5E574F;
  --rule: #DCD6CD;
  --imprint: #E2661B;
  --font-title: "Cabin", "Gill Sans", "Gill Sans MT", "Segoe UI", sans-serif;
  --font-text: "Libre Baskerville", Baskerville, "Baskerville Old Face", Georgia, serif;
  --wrap: 72rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

.pa-frame,
.pa-frame * {
  all: revert;
}

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

.pa-frame {
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  text-align: left;
}

.pa-frame a {
  color: inherit;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}

.pa-frame a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 1px;
}

.pa-frame .pa-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.pa-frame .pa-wrap {
  display: block;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* The cartouche: the imprint's oval mark. */
.pa-frame .pa-cartouche {
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: 2.7em;
  block-size: 1.75em;
  border: 0.14em solid currentColor;
  border-radius: 50%;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.pa-frame .pa-cartouche--small {
  font-size: 0.7rem;
}

/* ---------------------------------------------------------------- Bands */

.pa-frame .pa-band__label {
  margin: 0;
  padding-block: 0.8rem;
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* --------------------------------------------------------- Running head */

.pa-frame.pa-runhead {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  background: var(--series);
  color: var(--on-series);
  font-family: var(--font-title);
  font-size: 0.875rem;
  line-height: 1.3;
}

.pa-frame .pa-runhead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 0.6rem var(--gutter);
}

.pa-frame .pa-runhead__home {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  text-decoration: none;
}

.pa-frame .pa-runhead__series {
  font-weight: 600;
  text-decoration: none;
}

.pa-frame .pa-runhead__home:hover span,
.pa-frame .pa-runhead__series:hover {
  text-decoration: underline;
}

.pa-frame .pa-runhead__meta {
  margin-inline-start: auto;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pa-frame .pa-runhead__no {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pa-frame .pa-runhead__newer {
  font-weight: 700;
  text-decoration: underline;
  white-space: nowrap;
}

@media (max-width: 40rem) {
  .pa-frame .pa-runhead__meta {
    flex-basis: 100%;
    margin-inline-start: 0;
  }

  /* On an older edition the phone band keeps to two lines: the way to the newest edition wins. */
  .pa-frame.pa-runhead.is-older .pa-runhead__byline,
  .pa-frame.pa-runhead.is-older .pa-runhead__format,
  .pa-frame.pa-runhead.is-older .pa-runhead__dot {
    display: none;
  }
}

/* ------------------------------------------------------------- Entries */

.pa-frame .pa-entries {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A catalogue list: the work's number in its own column, the title block beside it. */
.pa-frame .pa-entry {
  position: relative;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  padding: 1.2rem 0 1.3rem;
  border-bottom: 1px solid var(--rule);
}

.pa-frame .pa-entry > :not(.pa-entry__no) {
  grid-column: 2;
}

.pa-frame .pa-entry__no {
  grid-column: 1;
  grid-row: 1;
  padding-top: 0.2em;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.pa-frame .pa-entry:last-child {
  border-bottom: 0;
}

.pa-frame .pa-entry__title {
  margin: 0 0 0.45rem;
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 1.06rem + 0.5vw, 1.45rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.pa-frame .pa-entry__link {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 0.2em;
  text-decoration-skip-ink: none;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.3s var(--ease-out);
}

/* The series colour marks the title you are about to open. */
.pa-frame .pa-entry__link:hover,
.pa-frame .pa-entry__link:focus-visible {
  text-decoration-color: var(--series);
}

/* The whole entry opens the post; edition links sit above this layer. */
.pa-frame .pa-entry__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.pa-frame .pa-entry__summary {
  max-width: 62ch;
  margin: 0 0 0.55rem;
  font-family: var(--font-text);
  font-size: 0.95rem;
  line-height: 1.65;
}

.pa-frame .pa-entry__meta {
  position: relative;
  margin: 0;
  font-family: var(--font-title);
  font-size: 0.875rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.pa-frame .pa-entry__edition {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  pointer-events: auto;
}

/* --------------------------------------------------------------- Spines */

/* The series stand upright on one shelf, names running down the spine. */
.pa-frame .pa-spines {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .pa-frame .pa-spines {
    grid-auto-columns: 5rem;
    justify-content: start;
  }
}

.pa-frame .pa-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  height: 9rem;
  padding: 0.8rem 0.25rem 0.6rem;
  background: var(--series);
  color: var(--on-series);
  font-family: var(--font-title);
  text-align: center;
  text-decoration: none;
  transition: transform 0.4s var(--ease-out);
}

@media (min-width: 40rem) {
  .pa-frame .pa-spine {
    height: 10.5rem;
  }
}

/* A spine drawn half out of the shelf. */
.pa-frame .pa-spine:hover,
.pa-frame .pa-spine:focus-visible {
  transform: translateY(-0.35rem);
}

/* currentColor is the spine's own text colour, which vanishes against the paper. */
.pa-frame .pa-spine:focus-visible {
  outline-color: var(--ink);
}

.pa-frame .pa-spine__name {
  flex: 1;
  min-height: 0;
  writing-mode: vertical-rl;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-transform: uppercase;
}

.pa-frame .pa-spine__count {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ Back flap */

/* Both frame pieces sit above any fixed texture a post lays over its own page. */
.pa-frame.pa-flap {
  display: block;
  position: relative;
  z-index: 1;
  clear: both;
  width: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--rule);
}

.pa-frame .pa-flap__band {
  background: var(--series);
  color: var(--on-series);
}

.pa-frame .pa-flap__section {
  padding-block: 2rem 2.5rem;
}

.pa-frame .pa-flap__heading {
  margin: 0 0 0.75rem;
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 700;
}

.pa-frame .pa-flap__heading--spaced {
  margin-top: 2.25rem;
}

.pa-frame .pa-flap__note {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.pa-frame .pa-flap__home {
  margin: 1.5rem 0 0;
  font-family: var(--font-title);
  font-weight: 700;
}

.pa-frame .pa-editions {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.pa-frame .pa-editions__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.9rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-title);
}

.pa-frame .pa-editions__label {
  min-width: 8.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-2);
}

.pa-frame .pa-editions__title {
  font-size: 1.05rem;
  font-weight: 700;
}

.pa-frame .pa-editions__here {
  padding: 0.1rem 0.5rem;
  background: var(--series);
  color: var(--on-series);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ------------------------------------------------------------- Colophon */

.pa-frame .pa-colophon {
  background: var(--series);
  color: var(--on-series);
}

.pa-frame .pa-colophon__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 1.4rem;
  font-family: var(--font-title);
  font-size: 0.875rem;
}

.pa-frame .pa-colophon__home {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.pa-frame .pa-colophon__note {
  margin: 0;
}

/* ------------------------------------------------------------- Homepage */

.pa-root {
  background: #FBFAF7;
  scroll-behavior: smooth;
}

.pa-frame.pa-home {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  caret-color: var(--imprint);
  scrollbar-color: #B9B1A6 var(--paper);
}

.pa-home ::selection {
  background: #F7CFB2;
  color: #1C1A17;
}

.pa-frame .pa-cover__band {
  background: var(--series);
  color: var(--on-series);
}

.pa-frame .pa-cover__bar {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.25rem);
  padding-block: clamp(1.75rem, 5vw, 3.5rem);
}

.pa-frame .pa-cover__bar .pa-cartouche {
  font-size: clamp(0.9rem, 0.7rem + 1vw, 1.35rem);
}

.pa-frame .pa-cover__name {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(2.1rem, 1.3rem + 4vw, 4.75rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.pa-frame .pa-cover__panel {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.25rem);
  padding-block: clamp(1.75rem, 4vw, 3rem);
}

.pa-frame .pa-cover__line {
  max-width: 34ch;
  margin: 0;
  font-family: var(--font-text);
  font-size: clamp(1.2rem, 0.95rem + 1.2vw, 1.85rem);
  line-height: 1.45;
  text-wrap: pretty;
}

/* The cover's lower band: band, paper, band, as on the paperback. */
.pa-frame .pa-cover__foot {
  height: clamp(1.25rem, 3vw, 2.25rem);
  background: var(--series);
}

.pa-frame .pa-shelf {
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 6vw, 5rem);
}

@media (min-width: 60rem) {
  .pa-frame .pa-shelf {
    columns: 2;
    column-gap: clamp(2.5rem, 5vw, 4.5rem);
  }
}

.pa-frame .pa-series {
  display: block;
  margin: 0 0 2.75rem;
  break-inside: avoid;
  scroll-margin-top: 1.5rem;
}

.pa-frame .pa-series__band {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0.75rem 0.9rem;
  background: var(--series);
  color: var(--on-series);
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.pa-frame .pa-series__count {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  .pa-root {
    background: #171512;
  }

  .pa-frame.pa-home {
    --paper: #171512;
    --ink: #ECE7DF;
    --ink-2: #A39A8E;
    --rule: #37322C;
    scrollbar-color: #4A443D var(--paper);
  }

  .pa-home ::selection {
    background: #7A3A12;
    color: #FBFAF7;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pa-root {
    scroll-behavior: auto;
  }

  .pa-frame *,
  .pa-frame *::after {
    transition: none !important;
  }
}
