/* Base styles */
:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #0ea5e9;
  --brand-700: #0369a1;
  --surface: #f3f4f6;
  --border: #e5e7eb;
  --header-h: 56px;
  --action-bar-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
.container { width: min(1100px, 92%); margin-inline: auto; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(150%) blur(6px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 14px rgba(2,6,23,0.06);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: calc(0.5rem + env(safe-area-inset-top)) 0 0.5rem; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; }
.brand-mark { width: 36px; height: 36px; background: linear-gradient(135deg, var(--brand), var(--brand-700)); border-radius: 6px; }
.brand-logo { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; display: block; }
.brand-name { font-weight: 700; letter-spacing: 0.2px; }
@media (max-width: 767px) {
  .brand-name { max-width: 58vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-toggle { min-width: 40px; min-height: 40px; }
}

.nav-toggle { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 0.75rem; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; cursor: pointer; }
.nav-toggle.is-active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 8px 20px rgba(14,165,233,0.35); }
.nav-toggle.is-active svg path { stroke: currentColor; }
.nav { display: none; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1rem; }
.nav a { text-decoration: none; color: var(--text); padding: 0.5rem 0.4rem; border-radius: 8px; font-weight: 600; }
.nav a:hover, .nav a:focus { color: var(--brand-700); }
.nav-cta { display: none; }

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .nav { display: block; }
  .nav-cta { display: none !important; }
}

