:root {
    --c-deep: #0b2a5b;
    --c-brand: #1e3a8a;
    --c-blue: #2563eb;
    --c-aqua: #0ea5e9;
    --c-mist: #e0f2fe;
    --c-bg: #f6fafd;
    --c-text: #1f2937;
    --c-muted: #6b7280;
    --c-line: #d8e3f1;
    --c-success: #047857;
    --c-success-bg: #d1fae5;
    --c-error: #b91c1c;
    --radius: 14px;
    --shadow-sm: 0 2px 6px rgba(11, 42, 91, 0.08);
    --shadow-md: 0 8px 30px rgba(11, 42, 91, 0.12);
    --container: 1140px;
    --gap: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* Guard against any descendant accidentally overflowing the viewport
   on small screens — prevents the unwanted horizontal scroll bar. */
html, body { overflow-x: hidden; }

body {
    margin: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.55;
}

img { max-width: 100%; display: block; }

a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--c-deep); margin: 0 0 .5em; line-height: 1.2; }

h1 { font-size: clamp(28px, 4.4vw, 44px); }
h2 { font-size: clamp(24px, 3.4vw, 34px); margin-bottom: 1em; }
h3 { font-size: 20px; }

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

.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--c-aqua), var(--c-blue));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-ghost {
    background: transparent;
    color: var(--c-deep);
    border-color: var(--c-line);
}
.btn-ghost:hover { background: #fff; border-color: var(--c-blue); }
.btn-block { width: 100%; padding: 14px 22px; font-size: 16px; }

/* Header */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--c-line);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.header-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    padding: 12px 0;
    flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 56px; width: auto; }
.header-contacts {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.header-phone {
    font-weight: 600;
    color: var(--c-deep);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
}
.header-phone:hover { color: var(--c-blue); text-decoration: none; }
.header-phone-fallback {
    font-weight: 500;
    color: var(--c-muted);
}
.phone-icon { font-size: 14px; }

/* Brand banner — visual introduction above the hero text */
.brand-banner {
    background: #fff;
    padding: 24px 0 0;
}
.brand-banner-img {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

/* Hero */
.hero {
    background:
        radial-gradient(1200px 400px at 90% -20%, rgba(14,165,233,.18), transparent 60%),
        linear-gradient(180deg, #fff 0%, var(--c-mist) 100%);
    padding: 36px 0 64px;
}
.hero-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 40px;
    align-items: center;
}
.hero-text p.hero-lead {
    font-size: 18px;
    color: #334155;
    max-width: 56ch;
}
.hero-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.stat {
    background: #fff;
    border-radius: var(--radius);
    padding: 22px 18px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--c-line);
}
.stat:nth-child(3) { grid-column: span 2; }
.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--c-blue);
    line-height: 1;
}
.stat-label {
    margin-top: 6px;
    color: var(--c-muted);
    font-size: 14px;
}

/* About */
.about { padding: 64px 0; }
.about-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 32px;
    align-items: start;
}
.about-text p { font-size: 17px; color: #334155; }
.about-bullets {
    list-style: none;
    padding: 24px;
    margin: 0;
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--c-line);
    box-shadow: var(--shadow-sm);
}
.about-bullets li {
    padding: 8px 0 8px 28px;
    position: relative;
    color: var(--c-deep);
    font-weight: 500;
}
.about-bullets li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--c-aqua);
    font-weight: 800;
}

/* Services */
.services {
    padding: 64px 0;
    background: linear-gradient(180deg, var(--c-mist) 0%, #fff 100%);
}
.services-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.service-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--c-line);
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .2s ease;
}
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.service-card h3 { color: var(--c-brand); }

/* Works gallery */
.works {
    padding: 64px 0;
    background: linear-gradient(180deg, #fff 0%, var(--c-mist) 100%);
}
.works-intro {
    color: var(--c-muted);
    margin: -8px 0 24px;
    max-width: 60ch;
}
.works-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.work-card {
    margin: 0;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--c-line);
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .2s ease;
}
.work-card { cursor: zoom-in; }
.work-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Lightbox — full-size photo overlay (built on the fly by lightbox_controller.js) */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(11, 42, 91, .92);
    cursor: zoom-out;
}
.lightbox-overlay.is-open { display: flex; }
.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
    cursor: default;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .25); }
.work-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: center;
    display: block;
}
.work-caption {
    padding: 14px 16px 16px;
    color: var(--c-deep);
    font-size: 14px;
    line-height: 1.5;
}

/* FAQ */
.faq { padding: 64px 0; }
.faq-list { display: grid; gap: 12px; }
.faq details {
    background: #fff;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--c-line);
    box-shadow: var(--shadow-sm);
}
.faq summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--c-deep);
    list-style: none;
    position: relative;
    padding-right: 28px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
    content: "+";
    position: absolute;
    right: 0;
    top: 0;
    color: var(--c-blue);
    font-size: 22px;
    line-height: 1;
}
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 12px 0 0; color: #334155; }

