/**
 * Haven Theme - Mobile Responsive Styles
 *
 * Mobile-first responsive design styles for all screen sizes.
 * Breakpoints follow modern mobile-first approach.
 *
 * Breakpoints:
 * - xs: 0-639px (mobile)
 * - sm: 640px-767px (large mobile)
 * - md: 768px-1023px (tablet)
 * - lg: 1024px-1279px (desktop)
 * - xl: 1280px+ (large desktop)
 *
 * @package Haven_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   Mobile Base Styles (0-639px)
   ========================================================================== */

/* Typography adjustments for mobile */
@media (max-width: 639px) {
	:root {
		--haven-font-size-base: 14px;
		--haven-spacing-xs: 0.375rem;
		--haven-spacing-sm: 0.75rem;
		--haven-spacing-md: 1rem;
		--haven-spacing-lg: 1.5rem;
		--haven-spacing-xl: 2rem;
		--haven-spacing-xxl: 2.5rem;
	}

	body {
		font-size: 14px;
	}

	h1 { font-size: 1.75rem; }
	h2 { font-size: 1.5rem; }
	h3 { font-size: 1.25rem; }
	h4 { font-size: 1.125rem; }
	h5 { font-size: 1rem; }
	h6 { font-size: 0.9375rem; }

	.haven-section-title {
		font-size: 1.75rem;
		margin-bottom: var(--haven-spacing-lg);
	}

	.haven-hero__title {
		font-size: 2rem;
	}

	.haven-hero__subtitle {
		font-size: 1.125rem;
	}
}

/* Container adjustments */
@media (max-width: 639px) {
	.haven-container {
		padding-left: var(--haven-spacing-sm);
		padding-right: var(--haven-spacing-sm);
	}

	.haven-section {
		padding: var(--haven-spacing-xl) 0;
	}
}

/* Property Grid - Single column on mobile */
@media (max-width: 639px) {
	.haven-property-grid {
		grid-template-columns: 1fr;
		gap: var(--haven-spacing-md);
	}

	.haven-property-card__image {
		height: 200px;
	}

	.haven-property-card__content {
		padding: var(--haven-spacing-sm);
	}

	.haven-property-card__title {
		font-size: 1.125rem;
	}

	.haven-property-card__price {
		font-size: 1.25rem;
	}

	.haven-property-card__meta {
		flex-wrap: wrap;
		gap: var(--haven-spacing-sm);
	}
}

/* Buttons on mobile */
@media (max-width: 639px) {
	.haven-btn,
	.haven-button {
		padding: 0.625rem 1.25rem;
		font-size: 0.9375rem;
	}

	.haven-btn--large {
		padding: 0.875rem 1.5rem;
		font-size: 1rem;
	}

	.haven-btn--small {
		padding: 0.5rem 0.875rem;
		font-size: 0.875rem;
	}

	/* Make buttons full-width on mobile for better touch targets */
	.haven-btn--block,
	.haven-search-submit .haven-btn {
		width: 100%;
		display: block;
	}
}

/* Forms on mobile */
@media (max-width: 639px) {
	.haven-form-field input,
	.haven-form-field textarea,
	.haven-form-field select,
	.haven-search-field input,
	.haven-search-field select {
		font-size: 16px; /* Prevents zoom on iOS */
		padding: 0.625rem 0.875rem;
	}

	.haven-property-search-form {
		padding: var(--haven-spacing-md);
	}
}

/* Navigation - Mobile Menu */
@media (max-width: 1023px) {
	.haven-nav {
		position: fixed;
		top: 0;
		right: -100%;
		width: 280px;
		height: 100vh;
		background: #FFFFFF;
		box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
		padding: var(--haven-spacing-xl) var(--haven-spacing-lg);
		flex-direction: column;
		align-items: flex-start;
		gap: var(--haven-spacing-md);
		transition: right var(--haven-transition-base);
		z-index: 9999;
		overflow-y: auto;
	}

	.haven-nav.is-active {
		right: 0;
	}

	.haven-nav a {
		width: 100%;
		padding: var(--haven-spacing-sm) 0;
		border-bottom: 1px solid var(--haven-color-border);
	}

	.haven-nav a::after {
		display: none;
	}

	/* Mobile menu toggle button */
	.haven-mobile-menu-toggle {
		display: block;
		background: none;
		border: none;
		padding: var(--haven-spacing-xs);
		cursor: pointer;
		z-index: 10000;
	}

	.haven-mobile-menu-toggle span {
		display: block;
		width: 25px;
		height: 2px;
		background-color: var(--haven-color-text);
		margin: 5px 0;
		transition: all var(--haven-transition-fast);
	}

	.haven-mobile-menu-toggle.is-active span:nth-child(1) {
		transform: rotate(45deg) translate(5px, 5px);
	}

	.haven-mobile-menu-toggle.is-active span:nth-child(2) {
		opacity: 0;
	}

	.haven-mobile-menu-toggle.is-active span:nth-child(3) {
		transform: rotate(-45deg) translate(7px, -6px);
	}

	/* Overlay for mobile menu */
	.haven-mobile-menu-overlay {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		opacity: 0;
		visibility: hidden;
		transition: all var(--haven-transition-base);
		z-index: 9998;
	}

	.haven-mobile-menu-overlay.is-active {
		opacity: 1;
		visibility: visible;
	}
}

