/* Field Notes: the listing, a note and its photo carousels. Builds on /css/site.css. */

.notes-page {
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3.5rem, 8vw, 6rem);
}

/* ---------- Listing ---------- */
.notes-head {
  max-width: 52rem;
  margin-bottom: 1.75rem;
}

.notes-head h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
}

.notes-head .lead {
  max-width: 46rem;
  margin: 0;
  color: var(--muted);
}

.note-tags a,
.note-tags strong {
  font-size: 0.85rem;
}

.note-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 2.5rem 0;
}

.note-tag-list a,
.note-tag-list strong {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 560;
  text-decoration: none;
}

.note-tag-list a:hover {
  border-color: var(--ink);
}

.note-tag-list strong {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.notes-empty {
  color: var(--muted);
}

/* One note per row: date and title, the summary, and its photo on the right when it has one. */
.note-list {
  border-top: 1px solid var(--line);
}

.note-card {
  display: grid;
  align-content: start;
  padding-block: clamp(1.5rem, 3.5vw, 2.25rem);
  border-bottom: 1px solid var(--line);
}

.note-card-image img {
  width: 100%;
  aspect-ratio: 16 / 10;
  margin-bottom: 1.1rem;
  border-radius: var(--radius);
  object-fit: cover;
}

.note-card h2 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
}

.note-card h2 a {
  color: var(--ink);
  text-decoration: none;
}

.note-card h2 a:hover {
  color: var(--accent);
}

.note-card p:last-child {
  max-width: var(--read);
  margin: 0;
}

.note-more {
  font-weight: 600;
  white-space: nowrap;
}

@media (min-width: 760px) {
  /* The photo is taller than the text: let the last row take up the slack so the text stays together. */
  .note-card.has-image {
    grid-template-columns: minmax(0, 1fr) 17rem;
    grid-template-rows: auto auto 1fr;
    column-gap: clamp(2rem, 5vw, 3.5rem);
  }

  .note-card.has-image > :not(.note-card-image) {
    grid-column: 1;
  }

  .note-card-image {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .note-card-image img {
    margin: 0;
  }
}

/* ---------- A note ---------- */
.note-meta {
  margin: 0 0 0.6rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.note-meta .note-tags a {
  margin-right: 0.35rem;
  color: var(--muted);
}

.note-meta .note-tags a:hover {
  color: var(--accent);
}

.note-article {
  max-width: 46rem;
  margin-inline: auto;
}

.notes-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 560;
  text-decoration: none;
}

.notes-back:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.note-header {
  margin-bottom: 1.75rem;
}

.note-header h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(2.1rem, 5vw, 3.25rem);
}

.note-header .note-meta {
  font-size: 0.925rem;
}

.note-hero {
  width: 100%;
  max-height: 460px;
  margin-bottom: 2rem;
  border-radius: var(--radius-lg);
  object-fit: cover;
}

.note-body {
  max-width: none;
}

.note-body figure {
  margin: 1.75rem 0;
}

.note-body figcaption,
.note-body img + em {
  color: var(--muted);
  font-size: 0.875rem;
}

.note-body table {
  display: block;
  overflow-x: auto;
}

.note-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.925rem;
}

.note-nav span:last-child {
  text-align: right;
}

/* ---------- :::carousel blocks ----------
   Scrolls sideways on its own; carousel.js adds the arrows and dots. */
.note-carousel {
  position: relative;
  margin: 1.75rem auto;
  container-type: inline-size;
  --note-carousel-ratio: 16 / 9;
  max-width: calc(80vh * (var(--note-carousel-ratio)));
}

.note-carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  border-radius: var(--radius);
}

.note-carousel.is-enhanced .note-carousel-track {
  scrollbar-width: none;
  cursor: grab;
}

.note-carousel.is-enhanced .note-carousel-track::-webkit-scrollbar {
  display: none;
}

.note-carousel .note-carousel-slide {
  flex: 0 0 100%;
  margin: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.note-carousel .note-carousel-slide img {
  display: block;
  width: 100%;
  aspect-ratio: var(--note-carousel-ratio);
  border-radius: 0;
  background: var(--bg-soft);
  object-fit: contain;
  user-select: none;
}

.note-carousel .note-carousel-slide figcaption {
  padding: 0.5rem 0.5rem 0;
  text-align: center;
}

.note-carousel-button {
  position: absolute;
  top: 50%;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  transform: translateY(-50%);
  cursor: pointer;
}

/* Centre the arrows on the photo, not the photo plus its caption. */
@supports (width: 1cqw) {
  .note-carousel-button {
    top: calc(50cqw / (var(--note-carousel-ratio)));
  }
}

.note-carousel-button:hover,
.note-carousel-button:focus-visible {
  background: #fff;
}

.note-carousel-button.prev {
  left: 12px;
}

.note-carousel-button.next {
  right: 12px;
}

.note-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 0 0;
}

.note-carousel-dot {
  width: 9px;
  height: 9px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #c9c8c2;
  cursor: pointer;
}

.note-carousel-dot[aria-current="true"] {
  background: var(--ink);
}
