:root {
  --ink: #3a2a44;
  --accent: #6b3a6e;
  --card-back: #fffaf5;
  --card-shadow: rgba(60, 30, 70, 0.25);
  --card-shadow-hover: rgba(60, 30, 70, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse 70% 60% at 8% 95%, rgba(255, 210, 170, 0.95) 0%, rgba(255, 210, 170, 0) 60%),
    radial-gradient(ellipse 90% 70% at 90% 100%, rgba(220, 170, 200, 0.55) 0%, rgba(220, 170, 200, 0) 65%),
    linear-gradient(180deg,
      #9aa8d6 0%,
      #b4a4d4 25%,
      #d3a8cf 50%,
      #ecb6c4 72%,
      #f4ccba 100%);
  background-attachment: fixed;
}

.page-header {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
}

.page-header h1 {
  margin: 0;
  font-family: "Pacifico", "Brush Script MT", cursive;
  font-weight: 400;
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 2px 12px rgba(70, 40, 80, 0.4);
}

.subtitle {
  margin: 0.5rem 0 0;
  font-style: italic;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 6px rgba(70, 40, 80, 0.3);
}

.intro {
  max-width: 720px;
  margin: 1rem auto 0;
  padding: 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 20px rgba(60, 30, 70, 0.15);
}

.intro p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink);
  text-align: center;
}

main {
  display: flex;
  justify-content: center;
  padding: 1.5rem 1rem 3rem;
}

.quilt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: min(900px, 100%);
  border: 16px solid #f69bcf; /* pink binding */
  border-radius: 24px;
  outline: 2px dashed rgba(255, 250, 240, 0.95); /* white running stitch */
  outline-offset: -22px;
  box-shadow:
    0 0 0 2px #f0b8d8, /* soft thread along the binding edge */
    0 18px 50px rgba(60, 30, 70, 0.35);
}

.card {
  position: relative;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  border-radius: 0; /* patches tile flush together */
  overflow: hidden;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.25s ease,
    filter 0.25s ease,
    border-radius 0.25s ease;
  will-change: transform;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* round the four corner patches to follow the binding's rounded edge */
.card:nth-child(1) { border-top-left-radius: 8px; }
.card:nth-child(3) { border-top-right-radius: 8px; }
.card:nth-child(7) { border-bottom-left-radius: 8px; }
.card:nth-child(9) { border-bottom-right-radius: 8px; }

.card:hover {
  transform: translateY(-8px) scale(1.04) rotate(-0.6deg);
  box-shadow: 0 14px 28px var(--card-shadow-hover);
  border-radius: 4px;
  z-index: 2;
}

.card:hover img {
  transform: scale(1.06);
}

.card:active {
  transform: translateY(-4px) scale(1.02);
}

.card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.card .hover-pill {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translate(-50%, 8px);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card:hover .hover-pill {
  opacity: 1;
  transform: translate(-50%, 0);
}

.references {
  max-width: 760px;
  margin: 2.5rem auto 0;
  padding: 1.5rem 1.75rem 1.75rem;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 20px rgba(60, 30, 70, 0.15);
}

.references h2 {
  margin: 0 0 1rem;
  color: var(--accent);
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.references ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--ink);
}

.references li {
  margin-bottom: 0.85rem;
  line-height: 1.5;
  font-size: 0.95rem;
  word-break: break-word;
}

.references li:last-child { margin-bottom: 0; }

.references a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.references a:hover {
  text-decoration-thickness: 2px;
}

.page-footer {
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(70, 40, 80, 0.25);
}

/* Modal — the "expanded" square */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modal-in 0.25s ease;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 12, 6, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-panel {
  position: relative;
  background: var(--card-back);
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  max-width: 900px;
  width: 100%;
  max-height: calc(100vh - 3rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: hidden;
  animation: panel-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes panel-in {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-image-wrap {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  max-height: calc(100vh - 3rem);
}

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

.modal-text {
  padding: 2rem 2rem 2.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 3rem);
}

.modal-text h2 {
  margin: 0 0 1rem;
  color: var(--accent);
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}

.modal-text p {
  margin: 0;
  line-height: 1.6;
  font-size: 1rem;
  white-space: pre-wrap;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  z-index: 2;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, background 0.15s ease;
}

.modal-close:hover {
  transform: scale(1.1);
  background: #fff;
}

@media (max-width: 700px) {
  .modal-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .modal-image-wrap { max-height: 40vh; min-height: 200px; }
  .modal-text { padding: 1.25rem; }
}

@media (max-width: 600px) {
  .quilt-grid { gap: 0.6rem; }
}