@media (min-width: 1024px) {
	.haven-mobile-menu-toggle,
	.haven-mobile-menu-overlay {
		display: none;
	}
}

/* Header adjustments for mobile */
@media (max-width: 639px) {
	.site-header {
		padding: var(--haven-spacing-sm) 0;
	}

	.site-branding img {
		max-height: 40px;
	}
}

/* Hero section on mobile */
@media (max-width: 639px) {
	.haven-hero {
		min-height: 400px;
	}

	.haven-hero__content {
		padding: var(--haven-spacing-lg);
	}
}

/* Footer adjustments */
@media (max-width: 767px) {
	.site-footer {
		padding: var(--haven-spacing-xl) 0 var(--haven-spacing-md);
	}

	.footer-widgets {
		grid-template-columns: 1fr;
		gap: var(--haven-spacing-lg);
	}
}

/* Testimonials on mobile */
@media (max-width: 639px) {
	.haven-testimonial {
		padding: var(--haven-spacing-md);
	}

	.haven-testimonial__content {
		font-size: 1rem;
	}
}

/* ==========================================================================
   Tablet Styles (640px-1023px)
   ========================================================================== */

@media (min-width: 640px) and (max-width: 1023px) {
	:root {
		--haven-font-size-base: 15px;
	}

	.haven-property-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: var(--haven-spacing-md);
	}

	.haven-container {
		padding-left: var(--haven-spacing-md);
		padding-right: var(--haven-spacing-md);
	}

	h1 { font-size: 2rem; }
	h2 { font-size: 1.75rem; }
	h3 { font-size: 1.5rem; }

	.haven-section-title {
		font-size: 2rem;
	}

	.haven-hero__title {
		font-size: 2.5rem;
	}

	.haven-hero__subtitle {
		font-size: 1.25rem;
	}
}

/* ==========================================================================
   Desktop Styles (1024px+)
   ========================================================================== */

@media (min-width: 1024px) {
	.haven-property-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	/* Hover effects only on desktop */
	.haven-property-card {
		transition: all var(--haven-transition-base);
	}

	.haven-property-card:hover {
		transform: translateY(-5px);
	}
}

/* ==========================================================================
   Large Desktop (1280px+)
   ========================================================================== */

@media (min-width: 1280px) {
	.haven-property-grid--four-columns {
		grid-template-columns: repeat(4, 1fr);
	}

	.haven-container {
		padding-left: var(--haven-spacing-lg);
		padding-right: var(--haven-spacing-lg);
	}
}

/* ==========================================================================
   Extra Large Desktop (1536px+)
   ========================================================================== */

@media (min-width: 1536px) {
	.haven-section {
		padding: 5rem 0;
	}

	.haven-hero {
		min-height: 600px;
	}

	.haven-hero__title {
		font-size: 4rem;
	}

	.haven-hero__subtitle {
		font-size: 1.75rem;
	}
}

/* ==========================================================================
   Touch Device Optimizations
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
	/* Increase touch targets for better mobile UX */
	.haven-btn,
	.haven-button,
	.haven-nav a,
	a {
		min-height: 44px;
		min-width: 44px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	/* Remove hover effects on touch devices */
	.haven-property-card:hover {
		transform: none;
		box-shadow: var(--haven-shadow-sm);
	}

	.haven-btn:hover,
	.haven-button:hover {
		transform: none;
	}

	/* Always show property card overlays on touch */
	.haven-property-card__overlay {
		opacity: 0;
	}
}

