<?php
$contact_email = 'you@example.com'; // change this

$success = '';
$error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $name = trim($_POST['name'] ?? '');
    $email = trim($_POST['email'] ?? '');
    $message = trim($_POST['message'] ?? '');
    $company = trim($_POST['company'] ?? ''); // honeypot

    if ($company !== '') {
        $error = 'Spam check failed.';
    } elseif ($name === '' || $email === '' || $message === '') {
        $error = 'Please fill out all fields.';
    } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $error = 'Please enter a valid email address.';
    } else {
        $subject = 'Old Dawgs Creative Contact Form';
        $body =
            "Name: {$name}\n" .
            "Email: {$email}\n\n" .
            "Message:\n{$message}\n";

        $headers = [];
        $headers[] = "From: Old Dawgs Creative <noreply@" . $_SERVER['HTTP_HOST'] . ">";
        $headers[] = "Reply-To: {$name} <{$email}>";
        $headers[] = "Content-Type: text/plain; charset=UTF-8";

        $sent = mail($contact_email, $subject, $body, implode("\r\n", $headers));

        if ($sent) {
            $success = 'Thank you. Your message was sent successfully.';
            $_POST = [];
        } else {
            $error = 'The message could not be sent. Your server mail settings may still need to be configured.';
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Old Dawgs Creative</title>
  <style>
    :root {
      --bg: #e8e1d8;
      --panel: #f7f5f2;
      --text: #2b1d17;
      --muted: #6f5a4e;
      --accent: #a46b42;
      --accent-hover: #8d5935;
      --success-bg: #dfeadf;
      --success-border: #aac5aa;
      --error-bg: #f3e1de;
      --error-border: #ddb8b1;
      --radius: 28px;
      --shadow: 0 12px 35px rgba(0,0,0,.08);
      --max: 1200px;
    }

    * {
      box-sizing: border-box;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      margin: 0;
      font-family: Arial, Helvetica, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.5;
    }

    .wrap {
      width: min(100%, var(--max));
      margin: 0 auto;
    }

    .hero {
      padding: 28px 0 20px;
    }

    .hero-title {
      text-align: center;
      font-size: clamp(2.2rem, 5vw, 4.5rem);
      line-height: 1.02;
      margin: 0 0 18px;
      font-weight: 800;
      letter-spacing: -0.03em;
    }

    .hero-image-wrap {
      width: 100%;
      overflow: hidden;
      border-radius: 0;
      box-shadow: var(--shadow);
    }

    .hero-image {
      display: block;
      width: 100%;
      height: auto;
    }

    .hero-sub {
      text-align: center;
      font-size: clamp(1.15rem, 2vw, 1.8rem);
      color: var(--muted);
      margin: 18px 0 20px;
    }

    .hero-cta {
      text-align: center;
    }

    .btn {
      display: inline-block;
      background: var(--accent);
      color: #fff;
      text-decoration: none;
      border: 0;
      border-radius: 999px;
      padding: 14px 26px;
      font-size: 1.1rem;
      font-weight: 700;
      cursor: pointer;
      transition: background .2s ease;
    }

    .btn:hover {
      background: var(--accent-hover);
    }

    .contact {
      padding: 26px 18px 48px;
    }

    .card {
      background: var(--panel);
      border-radius: var(--radius);
      padding: 34px;
      box-shadow: var(--shadow);
    }

    .card h2 {
      margin-top: 0;
      margin-bottom: 10px;
      font-size: clamp(2rem, 4vw, 3rem);
      line-height: 1.05;
    }

    .card p.lead {
      margin-top: 0;
      margin-bottom: 24px;
      color: var(--muted);
      font-size: 1.1rem;
    }

    .notice {
      border-radius: 18px;
      padding: 16px 18px;
      margin-bottom: 18px;
      font-size: 1.05rem;
    }

    .notice.success {
      background: var(--success-bg);
      border: 1px solid var(--success-border);
      color: #234323;
    }

    .notice.error {
      background: var(--error-bg);
      border: 1px solid var(--error-border);
      color: #6d2b25;
    }

    .grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 18px;
    }

    label {
      display: block;
      font-weight: 700;
      margin-bottom: 8px;
      font-size: 1.05rem;
    }

    input,
    textarea {
      width: 100%;
      border: 1px solid #d3cbc2;
      border-radius: 18px;
      padding: 16px 18px;
      font: inherit;
      color: var(--text);
      background: #fff;
    }

    textarea {
      min-height: 210px;
      resize: vertical;
    }

    .field {
      margin-bottom: 18px;
    }

    .hp {
      position: absolute;
      left: -9999px;
      opacity: 0;
      pointer-events: none;
    }

    .footnote {
      margin-top: 22px;
      color: var(--muted);
      font-size: 1rem;
    }

    @media (max-width: 700px) {
      .hero {
        padding-top: 16px;
      }

      .contact {
        padding: 20px 12px 36px;
      }

      .card {
        padding: 24px 18px;
        border-radius: 22px;
      }

      .grid {
        grid-template-columns: 1fr;
      }
    }
  </style>
</head>
<body>

  <section class="hero">
    <div class="wrap">
      <h1 class="hero-title">Old Dawgs Creative</h1>

      <div class="hero-image-wrap">
        <img
          class="hero-image"
          src="images/olddawg.jpg"
          alt="Old Dawgs Creative dog"
        >
      </div>

      <p class="hero-sub">Reach Us Here</p>

      </div>
  </section>

  <section class="contact" id="contact">
    <div class="wrap">
      <div class="card">
        <h2>Contact Old Dawgs Creative</h2>
        <p class="lead">Tell us a little about your project and we will get back to you.</p>

        <?php if ($success !== ''): ?>
          <div class="notice success"><?php echo htmlspecialchars($success, ENT_QUOTES, 'UTF-8'); ?></div>
        <?php endif; ?>

        <?php if ($error !== ''): ?>
          <div class="notice error"><?php echo htmlspecialchars($error, ENT_QUOTES, 'UTF-8'); ?></div>
        <?php endif; ?>

        <form method="post" action="">
          <div class="hp">
            <label for="company">Company</label>
            <input type="text" id="company" name="company" autocomplete="off">
          </div>

          <div class="grid">
            <div class="field">
              <label for="name">Name</label>
              <input
                type="text"
                id="name"
                name="name"
                required
                value="<?php echo htmlspecialchars($_POST['name'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"
              >
            </div>

            <div class="field">
              <label for="email">Email</label>
              <input
                type="email"
                id="email"
                name="email"
                required
                value="<?php echo htmlspecialchars($_POST['email'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"
              >
            </div>
          </div>

          <div class="field">
            <label for="message">Message</label>
            <textarea id="message" name="message" required><?php echo htmlspecialchars($_POST['message'] ?? '', ENT_QUOTES, 'UTF-8'); ?></textarea>
          </div>

          <button class="btn" type="submit">Send Message</button>
        </form>
      </div>
    </div>
  </section>

</body>
</html>