:root {
  --paper: #fbf6f6;
  --ink: #000000;
  --maroon: #671123;
  --blush: #f0e9e0;
  --cream: #f9f6ee;
  --navy: #1b2f86;
  --line: #c8c3be;
  --shadow: 0 10px 28px rgba(19, 23, 39, 0.14);

  /* category colors */
  --olive: #464a1f;
  --mustard: #8f6a1d;
  --slate-blue: #2b4b5c;
  --rust: #933a1d;

  --default-font-family: "Cormorant Garamond", serif;
  --header-title-font-family: "Bree Serif", serif;
  --all-caps-font-family: "Montserrat", sans-serif;

  --control-width: clamp(8.5rem, 10vw, 10.5rem);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: max(600px, 100dvh);
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: var(--ink);
  font-family: var(--default-font-family);
  background: var(--cream);
}

.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0; /* spacing is handled by margins below, not the gap */
  color: var(--ink);
  font-family: var(--header-title-font-family);
  font-weight: 400;
  font-style: normal;
}

.header a {
  text-decoration: none;
}

.header-title a,
.header-title a:visited {
  color: var(--ink);
}

.header-title-top a,
.header-title-top a:visited {
  color: var(--maroon);
}

.header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* right-justify content */
  text-align: right;
}

.header-title {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  margin-top: 1.5rem;
  font-weight: 700;
  font-size: clamp(2.1rem, 4.8vw, 4.4rem);
  font-style: italic;
  line-height: 0.9;
  font-weight: 800;
}

.header-title-top {
  position: absolute;
  top: -0.6em; /* lifts it above the main line, scales with font-size */
  left: 20%;
  transform: translateX(-50%);
  font-weight: 500;
  white-space: nowrap;
  color: var(--maroon);
  font-size: clamp(1.15rem, 2.5vw, 2.4rem);
}

.header-rule {
  width: 2px;
  align-self: stretch; /* line spans the full header height */
  background-color: var(--maroon);
  margin: 1.5rem;
}

.header-right {
  text-align: left;
}

.header-right-text {
  font-family: var(--default-font-family);
  font-size: clamp(1rem, 2vw, 2.6rem);
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: -0.02rem;
}

.page-main {
  display: flex;
  width: 100%;
  min-height: 0;
  padding: 0.25rem 2.25rem 0;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.stage {
  width: 100%;
  display: grid;
  grid-template-columns:
    minmax(max-content, 1fr)
    minmax(0, 1100px)
    minmax(max-content, 1fr);
  height: 100%;
  margin: 0 2rem;
  gap: 0 clamp(0.5rem, 1vw, 2rem);
}

.bite-card {
  grid-column: 2;
  grid-row: 1;
  width: auto;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  position: relative;
  perspective: 1600px;
  transform-style: preserve-3d;
  overflow: hidden;
  border-radius: 1.25rem;
  justify-self: stretch;
  align-self: stretch;
  background-color: var(--paper);
  box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.1);
  margin: 0 2rem;
}

.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  padding: 2rem 3rem 1rem 3rem;
  background: var(--paper);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: flat;
  will-change: transform;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-face--front {
  transform: rotateY(0deg) translateZ(0);
  z-index: 2;
}

.card-face--back {
  transform: rotateY(180deg) translateZ(0);
  z-index: 1;
}

.bite-card.is-flipped .card-face--front {
  transform: rotateY(-180deg) translateZ(0);
  z-index: 1;
}

.bite-card.is-flipped .card-face--back {
  transform: rotateY(0deg) translateZ(0);
  z-index: 2;
}

.card-header {
  max-height: 7rem;
  gap: 3rem;
}

.card-top-row {
  display: flex;
  align-items: center;
}

.card-kicker {
  flex-shrink: 0;
  background: var(--maroon);
  color: #ffffff;
  font-family: var(--all-caps-font-family);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: clamp(0.9rem, 1.45vw, 1.5rem);
  padding: 0.3rem 0.75rem 0.3rem 0.75rem;
  line-height: 1;
}

.card-top-line {
  height: 2px;
  background: var(--maroon);
  margin-top: 0;
  margin-left: 1rem;
  width: 100%;
  opacity: 0.9;
}

.card-title {
  grid-column: 1;
  grid-row: 2;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  line-height: 1;
  font-size: clamp(1.35rem, 4vw, 2.45rem);
  font-weight: 550;
}

.card-line {
  grid-column: 1;
  grid-row: 3;
  width: clamp(3.8rem, 8vw, 5.3rem);
  height: 3px;
  background: var(--maroon);
}

