/* =========================================================
   Treflyn Barn — COMPAT v2.2
   Mobile + all browsers (Safari, Chrome, Firefox, Edge, iOS)
   Never hide images
   ========================================================= */

/* —— Box model & overflow guards —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h, 90px) + 12px);
  scroll-padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.treflyn-barn-theme,
body.tb-front {
  overflow-x: hidden !important;
  max-width: 100vw;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* iOS rubber-band safe */
  overscroll-behavior-x: none;
}

body.treflyn-barn-theme *,
body.treflyn-barn-theme *::before,
body.treflyn-barn-theme *::after {
  box-sizing: border-box;
}

/* Images always paint */
body.treflyn-barn-theme img {
  max-width: 100%;
  height: auto;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Cover media exceptions (hero/gallery) keep forced size from wp-fix */
body.treflyn-barn-theme .hero-slide img {
  max-width: none;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

body.treflyn-barn-theme .gallery-item img,
body.treflyn-barn-theme .sleep-img img,
body.treflyn-barn-theme .loc-photo img,
body.treflyn-barn-theme .film-card img,
body.treflyn-barn-theme .about-images img {
  max-width: none;
}

/* —— Viewport height: classic + modern —— */
body.treflyn-barn-theme .hero {
  min-height: 100vh !important;
  min-height: 100svh !important;
  min-height: 100dvh !important;
}

body.treflyn-barn-theme .site-header .nav-links {
  /* drawer height fallbacks */
  height: 100vh;
  height: 100dvh;
}

/* —— Safe areas (iPhone notch / home indicator) —— */
@supports (padding: max(0px)) {
  body.treflyn-barn-theme .site-header .tb-nav-bar,
  body.treflyn-barn-theme .site-header .nav {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }

  body.treflyn-barn-theme .mobile-book-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.treflyn-barn-theme .back-top {
    right: max(1rem, env(safe-area-inset-right)) !important;
    bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + 1rem)) !important;
  }

  @media (max-width: 900px) {
    body.treflyn-barn-theme .back-top {
      bottom: max(
        1rem,
        calc(var(--mobile-bar-h, 74px) + env(safe-area-inset-bottom) + 0.75rem)
      ) !important;
    }
  }

  body.treflyn-barn-theme .desk-book-bar {
    bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* —— Touch targets —— */
body.treflyn-barn-theme .btn,
body.treflyn-barn-theme .nav-toggle,
body.treflyn-barn-theme .hero-arrow,
body.treflyn-barn-theme .back-top,
body.treflyn-barn-theme .rf-nav,
body.treflyn-barn-theme .book-step,
body.treflyn-barn-theme .gallery-filters button,
body.treflyn-barn-theme .faq-q {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(201, 166, 107, 0.2);
}

body.treflyn-barn-theme .nav-toggle {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* —— Forms: prevent iOS zoom on focus —— */
body.treflyn-barn-theme input,
body.treflyn-barn-theme select,
body.treflyn-barn-theme textarea {
  font-size: 16px !important;
  max-width: 100%;
}

body.treflyn-barn-theme input[type="date"] {
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

/* —— Backdrop-filter fallback (Firefox older / low power) —— */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.treflyn-barn-theme .site-header.scrolled {
    background: rgba(250, 247, 242, 0.98) !important;
  }
  body.treflyn-barn-theme .hero-card {
    background: rgba(15, 28, 22, 0.88) !important;
  }
  body.treflyn-barn-theme .desk-book-bar-inner {
    background: rgba(8, 14, 11, 0.96) !important;
  }
}

/* —— Hide desktop-only chrome on touch / small —— */
@media (max-width: 1179px) {
  body.treflyn-barn-theme .section-rail,
  body.treflyn-barn-theme .desk-book-bar,
  body.treflyn-barn-theme .hero-side-label,
  body.treflyn-barn-theme .hero-frame,
  body.treflyn-barn-theme .ambient-orbs,
  body.treflyn-barn-theme .sig-cursor,
  body.treflyn-barn-theme .sig-cursor-dot,
  body.treflyn-barn-theme .cursor-glow {
    display: none !important;
  }

  html.tb-signature.sig-cursor-on body.tb-front,
  html.tb-signature.sig-cursor-on body.tb-front * {
    cursor: auto !important;
  }
}

@media (hover: none), (pointer: coarse) {
  body.treflyn-barn-theme .sig-cursor,
  body.treflyn-barn-theme .sig-cursor-dot,
  body.treflyn-barn-theme .cursor-glow,
  body.treflyn-barn-theme .ambient-orbs {
    display: none !important;
  }

  html.sig-cursor-on body,
  html.sig-cursor-on body * {
    cursor: auto !important;
  }

  /* Touch: no hover-only captions */
  body.treflyn-barn-theme .gallery-caption {
    opacity: 1 !important;
    transform: none !important;
  }

  body.treflyn-barn-theme .gallery-zoom {
    opacity: 0.92 !important;
  }

  /* Kill sticky hover transforms on touch */
  body.treflyn-barn-theme .btn-magnetic {
    transform: none !important;
  }
}

/* =========================================================
   MOBILE LAYOUT (< 900px)
   ========================================================= */
@media (max-width: 900px) {
  body.treflyn-barn-theme {
    --nav-h: 72px;
    --mobile-bar-h: 78px;
  }

  body.treflyn-barn-theme .container,
  body.treflyn-barn-theme .hero-inner {
    width: min(100% - 1.5rem, var(--max, 1180px)) !important;
  }

  /* Hero stack */
  body.treflyn-barn-theme .hero {
    align-items: flex-end !important;
    padding: calc(var(--nav-h) + 1rem) 0 4.5rem !important;
    min-height: 100svh !important;
  }

  body.treflyn-barn-theme .hero-inner {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  body.treflyn-barn-theme .hero h1 {
    font-size: clamp(2.15rem, 9.5vw, 2.85rem) !important;
    line-height: 1.05 !important;
  }

  body.treflyn-barn-theme .hero .lead {
    font-size: 0.95rem !important;
    max-width: none !important;
  }

  body.treflyn-barn-theme .hero-actions {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  body.treflyn-barn-theme .hero-actions .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  body.treflyn-barn-theme .hero-card {
    max-width: none !important;
    width: 100% !important;
  }

  body.treflyn-barn-theme .hero-scroll-cue {
    display: none !important; /* overlaps mobile UI */
  }

  body.treflyn-barn-theme .hero-rotator {
    min-height: 1.4em;
    font-size: 0.85rem;
  }

  /* Stats */
  body.treflyn-barn-theme .stats-band-inner {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.85rem 0.5rem !important;
    padding: 1.1rem 1rem !important;
  }

  body.treflyn-barn-theme .stat-cell:nth-child(2)::after {
    display: none !important;
  }

  /* Promise */
  body.treflyn-barn-theme .promise-grid {
    grid-template-columns: 1fr !important;
    margin-top: 0 !important;
  }

  body.treflyn-barn-theme .promise-card {
    border-right: none !important;
    border-bottom: 1px solid var(--line, rgba(15, 28, 22, 0.09)) !important;
  }

  /* Checklist */
  body.treflyn-barn-theme .stay-checklist-inner {
    grid-template-columns: 1fr !important;
    padding: 1.25rem !important;
  }

  body.treflyn-barn-theme .check-grid {
    grid-template-columns: 1fr !important;
  }

  /* About / location / booking single column */
  body.treflyn-barn-theme .about-grid,
  body.treflyn-barn-theme .location-grid,
  body.treflyn-barn-theme .booking-wrap {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Gallery 2-col */
  body.treflyn-barn-theme .gallery-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  body.treflyn-barn-theme .gallery-item:nth-child(1) {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
    aspect-ratio: 16 / 10;
    min-height: 0 !important;
  }

  body.treflyn-barn-theme .gallery-filters {
    gap: 0.4rem !important;
    margin-bottom: 1.15rem !important;
  }

  body.treflyn-barn-theme .gallery-filters button {
    font-size: 0.68rem !important;
    padding: 0.5rem 0.75rem !important;
  }

  /* Sleep / exp / reviews */
  body.treflyn-barn-theme .sleep-grid,
  body.treflyn-barn-theme .exp-grid,
  body.treflyn-barn-theme .reviews-grid,
  body.treflyn-barn-theme .reviews-grid-quotes {
    grid-template-columns: 1fr !important;
  }

  body.treflyn-barn-theme .amenity-cats,
  body.treflyn-barn-theme .rules-grid-4,
  body.treflyn-barn-theme .rules-grid,
  body.treflyn-barn-theme .season-grid {
    grid-template-columns: 1fr !important;
  }

  /* Day timeline vertical only */
  body.treflyn-barn-theme .day-timeline {
    grid-template-columns: 1fr !important;
  }

  body.treflyn-barn-theme .day-timeline::before {
    display: none !important;
  }

  body.treflyn-barn-theme .day-timeline li {
    grid-template-columns: 3.25rem 0.85rem 1fr !important;
    text-align: left !important;
    justify-items: start !important;
  }

  /* Book reasons */
  body.treflyn-barn-theme .book-reasons {
    grid-template-columns: 1fr !important;
  }

  /* Book steps */
  body.treflyn-barn-theme .book-steps {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.treflyn-barn-theme .book-step {
    font-size: 0.65rem !important;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 0;
  }

  body.treflyn-barn-theme .book-wizard .book-panel:not([hidden]) {
    grid-template-columns: 1fr !important;
  }

  body.treflyn-barn-theme .wizard-nav {
    flex-direction: column;
  }

  body.treflyn-barn-theme .wizard-nav .btn {
    width: 100%;
  }

  /* Reviews carousel */
  body.treflyn-barn-theme .reviews-featured {
    padding: 0 2.5rem !important;
  }

  body.treflyn-barn-theme .rf-nav {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.2rem !important;
  }

  /* Filmstrip */
  body.treflyn-barn-theme .filmstrip {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    gap: 0.75rem !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  body.treflyn-barn-theme .film-card {
    flex: 0 0 min(78vw, 300px) !important;
  }

  body.treflyn-barn-theme .film-card img {
    height: 200px !important;
  }

  /* Atmosphere marquee not too tall */
  body.treflyn-barn-theme .atmosphere-strip {
    padding: 0.85rem 0 !important;
  }

  /* Footer */
  body.treflyn-barn-theme .footer-top,
  body.treflyn-barn-theme .footer-cols {
    grid-template-columns: 1fr !important;
  }

  body.treflyn-barn-theme .footer-bottom {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }

  /* Space for sticky mobile bar */
  body.treflyn-barn-theme .site-footer {
    padding-bottom: calc(var(--mobile-bar-h, 78px) + env(safe-area-inset-bottom, 0px) + 1.5rem) !important;
  }

  /* Mobile book bar */
  body.treflyn-barn-theme .mobile-book-bar {
    display: block !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 110 !important;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  body.treflyn-barn-theme .mobile-book-bar-inner {
    min-height: 64px;
    align-items: center;
  }

  body.treflyn-barn-theme .mobile-book-bar .btn {
    min-height: 44px;
    white-space: nowrap;
  }

  /* Trust bar */
  body.treflyn-barn-theme .trust-bar-inner {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem 0.75rem !important;
  }

  body.treflyn-barn-theme .tb-div {
    display: none !important;
  }

  /* Location photos */
  body.treflyn-barn-theme .location-photos {
    grid-template-columns: 1fr 1fr !important;
  }

  body.treflyn-barn-theme .loc-photo-main {
    grid-column: 1 / -1 !important;
  }

  body.treflyn-barn-theme .location-map {
    height: 220px !important;
    min-height: 220px !important;
  }

  /* Lightbox mobile */
  body.treflyn-barn-theme .lightbox img {
    max-width: 94vw !important;
    max-height: 62vh !important;
  }

  body.treflyn-barn-theme .lightbox-thumbs {
    bottom: 3.5rem !important;
    max-width: 94vw !important;
  }

  body.treflyn-barn-theme .lightbox-meta {
    bottom: 5.5rem !important;
    max-width: 90vw !important;
  }

  body.treflyn-barn-theme .lightbox-nav {
    width: 40px !important;
    height: 40px !important;
  }

  /* Hide section ornaments that eat space */
  body.treflyn-barn-theme .page-loader {
    /* keep */
  }

  /* Host card stack */
  body.treflyn-barn-theme .host-card {
    flex-direction: column !important;
    text-align: center;
    align-items: center !important;
  }

  body.treflyn-barn-theme .host-badges {
    justify-content: center;
  }
}

/* Extra-small phones */
@media (max-width: 380px) {
  body.treflyn-barn-theme .hero h1 {
    font-size: 2rem !important;
  }

  body.treflyn-barn-theme .hero-meta span:nth-child(n + 3) {
    display: none;
  }

  body.treflyn-barn-theme .stats-band-inner {
    padding: 0.9rem 0.65rem !important;
  }

  body.treflyn-barn-theme .stat-value {
    font-size: 1.65rem !important;
  }
}

/* Tablet landscape */
@media (min-width: 901px) and (max-width: 1100px) {
  body.treflyn-barn-theme .hero-inner {
    grid-template-columns: 1fr !important;
  }

  body.treflyn-barn-theme .promise-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  body.treflyn-barn-theme .reviews-grid-quotes {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* —— Sticky header solid enough on iOS Safari —— */
body.treflyn-barn-theme .site-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 10030 !important;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Nav toggle always above drawer */
body.treflyn-barn-theme .nav-toggle {
  position: relative;
  z-index: 10060 !important;
}

/* —— Reduce motion: show everything —— */
@media (prefers-reduced-motion: reduce) {
  body.treflyn-barn-theme .reveal,
  body.treflyn-barn-theme .reveal:not(.visible) {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    clip-path: none !important;
  }

  body.treflyn-barn-theme .page-loader {
    display: none !important;
  }

  body.treflyn-barn-theme .hero-slide.active img,
  body.treflyn-barn-theme .atmosphere-track,
  body.treflyn-barn-theme .topics-track {
    animation: none !important;
  }
}

/* —— Print: hide chrome —— */
@media print {
  body.treflyn-barn-theme .site-header,
  body.treflyn-barn-theme .mobile-book-bar,
  body.treflyn-barn-theme .desk-book-bar,
  body.treflyn-barn-theme .back-top,
  body.treflyn-barn-theme .section-rail,
  body.treflyn-barn-theme .page-loader,
  body.treflyn-barn-theme .scroll-progress {
    display: none !important;
  }
}

/* —— High contrast / forced colors —— */
@media (forced-colors: active) {
  body.treflyn-barn-theme .btn,
  body.treflyn-barn-theme .back-top,
  body.treflyn-barn-theme .gallery-item {
    border: 1px solid ButtonText;
  }
}

/* —— Fix iframe embeds (maps) —— */
body.treflyn-barn-theme .location-map iframe,
body.treflyn-barn-theme iframe {
  max-width: 100%;
  border: 0;
}

/* —— Prevent filmstrip / marquee from expanding page width —— */
body.treflyn-barn-theme .filmstrip-section,
body.treflyn-barn-theme .atmosphere-strip,
body.treflyn-barn-theme .topics-marquee {
  max-width: 100vw;
  overflow: hidden;
}

body.treflyn-barn-theme .filmstrip {
  max-width: 100vw;
}

/* —— Focus visible for keyboard (all browsers) —— */
body.treflyn-barn-theme :focus {
  outline: none;
}

body.treflyn-barn-theme :focus-visible {
  outline: 2px solid #c9a66b;
  outline-offset: 3px;
}

/* —— Utility: never leave reveal content invisible if JS delayed —— */
body.treflyn-barn-theme.tb-compat-ready .reveal {
  opacity: 1;
  transform: none;
  filter: none;
}