/* Mobile dropdown panel */
@media (max-width: 767px) {
  .site-header { position: sticky; top: 0; }
  .header-inner { position: relative; min-height: var(--header-h); }
  /* Keep header height static; dropdown is fixed overlay below header */
  .nav { position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 120; }
  .nav-backdrop { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
  .nav-panel { width: min(560px, calc(100% - 24px)); margin: 8px auto calc(10px + var(--action-bar-h)); background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 44px rgba(0,0,0,0.14); overflow: hidden; transform: translateY(-8px) scale(0.985); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .24s ease; max-height: calc(100dvh - var(--header-h) - var(--action-bar-h) - 24px); overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .nav ul { padding: 4px 6px; }
  .nav li + li { border-top: 1px solid var(--border); }
  .nav a { padding: 1.05rem 0.95rem; display: block; font-weight: 700; border-radius: 10px; }
  .nav a:hover, .nav a:focus { background: rgba(14,165,233,0.08); }
  .nav-cta { padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
  .nav-cta .btn { width: 100%; }
}

/* Hero */
.hero {
  position: relative;
  min-height: 58vh;
  display: grid; place-items: center; text-align: center;
  color: #0b1220;
  background: url('https://picsum.photos/1600/900?grayscale&blur=1') center/cover no-repeat; /* placeholder image */
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.62)); }
.hero-inner { position: relative; z-index: 1; padding: 5rem 0; }
.hero h1 { font-size: clamp(1.6rem, 2.6vw + 1rem, 2.6rem); margin: 0 0 0.5rem; }
.hero p { margin: 0 0 1rem; color: #1f2937; opacity: 0.9; }
@media (max-width: 767px) {
  .hero h1 { font-weight: 800; letter-spacing: -0.3px; }
}
@media (max-width: 767px) {
  .hero { min-height: 50vh; }
  .hero-inner { padding: 3.25rem 0; }
  .hero .btn { display: none; }
}
@media (max-width: 767px) {
  .brand-logo { width: 32px; height: 32px; }
}

/* Slightly denser layout on small screens */
@media (max-width: 767px) {
  .container { width: min(1100px, 94%); }
}

.btn { display: inline-block; background: var(--brand); color: white; text-decoration: none; padding: 0.7rem 1.05rem; border-radius: 12px; border: 1px solid transparent; font-weight: 700; box-shadow: 0 6px 16px rgba(2,6,23,0.12); }
.btn:hover, .btn:focus { background: var(--brand-700); box-shadow: 0 10px 22px rgba(2,6,23,0.18); }

/* Button variants */
.btn.btn-secondary { background: transparent; color: var(--brand-700); border-color: var(--brand-700); }
.btn.btn-secondary:hover, .btn.btn-secondary:focus { color: white; background: var(--brand-700); }

/* Sections */
.section { padding: 3.5rem 0; }
.section-alt { background: var(--surface); }
.section h2 { margin-top: 0; font-size: clamp(1.4rem, 1.5vw + 1rem, 2rem); }
@media (max-width: 767px) {
  .section { padding: 2.25rem 0; }
}

/* Services */
.services-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1rem; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; transition: box-shadow .18s ease, transform .18s ease; }
.card:hover { box-shadow: 0 12px 24px rgba(2,6,23,0.08); transform: translateY(-2px); }
.card-media { height: 120px; background: repeating-linear-gradient(45deg, #e5e7eb, #e5e7eb 10px, #f3f4f6 10px, #f3f4f6 20px); border-radius: 8px; margin-bottom: 0.75rem; }
.service-icon { width: 100%; height: 96px; display: block; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 10px; margin-bottom: 0.6rem; }

@media (min-width: 600px) {
  .services-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .services-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Area Converter - Calculator Style */
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 1.2rem; margin-top: 1rem; }
.calc-grid .card { background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%); box-shadow: 0 4px 16px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.8); border: 2px solid var(--border); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.calc-grid .card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.8); }
.calc-grid .card h3 { background: linear-gradient(135deg, var(--brand), var(--brand-700)); color: white; margin: -1rem -1rem 1rem; padding: 0.75rem 1rem; border-radius: 10px 10px 0 0; font-size: 1.05rem; box-shadow: 0 2px 8px rgba(14,165,233,0.2); }
.calc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.calc-row label:has(select) { min-width: 140px; }
.calc-row label { display: grid; gap: 0.4rem; font-weight: 700; color: var(--text); font-size: 0.9rem; }
.calc-row input, .calc-row select { width: 100%; padding: 0.85rem 0.9rem; border: 2px solid var(--border); border-radius: 10px; font: inherit; font-size: 1rem; background: white; box-shadow: inset 0 2px 4px rgba(0,0,0,0.04); transition: all 0.2s ease; }
.calc-row input:focus, .calc-row select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,165,233,0.15), inset 0 2px 4px rgba(0,0,0,0.04); transform: translateY(-1px); }
.calc-results { margin-top: 0.75rem; padding: 0.85rem 1rem; border: 2px solid var(--brand); border-radius: 10px; background: linear-gradient(135deg, rgba(14,165,233,0.05) 0%, rgba(14,165,233,0.02) 100%); color: var(--text); font-size: 0.95rem; font-weight: 600; box-shadow: 0 2px 8px rgba(14,165,233,0.1); min-height: 40px; }
.calc-clear-wrapper { display: flex; justify-content: center; margin-top: 0.6rem; }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.85rem; min-width: 80px; }
.btn:active { transform: scale(0.97); }
@media (min-width: 700px) { .calc-row { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .calc-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .calc-row { grid-template-columns: 1fr; } }
/* Specific grid for cards with 2 inputs + dropdown (Any Unit & Plot Calculator) */
#calc-any .calc-row { grid-template-columns: 1fr 1.3fr; }
#calc-plot .calc-row { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 480px) { 
  #calc-any .calc-row, #calc-plot .calc-row { grid-template-columns: 1fr; } 
}

/* Product (RoadStudio) */
.product-wrapper { display: grid; grid-template-columns: 1fr; gap: 1.1rem; align-items: start; margin-top: 0.8rem; }
.product-media { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); display: block; }
.product-illustration { width: 100%; max-height: 280px; height: auto; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); display: block; background: var(--surface); }
.product-content .features-list { margin: 0.5rem 0 1rem; padding-left: 1.1rem; }
.features-list li { margin: 0.25rem 0; }
.product-cta { display: flex; gap: 0.5rem; flex-wrap: wrap; }

@media (min-width: 900px) {
  .product-wrapper { grid-template-columns: 1fr 1.2fr; }
}

