/* ============================================
   Sparky HQ - Base Styles
   Clean, fast, mobile-first
   ============================================ */

:root {
    --accent: #D4910D;
    --accent-light: #F5A623;
    --dark: #1c1c1c;
    --white: #ffffff;
    --offwhite: #fafaf8;
    --gray: #f2f1ef;
    --border: #e2e0dc;
    --text: #2c2c2c;
    --text-light: #5a5a5a;
    --text-muted: #888888;
    --radius: 8px;
    --max-width: 1100px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--offwhite);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--white);
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    width: auto;
}

nav a {
    color: var(--text);
    text-decoration: none;
    margin-left: 24px;
    font-size: 0.95rem;
    font-weight: 500;
}

nav a:hover {
    color: var(--accent);
}

/* Hero - Subtle warm dark */
.hero {
    background: var(--dark);
    color: var(--white);
    padding: 44px 0;
    text-align: center;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Tools Grid */
.tools-grid {
    padding: 48px 0;
}

.tools-grid h2 {
    font-size: 1.5rem;
    margin-bottom: 28px;
    color: var(--text);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Tool Cards */
.tool-card {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--accent);
}

.tool-card .card-icon {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--white);
}

.tool-card .card-icon h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin: 0;
    font-weight: 700;
}

.tool-card .card-icon .nec-tag {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 3px;
    letter-spacing: 0.02em;
}

.tool-card .card-body {
    padding: 16px 24px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tool-card .card-body p {
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.6;
    flex: 1;
}

.tool-card .card-body .card-link {
    margin-top: 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.tool-card:hover .card-link {
    text-decoration: underline;
}

/* Footer */
.site-footer {
    background: var(--dark);
    color: var(--text-muted);
    padding: 32px 0;
    text-align: center;
    font-size: 0.85rem;
}

.site-footer p + p {
    margin-top: 8px;
    font-size: 0.75rem;
}

/* ============================================
   Calculator Pages - Shared Styles
   ============================================ */

.calc-page {
    padding: 40px 0;
}

.calc-page h1 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.calc-page .subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
}

/* Disclaimer Box (below calculators) */
.disclaimer-box {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px 20px 32px;
}

.disclaimer-box p {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 14px 18px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.6;
    text-align: center;
}

.disclaimer-box a {
    color: var(--text-muted);
    text-decoration: underline;
}

.calc-form {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--white);
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 145, 13, 0.12);
}

.btn {
    background: var(--accent);
    color: var(--white);
    border: none;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #b87c0a;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    background: transparent;
}

.result {
    background: var(--gray);
    border-radius: var(--radius);
    padding: 24px;
    display: none;
}

.result.show {
    display: block;
}

.result-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
}

.result-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.result-pass {
    color: #16a34a;
    font-weight: 700;
}

.result-fail {
    color: #dc2626;
    font-weight: 700;
}

/* Method Toggle */
.method-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.method-toggle button {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
}

.method-toggle button.active {
    background: var(--accent);
    color: var(--white);
}

/* Wire Entry Rows (conduit fill) */
.wire-entry {
    display: grid;
    grid-template-columns: 1fr 1fr 80px 40px;
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
}

.wire-entry select,
.wire-entry input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.wire-entry .btn-remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
}

.wire-entry .btn-remove:hover {
    background: #fef2f2;
    border-radius: 4px;
}

/* Breakdown Table */
.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.breakdown-table th,
.breakdown-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.breakdown-table th {
    font-weight: 600;
    color: var(--text);
    background: var(--gray);
}

.breakdown-table td {
    color: var(--text-light);
}

.breakdown-table tr:last-child td {
    border-bottom: none;
    font-weight: 600;
    color: var(--text);
}

/* NEC Reference Tag */
.nec-ref {
    display: inline-block;
    background: #f5f0e6;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

/* About Page */
.about-page {
    padding: 60px 0;
}

.about-page h1 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.about-page p {
    max-width: 680px;
    margin-bottom: 16px;
    color: var(--text-light);
    line-height: 1.8;
}

.about-page a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.about-page a:hover {
    text-decoration: underline;
}

/* Checkbox / Toggle Group */
.checkbox-group {
    margin-bottom: 16px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 6px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

/* Appliance Checklist (generator sizing) */
.appliance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
}

/* Result sections */
.result-section {
    margin-bottom: 16px;
}

.result-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text);
}

/* Install Banner */
#install-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--dark);
    color: #ccc;
    padding: 10px 20px;
    font-size: 0.84rem;
    line-height: 1.4;
}

#install-banner span {
    flex: 1;
}

#install-btn {
    background: var(--accent);
    color: var(--white);
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
}

#install-x {
    background: none;
    border: none;
    color: #666;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

/* Calc Header with Share */
.calc-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-share {
    background: var(--accent);
    border: 1px solid var(--accent);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--white);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.btn-share:hover {
    background: #b87c0a;
    border-color: #b87c0a;
}

/* Mobile */
@media (max-width: 600px) {
    .hero {
        padding: 32px 0;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .wire-entry {
        grid-template-columns: 1fr 1fr;
    }

    .wire-entry input[type="number"] {
        grid-column: 1;
    }

    .appliance-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Guidance Boxes — Reusable across all calcs
   ============================================ */

/* NEC context / informational notes */
.info-box {
    background: #fef9ee;
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.info-box strong { color: #b87c0a; }

/* Warnings — violations, concerns */
.warning-box {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.warning-box strong { color: #dc2626; }

/* Practical tips / suggestions */
.tip-box {
    background: #f0fdf4;
    border-left: 4px solid #16a34a;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.tip-box strong { color: #16a34a; }

/* Caution — approaching a limit, not yet a violation */
.caution-box {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.caution-box strong { color: #d97706; }

/* Small gray note under a field */
.field-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
}

/* Collapsible section */
.collapsible-section {
    margin-bottom: 16px;
}

.collapsible-section summary {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--accent);
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    background: var(--gray);
    border-left: 4px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

.collapsible-section summary:hover {
    background: #edecea;
}

.collapsible-section .section-content {
    padding: 12px 0 0;
}

/* Preset buttons row */
.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.preset-btn {
    background: var(--gray);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.preset-btn:hover {
    border-color: var(--accent);
    background: #f5f0e6;
}

.preset-btn.active {
    border-color: var(--accent);
    background: #f5f0e6;
    font-weight: 600;
    color: var(--accent);
}

/* Mode toggle for sub-modes within a calc */
.sub-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sub-toggle button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
}

.sub-toggle button.active {
    background: var(--accent);
    color: var(--white);
}

/* NEC result section with separator */
.nec-result-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid var(--accent);
}

.nec-result-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text);
}

/* ============================================
   Apply Button + Validation Messages
   ============================================ */

.apply-section {
    text-align: center;
    margin: 20px 0 0;
}

.apply-terms {
    font-size: 0.78rem;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto 10px;
    line-height: 1.5;
}

.validation-errors {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.validation-errors strong { color: #dc2626; }

.validation-errors ul,
.validation-warnings ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

.validation-errors li,
.validation-warnings li {
    margin-bottom: 2px;
}

.validation-warnings {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.validation-warnings strong { color: #d97706; }

@media (max-width: 600px) {
    .preset-row {
        gap: 6px;
    }

    .preset-btn {
        font-size: 0.78rem;
        padding: 5px 10px;
    }
}