/* ==========================================================================
   Landscape Mobile Optimizations
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
	.haven-hero {
		min-height: 300px;
	}

	.haven-hero__content {
		padding: var(--haven-spacing-md);
	}

	.haven-hero__title {
		font-size: 1.5rem;
		margin-bottom: var(--haven-spacing-sm);
	}

	.haven-hero__subtitle {
		font-size: 1rem;
		margin-bottom: var(--haven-spacing-md);
	}
}

/* ==========================================================================
   Print Optimizations
   ========================================================================== */

@media print {
	.haven-nav,
	.haven-mobile-menu-toggle,
	.haven-mobile-menu-overlay,
	.site-header,
	.site-footer,
	.haven-btn,
	.haven-button {
		display: none !important;
	}

	.haven-property-card {
		page-break-inside: avoid;
		box-shadow: none;
		border: 1px solid #E5E7EB;
	}

	.haven-section {
		padding: 1rem 0;
	}

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

	a {
		text-decoration: underline;
	}

	.haven-property-card__image {
		height: auto;
		max-height: 200px;
	}
}

/* ==========================================================================
   Reduced Motion Support (Accessibility)
   ========================================================================== */

@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;
	}

	.haven-property-card:hover {
		transform: none;
	}

	.haven-btn:hover,
	.haven-button:hover {
		transform: none;
	}
}

/* ==========================================================================
   High Contrast Mode Support (Accessibility)
   ========================================================================== */

@media (prefers-contrast: high) {
	:root {
		--haven-color-border: #000000;
	}

	.haven-property-card,
	.haven-btn,
	.haven-button,
	.haven-form-field input,
	.haven-form-field textarea,
	.haven-form-field select {
		border: 2px solid #000000;
	}

	.haven-btn--primary,
	.haven-button--primary {
		background-color: #000000;
		color: #FFFFFF;
	}
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
	/* Only apply if theme doesn't override with customizer */
	body:not(.has-custom-colors) {
		--haven-color-background: #1F2937;
		--haven-color-text: #E5E7EB;
		--haven-color-heading: #F9FAFB;
		--haven-color-border: #374151;
	}

	body:not(.has-custom-colors) .haven-property-card,
	body:not(.has-custom-colors) .haven-testimonial,
	body:not(.has-custom-colors) .haven-property-search-form {
		background-color: #374151;
		color: #E5E7EB;
	}

	body:not(.has-custom-colors) .haven-form-field input,
	body:not(.has-custom-colors) .haven-form-field textarea,
	body:not(.has-custom-colors) .haven-form-field select,
	body:not(.has-custom-colors) .haven-search-field input,
	body:not(.has-custom-colors) .haven-search-field select {
		background-color: #1F2937;
		color: #E5E7EB;
		border-color: #4B5563;
	}
}

/* ==========================================================================
   Flexible Layout Utilities
   ========================================================================== */

/* Stack elements vertically on mobile */
@media (max-width: 767px) {
	.haven-flex-stack-mobile {
		flex-direction: column !important;
	}

	.haven-hide-mobile {
		display: none !important;
	}

	.haven-show-mobile {
		display: block !important;
	}
}

/* Hide elements on desktop */
@media (min-width: 768px) {
	.haven-hide-desktop {
		display: none !important;
	}

	.haven-show-desktop {
		display: block !important;
	}
}

/* ==========================================================================
   Specific Component Responsive Adjustments
   ========================================================================== */

/* Search form responsive layout */
@media (max-width: 767px) {
	.haven-property-search-form {
		display: flex;
		flex-direction: column;
		gap: var(--haven-spacing-sm);
	}

	.haven-search-field {
		margin-bottom: 0;
	}
}

@media (min-width: 768px) {
	.haven-property-search-form {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
		gap: var(--haven-spacing-md);
		align-items: end;
	}

	.haven-search-submit {
		margin-top: 0;
	}
}

/* Property meta responsive */
@media (max-width: 480px) {
	.haven-property-card__meta {
		font-size: 0.8125rem;
	}

	.haven-property-card__meta-item svg {
		width: 16px;
		height: 16px;
	}
}

/* Image gallery responsive */
@media (max-width: 767px) {
	.haven-gallery {
		grid-template-columns: 1fr;
	}
}

@media (min-width: 768px) and (max-width: 1023px) {
	.haven-gallery {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 1024px) {
	.haven-gallery {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* Widget areas responsive */
@media (max-width: 767px) {
	.widget-area {
		margin-top: var(--haven-spacing-lg);
	}
}

@media (min-width: 768px) {
	.content-area {
		flex: 1;
	}

	.widget-area {
		width: 320px;
		flex-shrink: 0;
	}
}
