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

:root {
  --petal-bg: #FDF8F0;
  --blush: #F5D090;
  --rose: #C8830A;
  --deep-rose: #9E6508;
  --sage: #6B9980;
  --deep-sage: #4E7A68;
  --forest: #1A3A2E;
  --dark: #1E2E28;
  --mid: #6B7A72;
  --lavender-light: #EDE8F5;
  --lavender: #9178B5;
  --card-bg: #FFFDF5;
  --shadow: rgba(26, 58, 46, 0.08);
  --shadow-hover: rgba(26, 58, 46, 0.18);
  --radius: 14px;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font: 'Lato', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background-color: var(--petal-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70'%3E%3Cg transform='translate(35,35)'%3E%3Cellipse cx='0' cy='-8' rx='3.5' ry='8' fill='%23C8830A' opacity='0.055'/%3E%3Cellipse cx='0' cy='-8' rx='3.5' ry='8' fill='%23C8830A' opacity='0.055' transform='rotate(72)'/%3E%3Cellipse cx='0' cy='-8' rx='3.5' ry='8' fill='%23C8830A' opacity='0.055' transform='rotate(144)'/%3E%3Cellipse cx='0' cy='-8' rx='3.5' ry='8' fill='%23C8830A' opacity='0.055' transform='rotate(216)'/%3E%3Cellipse cx='0' cy='-8' rx='3.5' ry='8' fill='%23C8830A' opacity='0.055' transform='rotate(288)'/%3E%3Ccircle cx='0' cy='0' r='3' fill='%236B9980' opacity='0.07'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--dark);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

header {
  background: var(--forest);
  padding: 2.8rem 1.5rem 3.5rem;
  text-align: center;
  position: relative;
}

/* Organic wave bottom edge */
header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 32' preserveAspectRatio='none'%3E%3Cpath d='M0,16 Q50,0 100,16 Q150,32 200,16 Q250,0 300,16 Q350,32 400,16 Q450,0 500,16 Q550,32 600,16 Q650,0 700,16 Q750,32 800,16 Q850,0 900,16 Q950,32 1000,16 Q1050,0 1100,16 Q1150,32 1200,16 L1200,32 L0,32 Z' fill='%23FDF8F0'/%3E%3C/svg%3E") center/cover no-repeat;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  position: relative;
}

header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--blush);
}

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

.tagline {
  font-size: 1rem;
  color: var(--blush);
  opacity: 0.7;
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
  font-weight: 300;
}

/* Decorative divider below tagline */
.tagline::after {
  content: '';
  display: block;
  width: 80px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(245, 208, 144, 0.55), transparent);
  margin: 0.9rem auto 0;
}

/* ── Site nav ── */

.site-nav {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.25rem;
}

.nav-link {
  color: var(--blush);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.35rem 1rem;
  border-radius: 20px;
  border: 1.5px solid transparent;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
  opacity: 0.7;
}

.nav-link:hover {
  opacity: 1;
  border-color: rgba(245, 208, 144, 0.45);
}

.nav-link[aria-current="page"] {
  opacity: 1;
  border-color: rgba(245, 208, 144, 0.6);
  background: rgba(245, 208, 144, 0.1);
}

.region-picker {
  position: absolute;
  top: 0.9rem;
  right: 0;
}

.region-btn {
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
}

.region-btn:hover,
.region-btn[aria-expanded="true"] {
  opacity: 1;
  transform: scale(1.12);
}

.region-btn .fi {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.region-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  background: var(--forest);
  border: 1px solid rgba(245, 208, 144, 0.2);
  border-radius: 12px;
  padding: 0.4rem;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.15rem;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.region-dropdown[hidden] {
  display: none;
}

.region-option {
  background: none;
  border: none;
  padding: 0.3rem;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.1s, background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.region-option .fi {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.region-option:hover {
  opacity: 1;
  background: rgba(245, 208, 144, 0.12);
}

.region-option--active {
  opacity: 1;
  background: rgba(245, 208, 144, 0.2);
}

/* ── Main ── */

main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
}

/* ── Controls ── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.controls input,
.controls select {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  border: 1.5px solid var(--blush);
  border-radius: 30px;
  background: var(--card-bg);
  color: var(--dark);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.controls input {
  flex: 1 1 220px;
}

.controls select {
  flex: 1 1 160px;
}

.controls input:focus,
.controls select:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(200, 131, 10, 0.12);
}

/* ── Status bar ── */

#status-bar {
  font-size: 0.85rem;
  color: var(--mid);
  margin-bottom: 1rem;
  min-height: 1.2em;
  font-style: italic;
}

/* ── Books grid ── */

.books-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

/* ── Book card ── */

.book-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
  display: flex;
  flex-direction: column;
  border: 1.5px solid rgba(200, 131, 10, 0.14);
  flex: none;
  min-width: 130px;
  max-width: 300px;
}

.book-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 28px var(--shadow-hover);
  border-color: var(--sage);
}

.book-card:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
}

.card-cover {
  height: 280px;
  overflow: hidden;
  background: var(--blush);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
}

.card-cover img {
  height: 100%;
  width: auto;
  display: block;
}

.card-cover--placeholder {
  width: 200px;
  background: linear-gradient(145deg, #D4950A, #6B9980);
}

.card-cover--placeholder span {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 700;
  font-style: italic;
  color: rgba(255, 255, 255, 0.9);
  user-select: none;
}

.card-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  contain: inline-size;
  overflow-wrap: break-word;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--dark);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--mid);
  font-style: italic;
}

.card-author {
  font-size: 0.82rem;
  color: var(--sage);
  font-weight: 600;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.6rem;
}

.tag {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  background: var(--lavender-light);
  color: var(--lavender);
  white-space: nowrap;
}