.card-main-copy {
  margin: 0 2rem 0 0;
  margin-top: clamp(1.5rem, 0.4vw, 2rem);
  padding: 0.75rem 0;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  min-width: 0;
  font-size: 2.25rem;
  line-height: 0.96;
  font-weight: 500;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.card-footer {
  margin-top: auto;
  height: 3rem;
  display: flex;
  align-items: flex-end;
}

.card-authors {
  position: relative;
  color: #101010;
  display: flex;
  align-items: center;
}

.author-rule {
  position: absolute;
  width: 4px;
  height: clamp(0.8rem, 3vw, 2rem);
  background: var(--maroon);
}

.card-authors p {
  margin: 0;
  padding-left: 1rem;
  text-transform: uppercase;
  font-family: var(--all-caps-font-family);
  letter-spacing: 0.3rem;
  line-height: 1.2;
  font-size: 0.75rem;
  font-weight: 500;
}

.nav-control {
  background: transparent;
  border: 0;
  padding: 1rem;
  padding-bottom: 1.5rem;
  color: var(--maroon);
  background-color: var(--blush);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--all-caps-font-family);
  letter-spacing: 0.14em;
}

.nav-circle {
  width: clamp(3.8rem, 4.7vw, 4.6rem);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--maroon);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: clamp(3rem, 4vw, 4rem);
  line-height: 1;
  padding-bottom: 0.3rem;
}

.nav-label {
  font-size: clamp(1rem, 1.45vw, 1.45rem);
  font-weight: 600;
}

.nav-prev {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  width: var(--control-width);
}

.card-right {
  grid-column: 3;
  grid-row: 1;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center; /* horizontally centers every child, matching nav-prev */
}

.nav-next {
  grid-row: 2;
  width: var(--control-width);
  margin: 0;
}

.click-here {
  width: var(--control-width);

  grid-row: 3;
  align-self: start; /* pin to the top of the remaining space, right under nav-next */
  margin-top: 1rem; /* <- the only number you tune: the visual gap you want */
  width: 100%;
  border: 1.5px solid var(--slate-blue);
  background: rgba(253, 251, 249, 0.9);
  display: flex;
  align-items: center;
  padding: 0.4rem 0.4rem;
  cursor: pointer;
}

.click-here-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: var(--slate-blue);
  border-radius: 50%;
}

.click-here-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}

.click-here-text {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  text-transform: uppercase;
  text-wrap: nowrap;
  font-family: var(--all-caps-font-family);
  font-size: clamp(0.4rem, 0.9vw, 1rem);
  font-weight: 600;
  line-height: 1.5;
  padding-left: 0.3rem;
  padding-right: 0.3rem;
}

.site-footer {
  margin: clamp(0.35rem, 1vh, 1rem) 2.25rem 0;
  padding-bottom: clamp(0.45rem, 1vh, 1rem);
  border-top: 2px solid var(--line);
  padding-top: clamp(0.6rem, 1.2vh, 1.2rem);
}

.footer-menu {
  display: grid;
  grid-template-columns: repeat(5, minmax(8rem, 1fr));
  align-items: start;
  gap: clamp(0.3rem, 0.7vw, 0.85rem);
}

.filter-item {
  border: 0;
  background: transparent;
  color: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.1rem;
  cursor: pointer;
  margin-right: 1rem;
  margin-left: 1rem;
  transition:
    transform 140ms ease,
    opacity 140ms ease;
}

.filter-icon {
  width: clamp(2rem, 5.2vw, 3.4rem);
  height: clamp(2rem, 5.2vw, 3.4rem);
  padding: clamp(0.1rem, 0.5rem, 0.7rem);

  /* Circle around icon */
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--filter-icon-bg);
  color: var(--paper);
}

