/* ==========================================================================
   Technical Surveyor — Header, Footer & Global Layout
   Edit --color-primary below to rebrand site-wide.
   ========================================================================== */

:root,
[data-theme="light"] {
    --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;

    --color-bg: #f4f6f5;
    --color-surface: #ffffff;
    --color-surface-2: #f8faf9;
    --color-text: #1a2420;
    --color-text-muted: #5f7168;
    --color-primary: #0a7c6e;
    --color-primary-hover: #086558;
    --color-accent: #1e6fa0;
    --color-border: #d5ddd9;
    --color-divider: #e4ebe8;

    --shadow-sm: 0 1px 3px rgba(26, 36, 32, 0.08);
    --shadow-md: 0 8px 24px rgba(26, 36, 32, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --header-height: 4.5rem;
    --header-bg-solid: #065a50;
    --header-bg: linear-gradient(
        118deg,
        #044a42 0%,
        #086558 22%,
        #0a7c6e 48%,
        #14708a 78%,
        #1e6fa0 100%
    );
    --header-shine: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.16) 0%,
        rgba(255, 255, 255, 0.04) 38%,
        transparent 100%
    );
    --header-border: rgba(255, 255, 255, 0.18);
    --header-text: #ffffff;
    --header-text-muted: rgba(255, 255, 255, 0.86);
    --header-btn-bg: rgba(255, 255, 255, 0.11);
    --header-btn-border: rgba(255, 255, 255, 0.28);
    --header-btn-hover-bg: rgba(255, 255, 255, 0.22);
    --header-nav-hover-bg: rgba(255, 255, 255, 0.16);
    --header-shadow: 0 10px 28px rgba(6, 74, 66, 0.28), 0 2px 8px rgba(30, 111, 160, 0.14);
    --logo-max-height: 30px;
    --nav-desktop-min: 1200px;
    --touch-min: 2.75rem;
    --container-max: 1100px;
    --container-pad: max(1rem, calc(env(safe-area-inset-left, 0px) + 1rem));
}

[data-theme="dark"] {
    --color-bg: #111915;
    --color-surface: #161e19;
    --color-surface-2: #1b231d;
    --color-text: #dce8e2;
    --color-text-muted: #9db5aa;
    --color-primary: #3fb8a4;
    --color-primary-hover: #4fcfba;
    --color-accent: #5b9fd9;
    --color-border: #2d3730;
    --color-divider: #243029;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --header-bg-solid: #0c1f1a;
    --header-bg: linear-gradient(
        118deg,
        #070f0d 0%,
        #0a1612 24%,
        #0f2620 52%,
        #122a38 78%,
        #152838 100%
    );
    --header-shine: linear-gradient(
        180deg,
        rgba(63, 184, 164, 0.12) 0%,
        rgba(255, 255, 255, 0.03) 40%,
        transparent 100%
    );
    --header-border: rgba(63, 184, 164, 0.18);
    --header-text-muted: rgba(220, 232, 226, 0.86);
    --header-btn-bg: rgba(255, 255, 255, 0.07);
    --header-btn-border: rgba(255, 255, 255, 0.18);
    --header-btn-hover-bg: rgba(63, 184, 164, 0.18);
    --header-nav-hover-bg: rgba(63, 184, 164, 0.2);
    --header-shadow: 0 10px 28px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(63, 184, 164, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

.site-main {
    flex: 1;
}

body.menu-open { overflow: hidden; }

img, svg { max-width: 100%; height: auto; }

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.18s ease;
}
a:hover { color: var(--color-primary-hover); }

.site-main a:not(.ts-page-card):not(.ts-btn):not(.ts-hero-card):not(.ts-tool-card__link):not(.ts-article-card__cta):not(.ts-page-link-all):not(.site-title):not(.primary-menu a):not(.off-canvas-nav a):not(.footer-menu a):not(.elementor-button) {
    text-decoration: underline;
    text-decoration-color: rgba(10, 124, 110, 0.3);
    text-underline-offset: 0.12em;
}

[data-theme="dark"] .site-main a:not(.ts-page-card):not(.ts-btn):not(.site-title) {
    text-decoration-color: rgba(63, 184, 164, 0.35);
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.75rem 1rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.skip-link:focus { top: 1rem; }

/* Layout */
.container {
    width: min(100% - var(--container-pad) * 2, var(--container-max));
    margin-inline: auto;
    padding-inline: var(--container-pad);
}

.section {
    padding: 2rem 0 3rem;
}

#primary {
    scroll-margin-top: var(--header-height);
    min-height: 50vh;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    isolation: isolate;
    background-color: var(--header-bg-solid);
    background-image: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--header-shadow);
}

.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--header-shine);
    pointer-events: none;
    z-index: 0;
}

.site-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 85%);
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 85%);
    pointer-events: none;
    z-index: 0;
}

.site-header .header-inner {
    position: relative;
    z-index: 1;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    max-width: 1200px;
    margin: 0 auto;
    padding:
        0.55rem
        max(var(--container-pad), env(safe-area-inset-right, 0px))
        0.55rem
        max(var(--container-pad), env(safe-area-inset-left, 0px));
    min-height: var(--header-height);
}

