Example website for demonstration only. Not a real business.

Source

How this site is built

Everything below is the live project source, captured when the site was built. After you edit a file, run npm run dev or npm run build to see the change. Compiled HTML (the files in dist/) is also loaded below when you are viewing this page over http:// or https://.

Config and data

The knobs you will turn first: business details, package scripts, and Astro settings.

astro.config.mjs

Astro is set to a static build with one HTML file per page.

// @ts-check
import { defineConfig } from 'astro/config';

// Static HTML, CSS, and JS only — no server, no paid services, no trackers.
export default defineConfig({
  output: 'static',
  // One HTML file per page (index.html, menu.html, …) so the built
  // site can be opened from the dist/ folder or served by any static host.
  build: {
    format: 'file',
  },
});

IMAGES.md

Photographer credits and source URLs for every image.

# Photo credits — Ridge Line Home Co.

Every image is from Unsplash or Pexels and may be used commercially. Attribution is also listed in the site footer.

| File | Photographer | Source | License |
| --- | --- | --- | --- |
| `images/hero-site.jpg` | ROKS | https://www.pexels.com/photo/2760241/ | Pexels License (free for commercial use) |
| `images/crew.jpg` | ROKS | https://www.pexels.com/photo/2760243/ | Pexels License (free for commercial use) |
| `images/tools.jpg` | Todd Quackenbush | https://unsplash.com/photos/x5SRhkFajrA | Unsplash License (free for commercial use) |
| `images/truck.jpg` | Jeff Sheldon | https://unsplash.com/photos/ICfoiW1d_90 | Unsplash License (free for commercial use) |
| `images/brick.jpg` | Martin Wessely | https://unsplash.com/photos/sX4lxBWV0-A | Unsplash License (free for commercial use) |
| `images/framing.jpg` | Jeff Sheldon | https://unsplash.com/photos/guH91yuPaMk | Unsplash License (free for commercial use) |
| `images/kitchen.jpg` | Siddhesh Savant | https://www.pexels.com/photo/2089698/ | Pexels License (free for commercial use) |
| `images/stair.jpg` | Kim Denver | https://www.pexels.com/photo/2121121/ | Pexels License (free for commercial use) |
| `images/bedroom.jpg` | Benjamin Combs | https://unsplash.com/photos/5L4XAgMSno0 | Unsplash License (free for commercial use) |
| `images/dining.jpg` | Breather | https://unsplash.com/photos/DEdM9Vs6s8w | Unsplash License (free for commercial use) |

Images were resized and compressed for the web (generally under 300 KB each).
To swap a photo, replace the file in `public/images/`, then update this table, the footer credits in `src/data/site.json`, and any `alt` text.

package.json

npm scripts: dev, build, preview. The only runtime dependency is Astro.

{
  "name": "example-03-contractor",
  "type": "module",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "astro dev",
    "build": "astro build && node scripts/relative-paths.mjs",
    "preview": "astro preview"
  },
  "dependencies": {
    "astro": "^7.4.7"
  }
}

public/_headers

Sample Content-Security-Policy for hosts like Netlify.

