/* ================================================================
   SADLER.LIFE — Unified Theme
   Matches emcomm.life dark operational aesthetic
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Oswald:wght@400;500;600;700&display=swap');

:root {
    /* Core palette — matches emcomm.life weather dashboard */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --bg-card-hover: #292e36;
    --bg-inset: #0a0d12;
    --border: #30363d;
    --border-light: #3d444d;

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #96a3b0;
    --text-muted: #7d8d99;
    --text-bright: #ffffff;

    /* Accents */
    --accent-blue: #58a6ff;
    --accent-amber: #d29922;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-cyan: #39d2c0;
    --accent-purple: #bc8cff;

    /* Status */
    --good: #238636;
    --caution: #9e6a03;
    --warning: #da3633;

    /* Glow effects */
    --glow-blue: rgba(88, 166, 255, 0.15);
    --glow-amber: rgba(210, 153, 34, 0.15);
    --glow-green: rgba(63, 185, 80, 0.1);

    /* Typography */
    --font-display: 'Oswald', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --line-height-body: 1.65;

    /* Layout */
    --nav-height: 52px;
    --max-width: 1400px;
    --radius: 6px;
    --radius-lg: 10px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* touch-action: manipulation prevents the iOS double-tap-to-zoom gesture + 300ms tap delay in the
   Capacitor WebView WITHOUT disabling pinch-zoom — replaces the old viewport user-scalable=no, which
   killed pinch-zoom (a WCAG failure: Web:S5257 / Web:S7926). */
html { scroll-behavior: smooth; touch-action: manipulation; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100svh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-blue); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--text-bright); }

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

/* ── Navigation ── */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    height: var(--nav-height);
    background: rgba(13, 17, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.nav-brand-text {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-primary);
}
.nav-brand-text span { color: var(--accent-amber); }
.nav-brand-call {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent-amber);
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.25);
    padding: 2px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* Nav links container */
.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
}

.nav-links > li { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.15s;
    white-space: nowrap;
    cursor: pointer;
}
.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}
.nav-link.active { color: var(--accent-blue); }

.nav-link .icon { font-size: 14px; opacity: 0.7; }
.nav-link .caret {
    font-size: 9px;
    opacity: 0.5;
    transition: transform 0.2s;
}

/* Dropdowns */
.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    /* Smooth show/hide with persistence */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.12s, visibility 0.12s, transform 0.12s;
    transition-delay: 0.15s; /* delay HIDING — gives time to reach the menu */
    pointer-events: none;
}
.nav-dropdown.right { left: auto; right: 0; }

li:hover > .nav-dropdown,
li.open > .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition-delay: 0s; /* show IMMEDIATELY */
}

li:hover > .nav-link .caret { transform: rotate(180deg); }

.nav-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 12.5px;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.12s;
    text-decoration: none;
}
.nav-dropdown a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}
.nav-dropdown .separator {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}
.nav-dropdown .section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 12px 3px;
}
.nav-dropdown .ext-icon {
    font-size: 10px;
    opacity: 0.4;
    margin-left: auto;
}

/* Mobile hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 8px;
    border: none;
    background: none;
}
.nav-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all 0.2s;
}

/* Mobile responsive */
@media (max-width: 900px) {
    .nav-toggle { display: flex; }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        padding: 8px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
    .nav-links.open { display: flex; }
    .nav-links > li { width: 100%; }
    .nav-link { width: 100%; padding: 10px 14px; }

    .nav-dropdown {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 0;
        padding-left: 16px;
        /* Reset desktop hover system for mobile */
        opacity: 0;
        visibility: hidden;
        transform: none;
        transition: none;
        pointer-events: none;
        height: 0;
        overflow: hidden;
    }
    li:hover > .nav-dropdown {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        height: 0;
    }
    li.open > .nav-dropdown {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        height: auto;
        overflow: visible;
    }
}

/* ── Page body offset for fixed nav ── */
.page-body {
    padding-top: var(--nav-height);
    min-height: 100svh;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

/* ── Hero sections ── */
.hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 60px 20px;
    overflow: hidden;
    text-align: center;
}
.hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.3);
    z-index: 0;
}
.hero-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 12px;
}
.hero h1 span { color: var(--accent-amber); }
.hero .subtitle {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

/* ── Content sections ── */
.section {
    padding: 48px 20px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.section-header {
    margin-bottom: 32px;
}
.section-header h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-primary);
}
.section-header .accent-line {
    width: 40px;
    height: 3px;
    background: var(--accent-amber);
    border-radius: 2px;
    margin-top: 8px;
}

