update
@@ -0,0 +1,545 @@
|
||||
/* ============================================================
|
||||
FLOOR IT HARDWOOD FLOORS — Design System
|
||||
main.css: variables, reset, typography, layout, utilities
|
||||
============================================================ */
|
||||
|
||||
/* --- Custom Properties ------------------------------------ */
|
||||
:root {
|
||||
/* Color palette — warm wood tones, no gradients */
|
||||
--ink: #0c0805;
|
||||
--charcoal: #1c1208;
|
||||
--bark: #2e1d0a;
|
||||
--bark-mid: #3d2710;
|
||||
--amber: #c88b2a;
|
||||
--amber-dark: #a87220;
|
||||
--amber-light: #e8aa48;
|
||||
--parchment: #f5f0e8;
|
||||
--cream: #faf8f5;
|
||||
--grain: #ede5d8;
|
||||
--smoke: #7a6a56;
|
||||
--ash: #b8a898;
|
||||
--white: #ffffff;
|
||||
|
||||
/* Semantic aliases */
|
||||
--bg-dark: var(--ink);
|
||||
--bg-dark-alt: var(--charcoal);
|
||||
--bg-mid-dark: var(--bark);
|
||||
--bg-light: var(--cream);
|
||||
--bg-light-alt: var(--parchment);
|
||||
--bg-warm: var(--grain);
|
||||
|
||||
--text-on-dark: #f0e8da;
|
||||
--text-muted-dark:var(--ash);
|
||||
--text-on-light: var(--charcoal);
|
||||
--text-muted-light:var(--smoke);
|
||||
|
||||
--cta: var(--amber);
|
||||
--cta-hover: var(--amber-dark);
|
||||
--cta-text: var(--ink);
|
||||
|
||||
--border-dark: rgba(255,255,255,0.08);
|
||||
--border-light: rgba(0,0,0,0.08);
|
||||
|
||||
/* Typography */
|
||||
--font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
--font-display: 'Inter', Georgia, serif;
|
||||
|
||||
/* Scale */
|
||||
--text-xs: 0.75rem;
|
||||
--text-sm: 0.875rem;
|
||||
--text-base: 1rem;
|
||||
--text-md: 1.125rem;
|
||||
--text-lg: 1.25rem;
|
||||
--text-xl: 1.5rem;
|
||||
--text-2xl: 2rem;
|
||||
--text-3xl: 2.5rem;
|
||||
--text-4xl: 3.25rem;
|
||||
--text-5xl: 4.25rem;
|
||||
--text-6xl: 5.5rem;
|
||||
|
||||
/* Spacing */
|
||||
--space-1: 0.25rem;
|
||||
--space-2: 0.5rem;
|
||||
--space-3: 0.75rem;
|
||||
--space-4: 1rem;
|
||||
--space-5: 1.25rem;
|
||||
--space-6: 1.5rem;
|
||||
--space-8: 2rem;
|
||||
--space-10: 2.5rem;
|
||||
--space-12: 3rem;
|
||||
--space-16: 4rem;
|
||||
--space-20: 5rem;
|
||||
--space-24: 6rem;
|
||||
--space-32: 8rem;
|
||||
|
||||
/* Section rhythm */
|
||||
--section-py: clamp(4rem, 8vw, 8rem);
|
||||
--section-py-sm: clamp(2.5rem, 5vw, 5rem);
|
||||
|
||||
/* Layout */
|
||||
--container-max: 1200px;
|
||||
--container-wide: 1380px;
|
||||
--container-px: clamp(1.25rem, 5vw, 2.5rem);
|
||||
|
||||
/* Effects */
|
||||
--radius-sm: 4px;
|
||||
--radius: 8px;
|
||||
--radius-lg: 16px;
|
||||
--radius-xl: 24px;
|
||||
--radius-full: 9999px;
|
||||
|
||||
--shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
|
||||
--shadow: 0 4px 16px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08);
|
||||
--shadow-lg: 0 12px 40px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.10);
|
||||
--shadow-xl: 0 24px 64px rgba(0,0,0,0.22);
|
||||
|
||||
--transition: 0.25s ease;
|
||||
--transition-slow: 0.5s ease;
|
||||
|
||||
/* Header height */
|
||||
--header-h: 72px;
|
||||
}
|
||||
|
||||
/* --- Reset ------------------------------------------------ */
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-base);
|
||||
line-height: 1.65;
|
||||
color: var(--text-on-light);
|
||||
background: var(--bg-light);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
img, video, svg {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
ul, ol { list-style: none; }
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
input, textarea, select {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
/* --- Typography ------------------------------------------- */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 800;
|
||||
line-height: 1.15;
|
||||
letter-spacing: -0.02em;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl)); }
|
||||
h2 { font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl)); }
|
||||
h3 { font-size: clamp(var(--text-xl), 2.5vw, var(--text-2xl)); }
|
||||
h4 { font-size: var(--text-lg); font-weight: 700; }
|
||||
h5 { font-size: var(--text-base); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
|
||||
h6 { font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
|
||||
|
||||
p { max-width: 68ch; }
|
||||
|
||||
.lead {
|
||||
font-size: var(--text-md);
|
||||
line-height: 1.7;
|
||||
color: var(--text-muted-light);
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
display: inline-block;
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--amber);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
/* --- Layout ----------------------------------------------- */
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: var(--container-max);
|
||||
margin-inline: auto;
|
||||
padding-inline: var(--container-px);
|
||||
}
|
||||
|
||||
.container--wide {
|
||||
max-width: var(--container-wide);
|
||||
}
|
||||
|
||||
.section {
|
||||
padding-block: var(--section-py);
|
||||
}
|
||||
|
||||
.section--sm {
|
||||
padding-block: var(--section-py-sm);
|
||||
}
|
||||
|
||||
.section--dark { background: var(--bg-dark); color: var(--text-on-dark); }
|
||||
.section--mid { background: var(--bg-dark-alt); color: var(--text-on-dark); }
|
||||
.section--bark { background: var(--bg-mid-dark); color: var(--text-on-dark); }
|
||||
.section--light { background: var(--bg-light); color: var(--text-on-light); }
|
||||
.section--alt { background: var(--bg-light-alt); color: var(--text-on-light); }
|
||||
.section--warm { background: var(--bg-warm); color: var(--text-on-light); }
|
||||
|
||||
/* Grid */
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: var(--space-8);
|
||||
}
|
||||
|
||||
.grid--2 { grid-template-columns: repeat(2, 1fr); }
|
||||
.grid--3 { grid-template-columns: repeat(3, 1fr); }
|
||||
.grid--4 { grid-template-columns: repeat(4, 1fr); }
|
||||
|
||||
.grid--auto-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
|
||||
.grid--auto-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
|
||||
.grid--auto-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
|
||||
|
||||
/* Flex */
|
||||
.flex { display: flex; }
|
||||
.flex--center { align-items: center; justify-content: center; }
|
||||
.flex--between { align-items: center; justify-content: space-between; }
|
||||
.flex--gap-4 { gap: var(--space-4); }
|
||||
.flex--gap-6 { gap: var(--space-6); }
|
||||
.flex--gap-8 { gap: var(--space-8); }
|
||||
|
||||
/* Section header */
|
||||
.section-header {
|
||||
margin-bottom: clamp(2.5rem, 5vw, 4rem);
|
||||
}
|
||||
.section-header--center {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.section-header p {
|
||||
margin-top: var(--space-4);
|
||||
font-size: var(--text-md);
|
||||
color: var(--text-muted-light);
|
||||
}
|
||||
.section--dark .section-header p,
|
||||
.section--mid .section-header p,
|
||||
.section--bark .section-header p { color: var(--text-muted-dark); }
|
||||
.section--dark .lead,
|
||||
.section--mid .lead,
|
||||
.section--bark .lead { color: var(--text-muted-dark); }
|
||||
|
||||
/* --- Buttons --------------------------------------------- */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-2);
|
||||
padding: 0.875rem 2rem;
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
border-radius: var(--radius);
|
||||
border: 2px solid transparent;
|
||||
transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.btn:hover { transform: translateY(-1px); }
|
||||
.btn:active { transform: translateY(0); }
|
||||
|
||||
.btn--primary {
|
||||
background: var(--amber);
|
||||
color: var(--ink);
|
||||
border-color: var(--amber);
|
||||
}
|
||||
.btn--primary:hover {
|
||||
background: var(--amber-light);
|
||||
border-color: var(--amber-light);
|
||||
box-shadow: 0 6px 24px rgba(200, 139, 42, 0.35);
|
||||
}
|
||||
|
||||
.btn--outline-light {
|
||||
background: transparent;
|
||||
color: var(--text-on-dark);
|
||||
border-color: rgba(255,255,255,0.35);
|
||||
}
|
||||
.btn--outline-light:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
border-color: rgba(255,255,255,0.7);
|
||||
}
|
||||
|
||||
.btn--outline-dark {
|
||||
background: transparent;
|
||||
color: var(--text-on-light);
|
||||
border-color: var(--bark-mid);
|
||||
}
|
||||
.btn--outline-dark:hover {
|
||||
background: var(--bark-mid);
|
||||
color: var(--text-on-dark);
|
||||
}
|
||||
|
||||
.btn--ghost {
|
||||
background: transparent;
|
||||
color: var(--amber);
|
||||
border-color: var(--amber);
|
||||
}
|
||||
.btn--ghost:hover {
|
||||
background: var(--amber);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.btn--lg { padding: 1.1rem 2.5rem; font-size: var(--text-base); }
|
||||
.btn--sm { padding: 0.625rem 1.25rem; font-size: var(--text-xs); }
|
||||
.btn--full { width: 100%; }
|
||||
|
||||
/* CTA group */
|
||||
.cta-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-4);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* --- Forms ----------------------------------------------- */
|
||||
.form-grid {
|
||||
display: grid;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.form-field label {
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
color: var(--text-on-light);
|
||||
}
|
||||
|
||||
.form-field input,
|
||||
.form-field textarea,
|
||||
.form-field select {
|
||||
width: 100%;
|
||||
padding: 0.875rem 1rem;
|
||||
background: var(--white);
|
||||
border: 1.5px solid var(--border-light);
|
||||
border-radius: var(--radius);
|
||||
font-size: var(--text-base);
|
||||
color: var(--text-on-light);
|
||||
transition: border-color var(--transition), box-shadow var(--transition);
|
||||
outline: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.form-field input:focus,
|
||||
.form-field textarea:focus,
|
||||
.form-field select:focus {
|
||||
border-color: var(--amber);
|
||||
box-shadow: 0 0 0 3px rgba(200,139,42,0.15);
|
||||
}
|
||||
|
||||
.form-field input.valid { border-color: #2d9e57; }
|
||||
.form-field input.invalid { border-color: #c0392b; }
|
||||
|
||||
.form-field textarea {
|
||||
min-height: 130px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.form-field select {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237a6a56' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 1rem center;
|
||||
padding-right: 2.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.form-field .hint {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--smoke);
|
||||
}
|
||||
|
||||
.form-field .err-msg {
|
||||
font-size: var(--text-xs);
|
||||
color: #c0392b;
|
||||
display: none;
|
||||
}
|
||||
.form-field.has-error .err-msg { display: block; }
|
||||
|
||||
.form-trust {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3) var(--space-6);
|
||||
padding: var(--space-4) 0;
|
||||
border-top: 1px solid var(--border-light);
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
.form-trust-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 600;
|
||||
color: var(--smoke);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.form-trust-item::before {
|
||||
content: '';
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background: var(--amber);
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%230c0805' stroke='none' d='M10 3L5 8.5 2 5.5'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 10px;
|
||||
}
|
||||
|
||||
.form-status {
|
||||
padding: var(--space-4) var(--space-5);
|
||||
border-radius: var(--radius);
|
||||
font-weight: 600;
|
||||
font-size: var(--text-sm);
|
||||
display: none;
|
||||
}
|
||||
.form-status--success { background: #d4edda; color: #155724; display: block; }
|
||||
.form-status--error { background: #f8d7da; color: #721c24; display: block; }
|
||||
|
||||
/* --- Cards ----------------------------------------------- */
|
||||
.card {
|
||||
background: var(--white);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-light);
|
||||
transition: transform var(--transition), box-shadow var(--transition);
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.card--dark {
|
||||
background: var(--charcoal);
|
||||
border-color: var(--border-dark);
|
||||
color: var(--text-on-dark);
|
||||
}
|
||||
|
||||
/* --- Scroll Animations ----------------------------------- */
|
||||
[data-animate] {
|
||||
opacity: 0;
|
||||
transition: opacity 0.7s ease, transform 0.7s ease;
|
||||
}
|
||||
[data-animate="up"] { transform: translateY(40px); }
|
||||
[data-animate="left"] { transform: translateX(-40px); }
|
||||
[data-animate="right"] { transform: translateX(40px); }
|
||||
[data-animate="scale"] { transform: scale(0.92); }
|
||||
[data-animate="fade"] { transform: none; }
|
||||
|
||||
[data-animate].in-view {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
[data-delay="1"] { transition-delay: 0.1s; }
|
||||
[data-delay="2"] { transition-delay: 0.2s; }
|
||||
[data-delay="3"] { transition-delay: 0.3s; }
|
||||
[data-delay="4"] { transition-delay: 0.4s; }
|
||||
[data-delay="5"] { transition-delay: 0.5s; }
|
||||
[data-delay="6"] { transition-delay: 0.6s; }
|
||||
|
||||
/* --- Utility Classes ------------------------------------- */
|
||||
.text-center { text-align: center; }
|
||||
.text-amber { color: var(--amber); }
|
||||
.text-muted { color: var(--smoke); }
|
||||
.text-sm { font-size: var(--text-sm); }
|
||||
.text-lg { font-size: var(--text-lg); }
|
||||
|
||||
.mt-4 { margin-top: var(--space-4); }
|
||||
.mt-6 { margin-top: var(--space-6); }
|
||||
.mt-8 { margin-top: var(--space-8); }
|
||||
.mt-12 { margin-top: var(--space-12); }
|
||||
.mt-16 { margin-top: var(--space-16); }
|
||||
|
||||
.mb-4 { margin-bottom: var(--space-4); }
|
||||
.mb-6 { margin-bottom: var(--space-6); }
|
||||
.mb-8 { margin-bottom: var(--space-8); }
|
||||
|
||||
.w-full { width: 100%; }
|
||||
.block { display: block; }
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip: rect(0,0,0,0);
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* --- Dividers -------------------------------------------- */
|
||||
.divider {
|
||||
width: 60px;
|
||||
height: 3px;
|
||||
background: var(--amber);
|
||||
border-radius: var(--radius-full);
|
||||
margin-bottom: var(--space-6);
|
||||
}
|
||||
.section--dark .divider,
|
||||
.section--mid .divider,
|
||||
.section--bark .divider { background: var(--amber); }
|
||||
|
||||
/* --- Responsive ------------------------------------------ */
|
||||
@media (max-width: 1024px) {
|
||||
.grid--4 { grid-template-columns: repeat(2, 1fr); }
|
||||
.grid--3 { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.grid--2,
|
||||
.grid--3,
|
||||
.grid--4 { grid-template-columns: 1fr; }
|
||||
|
||||
.cta-group { justify-content: center; }
|
||||
.cta-group .btn { min-width: 220px; }
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
:root { --section-py: clamp(3rem, 8vw, 4rem); }
|
||||
p { max-width: 100%; }
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,84 @@
|
||||
/* ============================================================
|
||||
components.js — Component loader + header/footer init
|
||||
Loads shared HTML components, initializes sticky header,
|
||||
mobile nav, and active link state.
|
||||
============================================================ */
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* --- Component Loader ----------------------------------- */
|
||||
async function loadComponent(targetId, url) {
|
||||
const el = document.getElementById(targetId);
|
||||
if (!el) return;
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(res.status);
|
||||
const html = await res.text();
|
||||
el.innerHTML = html;
|
||||
} catch (err) {
|
||||
console.warn('[components.js] Could not load', url, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Active nav link ------------------------------------ */
|
||||
function markActiveNav() {
|
||||
const path = window.location.pathname.replace(/\/$/, '') || '/';
|
||||
document.querySelectorAll('.header-nav a, .mobile-nav-links a').forEach(a => {
|
||||
const href = a.getAttribute('href').replace(/\/$/, '') || '/';
|
||||
if (path === href || (href !== '/' && path.startsWith(href))) {
|
||||
a.classList.add('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* --- Sticky header -------------------------------------- */
|
||||
function initStickyHeader() {
|
||||
const header = document.querySelector('.site-header');
|
||||
if (!header) return;
|
||||
|
||||
const toggle = () => {
|
||||
header.classList.toggle('scrolled', window.scrollY > 60);
|
||||
};
|
||||
toggle();
|
||||
window.addEventListener('scroll', toggle, { passive: true });
|
||||
}
|
||||
|
||||
/* --- Mobile nav ---------------------------------------- */
|
||||
function initMobileNav() {
|
||||
const btn = document.querySelector('.header-menu-btn');
|
||||
const nav = document.querySelector('.mobile-nav');
|
||||
const overlay = document.querySelector('.mobile-nav-overlay');
|
||||
const close = document.querySelector('.mobile-nav-close');
|
||||
if (!btn || !nav) return;
|
||||
|
||||
const open = () => { nav.classList.add('open'); btn.classList.add('open'); document.body.style.overflow = 'hidden'; };
|
||||
const shut = () => { nav.classList.remove('open'); btn.classList.remove('open'); document.body.style.overflow = ''; };
|
||||
|
||||
btn.addEventListener('click', open);
|
||||
if (overlay) overlay.addEventListener('click', shut);
|
||||
if (close) close.addEventListener('click', shut);
|
||||
|
||||
document.addEventListener('keydown', e => { if (e.key === 'Escape') shut(); });
|
||||
}
|
||||
|
||||
/* --- Init on DOM ready ---------------------------------- */
|
||||
async function init() {
|
||||
const base = document.querySelector('meta[name="site-root"]')?.content || '/';
|
||||
|
||||
await Promise.all([
|
||||
loadComponent('site-header', base + 'components/header.html'),
|
||||
loadComponent('site-footer', base + 'components/footer.html'),
|
||||
]);
|
||||
|
||||
initStickyHeader();
|
||||
initMobileNav();
|
||||
markActiveNav();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,207 @@
|
||||
/* ============================================================
|
||||
form.js — Estimate form validation + submission
|
||||
Real-time validation, phone formatting, reCAPTCHA v3 hook
|
||||
============================================================ */
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const PHONE = /^\(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}$/;
|
||||
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
const RECAPTCHA_SITE_KEY = '6LdqrB8rAAAAAOrBCYmtk43IzemkiK_Fb2EYU5q2';
|
||||
|
||||
/* --- Helpers -------------------------------------------- */
|
||||
function field(el) {
|
||||
return el.closest('.form-field');
|
||||
}
|
||||
|
||||
function setValid(el) {
|
||||
const f = field(el);
|
||||
if (!f) return;
|
||||
f.classList.remove('has-error');
|
||||
el.classList.add('valid');
|
||||
el.classList.remove('invalid');
|
||||
}
|
||||
|
||||
function setInvalid(el, msg) {
|
||||
const f = field(el);
|
||||
if (!f) return;
|
||||
f.classList.add('has-error');
|
||||
el.classList.add('invalid');
|
||||
el.classList.remove('valid');
|
||||
const errEl = f.querySelector('.err-msg');
|
||||
if (errEl && msg) errEl.textContent = msg;
|
||||
}
|
||||
|
||||
function clearState(el) {
|
||||
const f = field(el);
|
||||
if (!f) return;
|
||||
f.classList.remove('has-error');
|
||||
el.classList.remove('valid', 'invalid');
|
||||
}
|
||||
|
||||
/* --- Phone formatter ------------------------------------ */
|
||||
function formatPhone(raw) {
|
||||
const digits = raw.replace(/\D/g, '').slice(0, 10);
|
||||
if (digits.length < 4) return digits;
|
||||
if (digits.length < 7) return '(' + digits.slice(0,3) + ') ' + digits.slice(3);
|
||||
return '(' + digits.slice(0,3) + ') ' + digits.slice(3,6) + '-' + digits.slice(6);
|
||||
}
|
||||
|
||||
/* --- Validators ----------------------------------------- */
|
||||
function validateRequired(el) {
|
||||
if (!el.value.trim()) {
|
||||
setInvalid(el, 'This field is required.');
|
||||
return false;
|
||||
}
|
||||
setValid(el);
|
||||
return true;
|
||||
}
|
||||
|
||||
function validateEmail(el) {
|
||||
if (!el.value.trim()) {
|
||||
setInvalid(el, 'Email address is required.');
|
||||
return false;
|
||||
}
|
||||
if (!EMAIL.test(el.value.trim())) {
|
||||
setInvalid(el, 'Please enter a valid email address.');
|
||||
return false;
|
||||
}
|
||||
setValid(el);
|
||||
return true;
|
||||
}
|
||||
|
||||
function validatePhone(el) {
|
||||
const val = el.value.replace(/\D/g, '');
|
||||
if (!val) {
|
||||
setInvalid(el, 'Phone number is required.');
|
||||
return false;
|
||||
}
|
||||
if (val.length !== 10) {
|
||||
setInvalid(el, 'Please enter a 10-digit phone number.');
|
||||
return false;
|
||||
}
|
||||
setValid(el);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* --- reCAPTCHA v3 token --------------------------------- */
|
||||
function getRecaptchaToken(action) {
|
||||
return new Promise((resolve) => {
|
||||
if (typeof grecaptcha === 'undefined') {
|
||||
resolve('');
|
||||
return;
|
||||
}
|
||||
grecaptcha.ready(() => {
|
||||
grecaptcha.execute(RECAPTCHA_SITE_KEY, { action }).then(resolve);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* --- Form handler --------------------------------------- */
|
||||
function initForm(form) {
|
||||
const nameEl = form.querySelector('#name');
|
||||
const emailEl = form.querySelector('#email');
|
||||
const phoneEl = form.querySelector('#phone');
|
||||
const addrEl = form.querySelector('#address');
|
||||
const serviceEl = form.querySelector('#service');
|
||||
const msgEl = form.querySelector('#message');
|
||||
const submit = form.querySelector('[type="submit"]');
|
||||
const status = form.querySelector('.form-status');
|
||||
|
||||
if (!submit) return;
|
||||
|
||||
/* Phone real-time format */
|
||||
if (phoneEl) {
|
||||
phoneEl.addEventListener('input', () => {
|
||||
const pos = phoneEl.selectionStart;
|
||||
const prev = phoneEl.value;
|
||||
phoneEl.value = formatPhone(prev);
|
||||
/* restore cursor roughly */
|
||||
const diff = phoneEl.value.length - prev.length;
|
||||
try { phoneEl.setSelectionRange(pos + diff, pos + diff); } catch (_) {}
|
||||
});
|
||||
|
||||
phoneEl.addEventListener('blur', () => validatePhone(phoneEl));
|
||||
}
|
||||
|
||||
/* Blur-time validation for other fields */
|
||||
if (nameEl) nameEl.addEventListener('blur', () => validateRequired(nameEl));
|
||||
if (emailEl) emailEl.addEventListener('blur', () => validateEmail(emailEl));
|
||||
if (addrEl) addrEl.addEventListener('blur', () => validateRequired(addrEl));
|
||||
if (serviceEl) serviceEl.addEventListener('change', () => validateRequired(serviceEl));
|
||||
|
||||
/* Submit */
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const checks = [
|
||||
nameEl ? validateRequired(nameEl) : true,
|
||||
emailEl ? validateEmail(emailEl) : true,
|
||||
phoneEl ? validatePhone(phoneEl) : true,
|
||||
addrEl ? validateRequired(addrEl) : true,
|
||||
serviceEl ? validateRequired(serviceEl) : true,
|
||||
];
|
||||
|
||||
if (checks.includes(false)) {
|
||||
const firstErr = form.querySelector('.invalid');
|
||||
if (firstErr) firstErr.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
const origText = submit.textContent;
|
||||
submit.disabled = true;
|
||||
submit.textContent = 'Sending...';
|
||||
if (status) { status.className = 'form-status'; status.textContent = ''; }
|
||||
|
||||
const token = await getRecaptchaToken('estimate_form');
|
||||
|
||||
const payload = {
|
||||
name: nameEl ? nameEl.value.trim() : '',
|
||||
email: emailEl ? emailEl.value.trim() : '',
|
||||
phone: phoneEl ? phoneEl.value.trim() : '',
|
||||
address: addrEl ? addrEl.value.trim() : '',
|
||||
service: serviceEl ? serviceEl.value : '',
|
||||
message: msgEl ? msgEl.value.trim() : '',
|
||||
token,
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/estimate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
if (!status) { submit.disabled = false; submit.textContent = origText; return; }
|
||||
|
||||
if (res.ok) {
|
||||
status.className = 'form-status form-status--success';
|
||||
status.textContent = 'Thank you! We will get back to you within 1 business hour.';
|
||||
form.reset();
|
||||
form.querySelectorAll('input, textarea, select').forEach(clearState);
|
||||
} else {
|
||||
throw new Error(res.status);
|
||||
}
|
||||
} catch (_) {
|
||||
if (status) {
|
||||
status.className = 'form-status form-status--error';
|
||||
status.textContent = 'Something went wrong. Please call us directly at (716) 602-1429.';
|
||||
}
|
||||
} finally {
|
||||
submit.disabled = false;
|
||||
submit.textContent = origText;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function boot() {
|
||||
document.querySelectorAll('.estimate-form').forEach(initForm);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', boot);
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,164 @@
|
||||
/* ============================================================
|
||||
main.js — Scroll animations, counters, FAQ, BA slider
|
||||
============================================================ */
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* --- Scroll animation (IntersectionObserver) ------------ */
|
||||
function initScrollAnimations() {
|
||||
const els = document.querySelectorAll('[data-animate]');
|
||||
if (!els.length) return;
|
||||
|
||||
const obs = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add('in-view');
|
||||
obs.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
|
||||
|
||||
els.forEach(el => obs.observe(el));
|
||||
}
|
||||
|
||||
/* --- Animated counters ---------------------------------- */
|
||||
function animateCounter(el) {
|
||||
const target = parseFloat(el.dataset.count);
|
||||
const suffix = el.dataset.suffix || '';
|
||||
const prefix = el.dataset.prefix || '';
|
||||
const decimals = (target % 1 !== 0) ? 1 : 0;
|
||||
const duration = 1600;
|
||||
const start = performance.now();
|
||||
|
||||
function tick(now) {
|
||||
const elapsed = now - start;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const ease = 1 - Math.pow(1 - progress, 3);
|
||||
const value = target * ease;
|
||||
el.textContent = prefix + value.toFixed(decimals) + suffix;
|
||||
if (progress < 1) requestAnimationFrame(tick);
|
||||
}
|
||||
|
||||
requestAnimationFrame(tick);
|
||||
}
|
||||
|
||||
function initCounters() {
|
||||
const counters = document.querySelectorAll('[data-count]');
|
||||
if (!counters.length) return;
|
||||
|
||||
const obs = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
animateCounter(entry.target);
|
||||
obs.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, { threshold: 0.3 });
|
||||
|
||||
counters.forEach(el => obs.observe(el));
|
||||
}
|
||||
|
||||
/* --- FAQ accordion -------------------------------------- */
|
||||
function initFAQ() {
|
||||
document.querySelectorAll('.faq-item').forEach(item => {
|
||||
const q = item.querySelector('.faq-question');
|
||||
if (!q) return;
|
||||
|
||||
q.addEventListener('click', () => {
|
||||
const isOpen = item.classList.contains('open');
|
||||
// close all
|
||||
document.querySelectorAll('.faq-item.open').forEach(i => {
|
||||
i.classList.remove('open');
|
||||
});
|
||||
if (!isOpen) item.classList.add('open');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* --- Before / After slider ------------------------------ */
|
||||
function initBASlider(slider) {
|
||||
const handle = slider.querySelector('.ba-handle');
|
||||
const beforeWrap = slider.querySelector('.ba-before-wrap');
|
||||
if (!handle || !beforeWrap) return;
|
||||
|
||||
let dragging = false;
|
||||
|
||||
function setPosition(clientX) {
|
||||
const rect = slider.getBoundingClientRect();
|
||||
const rawPct = (clientX - rect.left) / rect.width;
|
||||
const pct = Math.min(Math.max(rawPct, 0.02), 0.98);
|
||||
beforeWrap.style.width = (pct * 100) + '%';
|
||||
handle.style.left = (pct * 100) + '%';
|
||||
}
|
||||
|
||||
handle.addEventListener('mousedown', () => { dragging = true; });
|
||||
handle.addEventListener('touchstart', () => { dragging = true; }, { passive: true });
|
||||
|
||||
window.addEventListener('mousemove', e => { if (dragging) setPosition(e.clientX); });
|
||||
window.addEventListener('touchmove', e => { if (dragging) setPosition(e.touches[0].clientX); }, { passive: true });
|
||||
|
||||
window.addEventListener('mouseup', () => { dragging = false; });
|
||||
window.addEventListener('touchend', () => { dragging = false; });
|
||||
|
||||
slider.addEventListener('click', e => setPosition(e.clientX));
|
||||
}
|
||||
|
||||
function initBASliders() {
|
||||
document.querySelectorAll('.ba-slider').forEach(initBASlider);
|
||||
}
|
||||
|
||||
/* --- Smooth scroll for anchor links --------------------- */
|
||||
function initSmoothScroll() {
|
||||
document.querySelectorAll('a[href^="#"]').forEach(a => {
|
||||
a.addEventListener('click', e => {
|
||||
const id = a.getAttribute('href').slice(1);
|
||||
const target = document.getElementById(id);
|
||||
if (!target) return;
|
||||
e.preventDefault();
|
||||
const headerH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--header-h')) || 72;
|
||||
const top = target.getBoundingClientRect().top + window.scrollY - headerH - 16;
|
||||
window.scrollTo({ top, behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* --- Video hero fallback -------------------------------- */
|
||||
function initHeroVideo() {
|
||||
const video = document.querySelector('.hero-video-wrap video');
|
||||
if (!video) return;
|
||||
video.play().catch(() => {
|
||||
// autoplay blocked — poster image is visible; nothing to do
|
||||
});
|
||||
}
|
||||
|
||||
/* --- Testimonial auto-scroll (on mobile) ---------------- */
|
||||
function initTestimonialScroll() {
|
||||
const track = document.querySelector('.testimonial-track');
|
||||
if (!track) return;
|
||||
|
||||
let isPaused = false;
|
||||
track.addEventListener('mouseenter', () => { isPaused = true; });
|
||||
track.addEventListener('mouseleave', () => { isPaused = false; });
|
||||
|
||||
// keyboard scroll within track
|
||||
track.setAttribute('tabindex', '0');
|
||||
}
|
||||
|
||||
/* --- Boot ---------------------------------------------- */
|
||||
function boot() {
|
||||
initScrollAnimations();
|
||||
initCounters();
|
||||
initFAQ();
|
||||
initBASliders();
|
||||
initSmoothScroll();
|
||||
initHeroVideo();
|
||||
initTestimonialScroll();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', boot);
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
})();
|
||||