.tag-age {
  background: #DCF0E5;
  color: #3A7055;
}

/* ── State messages ── */

.loading,
.no-results,
.error {
  width: 100%;
  text-align: center;
  padding: 4rem 1rem;
  font-size: 1rem;
  color: var(--mid);
  font-style: italic;
}

.error {
  color: #A83232;
}

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 58, 46, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
  backdrop-filter: blur(3px);
}

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

.modal-content {
  background: var(--card-bg);
  border-radius: 18px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
  box-shadow: 0 24px 70px rgba(26, 58, 46, 0.3);
  border: 1px solid rgba(200, 131, 10, 0.18);
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1.5px solid var(--blush);
  background: var(--card-bg);
  color: var(--rose);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 1rem;
  margin-bottom: 0.5rem;
}

.modal-close:hover {
  background: var(--rose);
  color: white;
  border-color: var(--rose);
}

.modal-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.modal-cover {
  flex-shrink: 0;
  width: 160px;
}

.modal-cover-img {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 18px var(--shadow-hover);
  display: block;
}

.modal-info {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  font-style: italic;
  color: var(--dark);
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.modal-subtitle {
  font-size: 1rem;
  color: var(--mid);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.modal-assembly {
  font-size: 0.78rem;
  color: var(--mid);
  font-style: italic;
  margin-bottom: 0.4rem;
}

.modal-meta {
  font-size: 0.9rem;
  color: var(--dark);
  margin-bottom: 0.3rem;
}

.modal-link {
  color: var(--rose);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

.modal-link:hover {
  color: var(--deep-rose);
}

.modal-blurb {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--blush);
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--dark);
}

.modal-buy {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--blush);
}

.modal-buy h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.6rem;
}

.buy-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0.4rem 0.4rem 0;
  padding: 0.5rem 1.1rem;
  background: var(--rose);
  color: white;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.buy-link:hover {
  background: var(--deep-rose);
  transform: translateY(-1px);
}

/* ── Footer ── */

footer {
  background: var(--forest);
  color: var(--blush);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* ── About page ── */

.about-main {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

.about-section {
  margin-bottom: 2.5rem;
}

.about-section h2 {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  font-style: italic;
  color: var(--forest);
  margin-bottom: 0.9rem;
}

.about-section p {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--dark);
  margin-bottom: 0.8rem;
}

.about-section ul {
  margin: 0 0 0.8rem 0;
  padding-left: 1.4rem;
}

.about-section li {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--dark);
  margin-bottom: 0.25rem;
  padding-left: 0.3rem;
}

.about-section a:not(.submit-btn) {
  color: var(--rose);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.submit-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 2px 10px var(--shadow);
  border: 1px solid rgba(200, 131, 10, 0.15);
}

.submit-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.75rem 1.75rem;
  background: var(--rose);
  color: white;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
}

.submit-btn:hover {
  background: var(--deep-rose);
  transform: translateY(-2px);
}

/* ── Contributors grid ── */

.contributors-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

/* ── Contributor card ── */

.contributor-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1.5px solid rgba(200, 131, 10, 0.14);
  flex: none;
  width: 220px;
  padding: 1.5rem 1rem 1rem;
  text-align: center;
}

.contributor-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 28px var(--shadow-hover);
  border-color: var(--sage);
}

.contributor-card:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
}

.contributor-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--blush);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  flex-shrink: 0;
  border: 3px solid rgba(200, 131, 10, 0.2);
}

.contributor-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.contributor-avatar--placeholder {
  background: linear-gradient(145deg, #D4950A, #6B9980);
}

.contributor-avatar--placeholder span {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  font-style: italic;
  color: rgba(255, 255, 255, 0.9);
  user-select: none;
}

.contributor-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
}

.contributor-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.3;
}

.contributor-alt-names {
  font-size: 0.78rem;
  color: var(--mid);
}

.contributor-bio-excerpt {
  font-size: 0.8rem;
  color: var(--mid);
  line-height: 1.55;
  margin-top: 0.4rem;
  text-align: left;
}

/* ── Role tags ── */

.tag-role-author {
  background: #FFF0D4;
  color: #8A6020;
}

.tag-role-illustrator {
  background: #E8F0FF;
  color: #3A5EA0;
}

/* ── Contributor modal ── */

.modal-contributor-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.modal-contributor-avatar {
  flex-shrink: 0;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--blush);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(200, 131, 10, 0.25);
}

.modal-contributor-avatar--placeholder {
  background: linear-gradient(145deg, #D4950A, #6B9980);
}

.modal-contributor-avatar--placeholder span {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 700;
  font-style: italic;
  color: rgba(255, 255, 255, 0.9);
  user-select: none;
}

.modal-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-social {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--blush);
}

.modal-social h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.6rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.4rem 0.4rem 0;
  padding: 0.4rem 1rem;
  background: var(--sage);
  color: white;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.social-link:hover {
  background: var(--deep-sage);
  transform: translateY(-1px);
}

.modal-contributor-books {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--blush);
}

.modal-contributor-books h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.75rem;
}

.contributor-book-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.contributor-book-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.contributor-book-title {
  font-weight: 600;
  color: var(--dark);
}

.contributor-book-subtitle {
  color: var(--mid);
  font-style: italic;
}

.contributor-book-roles {
  display: flex;
  gap: 0.25rem;
}

/* ── Responsive ── */

@media (max-width: 520px) {
  .modal-layout {
    flex-direction: column;
  }

  .modal-cover {
    width: 130px;
    align-self: center;
  }

  .modal-contributor-layout {
    flex-direction: column;
    align-items: center;
  }

  .modal-content {
    padding: 1.25rem;
  }
}