# Sample HTTPS security headers for hosts that understand this file (e.g. Netlify).
# Safe to leave in place on any static host that ignores it.
/*
  Content-Security-Policy: default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; font-src 'self'; connect-src 'self'; form-action 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests
  X-Content-Type-Options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  X-Frame-Options: DENY

README.md

How to run, customize, and hook up a real form or payment provider.

# Ridge Line Home Co.

Example **Home services / contractor** website, built with [Astro](https://astro.build) 7 as a starting point you can hand to a client or reshape for a pitch.

**This is not a real business.** Names, people, reviews, prices, and the Example Bay address are fictional. The site is set to `noindex` so it will not wander into search results if you deploy it by accident. Remove that meta tag in `src/layouts/BaseLayout.astro` when a real client site should be indexed.

The quote calculator shows an example range only — it is not a bid. Request a visit with the form on the same page.

## How to run

You need Node.js 18 or newer (Node 22+ is fine). In this folder:

```bash
npm install
npm run dev
```

Then open the URL Astro prints (usually http://localhost:4321/).

To make a static build:

```bash
npm run build
npm run preview
```

`npm run build` writes to `dist/` and then rewrites root-absolute paths (`/images/...`) to document-relative ones (`./images/...`). After a build you can also serve the folder with any static server:

```bash
python3 -m http.server --directory dist 8080
```

Opening `dist/index.html` directly from the file system (double-click) usually shows the layout and images. Some browsers restrict JavaScript on `file://` URLs, so interactive features (filters, forms, the lightbox) are more reliable from `npm run preview` or another local server. There are no ES modules required for those features; they live in classic scripts under `public/js/`.

## How to customize

Start with **`src/data/site.json`**. It holds the business name, colors, fonts, hours, contact details, copy, and image credits. Colors are applied as CSS variables by `src/layouts/BaseLayout.astro`.

| Want to change… | Edit |
| --- | --- |
| Name, phone, hours, colors | `src/data/site.json` |
| Page layout and sections | `src/pages/*.astro` |
| Header, footer, hero, forms | `src/components/` |
| Spacing, typography, components | `src/styles/global.css` |
| Shared JS (menu, forms, filters) | `public/js/site.js` |
| This site’s unique JS | `public/js/features.js` |
| Photos | `public/images/` plus `IMAGES.md` and the `images` list in `site.json` |

All copy is written so a beginner can swap it without touching the logic.

## Forms

Every form is a **demo**. Submitting it does not send an email. `public/js/site.js` validates the fields, ignores a hidden honeypot, and writes a thank-you note with `textContent` (never `innerHTML`).

To accept real inquiries:

1. Create a [Formspree](https://formspree.io) form, or a small HTTPS endpoint you host yourself (better if you want to stay off third-party SaaS).
2. Set the form’s `action` to that URL and `method="POST"` in `src/components/ContactForm.astro`.
3. Adjust or remove the `data-demo-form` handler in `public/js/site.js`.
4. Serve the site over HTTPS.

Do not put API keys or secrets in this project. Do not collect passwords, payment details, or (for the dental starter) health information through these forms.

## Security

- No secrets in the frontend.
- User input is never written with `innerHTML`.
- Links to the built assets are relative, so the site is ready for HTTPS and will not mix in third-party scripts.
- `public/_headers` holds a sample Content-Security-Policy for hosts that understand that file (for example Netlify). There is also a commented CSP in the layout.
- Prefer a privacy-respecting map link (OpenStreetMap is used here) over a live Google Maps embed unless the client asks for one.

## Photos

See [IMAGES.md](IMAGES.md). All photos are from Unsplash or Pexels and are free for commercial use, with photographer credits in the footer.

## License of this example

This folder is an example you can copy and modify for client work. The photographs remain under their original Unsplash or Pexels licenses. Astro is MIT licensed.

src/data/site.json

Start here. Business name, colors, hours, copy, and image credits.

{
  "folder": "03-contractor",
  "kind": "Home services / contractor",
  "name": "Ridge Line Home Co.",
  "shortName": "Ridge Line",
  "monogram": "RL",
  "tagline": "Kitchens, baths, and honest site work",
  "description": "Example contractor website with a project gallery and a quote-range calculator.",
  "phone": "(555) 010-1403",
  "phoneHref": "tel:+15550101403",
  "email": "jobs@ridgelinehome.example",
  "address": {
    "street": "7 Mill Road",
    "city": "Example Bay",
    "state": "CA",
    "zip": "00000",
    "osm": "https://www.openstreetmap.org/search?query=Example%20Bay"
  },
  "hours": [
    {
      "days": "Monday \u2013 Friday",
      "time": "7:30 am \u2013 5:00 pm"
    },
    {
      "days": "Saturday",
      "time": "By appointment"
    },
    {
      "days": "Sunday",
      "time": "Closed"
    }
  ],
  "theme": {
    "bg": "#f3f0e8",
    "fg": "#1a1f24",
    "primary": "#1e3a5f",
    "primaryText": "#ffffff",
    "accent": "#c5811a",
    "muted": "#5c5a54",
    "card": "#fffcf6",
    "border": "#ddd6c8",
    "headerBg": "#fffcf6",
    "fontDisplay": "'Segoe UI', system-ui, sans-serif",
    "fontBody": "'Segoe UI', system-ui, sans-serif",
    "radius": "10px",
    "colorScheme": "light"
  },
  "nav": [
    {
      "label": "Home",
      "page": "index"
    },
    {
      "label": "Services",
      "page": "services"
    },
    {
      "label": "Projects",
      "page": "projects"
    },
    {
      "label": "Quote",
      "page": "quote"
    },
    {
      "label": "Source",
      "page": "source"
    }
  ],
  "headerCta": {
    "label": "Get a quote",
    "page": "quote"
  },
  "hero": {
    "variant": "full",
    "flip": false,
    "image": "images/hero-site.jpg",
    "imageAlt": "Construction worker at an active job site",
    "eyebrow": "Example contractor starter",
    "title": "Built on time, finished clean.",
    "lead": "A fictional general contractor for kitchens, baths, decks, and small additions in Example Bay.",
    "primaryCta": {
      "label": "Estimate a range",
      "page": "quote"
    },
    "secondaryCta": {
      "label": "See projects",
      "page": "projects"
    }
  },
  "intro": {
    "title": "One crew, one point of contact",
    "text": "Lead-generation sites like this one live or die by a clear next step. The calculator gives a visitor a ballpark; the form asks them to book a visit. Both are marked as examples so nobody mistakes a range for a bid.",
    "image": "images/framing.jpg",
    "imageAlt": "Wooden structural framing"
  },
  "servicesEyebrow": "The work",
  "servicesTitle": "What we build",
  "servicesLead": "Each card can later become its own SEO page (Kitchen remodeling, Bathroom renovation, and so on).",
  "services": [
    {
      "name": "Kitchens",
      "blurb": "Layout, cabinets, and the quiet work behind the walls.",
      "price": "By project"
    },
    {
      "name": "Bathrooms",
      "blurb": "Tile, fixtures, and ventilation that actually works.",
      "price": "By project"
    },
    {
      "name": "Decks and exteriors",
      "blurb": "Sun, rain, and a structure that will take both.",
      "price": "By project"
    },
    {
      "name": "Small additions",
      "blurb": "One more room, planned with the existing house in mind.",
      "price": "By project"
    },
    {
      "name": "Repairs",
      "blurb": "When something has failed and it should not wait for a full remodel.",
      "price": "By visit"
    },
    {
      "name": "Consults",
      "blurb": "A paid planning visit if you are not ready to build this season.",
      "price": "Flat fee"
    }
  ],
  "galleryEyebrow": "Projects",
  "galleryTitle": "Finished rooms and work in progress",
  "galleryLead": "Example photos. A real portfolio should be the contractor\u2019s own job sites, published with permission.",
  "gallery": [
    {
      "file": "images/kitchen.jpg",
      "alt": "Bright modern kitchen with a long island"
    },
    {
      "file": "images/stair.jpg",
      "alt": "Interior stairwell with wood treads and daylight"
    },
    {
      "file": "images/bedroom.jpg",
      "alt": "Bedroom with soft daylight from a large window"
    },
    {
      "file": "images/dining.jpg",
      "alt": "Dining area inside a finished home"
    },
    {
      "file": "images/framing.jpg",
      "alt": "Wooden structural framing"
    },
    {
      "file": "images/brick.jpg",
      "alt": "Close-up of a brick wall"
    },
    {
      "file": "images/tools.jpg",
      "alt": "Hand tools laid out on a work surface"
    },
    {
      "file": "images/truck.jpg",
      "alt": "Work truck parked beside a building"
    }
  ],
  "quote": {
    "title": "A first-pass range",
    "lead": "Pick a project type and a size. The number you see is a teaching tool, not a bid.",
    "disclaimer": "Example rates only. A real quote needs a site visit, a scope, and a written agreement.",
    "types": [
      {
        "id": "kitchen",
        "label": "Kitchen remodel",
        "rate": 180
      },
      {
        "id": "bath",
        "label": "Bathroom remodel",
        "rate": 220
      },
      {
        "id": "deck",
        "label": "Deck or patio",
        "rate": 85
      },
      {
        "id": "addition",
        "label": "Small addition",
        "rate": 260
      }
    ],
    "addons": [
      {
        "label": "Design drawings",
        "amount": 2500
      },
      {
        "label": "Permit handling",
        "amount": 1800
      },
      {
        "label": "Fixture package upgrade",
        "amount": 4000
      }
    ]
  },
  "testimonials": [
    {
      "name": "The Alvarez family",
      "role": "Kitchen project (example)",
      "quote": "They protected the rest of the house and finished when they said they would."
    },
    {
      "name": "Chris Nolan",
      "role": "Deck project (example)",
      "quote": "The range on the website was honest enough that the real bid did not surprise us."
    },
    {
      "name": "Dana Whit",
      "role": "Bath remodel (example)",
      "quote": "One foreman, clear weekly notes, no disappearing act in week four."
    }
  ],
  "cta": {
    "title": "Have a project in mind?",
    "lead": "Start with a range, then request a visit.",
    "label": "Request a visit",
    "page": "quote"
  },
  "about": {
    "title": "A local crew with a paper trail",
    "pageDescription": "About the fictional Ridge Line Home Co.",
    "paragraphs": [
      "This starter is for trades and remodelers: services, a project gallery, and a calculator that teaches a visitor what a job might cost before they call.",
      "Licensing, insurance, and lien notices are legal matters. Add the real ones with a lawyer\u2019s review \u2014 do not invent them on a live client site."
    ],
    "image": "images/crew.jpg",
    "imageAlt": "Crew member in safety gear on site",
    "id": "about"
  },
  "stats": [
    {
      "value": "18",
      "label": "Example years in trade"
    },
    {
      "value": "1",
      "label": "Foreman per job"
    },
    {
      "value": "25 mi",
      "label": "Example service radius"
    }
  ],
  "teamTitle": "People",
  "teamLead": "",
  "team": [],
  "contactPage": {
    "id": "quote",
    "eyebrow": "Quote",
    "title": "Request a project visit",
    "lead": "Use the calculator for a range, then send a note. The form is a demo and does not submit anywhere yet.",
    "formHeading": "Project inquiry",
    "formIntro": "A short description of the house and the work is enough to start.",
    "submitLabel": "Request a visit",
    "showService": true,
    "serviceLabel": "Project type",
    "serviceOptions": [
      "Kitchen remodel",
      "Bathroom remodel",
      "Deck or patio",
      "Small addition",
      "Repair",
      "Planning consult"
    ],
    "showDate": true,
    "extraNote": "The calculator on this page is an illustration, not a contract.",
    "warning": ""
  },
  "faqTitle": "FAQ",
  "faqLead": "",
  "faqs": [],
  "images": [
    {
      "file": "images/hero-site.jpg",
      "photographer": "ROKS",
      "source": "https://www.pexels.com/photo/2760241/",
      "license": "Pexels License (free for commercial use)",
      "alt": "Construction worker at an active job site"
    },
    {
      "file": "images/crew.jpg",
      "photographer": "ROKS",
      "source": "https://www.pexels.com/photo/2760243/",
      "license": "Pexels License (free for commercial use)",
      "alt": "Crew member in safety gear on site"
    },
    {
      "file": "images/tools.jpg",
      "photographer": "Todd Quackenbush",
      "source": "https://unsplash.com/photos/x5SRhkFajrA",
      "license": "Unsplash License (free for commercial use)",
      "alt": "Hand tools laid out on a work surface"
    },
    {
      "file": "images/truck.jpg",
      "photographer": "Jeff Sheldon",
      "source": "https://unsplash.com/photos/ICfoiW1d_90",
      "license": "Unsplash License (free for commercial use)",
      "alt": "Work truck parked beside a building"
    },
    {
      "file": "images/brick.jpg",
      "photographer": "Martin Wessely",
      "source": "https://unsplash.com/photos/sX4lxBWV0-A",
      "license": "Unsplash License (free for commercial use)",
      "alt": "Close-up of a brick wall"
    },
    {
      "file": "images/framing.jpg",
      "photographer": "Jeff Sheldon",
      "source": "https://unsplash.com/photos/guH91yuPaMk",
      "license": "Unsplash License (free for commercial use)",
      "alt": "Wooden structural framing"
    },
    {
      "file": "images/kitchen.jpg",
      "photographer": "Siddhesh Savant",
      "source": "https://www.pexels.com/photo/2089698/",
      "license": "Pexels License (free for commercial use)",
      "alt": "Bright modern kitchen with a long island"
    },
    {
      "file": "images/stair.jpg",
      "photographer": "Kim Denver",
      "source": "https://www.pexels.com/photo/2121121/",
      "license": "Pexels License (free for commercial use)",
      "alt": "Interior stairwell with wood treads and daylight"
    },
    {
      "file": "images/bedroom.jpg",
      "photographer": "Benjamin Combs",
      "source": "https://unsplash.com/photos/5L4XAgMSno0",
      "license": "Unsplash License (free for commercial use)",
      "alt": "Bedroom with soft daylight from a large window"
    },
    {
      "file": "images/dining.jpg",
      "photographer": "Breather",
      "source": "https://unsplash.com/photos/DEdM9Vs6s8w",
      "license": "Unsplash License (free for commercial use)",
      "alt": "Dining area inside a finished home"
    }
  ]
}

src/utils/paths.ts

Helpers so links work in dev and in the built dist/ folder.

/**
 * Helpers so links work both in `npm run dev` and in the built `dist/` folder.
 * After the post-build rewrite, production links are document-relative (./menu.html).
 */