/* ── Cards ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s;
}
.card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.card-body { padding: 20px; }
.card-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.card-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}
.card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-link:hover { color: var(--text-bright); }

/* ── Iframe containers (for embedded content) ── */
.embed-frame {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.embed-frame iframe {
    display: block;
    width: 100%;
    border: none;
}
.embed-label {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* ── Image gallery ── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}
.gallery-grid img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}
.gallery-grid img:hover {
    border-color: var(--accent-blue);
    transform: scale(1.02);
}

/* ── Badge / Tag ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}
.badge-amber {
    color: var(--accent-amber);
    background: var(--glow-amber);
    border: 1px solid rgba(210, 153, 34, 0.3);
}
.badge-blue {
    color: var(--accent-blue);
    background: var(--glow-blue);
    border: 1px solid rgba(88, 166, 255, 0.3);
}
.badge-green {
    color: var(--accent-green);
    background: var(--glow-green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

/* ── Org logos row ── */
.org-logos {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}
.org-logos a {
    opacity: 0.6;
    transition: opacity 0.2s;
    filter: grayscale(0.5) brightness(1.2);
}
.org-logos a:hover { opacity: 1; filter: none; }
.org-logos img { height: 50px; width: auto; }

/* ── Social links ── */
.social-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.15s;
    text-decoration: none;
}
.social-btn:hover {
    background: var(--glow-blue);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ── Two-column layout ── */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}
@media (max-width: 768px) {
    .two-col { grid-template-columns: 1fr; }
}

/* ── Footer ── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}
.site-footer a { color: var(--text-secondary); }

/* ── Utility ── */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-amber { color: var(--accent-amber); }
.text-blue { color: var(--accent-blue); }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--font-mono); }

/* ── Fade-in animation ── */
.fade-in {
    opacity: 0;
    transform: translateY(12px);
    animation: fadeUp 0.5s ease forwards;
}
.fade-in:nth-child(2) { animation-delay: 0.08s; }
.fade-in:nth-child(3) { animation-delay: 0.16s; }
.fade-in:nth-child(4) { animation-delay: 0.24s; }
.fade-in:nth-child(5) { animation-delay: 0.32s; }
.fade-in:nth-child(6) { animation-delay: 0.40s; }

@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Skip to content link (accessibility) ── */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-blue);
    color: var(--text-bright);
    padding: 8px 16px;
    z-index: 10000;
    font-family: var(--font-body);
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* ── Light Theme ── */
[data-theme="light"] {
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f2f5;
    --bg-inset: #eaeef2;
    --border: #d0d7de;
    --border-light: #e1e4e8;

    --text-primary: #1f2328;
    --text-secondary: #57606a;
    --text-muted: #6e7781;
    --text-bright: #000000;

    --accent-blue: #0969da;
    --accent-amber: #9a6700;
    --accent-green: #1a7f37;
    --accent-red: #cf222e;
    --accent-cyan: #1b7c83;
    --accent-purple: #8250df;

    --good: #1a7f37;
    --caution: #9a6700;
    --warning: #cf222e;

    --glow-blue: rgba(9, 105, 218, 0.1);
    --glow-amber: rgba(154, 103, 0, 0.1);
    --glow-green: rgba(26, 127, 55, 0.1);
}

/* ── Theme Toggle Button ── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius);
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}
.theme-toggle:hover {
    color: var(--accent-amber);
    border-color: var(--accent-amber);
}

/* ── Command Palette ── */
.cmd-palette-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15vh;
    backdrop-filter: blur(4px);
}
.cmd-palette-overlay.open {
    display: flex;
}
.cmd-palette {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}
.cmd-palette-input {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    outline: none;
}
.cmd-palette-input::placeholder {
    color: var(--text-muted);
}
.cmd-palette-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
}
.cmd-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}
.cmd-palette-item:hover,
.cmd-palette-item.selected {
    background: var(--bg-card-hover);
}
.cmd-palette-item .cmd-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}
.cmd-palette-item .cmd-label {
    flex: 1;
    font-size: 14px;
}
.cmd-palette-item .cmd-desc {
    font-size: 12px;
    color: var(--text-muted);
}
.cmd-palette-item .cmd-shortcut {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    background: var(--bg-inset);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--border);
}
.cmd-palette-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.cmd-palette-footer kbd {
    background: var(--bg-inset);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* ── Mobile: iOS input zoom prevention + safe area ── */
@media (max-width: 800px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
    select,
    textarea {
        font-size: 1rem !important;
    }
    select {
        -webkit-appearance: none;
        appearance: none;
    }
}