.site-branding {
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - 5.85rem);
}

.custom-logo-link {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    text-decoration: none;
    line-height: 0;
}

.custom-logo-link img,
.custom-logo,
.site-branding img {
    display: block;
    max-height: var(--logo-max-height);
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

@media (max-width: 767px) {
    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        --header-height: 4.5rem;
        --logo-max-height: 40px;
        --container-pad: max(0.45rem, calc(env(safe-area-inset-left, 0px) + 0.45rem));
    }

    .header-inner {
        gap: 0.35rem;
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .site-branding {
        max-width: calc(100% - 4.7rem);
    }

    .site-header .custom-logo,
    .site-header .site-branding img {
        max-height: 40px;
        max-width: min(78vw, 280px);
    }

    .site-header .header-actions {
        gap: 0.2rem;
        flex-shrink: 0;
    }

    .site-header .dark-mode-toggle,
    .site-header .menu-toggle {
        width: 2.3rem;
        height: 2.3rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 379px) {
    .site-branding {
        max-width: calc(100% - 4.55rem);
    }

    .site-header .custom-logo,
    .site-header .site-branding img {
        max-height: 36px;
        max-width: min(74vw, 230px);
    }
}

@media (min-width: 480px) {
    :root,
    [data-theme="light"] {
        --logo-max-height: 34px;
    }

    .site-branding {
        max-width: calc(100% - 6.75rem);
    }
}

@media (min-width: 768px) {
    :root,
    [data-theme="light"] {
        --logo-max-height: 40px;
    }

    .site-branding {
        max-width: calc(100% - 7rem);
    }
}

@media (min-width: 1200px) {
    :root,
    [data-theme="light"] {
        --logo-max-height: 48px;
    }

    .site-branding {
        flex-shrink: 0;
        max-width: min(320px, 34vw);
    }
}

.site-title {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    line-height: 1.2;
}

.site-header .site-title {
    color: var(--header-text);
}

.site-title i {
    color: var(--color-primary);
    font-size: 1.25rem;
}

.site-header .site-title i {
    color: rgba(255, 255, 255, 0.92);
}

.site-title:hover { color: var(--color-primary); }

.site-header .site-title:hover {
    color: #fff;
}

.site-title span {
    display: none;
}

@media (min-width: 480px) {
    .site-title span { display: inline; }
}

/* Desktop navigation — 8 items need >=1200px to avoid crowding */
.desktop-nav {
    display: none;
    flex: 1 1 auto;
    min-width: 0;
}

@media (min-width: 1200px) {
    .desktop-nav {
        display: block;
    }

    .header-inner {
        gap: 1rem;
    }
}

.primary-menu {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.05rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.primary-menu a {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-full);
    white-space: nowrap;
    transition: color 0.18s ease, background 0.18s ease;
}

.site-header .primary-menu a {
    color: var(--header-text-muted);
}

@media (min-width: 1280px) {
    .primary-menu {
        gap: 0.1rem;
    }

    .primary-menu a {
        padding: 0.45rem 0.7rem;
        font-size: 0.84rem;
    }
}

@media (min-width: 1360px) {
    .primary-menu a {
        padding: 0.45rem 0.75rem;
        font-size: 0.86rem;
    }
}

.primary-menu a:hover,
.primary-menu .current-menu-item a {
    color: var(--color-primary);
    background: rgba(10, 124, 110, 0.08);
}

.site-header .primary-menu a:hover,
.site-header .primary-menu .current-menu-item a {
    color: var(--header-text);
    background: var(--header-nav-hover-bg);
}

[data-theme="dark"] .primary-menu a:hover,
[data-theme="dark"] .primary-menu .current-menu-item a {
    background: rgba(63, 184, 164, 0.12);
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.dark-mode-toggle,
.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-min);
    height: var(--touch-min);
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.site-header .dark-mode-toggle,
.site-header .menu-toggle {
    border-color: var(--header-btn-border);
    background: var(--header-btn-bg);
    color: var(--header-text);
}

.dark-mode-toggle:hover,
.menu-toggle:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.site-header .dark-mode-toggle:hover,
.site-header .menu-toggle:hover {
    border-color: rgba(255, 255, 255, 0.45);
    background: var(--header-btn-hover-bg);
    color: #fff;
}

.menu-toggle {
    display: inline-flex;
}

@media (min-width: 1200px) {
    .menu-toggle { display: none; }
}

/* ==========================================================================
   OFF-CANVAS MOBILE MENU
   ========================================================================== */

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.off-canvas-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: min(320px, 88vw);
    height: 100vh;
    height: 100dvh;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    z-index: 201;
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.off-canvas-menu.active {
    transform: translateX(0);
}

.off-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    background-color: var(--header-bg-solid);
    background-image: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    flex-shrink: 0;
}

.off-canvas-header .off-canvas-close {
    background: var(--header-btn-bg);
    border: 1px solid var(--header-btn-border);
    color: var(--header-text);
}

.off-canvas-header .off-canvas-close:hover {
    background: var(--header-btn-hover-bg);
    color: #fff;
}

.off-canvas-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--header-text);
    letter-spacing: 0.02em;
}

