/* Theme Variables */
:root {
    /* Light Theme (default fallback) */
    --bg-color: #f5f6f8;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --accent-color: #9a6b00;
    --border-color: #e5e7eb;
    --input-bg: #f9fafb;
    --input-color: #111827;
    --input-border: #d1d5db;
    --input-focus-border: #9a6b00;
    --btn-bg: #f1c40f;
    --btn-hover: #d4ac0d;
    --btn-text: #121212;
    --toggle-bg: #ffffff;
    --toggle-border: #d1d5db;
    --toggle-color: #4b5563;
    --toggle-hover-bg: #f3f4f6;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --crest-shadow: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.12));
}

/* Automatically apply dark theme when system/browser prefers dark */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-color: #121212;
        --card-bg: #1e1e1e;
        --text-primary: #ffffff;
        --text-secondary: #e0e0e0;
        --text-muted: #9ca3af;
        --accent-color: #f1c40f;
        --border-color: #2e2e2e;
        --input-bg: #2a2a2a;
        --input-color: #ffffff;
        --input-border: #383838;
        --input-focus-border: #f1c40f;
        --btn-bg: #f1c40f;
        --btn-hover: #d4ac0d;
        --btn-text: #121212;
        --toggle-bg: #1e1e1e;
        --toggle-border: #383838;
        --toggle-color: #f1c40f;
        --toggle-hover-bg: #2a2a2a;
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
        --crest-shadow: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.5));
    }
}

/* Explicit data-theme rules for manual toggle override */
[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #9ca3af;
    --accent-color: #f1c40f;
    --border-color: #2e2e2e;
    --input-bg: #2a2a2a;
    --input-color: #ffffff;
    --input-border: #383838;
    --input-focus-border: #f1c40f;
    --btn-bg: #f1c40f;
    --btn-hover: #d4ac0d;
    --btn-text: #121212;
    --toggle-bg: #1e1e1e;
    --toggle-border: #383838;
    --toggle-color: #f1c40f;
    --toggle-hover-bg: #2a2a2a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --crest-shadow: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.5));
}

[data-theme="light"] {
    --bg-color: #f5f6f8;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --accent-color: #9a6b00;
    --border-color: #e5e7eb;
    --input-bg: #f9fafb;
    --input-color: #111827;
    --input-border: #d1d5db;
    --input-focus-border: #9a6b00;
    --btn-bg: #f1c40f;
    --btn-hover: #d4ac0d;
    --btn-text: #121212;
    --toggle-bg: #ffffff;
    --toggle-border: #d1d5db;
    --toggle-color: #4b5563;
    --toggle-hover-bg: #f3f4f6;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --crest-shadow: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.12));
}

/* Base Styling */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: clamp(12px, 2.5vh, 20px);
    right: clamp(12px, 2.5vw, 20px);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--toggle-bg);
    border: 1px solid var(--toggle-border);
    color: var(--toggle-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    z-index: 100;
}

.theme-toggle-btn:hover {
    transform: scale(1.08);
    background-color: var(--toggle-hover-bg);
}

.theme-toggle-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.theme-toggle-btn:hover svg {
    transform: rotate(15deg);
}

/* Icon visibility matching system theme and manual overrides */
.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun {
        display: block;
    }
    :root:not([data-theme="light"]) .icon-moon {
        display: none;
    }
}

[data-theme="dark"] .icon-sun {
    display: block !important;
}

[data-theme="dark"] .icon-moon {
    display: none !important;
}

[data-theme="light"] .icon-sun {
    display: none !important;
}

[data-theme="light"] .icon-moon {
    display: block !important;
}

.container {
    max-width: 680px;
    padding: clamp(10px, 2vh, 24px) 20px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Image Display */
.crest-img {
    max-width: 100%;
    /* Dynamically fills available vertical space while guaranteeing no scroll */
    max-height: clamp(170px, calc(100vh - 220px), 461px);
    width: auto;
    height: auto;
    object-fit: contain;
    margin-bottom: clamp(10px, 2vh, 20px);
    filter: var(--crest-shadow);
    transition: filter 0.3s ease;
}

/* Dynamic Quote Block */
.quote-container {
    margin: 0 0 clamp(12px, 2vh, 22px) 0;
    min-height: clamp(55px, 8vh, 75px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

.quote-text {
    font-size: clamp(1rem, 1.7vh, 1.25rem);
    font-style: italic;
    color: var(--text-secondary);
    margin: 0 0 6px 0;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.quote-author {
    font-size: clamp(0.85rem, 1.3vh, 0.95rem);
    color: var(--accent-color);
    /* Heritage Gold Accent */
    font-weight: bold;
    letter-spacing: 0.5px;
    margin: 0;
    transition: color 0.3s ease;
}

/* Lead Capture Form */
.lead-form {
    background-color: var(--card-bg);
    padding: clamp(14px, 2.2vh, 20px) clamp(18px, 3.5vw, 28px);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.lead-form h3 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: clamp(1.1rem, 1.9vh, 1.3rem);
    color: var(--accent-color);
    transition: color 0.3s ease;
}

.lead-form p {
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(0.85rem, 1.4vh, 0.95rem);
    transition: color 0.3s ease;
}

.form-group {
    display: flex;
    gap: 10px;
    margin-top: clamp(10px, 1.6vh, 16px);
}

input[type="email"] {
    flex: 1;
    padding: clamp(9px, 1.4vh, 12px) 14px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--input-color);
    font-size: clamp(0.9rem, 1.5vh, 1rem);
    outline: none;
    transition: background-color 0.3s ease, border-color 0.2s ease, color 0.3s ease, box-shadow 0.2s ease;
}

input[type="email"]:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.25);
}

button[type="submit"] {
    padding: clamp(9px, 1.4vh, 12px) 22px;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    border-radius: 6px;
    font-size: clamp(0.9rem, 1.5vh, 1rem);
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

button[type="submit"]:hover {
    background-color: var(--btn-hover);
    transform: translateY(-1px);
}

button[type="submit"]:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    .form-group {
        flex-direction: column;
    }
}