.filter-icon img,
.filter-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.filter-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.filter-label {
  font-family: var(--all-caps-font-family);
  font-size: clamp(0.75rem, 1.2vw, 1rem);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.05;
  text-align: center;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

.filter-item[data-filter="Big Ideas"] {
  --filter-icon-bg: var(--maroon);
}
.filter-item[data-filter="Intellectual Endeavors"] {
  --filter-icon-bg: var(--olive);
}
.filter-item[data-filter="Readers"] {
  --filter-icon-bg: var(--mustard);
}
.filter-item[data-filter="Creators"] {
  --filter-icon-bg: var(--slate-blue);
}
.filter-item[data-filter="Behind the Book"] {
  --filter-icon-bg: var(--rust);
}

/* Handle selected state */
.filter-icon,
.filter-label {
  transition:
    box-shadow 140ms ease,
    transform 140ms ease,
    font-weight 140ms ease;
}

.filter-item.is-active {
  transform: translateY(-1px);
}

.filter-item.is-active .filter-icon {
  /* Uses current text color, so no hardcoded active color needed */
  box-shadow:
    0 0 0 2px currentColor,
    0 0 0 5px var(--filter-icon-bg);
}

.filter-item.is-active .filter-label {
  font-weight: 700;
}

@media (max-width: 980px) {
  .header-right {
    margin-left: 0;
  }

  .stage {
    grid-template-columns:
      minmax(max-content, clamp(2.5rem, 8vw, 4rem))
      minmax(0, 1fr)
      minmax(max-content, clamp(2.5rem, 8vw, 4rem));
    column-gap: clamp(0.25rem, 0.8vw, 0.75rem);
    margin-left: 0;
    margin-right: 0;
  }

  .bite-card {
    padding: 3rem;
    margin-left: 0.75rem;
    margin-right: 0.75rem;
  }

  .nav-prev,
  .nav-next,
  .click-here {
    margin-left: 0;
    margin-right: 0;
  }

  .card-header {
    max-height: 6.5rem;
  }

  .card-title {
    font-size: clamp(1.25rem, 4vw, 2.45rem);
  }

  .card-main-copy {
    max-width: 100%;
    line-height: 1.04;
  }

  .nav-circle {
    width: clamp(2.5rem, 6vw, 3.4rem);
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    padding-bottom: 0.15rem;
  }

  .nav-icon {
    color: var(--cream);
  }

  .nav-label {
    font-size: clamp(0.68rem, 1.5vw, 1rem);
  }

  .card-right {
    justify-self: center;
  }

  .click-here-text {
    font-size: clamp(0.22rem, 0.7rem, 1rem);
    white-space: normal;
  }

  .click-here-icon {
    width: 20px;
    height: 20px;
  }

  .card-authors {
    margin-bottom: 1rem;
  }

  .filter-icon {
    width: clamp(3rem, 6.2vw, 10rem);
    height: clamp(3rem, 6.2vw, 10rem);
    padding: clamp(0.2rem, 0.4rem, 0.5rem);
  }
}

@media (max-width: 700px) {
  .header,
  .page-main,
  .site-footer {
    margin: 0;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .site-footer {
    margin-top: 0.95rem;
  }

  .stage {
    grid-template-areas:
      "card card card card"
      ". prev next more";

    grid-template-columns: 1fr auto auto 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    row-gap: 1rem;
    column-gap: clamp(0.25rem, 1vw, 0.6rem);
    margin: 1rem;
  }

  .bite-card {
    grid-area: card;
    border-radius: 1rem;
    padding-left: 1.5rem;
    padding-right: 1.1rem;
  }

  .card-header {
    max-height: 6rem;
  }

  .card-title {
    font-size: clamp(2.2rem, 4vw, 2.4rem);
  }

  .card-authors p {
    letter-spacing: 0.1em;
    font-size: 0.6rem;
  }

  .card-authors {
    margin-bottom: 0.8rem;
  }

  .card-right {
    display: contents;
  }

  .nav-prev {
    grid-area: prev;
    justify-self: end;
    align-self: center;
    width: auto;
  }
  .nav-next {
    grid-area: next;
    justify-self: start;
    align-self: center;
    width: auto;
  }

  .nav-control {
    padding: 0.3rem 0.45rem;
  }

  .nav-circle {
    width: clamp(1.75rem, 7vw, 2.2rem);
    font-size: clamp(1.1rem, 5.2vw, 1.6rem);
    padding-bottom: 0.08rem;
  }

  .nav-label {
    font-size: clamp(0.5rem, 1.6vw, 0.62rem);
    letter-spacing: 0.08em;
  }

  .card-right {
    width: 100%;
    min-width: 0;
  }

  .click-here {
    grid-area: more;
    justify-self: end;
    align-self: center;
    width: auto;
    min-width: 0;
    margin-top: 0;
  }

  .click-here-text {
    min-width: 0;
    text-wrap: wrap;
  }

  .site-footer {
    margin-top: 1.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .footer-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 0.3rem;
    row-gap: 0.4rem;
  }

  .filter-item {
    padding: 0.05rem;
    margin-left: 0.5rem;
    margin-right: 05rem;
  }
}

@media (max-width: 550px) {
  body {
    min-height: 650px;
  }

  .stage {
    grid-template-areas:
      "card card card card"
      "prev next . more";

    grid-template-columns: auto auto 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    row-gap: 1rem;
    column-gap: clamp(0.25rem, 1vw, 0.6rem);
    margin: 1rem;
  }

  .bite-card {
    padding: 1.5rem;
    padding-right: 1.5rem;
  }

  .card-top-line {
    display: none;
  }

  .card-title {
    font-size: clamp(1.2rem, 2vw, 2.2rem);
    margin-bottom: 3px;
    white-space: nowrap;
  }

  .card-line {
    height: 1px;
  }

  .nav-label {
    font-size: clamp(0.5rem, 1.5vw, 0.9rem);
  }

  .card-authors p {
    font-size: 0.5rem;
  }

  .nav-prev {
    margin-left: 1rem;
  }

  .click-here-text {
    font-size: clamp(0.4rem, 0.7rem, 0.5rem);
  }

  .footer-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
  }

  .filter-item {
    flex: 0 1 calc((100% - 0.7rem) / 3);
    max-width: 7.25rem;
    padding: 0.05rem;
    margin-left: 0;
    margin-right: 0;
  }

  .filter-label {
    font-size: clamp(0.5rem, 2.2vw, 0.85rem);
    line-height: 1.05;
  }

  .filter-icon {
    width: clamp(2rem, 8vw, 2.8rem);
    height: clamp(2rem, 8vw, 2.8rem);
    padding: clamp(0.1rem, 0.35vw, 0.28rem);
  }
}