.off-canvas-close {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.1rem;
}

.off-canvas-close:hover {
    color: var(--color-primary);
}

.off-canvas-content {
    padding: 0.75rem;
    flex: 1;
}

.off-canvas-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.off-canvas-nav li {
    border-bottom: 1px solid var(--color-divider);
}

.off-canvas-nav li:last-child {
    border-bottom: none;
}

.off-canvas-nav a {
    display: flex;
    align-items: center;
    min-height: var(--touch-min);
    padding: 0.75rem 0.85rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.off-canvas-nav a:hover,
.off-canvas-nav .current a {
    color: var(--color-primary);
    background: rgba(10, 124, 110, 0.08);
}

.off-canvas-theme-toggle {
    padding: 1rem 1.15rem;
    border-top: 1px solid var(--color-divider);
    flex-shrink: 0;
}

.dark-mode-toggle--menu {
    width: 100%;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
}

.dark-mode-toggle--menu span {
    margin-left: 0.35rem;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.site-footer {
    margin-top: auto;
    padding: 3rem 0 1.5rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-divider);
    overflow: visible;
}

.footer-grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 2rem;
}

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

@media (min-width: 1024px) {
    .footer-grid { grid-template-columns: 1.35fr 1fr 1fr 1fr; }
}

.footer-widget h3 {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 0 0 0.85rem;
    color: var(--color-text);
    letter-spacing: 0.01em;
}

.footer-widget p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--color-text-muted);
    line-height: 1.55;
}

.footer-widget p a {
    color: var(--color-text-muted);
}

.footer-widget p a:hover {
    color: var(--color-primary);
}

.footer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-menu li {
    margin-bottom: 0.35rem;
}

.footer-menu a {
    display: inline-block;
    padding: 0.2rem 0;
    font-size: 0.88rem;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.18s ease;
}

.footer-menu a:hover {
    color: var(--color-primary);
}

.footer-bottom {
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-divider);
    text-align: center;
    overflow: visible;
}

.footer-bottom p {
    margin: 0 0 0.4rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.footer-trust {
    margin-bottom: 0.65rem !important;
    font-size: 0.8rem !important;
    opacity: 0.92;
}

.footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
}

.footer-legal a {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.footer-legal a:hover {
    color: var(--color-primary);
}

#master-site-footer .sifa-credit__link {
    color: var(--color-primary);
}

#master-site-footer .sifa-credit__link:hover,
#master-site-footer .sifa-credit__link:focus-visible {
    color: var(--color-primary-hover);
}

[data-theme="dark"] #master-site-footer .sifa-credit__link:hover,
[data-theme="dark"] #master-site-footer .sifa-credit__link:focus-visible {
    color: #9ef5e6;
}

.sifa-credit {
    position: relative;
    display: inline;
    white-space: nowrap;
}

.sifa-credit__link {
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.18s ease;
    outline: none;
}

.sifa-credit__link:hover,
.sifa-credit__link:focus-visible {
    color: var(--color-primary-hover);
}

.sifa-credit__love {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(4px);
    transition:
        opacity 0.18s ease,
        visibility 0.18s ease,
        transform 0.18s ease;
}

.sifa-credit__love .fa-heart {
    color: #ff8fab;
    animation: sifaHeartPulse 1.2s ease-in-out infinite;
}

.sifa-credit__love::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-primary-hover);
}

.sifa-credit__link:hover + .sifa-credit__love,
.sifa-credit__link:focus-visible + .sifa-credit__love,
.sifa-credit:focus-within .sifa-credit__love {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@keyframes sifaHeartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
    .sifa-credit__love .fa-heart { animation: none; }
    .sifa-credit__love { transition: none; }
}

/* ==========================================================================
   ARTICLE SHELL (posts/tools)
   ========================================================================== */

.article-shell {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    overflow-x: clip;
}

.article-shell .entry-content {
    min-width: 0;
}

.entry-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2.1rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 1rem;
    color: var(--color-text);
}

/* Back to top */
.back-to-top {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right, 0px) + 1rem);
    bottom: max(1rem, env(safe-area-inset-bottom, 0px) + 1rem);
    z-index: 90;
    width: var(--touch-min);
    height: var(--touch-min);
    display: grid;
    place-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, border-color 0.18s ease;
}

.back-to-top:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.back-to-top[hidden] {
    display: none;
}

@media (max-width: 767px) {
    .section:not(.section--flush) {
        padding: 0.5rem 0 1.25rem;
    }

    .container {
        width: 100%;
    }

    .article-shell {
        padding: 0.5rem 0.35rem;
        border-radius: var(--radius-md);
    }

    .site-footer {
        padding: 2rem 0 1.25rem;
    }

    .footer-grid {
        gap: 1.25rem;
        margin-bottom: 1.25rem;
    }

    .back-to-top {
        right: max(0.45rem, env(safe-area-inset-right, 0px) + 0.45rem);
        bottom: max(0.45rem, env(safe-area-inset-bottom, 0px) + 0.45rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .off-canvas-menu { transition: none; }
    .back-to-top { transition: none; }
}