/* Lead form */
.lead-form-section {
    padding: 64px 0;
    background:
        radial-gradient(800px 300px at 0% 100%, rgba(14,165,233,.12), transparent 70%),
        var(--c-bg);
}
.lead-form-intro {
    color: var(--c-muted);
    margin: -8px 0 24px;
    max-width: 60ch;
}
.lead-form-wrapper {
    background: #fff;
    padding: 32px;
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--c-line);
    max-width: 720px;
}
.lead-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.lead-form .form-field { margin-bottom: 16px; }
.lead-form label {
    display: block;
    font-weight: 600;
    color: var(--c-deep);
    margin-bottom: 6px;
    font-size: 14px;
}
.lead-form .input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--c-line);
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.lead-form .input:focus {
    outline: none;
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.lead-form .textarea { resize: vertical; min-height: 110px; }
.lead-form ul {
    margin: 6px 0 0;
    padding-left: 18px;
    color: var(--c-error);
    font-size: 14px;
}
.form-disclaimer {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--c-muted);
}

/* Toast */
.toast {
    margin-top: 18px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 15px;
}
.toast-success {
    background: var(--c-success-bg);
    color: var(--c-success);
    border: 1px solid #6ee7b7;
}

/* Footer */
.site-footer {
    background: var(--c-deep);
    color: #cbd5e1;
    padding: 48px 0 16px;
    margin-top: 24px;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 32px;
}
.footer-brand p { margin: 12px 0 0; max-width: 36ch; color: #93a4bd; }
.footer-logo {
    height: 56px;
    width: auto;
    background: #fff;
    border-radius: 8px;
    padding: 6px;
}
.site-footer h4 {
    color: #fff;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 10px;
}
.phone-list { list-style: none; padding: 0; margin: 0; }
.phone-list li { padding: 4px 0; }
.phone-list a { color: #fff; font-weight: 600; }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.08);
    margin-top: 32px;
    padding-top: 16px;
    text-align: center;
    color: #64748b;
}

/* Mobile sticky action bar — hidden on desktop */
.mobile-action-bar { display: none; }

/* Responsive */
@media (max-width: 880px) {
    .hero-grid,
    .about-grid,
    .footer-grid { grid-template-columns: 1fr; }
    .hero-stats { grid-template-columns: 1fr 1fr; }
    .stat:nth-child(3) { grid-column: span 2; }
    .services-grid { grid-template-columns: 1fr 1fr; }
    .works-grid { grid-template-columns: 1fr 1fr; }
    .lead-form .form-row { grid-template-columns: 1fr; }
    .header-grid { gap: 12px; }
}

/* Extra right inset for the header CTA on tablet+desktop (above the mobile
   breakpoint) — keeps "Замовити свердловину" from sitting flush against the
   right edge whenever the container fills the viewport. */
@media (min-width: 601px) {
    .header-grid { padding-right: 12px; }
}
@media (max-width: 600px) {
    /* Reserve space at the bottom so the fixed action bar never covers content. */
    body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }

    .mobile-action-bar {
        display: grid;
        /* Auto-fit so one visible button stretches full width, two split 50/50. */
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 60;
        background: #fff;
        border-top: 1px solid var(--c-line);
        box-shadow: 0 -6px 18px rgba(11, 42, 91, .08);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .mab-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 14px 8px;
        font-weight: 600;
        font-size: 15px;
        color: #fff;
        text-decoration: none;
        min-height: 56px;
    }
    .mab-btn:hover { text-decoration: none; }
    .mab-call { background: linear-gradient(135deg, var(--c-aqua), var(--c-blue)); }
    .mab-viber { background: #7360F2; }
    .mab-ico { font-size: 18px; line-height: 1; }

    /* Mobile header: keep logo on the left, stack phones on the right
       (column instead of wrapping below the logo on a new line) */
    .header-grid {
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }
    .brand-logo { height: 42px; }
    .header-cta { display: none; }
    .header-contacts {
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        margin-left: auto;
        /* Visual breathing room from the viewport edge — phones felt cramped
           against the right when sitting flush with the container padding. */
        padding-right: 6px;
    }
    .header-phone {
        font-size: 14px;
        gap: 4px;
        white-space: nowrap;
    }
    .phone-icon { font-size: 12px; }
}
@media (max-width: 520px) {
    /* Tighter vertical rhythm on phones — the desktop 64px gaps add up to
       ~128px of empty space between FAQ and "Залишити заявку" otherwise. */
    .brand-banner { padding: 12px 0 0; }
    .brand-banner-img { border-radius: 8px; }
    .hero { padding: 24px 0 32px; }
    .about,
    .services,
    .faq,
    .lead-form-section { padding: 32px 0; }
    h2 { margin-bottom: .7em; }

    .services-grid { grid-template-columns: 1fr; }
    .works-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .work-img { height: 160px; }
    .work-caption { padding: 10px 12px 12px; font-size: 13px; }
    .lead-form-wrapper { padding: 18px; }
    .lead-form-intro { margin: -4px 0 16px; }

    .site-footer { padding: 32px 0 12px; }
    .footer-bottom { margin-top: 20px; }
}
