/*
 * Fonthill Care Home — Shared Responsive CSS
 * Loaded on every page via functions.php
 * Breakpoints:
 *   Desktop:      > 1024px  (no override needed)
 *   Tablet:       768px – 1024px
 *   Mobile:       < 768px
 *   Small mobile: < 480px
 */

/* ============================================================
   1. GLOBAL RESPONSIVE RESETS
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

img,
video,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
}

/* ============================================================
   2. TOUCH / TAP TARGETS
   Make all interactive elements comfortably tappable
   ============================================================ */
a,
button,
[role="button"],
input[type="submit"],
input[type="button"],
select {
  touch-action: manipulation;
}

/* Minimum tap target size */
button,
.btn,
input[type="submit"],
input[type="button"],
.hamburger,
.nav-cta {
  min-height: 44px;
}

/* ============================================================
   3. HEADER — FIXED / STICKY ON ALL DEVICES
   ============================================================ */
.site-header {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100%;
}

/* Header inner — prevent overflow */
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  min-height: 72px;
}

/* Logo responsive scaling */
.site-logo img {
  height: 48px;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

/* Hero / body offset — space for fixed header on all pages */
.hero,
.page-hero {
  margin-top: 72px;
}

/* ============================================================
   4. HAMBURGER MENU — TOUCH FRIENDLY
   ============================================================ */
.hamburger {
  /* Already 44×44 in page templates */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

/* Menu overlay — ensure it fills the screen properly on iOS */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   5. PHONE NUMBER — TAP TO CALL (already href="tel:", just ensure visible) 
   ============================================================ */
a[href^="tel:"] {
  white-space: nowrap;
}

/* ============================================================
   6. SECTION & CONTAINER RESPONSIVE PADDING
   ============================================================ */

/* ---- TABLET (768px – 1024px) ---- */
@media (max-width: 1024px) {
  .section {
    padding: 80px 0;
  }

  .container {
    padding: 0 32px;
  }

  .header-inner {
    padding: 0 32px;
  }
}

/* ---- MOBILE (< 768px) ---- */
@media (max-width: 767px) {
  .section {
    padding: 48px 0;
  }

  .container {
    padding: 0 20px;
  }

  .header-inner {
    padding: 0 16px;
    min-height: 64px;
  }

  .site-logo img {
    height: 40px;
  }

  /* Ensure header buttons don't crowd */
  .header-inner > div {
    gap: 12px !important;
  }

  /* Hide Enquire CTA button on very small screens to avoid overflow */
  .nav-cta {
    display: none;
  }

  /* Show phone number in header on mobile via a tap-to-call link */
  .header-phone {
    display: none !important; /* hidden, user uses menu overlay phone */
  }

  .menu-overlay-inner {
    padding: 80px 24px 40px;
  }
}

/* ---- SMALL MOBILE (< 480px) ---- */
@media (max-width: 479px) {
  .header-inner {
    padding: 0 12px;
  }

  .menu-overlay-inner {
    padding: 80px 16px 32px;
  }
}

/* ============================================================
   7. TYPOGRAPHY — FLUID SCALE FOR MOBILE
   ============================================================ */
@media (max-width: 767px) {
  body {
    font-size: 16px;
    line-height: 1.65;
  }

  h1 {
    font-size: clamp(28px, 8vw, 44px);
    line-height: 1.1;
    word-break: break-word;
  }

  h2 {
    font-size: clamp(24px, 7vw, 36px);
    line-height: 1.15;
  }

  h3 {
    font-size: clamp(20px, 5vw, 26px);
  }

  h4 {
    font-size: clamp(17px, 4vw, 22px);
  }

  p {
    margin-bottom: 14px;
  }

  .large-text {
    font-size: 17px !important;
    line-height: 1.6;
  }

  .section-narrow {
    padding: 0 4px;
  }
}

@media (max-width: 479px) {
  h1 {
    font-size: clamp(26px, 7.5vw, 36px);
  }

  h2 {
    font-size: clamp(22px, 6.5vw, 32px);
  }
}

/* ============================================================
   8. IMAGES — ALWAYS RESPONSIVE
   ============================================================ */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

.hero-background img,
.hero-background video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   9. HERO SECTIONS
   ============================================================ */
@media (max-width: 1024px) {
  .hero,
  .page-hero {
    min-height: 50vh;
  }
}

@media (max-width: 767px) {
  .hero,
  .page-hero {
    min-height: 45vh;
    margin-top: 64px;
  }

  /* Hero content padding */
  .hero-content,
  .hero-inner {
    padding: 24px 20px !important;
  }

  /* Hero subtitle */
  .hero-subtitle {
    font-size: 16px !important;
  }

  /* Hero buttons — stack vertically */
  .hero-cta {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }

  .hero-cta .btn {
    width: 100%;
    max-width: 320px;
  }
}

@media (max-width: 479px) {
  .hero,
  .page-hero {
    min-height: 40vh;
  }
}

/* ============================================================
   10. BUTTONS — FULL WIDTH ON MOBILE
   ============================================================ */
@media (max-width: 767px) {
  .btn {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    font-size: 15px;
  }

  /* Button rows stack vertically */
  .button-row,
  .contact-buttons {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }

  .contact-buttons .btn {
    width: 100%;
    max-width: 320px;
  }
}

/* ============================================================
   11. GRIDS — COLLAPSE TO 1 COLUMN ON MOBILE
   ============================================================ */

/* Auto-fit grids that use minmax — these already respond well,
   but we enforce 1-column on mobile for small min-widths */
@media (max-width: 767px) {
  /* Care / house / location cards */
  .care-grid,
  .house-grid,
  .location-grid,
  .benefits-grid,
  .outings-grid,
  .gallery-grid,
  .footer-content {
    grid-template-columns: 1fr !important;
  }

  /* Activity categories (3-col → 1-col) */
  .activity-categories {
    grid-template-columns: 1fr !important;
    gap: 28px;
  }

  /* CQC pillars (auto-fit → 2-col) */
  .cqc-pillars {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
  }

  /* About grid (2-col → 1-col) */
  .about-grid {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  /* Care service alternating (2-col → 1-col) */
  .care-service,
  .care-service.reverse {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
    direction: ltr !important;
  }

  /* Team profile (fixed 400px col → 1-col) */
  .team-profile {
    grid-template-columns: 1fr !important;
    gap: 24px;
    margin-bottom: 48px;
    padding-bottom: 48px;
  }

  .team-profile-photo {
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Details grid (2-col → 1-col) */
  .details-grid {
    grid-template-columns: 1fr !important;
    gap: 0;
  }

  /* Programme grid */
  .programme-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 479px) {
  /* CQC pillars → 1 col on tiny screens */
  .cqc-pillars {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   12. CARDS — FULL WIDTH, ADEQUATE PADDING ON MOBILE
   ============================================================ */
@media (max-width: 767px) {
  .care-card,
  .house-card,
  .day-card,
  .outing-card,
  .benefit-card,
  .contact-card,
  .location-item,
  .badge-item {
    padding: 24px 20px;
  }

  /* Role card on careers page */
  .role-card {
    padding: 28px 20px !important;
  }

  /* CTA box on careers page */
  .cta-box {
    padding: 36px 20px !important;
  }

  /* Contact form */
  .contact-form {
    padding: 28px 20px !important;
    margin: 32px 0 0;
  }
}

/* ============================================================
   13. FORMS — FULL WIDTH & TOUCH-FRIENDLY
   ============================================================ */
.form-group input,
.form-group textarea,
.form-group select,
.wpcf7-form input[type="text"],
.wpcf7-form input[type="email"],
.wpcf7-form input[type="tel"],
.wpcf7-form textarea {
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 767px) {
  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    min-height: 48px;
    padding: 12px 16px;
  }

  .form-group textarea {
    min-height: 120px;
  }

  .wpcf7-form input[type="text"],
  .wpcf7-form input[type="email"],
  .wpcf7-form input[type="tel"] {
    font-size: 16px;
    min-height: 48px;
  }

  .wpcf7-form input[type="submit"] {
    width: 100%;
    min-height: 52px;
    font-size: 16px;
  }
}

/* ============================================================
   14. FOOTER — RESPONSIVE
   ============================================================ */
@media (max-width: 767px) {
  .site-footer {
    padding: 48px 0 24px;
  }

  .footer-content {
    grid-template-columns: 1fr !important;
    gap: 32px;
    margin-bottom: 32px;
  }

  .footer-bottom {
    font-size: 13px;
    padding-top: 20px;
  }
}

/* ============================================================
   15. TABLE — HORIZONTAL SCROLL ON MOBILE
   ============================================================ */
@media (max-width: 767px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* ============================================================
   16. VIDEO / IFRAME — 16:9 RESPONSIVE CONTAINER
   ============================================================ */
.video-container,
.responsive-video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
}

.video-container iframe,
.video-container video,
.responsive-video iframe,
.responsive-video video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Map iframe */
.map-container iframe {
  width: 100%;
  display: block;
}

@media (max-width: 767px) {
  .map-container iframe {
    height: 300px !important;
  }
}

/* ============================================================
   17. BENTO GALLERY (Home page)
   ============================================================ */
@media (max-width: 1024px) {
  .bento-gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .bento-large {
    grid-column: span 2;
    grid-row: span 1;
  }

  .bento-medium,
  .bento-small {
    grid-column: span 1;
  }
}

@media (max-width: 767px) {
  .bento-gallery {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .bento-large,
  .bento-medium,
  .bento-small {
    grid-column: span 1;
    grid-row: span 1;
    aspect-ratio: 4/3;
  }
}

/* ============================================================
   18. TEAM SECTION (Home page)
   ============================================================ */

/* Team lead magazine layout */
@media (max-width: 1024px) {
  .team-lead {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
    text-align: center;
  }

  .team-lead-photo {
    width: 100%;
    max-width: 300px !important;
    height: 360px !important;
    margin: 0 auto !important;
  }

  .team-lead:nth-child(2) .team-lead-photo {
    order: 0 !important;
  }

  .team-lead:nth-child(2) .team-lead-info {
    order: 0 !important;
    text-align: left;
  }
}

@media (max-width: 767px) {
  .team-leads {
    margin-bottom: 48px !important;
  }

  .team-lead {
    padding: 32px 0 !important;
  }

  .team-lead-photo {
    max-width: 220px !important;
    height: 280px !important;
  }

  .team-lead-info h4 {
    font-size: 28px !important;
  }

  /* Team grid — scrollable strip on mobile */
  .team-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  .team-grid-wrapper {
    padding: 40px 16px !important;
  }

  .team-strip {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start !important;
    padding-bottom: 12px;
  }

  .team-member {
    scroll-snap-align: start;
    flex-shrink: 0;
    width: auto;
  }
}

@media (max-width: 479px) {
  .team-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    max-width: 100%;
    margin: 0 auto;
  }
  .team-member h4 {
    font-size: 16px !important;
  }
  .team-member .team-role {
    font-size: 11px !important;
  }
  .team-member .team-description {
    display: none !important;
  }
  .team-member-photo {
    margin-bottom: 10px !important;
  }
}

/* ============================================================
   19. LIFESTYLE FEATURE (Home page — activities)
   ============================================================ */
@media (max-width: 767px) {
  .lifestyle-feature {
    min-height: 340px;
    border-radius: 12px;
    margin-top: 28px;
  }

  .lifestyle-feature-content {
    padding: 24px 20px !important;
  }

  .lifestyle-feature-content h3 {
    font-size: 22px;
  }

  .lifestyle-feature-content p {
    font-size: 15px;
  }
}

/* ============================================================
   20. OUTINGS STRIP (Home page — horizontal scroll)
   ============================================================ */
.outings-strip {
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .outings-strip {
    padding-left: 20px;
    padding-right: 20px;
    margin-left: -20px;
    margin-right: -20px;
  }
}

/* ============================================================
   21. DINING SECTION (Home page)
   ============================================================ */
@media (max-width: 767px) {
  .dining-hero {
    min-height: 300px !important;
  }

  .dining-hero-content {
    padding: 28px 20px !important;
  }

  .dining-editorial {
    padding: 48px 20px !important;
  }

  .dining-mosaic {
    padding: 0 20px 48px !important;
  }

  .dining-mosaic-row {
    flex-direction: column !important;
  }

  .dining-photo-large,
  .dining-photo-tall,
  .dining-photo-equal {
    width: 100% !important;
    height: 240px !important;
  }

  .dining-footer {
    padding: 0 20px 48px !important;
  }
}

/* ============================================================
   22. LOCATION SECTION (Home page)
   ============================================================ */
@media (max-width: 767px) {
  .location-hero {
    min-height: 320px !important;
  }

  .location-hero-content {
    padding: 32px 20px !important;
  }

  .location-hero h2 {
    font-size: clamp(28px, 7vw, 40px) !important;
  }

  .location-editorial {
    padding: 40px 20px !important;
  }

  .location-landmarks {
    flex-direction: column !important;
    gap: 16px !important;
    padding: 0 20px 32px !important;
    align-items: flex-start !important;
  }

  .location-landmark {
    border-right: none !important;
    padding: 0 !important;
    width: 100%;
    text-align: left;
  }

  .location-footer {
    padding: 0 20px 48px !important;
  }
}

/* ============================================================
   23. GALLERY GRID (Home, Activities pages)
   ============================================================ */
@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 767px) {
  .gallery-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

/* ============================================================
   24. CONTACT CTA SECTION (Home page)
   ============================================================ */
@media (max-width: 767px) {
  .contact-cta-section {
    min-height: 360px;
    padding: 48px 20px;
  }

  .contact-content {
    padding: 0 8px;
  }

  .contact-phone {
    font-size: clamp(24px, 6vw, 32px);
    margin-bottom: 24px;
  }
}

/* ============================================================
   25. INTRO QUOTE / CQC SECTION (Home page)
   ============================================================ */
@media (max-width: 767px) {
  .intro-quote {
    font-size: clamp(22px, 5.5vw, 32px);
    padding: 0 4px;
  }

  .cqc-badge {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 16px 20px;
  }

  .cqc-badge-icon {
    font-size: 28px;
  }
}

/* ============================================================
   26. BADGES GRID (About page)
   ============================================================ */
@media (max-width: 767px) {
  .badges-grid {
    gap: 32px !important;
    flex-direction: column;
    align-items: center;
  }

  .badge-item img {
    height: 72px;
    width: auto;
  }
}

/* ============================================================
   27. FACILITY SECTION (Inside Our House page)
   ============================================================ */
@media (max-width: 767px) {
  .facility {
    margin-bottom: 60px !important;
  }

  .facility-image {
    border-radius: 12px;
  }

  .facility-image img {
    max-height: 260px;
  }
}

/* ============================================================
   28. TESTIMONIAL SECTION
   ============================================================ */
@media (max-width: 767px) {
  .testimonial-quote {
    font-size: clamp(18px, 5vw, 26px) !important;
  }

  .testimonial-card {
    padding: 28px 20px !important;
  }

  .testimonial-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .testimonial-text {
    font-size: 18px !important;
  }
}

/* ============================================================
   29. PREVENT HORIZONTAL OVERFLOW — GLOBAL SAFETY NET
   ============================================================ */
@media (max-width: 767px) {
  /* Anything with a fixed width wider than viewport could cause overflow */
  .hero-inner {
    max-width: 100% !important;
    width: 100%;
  }

  /* CQC section inner */
  .cqc-section,
  .cqc-content {
    overflow: hidden;
  }

  /* Section narrow — full width on small screens */
  .section-narrow {
    max-width: 100%;
    padding: 0 4px;
  }

  /* Ensure no absolute positioned items bleed out */
  section,
  .section {
    overflow: hidden;
  }

  /* Gallery & bento items — no hover transforms on mobile (prevents layout shift) */
  .gallery-item:hover,
  .bento-item:hover,
  .care-card:hover,
  .house-card:hover,
  .day-card:hover {
    transform: none;
  }
}

/* ============================================================
   30. MENU OVERLAY — MOBILE TYPOGRAPHY
   ============================================================ */
@media (max-width: 767px) {
  .menu-item-link {
    font-size: clamp(28px, 8vw, 40px) !important;
    padding: 16px 0 !important;
  }

  .submenu li a {
    font-size: 16px !important;
    padding: 10px 0 10px 20px !important;
  }

  .menu-contact {
    margin-top: 32px !important;
    padding-top: 24px !important;
  }

  .menu-contact p {
    font-size: 14px !important;
  }
}

/* ============================================================
   31. PRINT — BASIC PRINT STYLES
   ============================================================ */
@media print {
  .site-header,
  .hamburger,
  .menu-overlay,
  .site-footer {
    display: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
  }

  .hero,
  .page-hero {
    min-height: auto;
  }
}

/* ============================================================
   32. ACCESSIBILITY — REDUCED MOTION RESPECT
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
