/* ============================================================
   TRIP MEDIA — galleries, uploader, lightbox
   Layers on top of the original itinerary design.
   Uses the same palette/tokens defined in index.html :root
   ============================================================ */

/* ---------- Sticky calendar nav ---------- */
.tm-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8000;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  transform: translateY(-110%);
  transition: transform .25s ease;
}
.tm-nav.tm-nav-show { transform: translateY(0); }
.tm-nav-top {
  flex-shrink: 0; width: 42px; height: 46px; border: none;
  background: var(--sand); border-radius: 10px; font-size: 20px; cursor: pointer;
}
.tm-nav-top:hover { background: var(--coral-light); }
.tm-nav-latest {
  flex-shrink: 0; height: 46px; border: none;
  background: var(--gold-light); color: var(--gold); border-radius: 10px;
  font: 700 14px 'DM Sans', sans-serif; cursor: pointer;
  padding: 0 14px; white-space: nowrap;
}
.tm-nav-latest:hover { filter: brightness(.97); }
.tm-nav-strip {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tm-nav-strip::-webkit-scrollbar { display: none; }
.tm-nav-label {
  flex-shrink: 0; align-self: center; padding: 0 4px;
  font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--pale);
}
.tm-date {
  position: relative;
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 40px; padding: 5px 0 4px; line-height: 1.15;
  border: none; border-radius: 10px; cursor: pointer;
  background: var(--sand); border-bottom: 3px solid var(--c, #ccc);
}
.tm-has-media::after {
  content: ''; position: absolute; top: 4px; right: 5px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c, var(--coral)); box-shadow: 0 0 0 1.5px #fff;
}
.tm-date.active.tm-has-media::after { background: #fff; box-shadow: 0 0 0 1.5px var(--c, var(--coral)); }
.tm-date-wd { font-size: 10px; font-weight: 700; color: var(--mid); text-transform: uppercase; }
.tm-date-num { font-size: 16px; font-weight: 800; color: var(--ink); }
.tm-date.active { background: var(--c, var(--coral)); }
.tm-date.active .tm-date-wd, .tm-date.active .tm-date-num { color: #fff; }
.tm-date.today { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c, var(--coral)); }

/* ---------- count badges ---------- */
.tm-day-count {
  display: inline-block; margin-left: 10px; vertical-align: middle;
  font-size: 12px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.22); padding: 2px 9px; border-radius: 12px;
}
.tm-gallery-count { font-size: 12px; font-weight: 700; color: var(--mid); margin-bottom: 6px; }

/* ---------- "Latest" feed overlay ---------- */
.tm-latest { position: fixed; inset: 0; z-index: 9400; background: var(--sand); display: flex; flex-direction: column; }
.tm-latest[hidden] { display: none; }
.tm-latest-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; background: #fff; border-bottom: 1px solid var(--rule); flex-shrink: 0;
}
.tm-latest-title { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--ink); }
.tm-latest-x { background: none; border: none; font-size: 30px; line-height: 1; color: var(--mid); cursor: pointer; }
.tm-latest-grid {
  overflow-y: auto; padding: 14px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.tm-latest-empty { grid-column: 1 / -1; text-align: center; color: var(--mid); padding: 60px 20px; font-style: italic; }
.tm-latest-tile {
  border: none; background: #fff; border-radius: 12px; overflow: hidden; cursor: pointer;
  text-align: left; padding: 0; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.tm-latest-tile:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.tm-latest-media { position: relative; aspect-ratio: 1 / 1; background: #ece6df; }
.tm-latest-media img, .tm-latest-media video { width: 100%; height: 100%; object-fit: cover; }
.tm-latest-cap { padding: 8px 10px 10px; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.tm-latest-city { display: block; font-size: 11px; font-weight: 700; color: var(--coral); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }

/* ---------- cover "view the trip" button + clickable pills ---------- */
.cover-enter {
  margin-top: 36px; cursor: pointer;
  background: rgba(255,255,255,.18); color: #fff;
  border: 1.5px solid rgba(255,255,255,.5);
  padding: 14px 28px; border-radius: 40px;
  font: 700 16px 'DM Sans', sans-serif;
}
.cover-enter:hover { background: rgba(255,255,255,.3); }
.cover-pill { cursor: pointer; transition: background .15s; }
.cover-pill:hover { background: rgba(255,255,255,.32); }

/* ---------- Per-activity gallery ---------- */
.tm-gallery { margin-top: 14px; }

.tm-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
/* the first photo of a moment gets a big "feature" treatment */
.tm-gallery-grid .tm-thumb:first-child { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
@media (min-width: 640px) {
  /* compact, uniform thumbnails on desktop — click any to enlarge.
     Keeps galleries tidy even with lots of photos. */
  .tm-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
  .tm-gallery-grid .tm-thumb:first-child { grid-column: auto; grid-row: auto; aspect-ratio: 1 / 1; }
}

/* Center the whole itinerary into a readable column on large screens
   (full-width colour bands stay, but text + photos stop stretching). */
@media (min-width: 980px) {
  .city-header,
  .city-content,
  .page-footer {
    padding-left: calc((100% - 900px) / 2);
    padding-right: calc((100% - 900px) / 2);
  }
}

.tm-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #ece6df;
  cursor: pointer;
  border: none;
  padding: 0;
  display: block;
}
.tm-thumb img,
.tm-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tm-thumb .tm-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
  background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.35));
  pointer-events: none;
}
.tm-thumb .tm-uploading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
}

