/* Reset & base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Open Sans", sans-serif;
  font-size: 0.875rem;
  background: linear-gradient(180deg, #f8f6fc 0%, #fdf6f3 50%, #f9ebe6 100%);
  color: #1a1a1a;
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 4rem;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* Hero */
.hero {
  text-align: center;
  padding: 2.25rem 1.5rem 2rem;
}

.hero h1 {
  font-family: "Oswald", sans-serif;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 300;
  letter-spacing: 0;
  color: #8B807A;
  line-height: 1.2;
}

/* Bento grid */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.bento-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bento-card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.bento-card:hover:not(.card-featured) {
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
}

.image-placeholder {
  display: block;
}

.book-cover {
  width: auto;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: 0 auto;
  background: transparent;
  padding: 0;
}

.portrait-photo {
  width: auto;
  height: 100%;
  max-width: 72%;
  object-fit: contain;
  border-radius: 1.5rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Card: featured */
.card-featured {
  background: #ffffff;
  color: #1a1a1a;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1rem;
}

.featured-text {
  font-family: inherit;
  font-size: inherit;
  font-weight: 400;
  line-height: 1.5;
  color: #4a4a4a;
  margin: 0;
}

.infographic {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 1rem;
  flex: 1 1 auto;
}

/* Right-column logos */
.card-quote {
  background: #ffffff;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.r4-logo {
  width: auto;
  height: auto;
  max-width: 72%;
  max-height: 72%;
  object-fit: contain;
  display: block;
}

.card-r4-publishing {
  background: #0b1220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.publishing-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 86%;
  max-height: 86%;
  object-fit: contain;
  border-radius: 1rem;
}

/* Responsive */
@media (min-width: 640px) {
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .col-center {
    grid-column: span 2;
  }
}

@media (min-width: 900px) {
  .bento-grid {
    grid-template-columns: 1.1fr 1.6fr 1.1fr;
    height: 600px;
    align-items: stretch;
  }

  .bento-col,
  .bento-card {
    min-height: 0;
  }

  .col-left {
    height: 85%;
    align-self: end;
    display: grid;
    grid-template-rows: 1fr 2fr;
  }

  .col-left .card-soft {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: visible;
  }

  .col-left .card-soft:hover {
    transform: none;
    box-shadow: none;
  }

  .col-left .card-soft:hover .portrait-photo {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
  }

  .card-book {
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
  }

  .col-center {
    grid-column: auto;
    height: 100%;
  }

  .card-featured {
    height: 100%;
  }

  .col-right {
    height: 70%;
    align-self: center;
    display: grid;
    grid-template-rows: 0.56fr 1.14fr;
  }
}

@media (max-width: 899px) {
  .bento-col {
    display: contents;
    min-height: 0;
  }

  /* Tile order when stacked: featured, profile, rfour.org, book, R4 */
  .card-featured {
    order: 1;
    grid-column: 1 / -1;
  }

  #profile-card { order: 2; }
  #rfour-card { order: 3; }
  #book-card { order: 4; }
  #r4-publishing-card { order: 5; }

  .card-image,
  .card-quote,
  .card-r4-publishing {
    min-height: 280px;
  }

  .col-left .card-soft {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .portrait-photo {
    max-height: 260px;
    width: auto;
  }

  .card-book,
  .card-quote,
  .card-r4-publishing {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
  }

  .card-featured {
    min-height: 520px;
  }
}

/* Focus styles */
a:focus-visible,
button:focus-visible {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}

/* Modal */
body.modal-open {
  overflow: hidden;
}

#rfour-card,
#book-card,
#profile-card,
#r4-publishing-card {
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: linear-gradient(180deg, #f8f6fc 0%, #fdf6f3 50%, #f9ebe6 100%);
  overflow-y: auto;
  animation: modal-fade 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-page {
  position: relative;
  max-width: 575px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  text-align: left;
}

.modal-sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  margin: 0 -1.5rem;
  padding: 1.25rem 1.5rem 0.85rem;
  background: rgba(248, 246, 252, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: none;
}

.sticky-title {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 4px);
  font-family: "Oswald", sans-serif;
  font-size: 1.05rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: #8B807A;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}

.modal-overlay.title-scrolled .sticky-title {
  opacity: 1;
  transform: translate(-50%, 0);
}

.back-link {
  padding: 0.5rem 0;
  border: none;
  background: transparent;
  color: #0B1220;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: #1373C5;
}

.modal-title {
  font-family: "Oswald", sans-serif;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  color: #8B807A;
  margin: 1.75rem 0;
  text-align: center;
}

.modal-text p,
.modal-text ol {
  font-size: inherit;
  line-height: 1.7;
  color: #4a4a4a;
  margin: 0 0 1.25rem;
}

.modal-text ol {
  padding-left: 1.25rem;
}

.modal-text li {
  margin-bottom: 1.25rem;
  padding-left: 0.5rem;
}

.modal-text li::marker {
  font-weight: 600;
}

.modal-text h3 {
  font-family: "Oswald", sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #8B807A;
  margin: 2.25rem 0 1rem;
}

.modal-text a {
  color: #0B1220;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.modal-text a.plain-link {
  text-decoration: none;
}

.modal-text a:hover {
  color: #1373C5;
}