export function pageHref(page: string): string {
  const name = page.replace(/^\//, "").replace(/\.html$/, "");
  const file = !name || name === "index" ? "index.html" : `${name}.html`;
  return import.meta.env.DEV ? `/${file}` : `./${file}`;
}

export function asset(path: string): string {
  const clean = path.replace(/^\//, "");
  return import.meta.env.DEV ? `/${clean}` : `./${clean}`;
}

Astro layouts and components

Reusable pieces. Each file has a front-matter comment describing what to edit.

src/components/ContactForm.astro

Demo form. Does not send data until you add an endpoint.

---
/**
 * Demo contact / booking / inquiry form.
 *
 * Nothing is sent. The submit handler in public/js/site.js only validates
 * and shows a thank-you message (via textContent, never innerHTML).
 *
 * To accept real messages:
 *  1. Create a Formspree form (https://formspree.io) or a small HTTPS
 *     endpoint you host yourself (recommended if you want to stay off
 *     third-party SaaS).
 *  2. Set this form's action to that URL and method="POST".
 *  3. Remove data-demo-form, or keep it and adjust the JS so a successful
 *     native submit can proceed.
 *  4. Serve the site over HTTPS.
 * Do not put API keys in this file or any other frontend file.
 */
interface Props {
  heading?: string;
  intro?: string;
  submitLabel?: string;
  showService?: boolean;
  serviceLabel?: string;
  serviceOptions?: string[];
  showDate?: boolean;
  extraNote?: string;
}
const {
  heading = 'Get in touch',
  intro = 'This is a demo form. Submissions stay in your browser until you connect an endpoint.',
  submitLabel = 'Send message',
  showService = false,
  serviceLabel = 'Interested in',
  serviceOptions = [],
  showDate = false,
  extraNote,
} = Astro.props;
---
<form class="card" data-demo-form novalidate>
  <h2>{heading}</h2>
  <p class="form-note">{intro}</p>

  <!-- Honeypot: hidden from people, filled by some bots. Must stay empty. -->
  <div class="hp" aria-hidden="true">
    <label>
      Company website
      <input type="text" name="company_website" tabindex="-1" autocomplete="off" />
    </label>
  </div>

  <label>
    Name
    <input type="text" name="name" required maxlength="80" autocomplete="name" />
  </label>
  <label>
    Email
    <input type="email" name="email" required maxlength="120" autocomplete="email" />
  </label>
  <label>
    Phone
    <input type="tel" name="phone" maxlength="40" autocomplete="tel" />
  </label>
  {showService && serviceOptions.length > 0 && (
    <label>
      {serviceLabel}
      <select name="service">
        {serviceOptions.map((opt) => <option value={opt}>{opt}</option>)}
      </select>
    </label>
  )}
  {showDate && (
    <label>
      Preferred date
      <input type="date" name="preferred_date" />
    </label>
  )}
  <label>
    Message
    <textarea name="message" required maxlength="2000"></textarea>
  </label>
  {extraNote && <p class="form-note">{extraNote}</p>}
  <button type="submit" class="btn">{submitLabel}</button>
  <p class="form-status" data-form-status role="status"></p>
</form>

src/components/CtaBand.astro

Full-width closing call to action.

---
/** Full-width call to action. Copy comes from site.cta. */
import site from '../data/site.json';
import { pageHref } from '../utils/paths';
const cta = site.cta;
---
<section class="section section--primary" id="cta">
  <div class="wrap split">
    <div>
      <h2>{cta.title}</h2>
      <p>{cta.lead}</p>
    </div>
    <div class="btn-row">
      <a class="btn btn--light" href={pageHref(cta.page)}>{cta.label}</a>
      <a class="btn btn--ghost" href={site.phoneHref} style="color:inherit;border-color:currentColor">
        Call {site.phone}
      </a>
    </div>
  </div>
</section>

src/components/Header.astro

Logo, navigation, and the mobile menu button.

---
/**
 * Site header: logo, navigation from site.json, phone/booking CTA, mobile menu.
 * Mark the current page with the `current` prop so aria-current is set.
 */
import site from '../data/site.json';
import { pageHref } from '../utils/paths';

interface Props { current?: string; }
const { current = 'index' } = Astro.props;
---
<header class="site-header" data-header>
  <div class="wrap header-inner">
    <a class="logo" href={pageHref('index')}>
      <span class="logo-mark" aria-hidden="true">{site.monogram}</span>
      <span>{site.shortName}</span>
    </a>
    <button
      type="button"
      class="nav-toggle"
      data-nav-toggle
      aria-expanded="false"
      aria-controls="site-nav"
    >
      <span class="sr-only">Menu</span>
      <span class="nav-toggle-bar"></span>
      <span class="nav-toggle-bar"></span>
      <span class="nav-toggle-bar"></span>
    </button>
    <nav class="site-nav" id="site-nav" aria-label="Primary">
      <ul class="nav-list">
        {site.nav.map((item) => (
          <li>
            <a
              href={pageHref(item.page)}
              aria-current={item.page === current ? 'page' : undefined}
            >
              {item.label}
            </a>
          </li>
        ))}
        <li>
          <a class="btn header-cta" href={pageHref(site.headerCta.page)}>
            {site.headerCta.label}
          </a>
        </li>
      </ul>
    </nav>
  </div>
</header>

src/components/Hero.astro

Top-of-page band. Layout variant is set in site.json.

---
/**
 * Hero band. The variant (full, split, or stack) and all copy live in site.json.
 */
import site from '../data/site.json';
import { pageHref, asset } from '../utils/paths';

const hero = site.hero;
const variant = hero.variant || 'split';
---
<section class={`hero hero--${variant}`} aria-label="Introduction">
  {variant === 'full' && (
    <div class="hero-media" aria-hidden="true">
      <img src={asset(hero.image)} alt="" />
    </div>
  )}
  <div class="wrap">
    {variant !== 'full' ? (
      <div class={`split ${variant === 'split' && hero.flip ? 'split--flip' : ''}`}>
        <div class="hero-copy">
          {hero.eyebrow && <p class="eyebrow">{hero.eyebrow}</p>}
          <h1>{hero.title}</h1>
          <p class="lead">{hero.lead}</p>
          <div class="btn-row">
            <a class="btn" href={pageHref(hero.primaryCta.page)}>{hero.primaryCta.label}</a>
            {hero.secondaryCta && (
              <a class="btn btn--ghost" href={pageHref(hero.secondaryCta.page)}>
                {hero.secondaryCta.label}
              </a>
            )}
          </div>
        </div>
        <div class="hero-media media">
          <img src={asset(hero.image)} alt={hero.imageAlt} />
        </div>
      </div>
    ) : (
      <div class="hero-copy">
        {hero.eyebrow && <p class="eyebrow">{hero.eyebrow}</p>}
        <h1>{hero.title}</h1>
        <p class="lead">{hero.lead}</p>
        <div class="btn-row">
          <a class="btn btn--light" href={pageHref(hero.primaryCta.page)}>{hero.primaryCta.label}</a>
          {hero.secondaryCta && (
            <a class="btn btn--ghost" href={pageHref(hero.secondaryCta.page)} style="color:#fff;border-color:rgba(255,255,255,.5)">
              {hero.secondaryCta.label}
            </a>
          )}
        </div>
      </div>
    )}
  </div>
</section>

src/components/QuoteCalculator.astro

Project file included so the source page stays complete.

---
/**
 * Example project-cost range calculator.
 * Rates are in site.quote. This is not a bid — the README explains that.
 * Math lives in public/js/features.js and is written into the page with textContent.
 */
import site from '../data/site.json';
---
<section class="section section--alt" id="quote">
  <div class="wrap split">
    <div>
      <p class="eyebrow">Example estimate</p>
      <h2>{site.quote.title}</h2>
      <p class="lead">{site.quote.lead}</p>
      <p class="form-note">{site.quote.disclaimer}</p>
    </div>
    <form class="card" data-quote-calc onsubmit="return false;">
      <label>
        Project type
        <select name="projectType">
          {site.quote.types.map((t) => (
            <option value={t.id} data-rate={t.rate}>{t.label} (example ${t.rate}/sq ft)</option>
          ))}
        </select>
      </label>
      <label>
        Approximate square feet
        <input type="number" name="sqft" min="1" max="20000" value="200" />
      </label>
      <fieldset>
        <legend>Optional add-ons</legend>
        {site.quote.addons.map((a) => (
          <label style="font-weight:500;display:flex;gap:0.5rem;align-items:center;">
            <input type="checkbox" data-addon={a.amount} />
            {a.label} (+${a.amount.toLocaleString()})
          </label>
        ))}
      </fieldset>
      <p class="meta">Example range</p>
      <p class="estimate" data-estimate>—</p>
      <p class="form-note">For illustration only. Request a visit for a real quote.</p>
    </form>
  </div>
</section>

src/components/Services.astro

Project file included so the source page stays complete.

---
/** Service / offer cards from site.services. Swap the copy in site.json. */
import site from '../data/site.json';
---
<section class="section" id="services">
  <div class="wrap">
    <div class="section-head">
      <p class="eyebrow">{site.servicesEyebrow}</p>
      <h2>{site.servicesTitle}</h2>
      <p class="lead">{site.servicesLead}</p>
    </div>
    <div class="grid grid-3">
      {site.services.map((s) => (
        <article class="card">
          <h3>{s.name}</h3>
          <p>{s.blurb}</p>
          {s.price && <p class="price">{s.price}</p>}
        </article>
      ))}
    </div>
  </div>
</section>

src/components/Testimonials.astro

Quote cards fed by site.testimonials.

---
/** Pull quotes from site.testimonials. Easy to add, edit, or remove. */
import site from '../data/site.json';
---
<section class="section section--alt" id="testimonials">
  <div class="wrap">
    <div class="section-head">
      <p class="eyebrow">Kind words</p>
      <h2>What clients say</h2>
      <p class="lead">Fictional reviews for this example site — replace them with real permissioned testimonials.</p>
    </div>
    <div class="grid grid-3">
      {site.testimonials.map((t) => (
        <figure class="card">
          <blockquote>
            <p>“{t.quote}”</p>
          </blockquote>
          <figcaption>
            <strong>{t.name}</strong>
            <div class="meta">{t.role}</div>
          </figcaption>
        </figure>
      ))}
    </div>
  </div>
</section>

src/layouts/BaseLayout.astro

HTML shell, meta tags, theme variables, and script tags.

---
/**
 * HTML shell for every page.
 * Theme colors and fonts are read from src/data/site.json and applied
 * as CSS variables. Change that file to re-skin the site.
 */
import '../styles/global.css';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import site from '../data/site.json';
import { asset } from '../utils/paths';

interface Props {
  title?: string;
  description?: string;
  page?: string;
}

const { title, description, page = 'index' } = Astro.props;
const pageTitle = title
  ? `${title} · ${site.name}`
  : `${site.name} · ${site.tagline}`;

/** Only allow safe theme values through to the style attribute. */
function themeStyle(theme: Record<string, string>): string {
  const map: Record<string, string> = {
    bg: '--bg',
    fg: '--fg',
    primary: '--primary',
    primaryText: '--primary-text',
    accent: '--accent',
    muted: '--muted',
    card: '--card',
    border: '--border',
    headerBg: '--header-bg',
    fontDisplay: '--font-display',
    fontBody: '--font-body',
    radius: '--radius',
  };
  const parts: string[] = [];
  for (const [key, cssVar] of Object.entries(map)) {
    const value = theme[key];
    if (!value) continue;
    if (key.startsWith('font')) {
      if (!/^[A-Za-z0-9"'\s,\-]+$/.test(value)) continue;
    } else if (key === 'radius') {
      if (!/^\d+(\.\d+)?(px|rem)$/.test(value)) continue;
    } else if (!/^#([0-9a-fA-F]{3,8})$/.test(value)) {
      continue;
    }
    parts.push(`${cssVar}: ${value}`);
  }
  return parts.join('; ');
}

const scheme = site.theme.colorScheme === 'dark' ? 'dark' : 'light';
---
<!doctype html>
<html lang="en" data-theme={scheme} style={themeStyle(site.theme as Record<string, string>)}>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content={description ?? site.description} />
    <meta name="color-scheme" content={scheme} />
    <!-- Fictional example: hide from search engines until you replace the copy. -->
    <meta name="robots" content="noindex, nofollow" />
    <title>{pageTitle}</title>
    <link rel="icon" href={asset('favicon.svg')} type="image/svg+xml" />
    <!--
      Sample Content-Security-Policy for an HTTPS deploy.
      Uncomment the meta tag, or use public/_headers on Netlify / similar.
      style-src includes 'unsafe-inline' because theme variables are set on <html>
      and small critical CSS may be inlined by Astro.

      default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline';
      script-src 'self'; font-src 'self'; connect-src 'self'; form-action 'self';
      base-uri 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests
    -->
  </head>
  <body>
    <a class="skip-link" href="#main">Skip to content</a>
    <div class="example-banner">
      Example website for demonstration only. Not a real business.
    </div>
    <Header current={page} />
    <main id="main">
      <slot />
    </main>
    <Footer />
    <script src={asset('js/site.js')} defer></script>
    <script src={asset('js/features.js')} defer></script>
  </body>
</html>

Pages

One file per URL. After `npm run build` these compile to HTML in dist/.

src/pages/index.astro

Home page. Compose or rearrange sections here.

---
import BaseLayout from '../layouts/BaseLayout.astro';
import Hero from '../components/Hero.astro';
import Services from '../components/Services.astro';
import Gallery from '../components/Gallery.astro';
import Testimonials from '../components/Testimonials.astro';
import CtaBand from '../components/CtaBand.astro';
import site from '../data/site.json';
import { asset } from '../utils/paths';
import QuoteCalculator from '../components/QuoteCalculator.astro';
---
<BaseLayout page="index">
  <Hero />

  <section class="section" id="intro">
    <div class="wrap split">
      <div>
        <p class="eyebrow">Welcome</p>
        <h2>{site.intro.title}</h2>
        <p>{site.intro.text}</p>
      </div>
      <div class="media">
        <img src={asset(site.intro.image)} alt={site.intro.imageAlt} />
      </div>
    </div>
  </section>

  <Services />

  <QuoteCalculator />

  {site.team && site.team.length > 0 && (
    <section class="section" id="people">
      <div class="wrap">
        <div class="section-head">
          <p class="eyebrow">People</p>
          <h2>{site.teamTitle}</h2>
          <p class="lead">{site.teamLead}</p>
        </div>
        <div class="grid grid-3">
          {site.team.slice(0, 3).map((person) => (
            <article class="card">
              <h3>{person.name}</h3>
              <p class="meta">{person.role}</p>
              <p>{person.bio}</p>
            </article>
          ))}
        </div>
      </div>
    </section>
  )}

  <Gallery />
  <Testimonials />
  <CtaBand />
</BaseLayout>

src/pages/projects.astro

Project file included so the source page stays complete.

---
import BaseLayout from '../layouts/BaseLayout.astro';
import Gallery from '../components/Gallery.astro';
import CtaBand from '../components/CtaBand.astro';
import site from '../data/site.json';
---
<BaseLayout page="projects" title="Projects" description={site.galleryLead}>
  <Gallery />
  <CtaBand />
</BaseLayout>

src/pages/quote.astro

Project file included so the source page stays complete.

---
import BaseLayout from '../layouts/BaseLayout.astro';
import ContactForm from '../components/ContactForm.astro';
import QuoteCalculator from '../components/QuoteCalculator.astro';
import site from '../data/site.json';
---
<BaseLayout page="quote" title={site.contactPage.title} description={site.contactPage.lead}>
  <QuoteCalculator />
  <section class="section">
    <div class="wrap split">
      <div>
        <p class="eyebrow">{site.contactPage.eyebrow}</p>
        <h1>{site.contactPage.title}</h1>
        <p class="lead">{site.contactPage.lead}</p>
        <p>
          <a href={site.phoneHref}>{site.phone}</a><br />
          <a href={`mailto:${site.email}`}>{site.email}</a>
        </p>
        <p>
          {site.address.street}<br />
          {site.address.city}, {site.address.state} {site.address.zip}
        </p>
        {site.contactPage.warning && <p class="form-note">{site.contactPage.warning}</p>}
      </div>
      <ContactForm
        heading={site.contactPage.formHeading}
        intro={site.contactPage.formIntro}
        submitLabel={site.contactPage.submitLabel}
        showService={site.contactPage.showService}
        serviceLabel={site.contactPage.serviceLabel}
        serviceOptions={site.contactPage.serviceOptions}
        showDate={site.contactPage.showDate}
        extraNote={site.contactPage.extraNote}
      />
    </div>
  </section>
</BaseLayout>

src/pages/services.astro

Project file included so the source page stays complete.

---
import BaseLayout from '../layouts/BaseLayout.astro';
import Services from '../components/Services.astro';
import CtaBand from '../components/CtaBand.astro';
import site from '../data/site.json';
---
<BaseLayout page="services" title="Services" description={site.servicesLead}>
  <Services />
  <CtaBand />
</BaseLayout>

src/pages/source.astro

This page. Built at compile time from the files on disk.

---
/**
 * /source — shows this site's code, grouped by type, generated at build time.
 * Short notes explain what each major file is for. Edit the map below if you
 * add files. The contents themselves come from import.meta.glob(?raw), so
 * they stay in sync with the project.
 */
import BaseLayout from '../layouts/BaseLayout.astro';
import site from '../data/site.json';
import sourcePage from './source.astro?raw';

const discovered = import.meta.glob(
  [
    '../**/*.{astro,css,js,ts,json}',
    '../../public/js/site.js',
    '../../public/js/features.js',
    '../../public/_headers',
    '../../astro.config.mjs',
    '../../package.json',
    '../../README.md',
    '../../IMAGES.md',
  ],
  { query: '?raw', import: 'default', eager: true }
);

type Entry = { path: string; code: string; note: string };

const notes: Record<string, string> = {
  'src/data/site.json': 'Start here. Business name, colors, hours, copy, and image credits.',
  'src/layouts/BaseLayout.astro': 'HTML shell, meta tags, theme variables, and script tags.',
  'src/components/Header.astro': 'Logo, navigation, and the mobile menu button.',
  'src/components/Footer.astro': 'Contact, hours, and required photo attribution.',
  'src/components/Hero.astro': 'Top-of-page band. Layout variant is set in site.json.',
  'src/components/Testimonials.astro': 'Quote cards fed by site.testimonials.',
  'src/components/CtaBand.astro': 'Full-width closing call to action.',
  'src/components/ContactForm.astro': 'Demo form. Does not send data until you add an endpoint.',
  'src/styles/global.css': 'Shared typography, layout, forms, gallery, and components.',
  'src/utils/paths.ts': 'Helpers so links work in dev and in the built dist/ folder.',
  'src/pages/index.astro': 'Home page. Compose or rearrange sections here.',
  'src/pages/source.astro': 'This page. Built at compile time from the files on disk.',
  'public/js/site.js': 'Shared vanilla JS: menu, forms, accordion, lightbox, filters.',
  'public/js/features.js': 'Interactive features unique to this starter.',
  'public/_headers': 'Sample Content-Security-Policy for hosts like Netlify.',
  'astro.config.mjs': 'Astro is set to a static build with one HTML file per page.',
  'package.json': 'npm scripts: dev, build, preview. The only runtime dependency is Astro.',
  'README.md': 'How to run, customize, and hook up a real form or payment provider.',
  'IMAGES.md': 'Photographer credits and source URLs for every image.',
};

function normalize(raw: string): string {
  if (raw.startsWith('../../public/')) return raw.slice(6); // public/...
  if (raw.startsWith('../../')) return raw.slice(6);
  if (raw.startsWith('../')) return 'src/' + raw.slice(3);
  if (raw.startsWith('./')) return 'src/pages/' + raw.slice(2);
  return raw;
}

const files: Entry[] = Object.entries(discovered).map(([rawPath, code]) => {
  const path = normalize(rawPath);
  return {
    path,
    code: String(code),
    note: notes[path] || 'Project file included so the source page stays complete.',
  };
});

// import.meta.glob often skips the file that contains the glob. Add it by hand.
if (!files.some((f) => f.path.endsWith('pages/source.astro'))) {
  files.push({
    path: 'src/pages/source.astro',
    code: String(sourcePage),
    note: notes['src/pages/source.astro'],
  });
}

files.sort((a, b) => a.path.localeCompare(b.path));

const groups: { id: string; title: string; blurb: string; match: (p: string) => boolean }[] = [
  {
    id: 'config',
    title: 'Config and data',
    blurb: 'The knobs you will turn first: business details, package scripts, and Astro settings.',
    match: (p) =>
      p.endsWith('site.json') ||
      p.endsWith('package.json') ||
      p.endsWith('astro.config.mjs') ||
      p.endsWith('README.md') ||
      p.endsWith('IMAGES.md') ||
      p.endsWith('_headers') ||
      p.endsWith('paths.ts'),
  },
  {
    id: 'astro-components',
    title: 'Astro layouts and components',
    blurb: 'Reusable pieces. Each file has a front-matter comment describing what to edit.',
    match: (p) => p.endsWith('.astro') && !p.includes('/pages/'),
  },
  {
    id: 'pages',
    title: 'Pages',
    blurb: 'One file per URL. After `npm run build` these compile to HTML in dist/.',
    match: (p) => p.includes('/pages/') && p.endsWith('.astro'),
  },
  {
    id: 'css',
    title: 'CSS',
    blurb: 'One global stylesheet, themed with CSS variables from site.json.',
    match: (p) => p.endsWith('.css'),
  },
  {
    id: 'js',
    title: 'JavaScript',
    blurb: 'Classic scripts (not modules) so built pages can also run from a simple static server.',
    match: (p) => p.endsWith('.js') && p.startsWith('public/'),
  },
];

function groupFiles(g: (typeof groups)[number]): Entry[] {
  return files.filter((f) => g.match(f.path));
}
---
<BaseLayout
  page="source"
  title="Source"
  description={`Browse the full source for the ${site.name} example site.`}
>
  <section class="section">
    <div class="wrap">
      <p class="eyebrow">Source</p>
      <h1>How this site is built</h1>
      <p class="lead">
        Everything below is the live project source, captured when the site was built.
        After you edit a file, run <code>npm run dev</code> or <code>npm run build</code> to see the change.
        Compiled HTML (the files in <code>dist/</code>) is also loaded below when you are viewing this
        page over http:// or https://.
      </p>
    </div>
  </section>

  <section class="section section--alt">
    <div class="wrap source-layout">
      <nav class="source-nav" aria-label="Source sections">
        {groups.map((g) => (
          <a href={`#${g.id}`}>{g.title}</a>
        ))}
        <a href="#compiled-html">Compiled HTML</a>
      </nav>
      <div>
        {groups.map((g) => (
          <div id={g.id}>
            <h2>{g.title}</h2>
            <p class="lead">{g.blurb}</p>
            {groupFiles(g).map((f) => (
              <article class="source-file" id={f.path.replace(/[^\w]+/g, '-')}>
                <header>
                  <h3><code>{f.path}</code></h3>
                  <p class="meta">{f.note}</p>
                </header>
                <pre><code>{f.code}</code></pre>
              </article>
            ))}
          </div>
        ))}

        <div id="compiled-html">
          <h2>Compiled HTML</h2>
          <p class="lead">
            Astro turns the <code>.astro</code> pages into static HTML at build time.
            If you are viewing this page from a local static server (not a raw file:// URL),
            the built homepage is fetched and shown below. You can also open
            <code>dist/index.html</code> in a text editor after <code>npm run build</code>.
          </p>
          <article class="source-file">
            <header>
              <h3><code>dist/index.html</code></h3>
              <p class="meta">Loaded in the browser when possible. This is output, not the file you edit.</p>
            </header>
            <pre><code data-compiled-html>Open this page via npm run preview (or another static server) to load compiled HTML here.</code></pre>
          </article>
        </div>
      </div>
    </div>
  </section>
</BaseLayout>

CSS

One global stylesheet, themed with CSS variables from site.json.

src/styles/global.css

Shared typography, layout, forms, gallery, and components.

/* ========================================================================
   Shared starter styles
   -----------------------------------------------------------------------
   Colors, fonts, and radius come from src/data/site.json, injected as
   CSS variables on <html> by BaseLayout.astro. Edit that file first.
   You can still override anything below.

   No webfonts are loaded (privacy and performance). Display and body
   stacks use system fonts defined in the theme.
   ======================================================================== */

/* --- Reset-ish base --------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* Fallbacks in case a theme variable is missing */
  --bg: #f6f3ee;
  --fg: #1c1917;
  --primary: #9a3412;
  --primary-text: #fff;
  --accent: #b45309;
  --muted: #57534e;
  --card: #ffffff;
  --border: #e7e0d6;
  --header-bg: #fffdf9;
  --font-display: Georgia, "Iowan Old Style", Palatino, "Times New Roman", serif;
  --font-body: "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.08);
  --max: 70rem;
  --gutter: clamp(1rem, 3vw, 1.75rem);
  background: var(--bg);
  color: var(--fg);
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-underline-offset: 0.15em; }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link appears on keyboard focus */
.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  z-index: 100;
  background: var(--primary);
  color: var(--primary-text);
  padding: 0.5rem 0.8rem;
  border-radius: 0.4rem;
  text-decoration: none;
}
.skip-link:focus { top: 0.5rem; }

/* Demo notice so nobody mistakes these for real businesses */
.example-banner {
  background: var(--fg);
  color: var(--bg);
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  padding: 0.45rem var(--gutter);
}
.example-banner a { color: inherit; }

/* --- Layout ----------------------------------------------------------- */
.wrap {
  width: min(var(--max), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

main { flex: 1 0 auto; }

.section {
  padding: clamp(3rem, 6vw, 5rem) 0;
}
.section--alt { background: color-mix(in srgb, var(--card) 80%, var(--bg)); }
.section--primary {
  background: var(--primary);
  color: var(--primary-text);
}
.section--primary a { color: var(--primary-text); }

.section-head {
  max-width: 40rem;
  margin-bottom: 2rem;
}
.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.lead { font-size: 1.15rem; color: var(--muted); }

.grid {
  display: grid;
  gap: 1.25rem;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }

.split {
  display: grid;
  gap: 2rem;
  align-items: center;
}
@media (min-width: 800px) {
  .split { grid-template-columns: 1.1fr 0.9fr; }
  .split--flip { grid-template-columns: 0.9fr 1.1fr; }
  .split--flip > :first-child { order: 2; }
}

/* --- Header / nav ----------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--header-bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header.is-scrolled { box-shadow: var(--shadow); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.logo:hover { color: var(--primary); }
.logo-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  letter-spacing: 0;
  font-family: var(--font-body);
  font-weight: 700;
}

.nav-list {
  display: flex;
  gap: 0.25rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}
.nav-list a {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.35rem 0.15rem;
}
.nav-list a:hover,
.nav-list a[aria-current="page"] { color: var(--primary); }
.nav-list a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--primary); }

.header-cta { margin-left: 0.5rem; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.55rem;
  color: var(--fg);
  cursor: pointer;
}
.nav-toggle-bar {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: currentColor;
  margin: 0.25rem 0;
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-block; }
  .site-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    display: none;
    padding: 0.75rem var(--gutter) 1rem;
  }
  .site-nav.is-open { display: block; }
  .nav-list { flex-direction: column; align-items: stretch; }
  .nav-list a { display: block; padding: 0.55rem 0; }
  .header-cta { margin: 0.5rem 0 0; display: block; text-align: center; }
}

/* --- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  border: 2px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  background: var(--primary);
  color: var(--primary-text);
  line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); color: var(--primary-text); }
.btn--ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.btn--ghost:hover { color: var(--primary); border-color: var(--primary); }
.btn--light {
  background: var(--card);
  color: var(--fg);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.7rem; }

/* --- Cards, chips, media ---------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; }
.card h3 { margin-bottom: 0.35em; }

.media {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.media img { width: 100%; height: 100%; object-fit: cover; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip, .filter-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.filter-btn.is-active,
.chip--on {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.price {
  font-family: var(--font-display);
  font-size: 1.4rem;
}
.muted, .meta { color: var(--muted); font-size: 0.92rem; }

/* --- Hero variants ---------------------------------------------------- */
.hero {
  position: relative;
  min-height: 70vh;
  display: grid;
  align-items: center;
}
.hero--full {
  min-height: 80vh;
  color: #fff;
}
.hero--full .hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero--full .hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero--full .hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.55)),
    linear-gradient(90deg, rgba(0,0,0,0.45), rgba(0,0,0,0.15));
}
.hero--full .hero-copy {
  position: relative;
  z-index: 1;
  padding: clamp(4rem, 10vw, 8rem) 0;
  max-width: 38rem;
}
.hero--full .eyebrow,
.hero--full .lead { color: rgba(255,255,255,0.86); }
.hero--full h1 { font-size: clamp(2.3rem, 6vw, 4.2rem); color: #fff; }

.hero--split { padding: clamp(2rem, 5vw, 4rem) 0; }
.hero--split h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
.hero--stack { padding: clamp(2rem, 5vw, 3.5rem) 0; }
.hero--stack .hero-media { margin-top: 1.5rem; max-height: 28rem; }

/* --- Forms ------------------------------------------------------------ */
form { display: grid; gap: 0.85rem; }
label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
}
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.form-status {
  min-height: 1.4em;
  font-weight: 600;
  color: var(--primary);
}
.form-note { font-size: 0.85rem; color: var(--muted); }

/* --- FAQ accordion ---------------------------------------------------- */
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 650;
  color: var(--fg);
  padding: 1rem 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.faq-item button::after {
  content: "+";
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1;
}
.faq-item button[aria-expanded="true"]::after { content: "–"; }
.faq-panel { padding: 0 0 1rem; color: var(--muted); }

/* --- Gallery + lightbox ----------------------------------------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
}
.gallery button {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
}
.gallery img { width: 100%; height: 14rem; object-fit: cover; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  display: none;
  place-items: center;
  z-index: 80;
  padding: 1.5rem;
}
.lightbox.is-open { display: grid; }
.lightbox img {
  max-width: min(1100px, 100%);
  max-height: 80vh;
  object-fit: contain;
  border-radius: 0.5rem;
}
.lightbox-caption {
  color: #fff;
  text-align: center;
  margin-top: 0.75rem;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: #fff;
  color: #111;
  border: 0;
  border-radius: 999px;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  font-size: 1.2rem;
}
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev { left: 1rem; top: 50%; }
.lightbox-next { right: 1rem; top: 50%; }

/* --- Tables, hours, lists --------------------------------------------- */
.hours { list-style: none; padding: 0; margin: 0; }
.hours li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* --- Footer ----------------------------------------------------------- */
.site-footer {
  background: color-mix(in srgb, var(--fg) 94%, var(--primary));
  color: color-mix(in srgb, var(--bg) 90%, white);
  padding: 3rem 0 1.5rem;
  margin-top: auto;
}
[data-theme="dark"] .site-footer {
  background: color-mix(in srgb, var(--card) 40%, #000);
}
.site-footer a { color: inherit; }
.footer-grid {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin-bottom: 2rem;
}
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 1rem;
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  justify-content: space-between;
}
.credits { font-size: 0.82rem; opacity: 0.9; }
.credits ul { padding-left: 1.1rem; margin: 0.4rem 0 0; }

/* --- Source page ------------------------------------------------------ */
.source-layout { display: grid; gap: 1.5rem; }
@media (min-width: 900px) {
  .source-layout { grid-template-columns: 16rem 1fr; align-items: start; }
}
.source-nav {
  position: sticky;
  top: 5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.source-nav a {
  display: block;
  color: var(--fg);
  text-decoration: none;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}
.source-file {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}
.source-file header {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, var(--card));
}
.source-file h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.source-file pre {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.45;
  background: #161311;
  color: #f3ece6;
  max-height: 32rem;
}
[data-theme="dark"] .source-file pre { background: #0b0b0c; }
.copy-btn { margin-top: 0.4rem; }

/* --- Feature-specific bits -------------------------------------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.stat-row strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
}
.menu-item, .listing-card, .product-card, .class-row { transition: opacity 0.2s; }
.is-hidden { display: none !important; }

.estimate {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0.4rem 0;
}
.sandbox-flag {
  display: inline-block;
  background: var(--accent);
  color: #111;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 0.3rem;
}

.cart-panel {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--card);
}
.metronome {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
}
.metronome-pulse {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.metronome-pulse.is-on { background: var(--primary); color: var(--primary-text); }

.membership-card.is-featured {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

JavaScript

Classic scripts (not modules) so built pages can also run from a simple static server.

public/js/features.js

Interactive features unique to this starter.

/**
 * Example project quote range. Rates come from data-rate / data-addon
 * attributes in the markup (themselves from site.json).
 * The result is written with textContent only — never innerHTML.
 */
(function () {
  "use strict";

  var form = document.querySelector("[data-quote-calc]");
  if (!form) return;

  function money(n) {
    return "$" + Math.round(n).toLocaleString("en-US");
  }

  function selectedOption(select) {
    var i = select.selectedIndex;
    return i >= 0 ? select.options[i] : null;
  }

  function run() {
    var typeField = form.querySelector("[name='projectType']");
    var sqField = form.querySelector("[name='sqft']");
    var out = form.querySelector("[data-estimate]");
    if (!typeField || !sqField || !out) return;

    var opt = selectedOption(typeField);
    var rate = opt ? Number(opt.getAttribute("data-rate") || 0) : 0;
    var sq = Number(sqField.value || 0);
    var addons = 0;
    form.querySelectorAll("[data-addon]:checked").forEach(function (cb) {
      addons += Number(cb.getAttribute("data-addon") || 0);
    });

    if (!sq || !rate) {
      out.textContent = "Enter a size to see an example range.";
      return;
    }
    var low = sq * rate * 0.85 + addons;
    var high = sq * rate * 1.2 + addons;
    out.textContent = money(low) + " – " + money(high);
  }

  form.addEventListener("input", run);
  form.addEventListener("change", run);
  run();
})();

public/js/site.js

Shared vanilla JS: menu, forms, accordion, lightbox, filters.

/**
 * Shared front-end behavior for the starter sites.
 *
 * Security notes:
 * - Never assign user input to innerHTML. Status messages use textContent.
 * - Forms do not send data anywhere until you hook up an endpoint
 *   (see the form's comments and the README).
 * - No API keys or secrets belong in this file.
 */
(function () {
  "use strict";

  function ready(fn) {
    if (document.readyState === "loading") {
      document.addEventListener("DOMContentLoaded", fn);
    } else {
      fn();
    }
  }

  ready(function () {
    initYear();
    initHeader();
    initMobileNav();
    initForms();
    initAccordion();
    initLightbox();
    initFilters();
    initCompiledHtml();
  });

  function initYear() {
    var nodes = document.querySelectorAll("[data-year]");
    var year = String(new Date().getFullYear());
    nodes.forEach(function (el) {
      el.textContent = year;
    });
  }

  function initHeader() {
    var header = document.querySelector("[data-header]");
    if (!header) return;
    var onScroll = function () {
      header.classList.toggle("is-scrolled", window.scrollY > 8);
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
  }

  function initMobileNav() {
    var toggle = document.querySelector("[data-nav-toggle]");
    var nav = document.querySelector("#site-nav");
    if (!toggle || !nav) return;

    var close = function () {
      nav.classList.remove("is-open");
      toggle.setAttribute("aria-expanded", "false");
    };
    var open = function () {
      nav.classList.add("is-open");
      toggle.setAttribute("aria-expanded", "true");
    };

    toggle.addEventListener("click", function () {
      if (nav.classList.contains("is-open")) close();
      else open();
    });
    document.addEventListener("keydown", function (e) {
      if (e.key === "Escape") close();
    });
    nav.querySelectorAll("a").forEach(function (link) {
      link.addEventListener("click", close);
    });
  }

  /**
   * Demo forms: validate, ignore honeypot spam, and show a thank-you
   * message without submitting anywhere.
   *
   * To go live, set the form's action to a Formspree (or similar) URL
   * or to your own HTTPS endpoint, remove the preventDefault submit
   * handler below (or only preventDefault when the honeypot is filled),
   * and serve the site over HTTPS.
   */
  function initForms() {
    document.querySelectorAll("form[data-demo-form]").forEach(function (form) {
      form.addEventListener("submit", function (e) {
        e.preventDefault();

        var honeypot = form.querySelector("[name='company_website']");
        if (honeypot && honeypot.value) {
          return;
        }

        if (typeof form.reportValidity === "function" && !form.checkValidity()) {
          form.reportValidity();
          return;
        }

        var status = form.querySelector("[data-form-status]");
        var rawName = "";
        var nameField = form.querySelector("[name='name']");
        if (nameField && nameField.value) {
          rawName = String(nameField.value).slice(0, 80);
        }
        var message =
          "Thanks" +
          (rawName ? ", " + rawName : "") +
          ". This is a demo form — nothing was sent. Connect Formspree or your own endpoint to accept real inquiries. See the README.";
        if (status) {
          status.textContent = message;
        }
        form.reset();
      });
    });
  }

  function initAccordion() {
    document.querySelectorAll("[data-accordion]").forEach(function (root) {
      root.querySelectorAll("button[aria-controls]").forEach(function (btn) {
        var panel = document.getElementById(btn.getAttribute("aria-controls"));
        if (!panel) return;
        btn.addEventListener("click", function () {
          var open = btn.getAttribute("aria-expanded") === "true";
          btn.setAttribute("aria-expanded", open ? "false" : "true");
          if (open) {
            panel.setAttribute("hidden", "");
          } else {
            panel.removeAttribute("hidden");
          }
        });
      });
    });
  }

  function initLightbox() {
    var buttons = Array.prototype.slice.call(
      document.querySelectorAll("[data-lightbox]")
    );
    if (!buttons.length) return;

    var dialog = document.createElement("div");
    dialog.className = "lightbox";
    dialog.setAttribute("role", "dialog");
    dialog.setAttribute("aria-modal", "true");
    dialog.setAttribute("hidden", "");

    var img = document.createElement("img");
    img.alt = "";
    var caption = document.createElement("p");
    caption.className = "lightbox-caption";
    var closeBtn = document.createElement("button");
    closeBtn.type = "button";
    closeBtn.className = "lightbox-close";
    closeBtn.setAttribute("aria-label", "Close image");
    closeBtn.textContent = "×";
    var prevBtn = document.createElement("button");
    prevBtn.type = "button";
    prevBtn.className = "lightbox-prev";
    prevBtn.setAttribute("aria-label", "Previous image");
    prevBtn.textContent = "‹";
    var nextBtn = document.createElement("button");
    nextBtn.type = "button";
    nextBtn.className = "lightbox-next";
    nextBtn.setAttribute("aria-label", "Next image");
    nextBtn.textContent = "›";

    var frame = document.createElement("div");
    frame.appendChild(img);
    frame.appendChild(caption);
    dialog.appendChild(closeBtn);
    dialog.appendChild(prevBtn);
    dialog.appendChild(nextBtn);
    dialog.appendChild(frame);
    document.body.appendChild(dialog);

    var index = 0;

    function show(i) {
      index = (i + buttons.length) % buttons.length;
      var btn = buttons[index];
      var src = btn.getAttribute("data-src") || "";
      var alt = btn.getAttribute("data-alt") || "";
      img.src = src;
      img.alt = alt;
      caption.textContent = alt;
      dialog.classList.add("is-open");
      dialog.removeAttribute("hidden");
      closeBtn.focus();
    }

    function hide() {
      dialog.classList.remove("is-open");
      dialog.setAttribute("hidden", "");
      img.removeAttribute("src");
    }

    buttons.forEach(function (btn, i) {
      btn.addEventListener("click", function () {
        show(i);
      });
    });
    closeBtn.addEventListener("click", hide);
    prevBtn.addEventListener("click", function () { show(index - 1); });
    nextBtn.addEventListener("click", function () { show(index + 1); });
    dialog.addEventListener("click", function (e) {
      if (e.target === dialog) hide();
    });
    document.addEventListener("keydown", function (e) {
      if (!dialog.classList.contains("is-open")) return;
      if (e.key === "Escape") hide();
      if (e.key === "ArrowLeft") show(index - 1);
      if (e.key === "ArrowRight") show(index + 1);
    });
  }

  /**
   * Generic filter: buttons with [data-filter] and [data-filter-group]
   * hide siblings of the group that don't match a data-* attribute.
   * Used by menus, class lists, product grids, and listings.
   */
  function initFilters() {
    document.querySelectorAll("[data-filter-group]").forEach(function (group) {
      var targetSel = group.getAttribute("data-filter-target");
      if (!targetSel) return;
      var items = document.querySelectorAll(targetSel);
      var buttons = group.querySelectorAll("[data-filter]");

      buttons.forEach(function (btn) {
        btn.addEventListener("click", function () {
          buttons.forEach(function (b) {
            b.classList.remove("is-active");
            b.setAttribute("aria-pressed", "false");
          });
          btn.classList.add("is-active");
          btn.setAttribute("aria-pressed", "true");
          var key = btn.getAttribute("data-filter-key") || "category";
          var value = btn.getAttribute("data-filter") || "all";
          items.forEach(function (item) {
            var hay = (item.getAttribute("data-" + key) || "").toLowerCase();
            var show = value === "all" || hay.indexOf(value.toLowerCase()) !== -1;
            item.classList.toggle("is-hidden", !show);
          });
        });
      });
    });
  }
  /**
   * On the source page, try to fetch the compiled homepage HTML when we are
   * served over HTTP(S). The result is shown with textContent only.
   */
  function initCompiledHtml() {
    var slot = document.querySelector("[data-compiled-html]");
    if (!slot) return;
    if (location.protocol !== "http:" && location.protocol !== "https:") return;
    fetch("index.html")
      .then(function (res) {
        if (!res.ok) throw new Error("Could not load index.html");
        return res.text();
      })
      .then(function (text) {
        slot.textContent = text;
      })
      .catch(function () {
        slot.textContent =
          "Compiled HTML could not be loaded. Open dist/index.html after npm run build.";
      });
  }

})();

Compiled HTML

Astro turns the .astro pages into static HTML at build time. If you are viewing this page from a local static server (not a raw file:// URL), the built homepage is fetched and shown below. You can also opendist/index.html in a text editor after npm run build.

dist/index.html

Loaded in the browser when possible. This is output, not the file you edit.

Open this page via npm run preview (or another static server) to load compiled HTML here.