/* Contact */
.contact-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-top: 1rem; }
.contact-info p { margin: 0.25rem 0; }
.contact-form { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; }
.form-field { display: grid; gap: 0.35rem; margin-bottom: 0.75rem; }
.form-field input, .form-field textarea { padding: 0.6rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; background: var(--surface); color: var(--text); font-family: inherit; }
.form-field input:focus, .form-field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,233,0.18); }
button.btn { cursor: pointer; }
.contact-map { margin-top: 1.25rem; }
.contact-map iframe { box-shadow: 0 2px 8px rgba(0,0,0,0.1); display: block; }

@media (min-width: 900px) {
  .contact-grid { grid-template-columns: 1fr 1fr; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: #fafafa; }
.footer-inner { display: grid; grid-template-columns: 1fr; gap: 0.75rem; padding: 1rem 0; align-items: center; }
.socials { display: flex; gap: 0.5rem; }
.social-link { display: inline-flex; width: 36px; height: 36px; border-radius: 8px; align-items: center; justify-content: center; text-decoration: none; background: var(--surface); color: var(--muted); border: 1px solid var(--border); font-weight: 700; }
.social-link:hover { color: var(--brand-700); border-color: var(--brand-700); }
.footer-links { list-style: none; display: flex; gap: 0.75rem; padding: 0; margin: 0; flex-wrap: wrap; }
.footer-links a { color: var(--muted); text-decoration: none; padding: 0.25rem 0.25rem; }
.footer-links a:hover, .footer-links a:focus { color: var(--brand-700); }
.footer-brand { display: inline-flex; align-items: center; gap: 0.5rem; }
.footer-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; display: block; border: 1px solid var(--border); }
.footer-name { font-weight: 700; font-size: 0.95rem; }
.footer-aside { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; justify-content: flex-start; }
.footer-legal { list-style: none; display: flex; gap: 0.5rem; padding: 0; margin: 0; }
.footer-legal a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.footer-copy { color: var(--muted); margin: 0; font-size: 0.9rem; }
@media (min-width: 768px) {
  .footer-inner { grid-template-columns: 1.2fr 1fr auto; }
  .footer-aside { justify-content: flex-end; }
}
@media (max-width: 767px) {
  .footer-logo { width: 20px; height: 20px; }
  .footer-name { font-size: 0.9rem; }
}

/* Utilities */
.visually-hidden { position: absolute !important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }
.hidden { display: none !important; }

/* Modals */
.modal { position: fixed; inset: 0; display: none; z-index: 200; }
.modal.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-dialog { position: relative; z-index: 1; width: min(520px, 92%); margin: 8vh auto; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; box-shadow: 0 10px 35px rgba(0,0,0,0.15); }
.modal-dialog.land-modal { width: min(960px, 96%); max-height: 84vh; overflow: auto; }
.modal-close { position: absolute; top: 8px; right: 8px; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; width: 36px; height: 36px; font-size: 20px; line-height: 1; cursor: pointer; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* Mobile-friendly Area Converter modal */
@media (max-width: 767px) {
  .modal-dialog.land-modal { width: 96%; height: calc(100dvh - 24px); max-height: none; margin: 12px auto; border-radius: 14px; display: flex; flex-direction: column; }
  .land-modal h2 { position: sticky; top: 0; background: var(--bg); margin: 0 0 .5rem; padding: .25rem 0 .5rem; border-bottom: 1px solid var(--border); z-index: 1; }
  .land-modal .calc-grid { overflow: auto; padding-top: .25rem; }
  .calc-actions .btn { flex: 1 1 auto; }
  .modal-close { width: 40px; height: 40px; font-size: 24px; top: 6px; right: 6px; z-index: 100; background: white; }
}

/* Mobile nav expanded */
.nav.is-open { display: block; }
.nav.is-open ul { flex-direction: column; padding-top: 0; }
@media (max-width: 767px) {
  .nav.is-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav.is-open .nav-panel { opacity: 1; transform: none; pointer-events: auto; }
  .nav.is-open .nav-cta { display: none; }
}

/* Extend mobile navbar pattern up to tablets */
@media (max-width: 991px) {
  .header-inner { min-height: var(--header-h); }
  .nav { position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 120; }
  .nav-backdrop { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(15,23,42,0.35); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
  .nav-panel { width: min(560px, calc(100% - 24px)); margin: 8px auto calc(10px + var(--action-bar-h)); border-radius: 14px; box-shadow: 0 18px 44px rgba(0,0,0,0.14); transform: translateY(-8px) scale(0.985); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .24s ease; max-height: calc(100dvh - var(--header-h) - var(--action-bar-h) - 24px); overflow: auto; }
  .nav ul { padding: 4px 6px; }
  .nav li + li { border-top: 1px solid var(--border); }
  .nav a { padding: 1.05rem 0.95rem; display: block; font-weight: 700; border-radius: 10px; }
  .nav a:hover, .nav a:focus { background: rgba(14,165,233,0.08); }
  .nav.is-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav.is-open .nav-panel { opacity: 1; transform: none; pointer-events: auto; }
  .nav-cta { display: none; }
  .nav.is-open .nav-cta { display: none; }
}
@media (min-width: 992px) {
  .nav-toggle { display: none; }
  .nav { display: block; position: static; box-shadow: none; }
  .nav-cta { display: none !important; }
}

/* Login popover */
.login-link-wrap { position: relative; }
.popover { position: fixed; display: none; width: min(360px, 92%); background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; box-shadow: 0 20px 50px rgba(2, 6, 23, 0.18); z-index: 120; }
.popover.is-open { display: block; }
.popover:after { content: ""; position: absolute; top: -8px; right: 16px; border: 8px solid transparent; border-bottom-color: var(--bg); }
.popover:before { content: ""; position: absolute; top: -9px; right: 16px; border: 9px solid transparent; border-bottom-color: var(--border); }
/* Popover form refinements */
.popover .form-field label { color: var(--muted); font-weight: 600; }
.popover input[type="email"],
.popover input[type="password"] { border-radius: 10px; border-color: var(--border); box-shadow: inset 0 1px 0 rgba(0,0,0,0.02); }
.popover input[type="email"]:focus,
.popover input[type="password"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,233,0.22), 0 0 0 1px var(--brand); }
.popover .product-cta { margin-top: 0.4rem; }
.popover .btn { border-radius: 10px; }
.popover .btn.btn-secondary { color: var(--brand-700); border-color: var(--brand-700); background: transparent; }
.popover .btn.btn-secondary:hover, .popover .btn.btn-secondary:focus { background: var(--brand-700); color: #fff; }

/* Back to top */
.back-to-top { position: fixed; right: 12px; bottom: 88px; display: none; width: 40px; height: 40px; border-radius: 999px; align-items: center; justify-content: center; text-decoration: none; background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.6); z-index: 90; font-weight: 700; }
.back-to-top:hover, .back-to-top:focus { background: var(--brand-700); }
.back-to-top.is-visible { display: inline-flex; }

/* Mobile action bar */
.mobile-action-bar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.98); backdrop-filter: saturate(150%) blur(6px); border-top: 1px solid var(--border); padding: 6px max(10px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right)); display: none; gap: 0.6rem; justify-content: center; z-index: 95; min-height: var(--action-bar-h); }
.mobile-action-bar .action { display: inline-flex; align-items: center; justify-content: center; min-width: 88px; padding: 0.45rem 0.7rem; border-radius: 10px; text-decoration: none; color: #fff; background: var(--brand); border: 1px solid transparent; font-weight: 700; font-size: 0.9rem; }
.mobile-action-bar .action:hover, .mobile-action-bar .action:focus { background: var(--brand-700); }
@media (max-width: 767px) {
  .mobile-action-bar { display: flex; }
}

/* Body scroll lock when overlays are open */
body.no-scroll { overflow: hidden; }
@media (max-width: 767px) {
  :root { --action-bar-h: 48px; }
  body { padding-bottom: calc(var(--action-bar-h) + env(safe-area-inset-bottom)); }
}
