.reports-layout {
  display: flex;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--color-parchment-dark);
  border-right: 3px solid var(--color-forest-dark);
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebar__title {
  font-family: var(--font-display);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-forest-dark);
  margin: 0 0 14px;
}

.sidebar__filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.sidebar__filters select {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-slate-light);
  background: var(--color-parchment);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar__item button {
  width: 100%;
  text-align: left;
  background: var(--color-parchment);
  border: 1px solid var(--color-slate-light);
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: var(--font-body);
}

.sidebar__item button[aria-current='true'] {
  background: var(--color-rust);
  color: white;
  border-color: var(--color-rust);
}

.sidebar__item-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
}

.sidebar__item-date {
  display: block;
  font-size: 0.72rem;
  opacity: 0.75;
}

.sidebar__item.is-filtered-out {
  display: none;
}

/* ---------- Stack ---------- */

.stack {
  flex: 1;
  overflow-y: auto;
  padding: 40px 5% 60px;
  position: relative;
  perspective: 1800px;
}

.stack__open {
  transform-style: preserve-3d;
  transform-origin: top center;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.stack__open.flip-out {
  transform: rotateX(-100deg);
  opacity: 0;
}

.stack__open.flip-in {
  transform: rotateX(100deg);
  opacity: 0;
}

.report-card {
  background: var(--color-paper);
  box-shadow: 0 10px 30px var(--color-paper-shadow);
  border-radius: 2px;
  border: 1px solid var(--color-ink);
  padding: 0;
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

/* ---------- One-piece-of-paper sheet ---------- */

.report-sheet {
  display: flex;
  flex-direction: column;
}

.sheet-row {
  display: flex;
  border-top: 1px solid var(--color-ink);
}

.sheet-row--title {
  border-top: none;
}

.cell {
  flex: 1;
  padding: 6px 12px 8px;
  border-right: 1px solid var(--color-ink);
  min-width: 0;
}

.cell:last-child {
  border-right: none;
}

.sheet-row--title .cell {
  text-align: center;
  padding: 8px 12px;
  border-right: none;
}

.sheet-title-text {
  font-family: var(--font-form);
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: bold;
  color: var(--color-ink);
}

.field__label {
  display: block;
  font-family: var(--font-form);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-ink);
  margin-bottom: 3px;
}

.field__value {
  font-family: var(--font-hand);
  font-weight: 400;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--color-ink);
  letter-spacing: 0.01em;
}

.field__value.lined {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(1.55em - 1px),
    var(--color-paper-line) calc(1.55em - 1px),
    var(--color-paper-line) calc(1.55em)
  );
  line-height: 1.55em;
  white-space: pre-wrap;
}

/* ---------- Top row: date + route ---------- */

.cell--date {
  flex: 0 0 135px;
}

.cell--route {
  flex: 1.05;
}

.cell--weather {
  flex: 1.4;
}

.route-line {
  margin-bottom: 8px;
}

.route-line:last-child {
  margin-bottom: 0;
}

.route-line__blank {
  display: block;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  border-bottom: 1px solid var(--color-ink);
  padding-bottom: 2px;
}

.route-line__hint {
  display: block;
  margin-top: 2px;
  font-family: var(--font-form);
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  color: var(--color-slate);
}

/* ---------- Date line (blank + helper text, matches location field) ---------- */

.date-line {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-hand);
  font-size: 1.2rem;
}

.date-line__blank {
  border-bottom: 1px solid var(--color-ink);
  text-align: center;
  padding-bottom: 2px;
}

.date-line__blank--month {
  width: 36px;
}

.date-line__blank--day {
  width: 20px;
}

.date-line__blank--year {
  width: 46px;
}

.date-line__comma {
  font-family: var(--font-hand);
}

.date-line__hints {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}

.date-line__hints span {
  text-align: center;
  font-family: var(--font-form);
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  color: var(--color-slate);
}

.date-line__hint--month {
  width: 36px;
}

.date-line__hint--day {
  width: 20px;
}

.date-line__hint--spacer {
  width: 10px;
}

.date-line__hint--year {
  width: 46px;
}

/* ---------- Weather events ---------- */

.checklist--weather {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 6px;
}

/* ---------- Stats row (miles / elevation / days riding / what broke) ---------- */

.cell--miles,
.cell--elevation {
  flex: 0.85;
}

.cell--days {
  flex: 0.55;
}

.cell--broke {
  flex: 1.7;
}

.stat-value {
  font-family: var(--font-hand);
  font-size: 2.6rem;
  color: var(--color-ink);
}

.elevation-lines__row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-hand);
  font-size: 1.55rem;
}

.elevation-lines__sign {
  font-family: var(--font-form);
  color: var(--color-slate);
  width: 10px;
}

/* ---------- Report body ---------- */

.cell--report .field__value {
  min-height: 145px;
  font-family: var(--font-hand-prose);
  font-size: 1.15rem;
  font-weight: 400;
}

/* ---------- Photos row (full width, bottom) ---------- */

.cell--photos {
  padding: 10px 14px 14px;
}

.photos-well {
  position: relative;
  height: 430px;
  border: 2px dotted var(--color-slate);
  border-radius: 2px;
}

.photos-well__label {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 10;
  font-family: var(--font-form);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-slate);
  text-shadow: 0 0 4px var(--color-paper), 0 0 4px var(--color-paper);
}

