/* Travel Blog Stylesheet */
/* encoding: utf-8 */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
  overflow-x: hidden;
}

/* ============================================
   HEADER SECTION
   ============================================ */

/* Owner-only quick links (drop / edit), shown when logged in as the owner */
.owner-bar {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.owner-bar .owner-link {
  color: #fff;
  background: rgba(255,255,255,0.18);
  text-decoration: none;
  font-size: 0.78em;
  padding: 3px 10px;
  border-radius: 12px;
}

.owner-bar .owner-link:hover {
  background: rgba(255,255,255,0.32);
}

.blog-header {
  position: relative;
  background: linear-gradient(135deg, #1a5276 0%, #2980b9 50%, #5dade2 100%);
  color: white;
  padding: 8px 0;
  margin: 0;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.blog-header h1 .date-range {
  font-size: 0.5em;
  font-weight: 300;
  opacity: 0.85;
  margin-right: 10px;
  display: inline-block;
}

.blog-header h1 {
  margin: 0;
  font-size: 2em;
  font-weight: 300;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  word-wrap: break-word;
}

.blog-header h1 .subtitle {
  font-size: 0.5em;
  font-weight: 300;
  opacity: 0.85;
  margin-left: 10px;
  display: inline-block;
}


.header-wrapper {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 15px;
}

/* ============================================
   MAP SECTION
   ============================================ */

.map-container {
  position: relative;
  width: 100%;
  height: 300px;
  margin: 0;
  padding: 0;
}

#map {
  width: 100%;
  height: 100%;
}

/* ============================================
   POSTS SECTION
   ============================================ */

.posts-container {
  max-width: 1200px;
  margin: 0 auto;
  /* With viewport-fit=cover, keep text clear of the notch in landscape. */
  padding: 15px max(15px, env(safe-area-inset-right)) 15px max(15px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

body.posts-reversed .posts-container {
  flex-direction: column-reverse;
}

.post {
  position: relative;
  background: white;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
}

.post-header {
  background: linear-gradient(to right, #ecf0f1, #f8f9fa);
  padding: 6px 15px;
  border-bottom: 1px solid #e0e0e0;
}

.post-header h2 {
  margin: 0 0 2px 0;
  font-size: 1.3em;
  font-weight: 500;
  color: #2c3e50;
  word-wrap: break-word;
}

.post-header h2 .post-date {
  font-size: 0.6em;
  font-weight: 400;
  color: #7f8c8d;
  margin-left: 10px;
}

.post-header .post-meta {
  font-size: 0.85em;
  color: #7f8c8d;
}

.post-header .post-meta .day-number {
  font-weight: 600;
  color: #3498db;
}

.post-header .post-meta .stats {
  display: block;
  margin-top: 3px;
}

.edit-link {
  position: absolute;
  top: 6px;
  right: 12px;
  z-index: 2;
  padding: 1px 8px;
  color: #c0392b;
  text-decoration: none;
  font-size: 0.8em;
  text-transform: uppercase;
}

.edit-link:hover {
  text-decoration: underline;
}

/* Photo Grid */
.post-photos {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  -webkit-touch-callout: none;
}

.photo-thumb:active {
  opacity: 0.8;
}

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

.thumb-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.75em;
  padding: 4px 6px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}

body.show-captions .thumb-caption {
  display: block;
}

/* ============================================
   OWNER-TOGGLED DISPLAY FEATURES
   ============================================ */

/* Pinterest / masonry photo layout (feat_pinterest): JS lays photos into the
   shortest column (balanced bottoms, natural reading order). */
body.feat-pinterest .photo-thumb { aspect-ratio: auto; }
body.feat-pinterest .photo-thumb img { height: auto; }
.post-photos.pin-laid {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.post-photos.pin-laid .pin-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Trip stats dashboard (feat_stats): hidden unless enabled. Single compact
   row — stats centered, date range pushed to the right in the small font. */
.trip-stats { display: none; }
body.feat-stats .trip-stats {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #1a5276 0%, #2980b9 60%, #5dade2 100%);
  color: #fff;
  padding: 7px 15px;
}
.trip-stats .ts-grid {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
}
.trip-stats .ts-item { min-width: 56px; text-align: center; }
.trip-stats .ts-num { display: block; font-size: 1.25em; font-weight: 700; line-height: 1.15; }
.trip-stats .ts-label { font-size: 0.62em; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.85; }
.trip-stats .ts-range {
  flex: 0 0 auto;
  padding-left: 14px;
  font-size: 0.78em;
  opacity: 0.9;
  white-space: nowrap;
}

/* Day markers with photo thumbnails (feat_day_markers): circular map avatars */
.day-marker {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #fff;
  background: #2980b9;
  box-shadow: 0 1px 5px rgba(0,0,0,0.45);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.day-marker img { width: 100%; height: 100%; object-fit: cover; display: block; }
.day-marker:hover { transform: scale(1.18); z-index: 5; }

/* Type pairing (feat_typography): a characterful serif for titles, sans body */
body.feat-typography .blog-header h1,
body.feat-typography .post-header h2 {
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Per-post track panel: a Strava-style map + elevation that opens right above
   the post's photos. Only one is ever open across the whole blog. */
.post-track {
  position: relative;
  margin: 0 0 14px;
  border: 1px solid #e6e6e6;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.post-track-map {
  position: relative;
  width: 100%;
  height: 340px;
}

/* Strava-style elevation chart: gray profile, ft on the left, mi along the
   bottom, and a live hover (cursor line + dot + stats) synced to a map marker. */
.ride-elev-chart {
  position: relative;
  width: 100%;
  background: #fff;
  border-top: 1px solid #eee;
}
.ride-elev-chart .ree-plot {
  position: relative;
  width: 100%;
  height: 92px;
}
.ride-elev-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}
.ride-elev-chart .ree-y {
  position: absolute;
  left: 6px;
  font-size: 10px;
  color: #9aa0a6;
  pointer-events: none;
}
.ride-elev-chart .ree-y-top { top: 3px; }
.ride-elev-chart .ree-y-bot { bottom: 3px; }
.ride-elev-chart .ree-x {
  position: relative;
  height: 16px;
  font-size: 10px;
  color: #9aa0a6;
}
.ride-elev-chart .ree-xl {
  position: absolute;
  top: 1px;
  transform: translateX(-50%);
  white-space: nowrap;
}
.ride-elev-chart .ree-xl:first-child { transform: none; }
.ride-elev-chart .ree-cursor {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(0,0,0,0.4); pointer-events: none;
}
.ride-elev-chart .ree-dot {
  position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: #2979ff; border: 2px solid #fff;
  box-shadow: 0 0 2px rgba(0,0,0,0.5); pointer-events: none;
}
.ride-elev-chart .ree-tip {
  position: absolute; top: 4px; background: rgba(20,20,20,0.92); color: #fff;
  font-size: 11px; line-height: 1.35; padding: 4px 8px; border-radius: 4px;
  white-space: nowrap; pointer-events: none;
}
.ride-elev-chart .ree-tip b { font-weight: 600; }

/* "Close Track" — overlaid on the map upper-right, shown while a track is open */
.track-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  background: rgba(255,255,255,0.95);
  color: #333;
  font-size: 0.82em;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.track-close:hover { background: #fff; }

.view-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 15px;
  padding: 4px 15px;
  font-size: 0.8em;
  color: #666;
}

.view-controls label {
  cursor: pointer;
}

.view-controls input[type="checkbox"] {
  margin-right: 4px;
  vertical-align: middle;
}

.view-controls select {
  padding: 2px 6px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: white;
}

/* Post Text */
.post-text {
  padding: 15px;
  font-size: 1em;
  line-height: 1.7;
}

.post-text p {
  margin: 0 0 1em 0;
}

.post-text p:last-child {
  margin-bottom: 0;
}

.post-text pre {
  background: #f8f8f0;
  padding: 15px 20px;
  margin: 15px 0;
  border-radius: 4px;
  border-left: 4px solid #3498db;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  overflow-x: auto;
  font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
  font-size: 0.85em;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #444;
}

.post-text code {
  background: #f4f4f4;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.post-text a {
  color: #2980b9;
  text-decoration: none;
}

.post-text a:hover {
  text-decoration: underline;
}

/* Rich-text content (from the post editor) */
.post-text h2 { font-size: 1.4em; margin: 0.8em 0 0.3em; line-height: 1.25; }
.post-text h3 { font-size: 1.2em; margin: 0.8em 0 0.3em; line-height: 1.25; }
.post-text h2:first-child, .post-text h3:first-child { margin-top: 0; }
.post-text ul, .post-text ol { margin: 0 0 1em; padding-left: 1.6em; }
.post-text li { margin: 0.2em 0; }
.post-text blockquote {
  margin: 0 0 1em;
  padding: 4px 0 4px 14px;
  border-left: 3px solid #ccc;
  color: #555;
}

/* RWGPS Embed */
.rwgps-embed {
  display: none;
  padding: 10px 15px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  width: 100%;
  box-sizing: border-box;
}

.post.show-embed .rwgps-embed {
  display: block;
}

.rwgps-scale-wrapper {
  width: 100%;
  height: 350px;
  overflow: hidden;
  position: relative;
}

.rwgps-scale-wrapper iframe {
  width: 100%;
  height: 500px;
  border: none;
  transform: scale(1);
  transform-origin: 0 0;
}

.rwgps-embed iframe {
  display: block;
}

/* Comments Footer */
.post-footer {
  background: #d6eaf8;
  padding: 8px 15px;
  border-top: 1px solid #aed6f1;
  font-size: 0.9em;
  color: #333;
}

.post-footer .footer-info {
  color: #333;
}

.post-footer .comments-link {
  color: #922;
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}

.post-footer .comments-link:hover {
  text-decoration: underline;
}

/* Comments Section */
.comments-section {
  padding: 6px 15px;
  background: #d6eaf8;
  border-top: 1px solid #aed6f1;
  font-size: 0.8em;
}

.comment {
  margin-bottom: 4px;
  line-height: 1.4;
}

.comment:last-child {
  margin-bottom: 0;
}

.comment strong {
  font-weight: 700;
  color: #2c3e50;
}

.comment-reply {
  margin-left: 20px;
  margin-top: 4px;
  color: #555;
}

.comment-reply .reply-author {
  color: #666;
  font-weight: 400;
}

/* ============================================
   LIGHTBOX / GALLERY
   ============================================ */

/* Mobile-first: the lightbox takes over the whole screen (portrait & landscape).
   Action buttons (like/comment/share) overlay the photo; comments slide up. */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #000;
  z-index: 1000;
  display: none;
  flex-direction: column;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  /* Border + dark fill so the button is visible on a bright photo AND on the
     black letterbox bars (where a plain dark circle would vanish). */
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  font-size: 1.8em;
  line-height: 1;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 1005;
  border-radius: 50%;
}

.lightbox-nav:active { background: rgba(255,255,255,0.3); }
/* Keep arrows clear of the notch / curved corners. max() so they clear it even
   when a browser reports a 0 inset (Safari/Chrome differ in landscape). */
.lightbox-nav.prev { left: max(6px, env(safe-area-inset-left, 0px)); }
.lightbox-nav.next { right: max(6px, env(safe-area-inset-right, 0px)); }

.lightbox-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  background: rgba(0,0,0,0.45);
  border: none;
  color: white;
  font-size: 1.5em;
  line-height: 1;
  cursor: pointer;
  padding: 6px 12px;
  z-index: 1006;
  border-radius: 4px;
}

.lightbox-close:active { background: rgba(255,255,255,0.3); }

/* Panel: overlaid on the photo (mobile). Actions always visible; comments
   live in a sheet that expands when 'comment' is tapped (panel-open). */
.lightbox-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1001;
  color: #fff;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 55%, rgba(0,0,0,0));
}

.lightbox-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: transparent;
}

.lb-action {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: none;
  color: #fff;
  font-size: 0.95em;
  padding: 10px 6px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.lb-action:active { background: rgba(255,255,255,0.2); }
.lb-like.liked, .lb-like.liked .lb-heart { color: #ff4d6d; }
.lb-heart { font-size: 1.15em; }

.lightbox-scroll {
  max-height: 0;
  overflow: hidden;
  background: rgba(0,0,0,0.92);
  transition: max-height 0.25s ease;
  padding: 0 14px;
}

.lightbox-overlay.panel-open .lightbox-scroll {
  max-height: 55vh;
  overflow-y: auto;
  padding: 8px 14px 14px;
}

/* While reading/adding comments, hide the prev/next arrows so they don't sit
   under the comments panel. Close the comments (back to photo) to navigate. */
/* !important to beat the inline style.display the JS sets for multi-photo nav. */
.lightbox-overlay.panel-open .lightbox-nav { display: none !important; }

.lightbox-caption {
  color: #fff;
  font-size: 0.95em;
  padding: 8px 14px 4px;
  word-wrap: break-word;
}

/* 'Back to photo' button — only when the comments sheet is open (mobile/landscape) */
.lb-sheet-close {
  display: none;
  background: rgba(255,255,255,0.16);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 7px 14px;
  font-size: 0.9em;
  cursor: pointer;
  margin: 2px 0 10px;
}
.lightbox-overlay.panel-open .lb-sheet-close { display: inline-block; }

.lb-meta { font-size: 0.8em; padding-bottom: 6px; }
.lightbox-counter { color: rgba(255,255,255,0.6); }
.lightbox-fullpic { color: rgba(255,255,255,0.6); text-decoration: none; margin-left: 8px; }
.lightbox-fullpic:hover { color: #fff; }

.lb-likers { font-size: 0.85em; color: #ddd; padding: 4px 0 8px; }
.lb-heart-sm { color: #ff4d6d; }

.lb-comments { display: flex; flex-direction: column; gap: 7px; }
.lb-comment-row { font-size: 0.9em; color: #eee; line-height: 1.35; }
.lb-comment-row strong { color: #fff; margin-right: 4px; }

.lb-addcomment {
  display: flex;
  gap: 6px;
  padding: 10px 0 4px;
  position: sticky;
  bottom: 0;
  background: rgba(0,0,0,0.92);
}

.lb-comment-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 16px;
  padding: 8px 12px;
  font-family: inherit; /* same system stack on every OS, not the form default */
  font-size: 16px;      /* 16px keeps iOS from zooming the page on focus */
}

.lb-comment-input::placeholder { color: rgba(255,255,255,0.5); }

.lb-comment-send {
  background: #e67e22;
  border: none;
  color: #fff;
  border-radius: 16px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9em;
}

/* ============================================
   COMMENT POPUP
   ============================================ */

.comment-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 15px;
}

.comment-popup-overlay.active {
  display: flex;
}

.comment-popup {
  background: white;
  padding: 20px;
  border-radius: 8px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.comment-popup h3 {
  margin: 0 0 15px 0;
  color: #2c3e50;
  font-size: 1.2em;
}

.comment-popup label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #555;
}

.comment-popup input,
.comment-popup textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px; /* Prevents iOS zoom */
  margin-bottom: 15px;
  font-family: inherit;
  -webkit-appearance: none;
}

.comment-popup textarea {
  min-height: 100px;
  resize: vertical;
}

.comment-popup .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.comment-popup button {
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}

.comment-popup .btn-cancel {
  background: #ecf0f1;
  color: #555;
}

.comment-popup .btn-submit {
  background: #3498db;
  color: white;
}

/* ============================================
   FULL BLOG BUTTON
   ============================================ */

.full-blog-container {
  text-align: center;
  padding: 20px;
}

.full-blog-btn {
  display: inline-block;
  padding: 15px 30px;
  background: #3498db;
  color: white;
  text-decoration: none;
  border-radius: 30px;
  font-size: 1em;
}

.full-blog-btn:active {
  background: #2980b9;
}

/* ============================================
   NO POSTS MESSAGE
   ============================================ */

.no-posts {
  text-align: center;
  padding: 40px 20px;
  color: #7f8c8d;
  font-size: 1.1em;
}

.no-posts p {
  margin: 0;
}

/* ============================================
   DESKTOP STYLES
   ============================================ */

@media (min-width: 768px) {
  .blog-header {
    padding: 8px 0;
  }

  .blog-header h1 {
    font-size: 2.5em;
  }

  .map-container {
    height: 400px;
  }

  .posts-container {
    padding: 20px;
  }

  .post {
    margin-bottom: 30px;
  }

  .post-header {
    padding: 15px 20px;
  }

  .post-header h2 {
    font-size: 1.5em;
  }

  .post-header .post-meta .stats {
    display: inline;
    margin-left: 10px;
    margin-top: 0;
  }

  .post-photos {
    padding: 15px;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }

  .photo-thumb:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }

  .post-text {
    padding: 20px;
    font-size: 1.05em;
  }

  .lightbox-nav {
    font-size: 2.2em;
    width: 52px;
    height: 52px;
  }
}

/* Wide screens (desktop / tablet / wide landscape): the photo still takes over
   the whole window. The like/comment/share bar stays overlaid on the photo, and
   the comments open as a right-side panel ONLY when 'comment' is clicked — so
   nothing covers the photo by default. */
@media (min-width: 768px) {
  /* notch-safe even on wide landscape phones (max() keeps a desktop-friendly
     18px when there's no inset). */
  .lightbox-nav.prev { left: max(18px, env(safe-area-inset-left, 0px)); }
  .lightbox-nav.next { right: max(18px, env(safe-area-inset-right, 0px)); }

  .lightbox-close {
    top: 16px;
    right: max(16px, env(safe-area-inset-right, 0px));
    font-size: 1.7em;
  }

  .lightbox-nav:hover,
  .lightbox-close:hover {
    background: rgba(0,0,0,0.7);
  }

  .lb-action:hover {
    background: rgba(255,255,255,0.12);
  }

  /* Keep the action bar compact and centered on the photo (not full width). */
  .lightbox-actions {
    max-width: 460px;
    margin: 0 auto;
  }

  /* Comments slide in from the right when opened. */
  .lightbox-overlay.panel-open .lightbox-scroll {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-height: none;
    height: 100%;
    padding: 60px 20px 20px;
    background: rgba(0,0,0,0.94);
    box-shadow: -4px 0 24px rgba(0,0,0,0.6);
  }

  /* Keep the bottom action bar to the left of the open comments panel. */
  .lightbox-overlay.panel-open .lightbox-panel { right: 360px; }
}

/* Landscape phones: comments open as a right-side sheet so they don't bury the
   (short) photo. Placed AFTER the min-width:768 block so its notch-safe arrow
   insets win on wide landscape phones (which match both queries). */
@media (orientation: landscape) and (max-height: 600px) {
  .lightbox-overlay.panel-open .lightbox-scroll {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 82vw);
    max-height: none;
    height: 100%;
    padding: 52px 14px 14px;
    background: rgba(0,0,0,0.94);
    box-shadow: -4px 0 24px rgba(0,0,0,0.6);
  }
  .lightbox-actions { max-width: 560px; margin: 0 auto; }

  /* The notch/Dynamic Island sits on one side in landscape. Inset the arrows
     enough to clear it on whichever side it is, regardless of whether the
     browser reports a safe-area inset (Safari/Chrome differ here). */
  .lightbox-nav.prev { left: max(50px, env(safe-area-inset-left, 0px)); }
  .lightbox-nav.next { right: max(50px, env(safe-area-inset-right, 0px)); }
  .lightbox-close { right: max(50px, env(safe-area-inset-right, 0px)); }
  /* Keep the bottom action bar to the left of the open comments sheet. */
  .lightbox-overlay.panel-open .lightbox-panel { right: min(380px, 82vw); }
}

/* ============================================
   VERY SMALL SCREENS
   ============================================ */

@media (max-width: 374px) {
  .blog-header h1 {
    font-size: 1.5em;
  }

  .blog-header h1 .subtitle {
    display: block;
    margin-left: 0;
    margin-top: 5px;
  }

  .post-photos {
    grid-template-columns: repeat(2, 1fr);
  }
}