/* owner-only delete button on each thumbnail */
.tm-del {
  position: absolute;
  top: 4px; right: 4px;
  width: 24px; height: 24px;
  border: none; border-radius: 50%;
  background: rgba(20,20,20,.6); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; z-index: 2;
  opacity: 0; transition: opacity .12s;
}
.tm-thumb:hover .tm-del { opacity: 1; }
.tm-del:hover { background: var(--coral); }
@media (hover: none) { .tm-del { opacity: 1; } } /* always visible on touch devices */

/* "+N more" expander tile */
.tm-more { display: flex; align-items: center; justify-content: center; background: #efe9e2; }
.tm-more-label { text-align: center; font-weight: 800; color: var(--coral); font-size: 19px; line-height: 1.1; }
.tm-more-label span { display: block; font-size: 10px; font-weight: 700; color: var(--mid); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

/* show-fewer control */
.tm-gallery-foot { margin-top: 8px; }
.tm-showless { background: none; border: none; color: var(--mid); font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 0; }
.tm-showless:hover { color: var(--coral); }

.tm-gallery-empty {
  font-size: 13px;
  color: var(--pale);
  font-style: italic;
  padding: 4px 0;
}
.tm-gallery-empty .tm-camera { font-style: normal; margin-right: 4px; opacity: .7; }

/* ---------- city header cover photo ---------- */
.city-header.tm-has-cover {
  background-size: cover;
  background-position: center;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.city-header.tm-has-cover::after { display: none; }

/* ---------- reactions ---------- */
.tm-thumb-hearts {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(0,0,0,.5); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 12px;
  pointer-events: none;
}
.tm-lb-heart {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.14); color: #fff; border: none;
  padding: 11px 20px; border-radius: 30px; cursor: pointer;
  font: 700 16px 'DM Sans', sans-serif; backdrop-filter: blur(4px);
}
.tm-lb-heart:hover { background: rgba(255,255,255,.26); }
.tm-lb-heart.on { background: rgba(200,85,58,.85); }
.tm-lb-heart-ico { font-size: 18px; }

/* ---------- nav family/plan toggle ---------- */
.tm-nav-view {
  flex-shrink: 0; width: 42px; height: 46px; border: none;
  background: var(--sand); border-radius: 10px; font-size: 18px; cursor: pointer;
}
.tm-nav-view.on { background: var(--coral-light); }

/* ---------- family view: hide planning-only details ---------- */
body.tm-family .item-badge,
body.tm-family .warn-box,
body.tm-family .item-price,
body.tm-family .item-detail .highlight,
body.tm-family .item-detail .warn { display: none !important; }

/* ---------- route map ---------- */
.tm-map { background: linear-gradient(180deg, var(--sky-light), #fff); padding: 28px 20px 34px; text-align: center; }
.tm-map-title { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
.tm-map-canvas {
  height: 400px; max-width: 560px; margin: 0 auto;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  border: 1px solid var(--rule);
}
.tm-mappin-dot {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.45);
  color: #fff; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.leaflet-tooltip b { font-weight: 800; }
.tm-map-legend { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 18px auto 0; }
.tm-map-leg {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: #fff; border: 1.5px solid var(--rule); border-radius: 12px;
  cursor: pointer; text-align: left; font-family: inherit; transition: border-color .15s, background .15s;
}
.tm-map-leg:hover { border-color: var(--coral); background: var(--coral-light); }
.tm-map-num { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.tm-map-leg-txt b { display: block; font-size: 15px; color: var(--ink); }
.tm-map-leg-txt span { font-size: 12px; color: var(--mid); }

/* ---------- Floating Add Media button ---------- */
.tm-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 40px;
  background: var(--coral);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(200,85,58,.4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tm-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(200,85,58,.5); }
.tm-fab-plus { font-size: 22px; line-height: 1; font-weight: 400; }
@media (max-width: 480px) {
  .tm-fab-label { display: none; }
  .tm-fab { padding: 16px; }
  .tm-fab-plus { font-size: 26px; }
}

/* ---------- Modal ---------- */
.tm-modal { position: fixed; inset: 0; z-index: 9500; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 600px) { .tm-modal { align-items: center; } }
.tm-modal[hidden] { display: none; }
.tm-modal-backdrop { position: absolute; inset: 0; background: rgba(28,28,28,.55); backdrop-filter: blur(3px); }
.tm-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 32px;
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  animation: tm-slide-up .25s ease;
}
@media (min-width: 600px) { .tm-modal-card { border-radius: 20px; animation: tm-fade .2s ease; } }
@keyframes tm-slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes tm-fade { from { opacity: 0; } to { opacity: 1; } }

.tm-modal-x {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 28px; line-height: 1;
  color: var(--pale); cursor: pointer;
}

.tm-step-emoji { font-size: 40px; margin-bottom: 8px; }
.tm-step-title { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.tm-step-title span { color: var(--coral); }
.tm-step-sub { font-size: 14px; color: var(--mid); margin-bottom: 18px; line-height: 1.5; }

.tm-input {
  width: 100%; padding: 14px 16px; font-size: 16px; font-family: inherit;
  border: 1.5px solid var(--rule); border-radius: 10px; margin-bottom: 14px; background: var(--sand);
}
.tm-input:focus { outline: none; border-color: var(--coral); background: #fff; }

.tm-btn {
  width: 100%; padding: 15px; font-size: 16px; font-weight: 700; font-family: inherit;
  border: none; border-radius: 10px; cursor: pointer; transition: filter .15s ease;
}
.tm-btn-primary { background: var(--coral); color: #fff; }
.tm-btn-primary:hover { filter: brightness(1.05); }
.tm-error { color: var(--coral); font-size: 13px; font-weight: 600; margin-top: 10px; }

.tm-back { background: none; border: none; color: var(--mid); font-size: 14px; font-weight: 600; cursor: pointer; padding: 0; margin-bottom: 14px; }

/* City + activity choosers */
.tm-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tm-choice-city {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 16px; border: 1.5px solid var(--rule); border-radius: 12px;
  background: var(--sand); cursor: pointer; text-align: left; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.tm-choice-city:hover { border-color: var(--coral); background: var(--coral-light); }
.tm-choice-city .tm-city-emoji { font-size: 26px; }
.tm-choice-city .tm-city-name { font-weight: 700; font-size: 15px; color: var(--ink); }
.tm-choice-city .tm-city-count { font-size: 12px; color: var(--mid); }

.tm-choice-list { display: flex; flex-direction: column; gap: 8px; }
.tm-choice-activity {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 16px; border: 1.5px solid var(--rule); border-radius: 10px;
  background: var(--sand); cursor: pointer; text-align: left; font-family: inherit; width: 100%;
  transition: border-color .15s, background .15s;
}
.tm-choice-activity:hover { border-color: var(--coral); background: var(--coral-light); }
.tm-choice-activity .tm-act-title { font-weight: 600; font-size: 14px; color: var(--ink); line-height: 1.3; }
.tm-choice-activity .tm-act-day { font-size: 11px; color: var(--pale); text-transform: uppercase; letter-spacing: 1px; }
.tm-choice-activity .tm-act-count { font-size: 12px; color: var(--sage); font-weight: 700; flex-shrink: 0; }

/* Dropzone + staged previews */
.tm-dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 32px 20px; border: 2px dashed var(--rule); border-radius: 14px;
  background: var(--sand); cursor: pointer; text-align: center; margin-bottom: 16px;
  transition: border-color .15s, background .15s;
}
.tm-dropzone:hover { border-color: var(--coral); background: var(--coral-light); }
.tm-dropzone-emoji { font-size: 32px; }
.tm-dropzone-text { font-weight: 700; font-size: 15px; color: var(--ink); }
.tm-dropzone-sub { font-size: 12px; color: var(--mid); }

.tm-staged { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-bottom: 16px; }
.tm-staged:empty { display: none; }
.tm-staged-item { position: relative; aspect-ratio: 1/1; border-radius: 8px; overflow: hidden; background: #ece6df; }
.tm-staged-item img, .tm-staged-item video { width: 100%; height: 100%; object-fit: cover; }
.tm-staged-item .tm-staged-vid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.6); }

/* ---------- Lightbox ---------- */
.tm-lightbox { position: fixed; inset: 0; z-index: 9800; background: rgba(10,10,10,.95); display: flex; align-items: center; justify-content: center; }
.tm-lightbox[hidden] { display: none; }
.tm-lb-stage { max-width: 92vw; max-height: 88vh; display: flex; align-items: center; justify-content: center; }
.tm-lb-stage img, .tm-lb-stage video { max-width: 92vw; max-height: 88vh; border-radius: 6px; }
.tm-lb-x { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 38px; line-height: 1; cursor: pointer; opacity: .85; }
.tm-lb-download {
  position: absolute; top: 20px; left: 20px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 30px;
  background: rgba(255,255,255,.14); color: #fff;
  font: 700 13px 'DM Sans', sans-serif; text-decoration: none;
  backdrop-filter: blur(4px);
}
.tm-lb-download:hover { background: rgba(255,255,255,.28); }
.tm-lb-download[hidden] { display: none; }
.tm-lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: none; color: #fff; font-size: 30px; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; }
.tm-lb-prev { left: 14px; }
.tm-lb-next { right: 14px; }
.tm-lb-nav:hover { background: rgba(255,255,255,.25); }