.loose-photo-pile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 640px;
  height: 380px;
  transform: translate(-50%, -50%);
}

.loose-photo {
  position: absolute;
  padding: 6px 6px 14px;
  background: white;
  border: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transform: rotate(var(--rot));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.loose-photo--portrait {
  width: 220px;
  aspect-ratio: 5 / 7;
}

.loose-photo--landscape {
  width: 280px;
  aspect-ratio: 7 / 5;
}

.loose-photo:hover,
.loose-photo:focus-visible {
  transform: rotate(var(--rot)) translateY(-4px) scale(1.03);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.38);
}

.loose-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loose-photo__badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: var(--color-rust);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

/* ---------- Extras row (trail musings / listening / reading) ---------- */

.cell--musings {
  flex: 2;
  min-height: 170px;
}

.cell--musings .field__value {
  font-family: var(--font-hand-prose);
  font-size: 1.15rem;
  font-weight: 400;
}

.cell--musings .field__value.lined {
  min-height: 140px;
}

.cell--side {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sub-cell {
  padding: 6px 12px 8px;
}

.sub-cell + .sub-cell {
  border-top: 1px solid var(--color-ink);
}

.field__value.lined.lined--short {
  min-height: calc(3.1em + 6px);
}

/* ---------- Checklists (what broke / weather events) ---------- */

.checklist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-hand);
  font-size: 1.05rem;
  line-height: 1.4;
}

.checklist--weather li {
  font-family: var(--font-form);
  font-size: 0.68rem;
  gap: 4px;
  white-space: nowrap;
}

.checklist__box {
  position: relative;
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--color-ink);
  margin-top: 3px;
}

.is-checked .checklist__box::after {
  content: '';
  position: absolute;
  left: -2px;
  top: -6px;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 13 Q7 18 10 20 Q15 10 22 3' stroke='%232b2b26' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  transform: rotate(-6deg);
}

.checklist--dash li {
  gap: 0;
}

.checklist--dash li::before {
  content: '\2013';
  margin-right: 6px;
}

/* ---------- Unit toggle (distance / elevation) ---------- */

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.unit-toggle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.unit-toggle__option {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-form);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-slate);
}

.unit-toggle__option .checklist__box {
  margin-top: 0;
}

/* ---------- Nav controls ---------- */

.report-nav {
  max-width: 900px;
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.report-nav button,
.report-nav a {
  background: var(--color-forest-dark);
  color: var(--color-parchment);
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.report-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__img {
  max-width: 88vw;
  max-height: 76vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.photo-fallback--lightbox {
  width: min(360px, 80vw);
  height: min(240px, 50vh);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.photo-fallback--lightbox .photo-fallback__icon {
  font-size: 2.4rem;
}

.photo-fallback--lightbox .photo-fallback__caption {
  font-size: 1rem;
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.lightbox__nav:disabled {
  opacity: 0.2;
  cursor: default;
}

.lightbox__nav:disabled:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lightbox__nav--prev {
  left: 18px;
}

.lightbox__nav--next {
  right: 18px;
}

.lightbox__album-link {
  margin-top: 18px;
  color: var(--color-parchment);
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-decoration: underline;
}

/* ---------- Mobile ---------- */

@media (max-width: 800px) {
  .reports-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 3px solid var(--color-forest-dark);
  }

  .sidebar__list {
    flex-direction: column;
    max-height: 108px;
    overflow-y: auto;
  }

  .sidebar__item {
    flex: none;
  }

  .stack {
    overflow-y: visible;
    padding: 24px 4% 50px;
  }

  .sheet-row {
    flex-direction: column;
  }

  .cell {
    border-right: none;
    border-bottom: 1px solid var(--color-ink);
  }

  .cell:last-child {
    border-bottom: none;
  }

  .cell--date {
    flex-basis: auto;
  }

  .cell--musings {
    min-height: 0;
  }

  /* Keep miles / elevation / days riding on one line where space allows */
  .sheet-row--stats {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .cell--miles,
  .cell--elevation {
    flex: 1 1 30%;
    border-right: 1px solid var(--color-ink);
  }

  .cell--days {
    flex: 1 1 30%;
  }

  .cell--broke {
    flex: 1 1 100%;
  }

  /* Shrink distance/elevation numbers so both can keep the unit toggle beside them */
  .cell--miles .stat-value {
    font-size: 1.8rem;
  }

  .cell--elevation .elevation-lines__row {
    font-size: 0.95rem;
  }

  .cell--miles .unit-toggle__option,
  .cell--elevation .unit-toggle__option {
    font-size: 0.55rem;
  }

  .cell--miles .checklist__box,
  .cell--elevation .checklist__box {
    width: 8px;
    height: 8px;
  }

  .cell--miles .is-checked .checklist__box::after,
  .cell--elevation .is-checked .checklist__box::after {
    width: 13px;
    height: 13px;
    left: -2px;
    top: -5px;
  }

  /* Keep listening/reading side by side instead of stacked */
  .cell--side {
    flex-direction: row;
  }

  .sub-cell {
    flex: 1;
  }

  .sub-cell + .sub-cell {
    border-top: none;
    border-left: 1px solid var(--color-ink);
  }

  .photos-well {
    height: 220px;
  }

  .loose-photo-pile {
    width: 220px;
    height: 180px;
  }

  .loose-photo--portrait {
    width: 90px;
  }

  .loose-photo--landscape {
    width: 110px;
  }
}
