/* ============================================================
   EverydayEarth — Theme System
   Light (nature-inspired) + Dark (cosmic) with CSS custom props
   ============================================================ */

/* ---------- Self-hosted Mulish variable font ----------
   Eliminates the 750ms render-blocking Google Fonts request.
   Only latin + latin-ext subsets; browser uses unicode-range
   to download only the file it needs.
   -------------------------------------------------------*/
/* latin-ext */
@font-face {
    font-family: 'Mulish';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url(/fonts/mulish-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
    font-family: 'Mulish';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url(/fonts/mulish-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Light theme (default) ---------- */
:root,
[data-theme="light"] {
    --bg: #f7f5f0;
    --bg-elev: #ffffff;
    --bg-subtle: #efede7;
    --card: #ffffff;
    --card-hover: #f9f8f5;
    --card-border: #e2ddd4;
    --text: #1a1a1a;
    --text-secondary: #4a4a4a;
    --muted: #6b6b6b;
    --muted-dim: #9a9a9a;
    --primary: #2d6a1e;
    --primary-hover: #3d8a2e;
    --primary-light: #e8f5e3;
    --primary-text: #ffffff;
    --accent: #c97b1a;
    --accent-light: #fef5e7;
    --link: #2d6a1e;
    --link-hover: #1e4a12;
    --border: #e2ddd4;
    --border-light: #f0ece4;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.04);
    --nav-bg: rgba(255, 255, 255, 0.92);
    --nav-border: #e2ddd4;
    --footer-bg: #2c2c2c;
    --footer-text: #d4d4d4;
    --hero-gradient: linear-gradient(160deg, #e8f5e3 0%, #f7f5f0 40%, #fef5e7 100%);
    --section-alt: #f0ece4;
    --badge-bg: #e8f5e3;
    --badge-text: #2d6a1e;
    --input-bg: #ffffff;
    --input-border: #d4cfc6;
    --input-focus: #2d6a1e;
    --tag-bg: #f0ece4;
    --tag-text: #4a4a4a;
    --success: #2d6a1e;
    --warning: #c97b1a;
    --error: #b33a3a;
    --info: #2a6496;
    --overlay: rgba(0, 0, 0, 0.3);
    --surface: #ffffff;
    --surface-alt: #f5f3ee;
    --surface-2: #f5f3ee;
    /* Semantic aliases (added by design review) */
    --danger: #b33a3a;
    --danger-soft: #f9e3e1;
    --error-subtle: #f9e3e1;
    --primary-bg: #e8f5e3;
    --primary-subtle: #e8f5e3;
    --highlight: #b8690f;
    --highlight-soft: #fbf0dd;
    --status-ok-soft: #e8f5e3;
    --status-warn-soft: #fbf0dd;
    --status-bad-soft: #f9e3e1;
    --overlay-strong: rgba(0, 0, 0, 0.85);
    --bg-rgb: 247, 245, 240;
    --nav-height: 61px; /* collapsed (<=1080px) nav: 12px padding x2 + 36px controls + 1px border */
    --radius: 10px;
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
    --space-9: 48px;
    --space-10: 64px;
    --space-11: 80px;
    --space-12: 96px;
    --max-width: 1200px;
    --max-width-narrow: 800px;
    --font-sans: 'Mulish', system-ui, -apple-system, sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
    --font-size-2xs: 0.6875rem;
    --font-size-xs: 0.75rem;
    --font-size-sm-2: 0.8125rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    --transition: 0.2s ease;
    --transition-slow: 0.4s ease;
    /* Z-index scale */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-nav: 300;      /* site nav + its menus: above sticky page bars, below overlays */
    --z-overlay: 1000;
    --z-modal: 1100;
    --z-toast: 1200;
    /* Breakpoints (documentation only: custom properties cannot be used
       inside @media; keep these in sync with the queries below) */
    --breakpoint-sm: 480px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
    color-scheme: dark;
    /* NIGHT theme: infrared trail-cam ground, warm amber accent */
    --bg: #0f1612;
    --bg-elev: #17201a;
    --bg-subtle: #1b2620;
    --card: #17201a;
    --card-hover: #1e2a22;
    --card-border: #26332a;
    --text: #e8ece4;
    --text-secondary: #c3cbbd;
    --muted: #8a9584;
    --muted-dim: #5c665a;
    --primary: #8fbf7a;
    --primary-hover: #a5d090;
    --primary-light: rgba(143, 191, 122, 0.16);
    --primary-text: #0f1612;
    --accent: #e0a458;
    --accent-light: rgba(224, 164, 88, 0.14);
    --link: #a5d090;
    --link-hover: #c2e3b1;
    --border: #26332a;
    --border-light: #1e2a22;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
    --nav-bg: rgba(15, 22, 18, 0.92);
    --nav-border: #1e2a22;
    --footer-bg: #0a100c;
    --footer-text: #8a9584;
    --hero-gradient: radial-gradient(900px 500px at 15% -10%, rgba(224, 164, 88, 0.10), transparent 60%),
    linear-gradient(180deg, #121a15 0%, #0f1612 100%);
    --section-alt: #131c16;
    --badge-bg: rgba(143, 191, 122, 0.16);
    --badge-text: #a5d090;
    --input-bg: #17201a;
    --input-border: #2c3a2f;
    --input-focus: #8fbf7a;
    --tag-bg: #1e2a22;
    --tag-text: #c3cbbd;
    --success: #8fbf7a;
    --warning: #e0a458;
    --error: #e88a7a;
    --info: #7ab8c9;
    --overlay: rgba(0, 0, 0, 0.6);
    --overlay-strong: rgba(0, 0, 0, 0.85);
    --surface: #17201a;
    --surface-alt: #131c16;
    --surface-2: #131c16;
    --danger: #e88a7a;
    --danger-soft: rgba(232, 138, 122, 0.16);
    --error-subtle: rgba(232, 138, 122, 0.16);
    --primary-bg: rgba(143, 191, 122, 0.16);
    --primary-subtle: rgba(143, 191, 122, 0.16);
    --highlight: #e0a458;
    --highlight-soft: rgba(224, 164, 88, 0.14);
    --status-ok-soft: rgba(143, 191, 122, 0.16);
    --status-warn-soft: rgba(224, 164, 88, 0.16);
    --status-bad-soft: rgba(232, 138, 122, 0.16);
    --bg-rgb: 15, 22, 18;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background var(--transition-slow), color var(--transition-slow);
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    font-weight: 700;
    color: var(--text);
}

/* Display face for the two top heading levels and hero/dialog titles */
h1, h2, .page-hero__title, .base-dialog__title, .hero__title {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    font-variation-settings: 'opsz' 96;
}

h1 {
    font-variation-settings: 'opsz' 144;
}

h1 {
    font-size: var(--font-size-5xl);
}

h2 {
    font-size: var(--font-size-4xl);
}

h3 {
    font-size: var(--font-size-2xl);
}

h4 {
    font-size: var(--font-size-xl);
}

p {
    color: var(--text-secondary);
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--link-hover);
}

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

/* Keyboard focus ring (mouse clicks do not show it) */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Material Icons base: width/overflow stop the ligature text from
   flashing as words before the icon font loads */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    display: inline-block;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    width: 1em;
    height: 1em;
}

/* Skip-to-content link: visually hidden until focused */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: var(--z-toast);
    background: var(--primary);
    color: var(--primary-text);
    padding: var(--space-3) var(--space-5);
    border-radius: 0 0 var(--radius-sm) 0;
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus,
.skip-link:focus-visible {
    position: fixed;
    left: 0;
    top: 0;
    outline: 2px solid #fff;
    outline-offset: -4px;
}

/* Body scroll lock while the mobile nav is open */
body.nav-open {
    overflow: hidden;
}

/* ============================================================
   Layout Utilities
   ============================================================ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.container--narrow {
    max-width: var(--max-width-narrow);
}

/* App/SPA page wrapper: consistent content width for every view */
.app-page {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-6) var(--space-6) var(--space-10);
}

@media (max-width: 768px) {
    .app-page {
        padding: var(--space-5) var(--space-4) var(--space-9);
    }
}

.section {
    padding: var(--space-9) 0;
}

.section--alt {
    background: var(--section-alt);
}

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid--3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid--4,
    .grid--3,
    .grid--2 {
        grid-template-columns: 1fr;
    }

    .section {
        padding: var(--space-7) 0;
    }

    h1 {
        font-size: var(--font-size-3xl);
    }

    h2 {
        font-size: var(--font-size-2xl);
    }
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.gap-8 {
    gap: var(--space-8);
}

.text-center {
    text-align: center;
}

/* ============================================================
   Navigation
   ============================================================ */
.nav {
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--nav-border);
    transition: background var(--transition-slow);
}

.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-4) var(--space-6);
    min-width: 0;
}

.nav__brand {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.nav__brand .material-icons {
    color: var(--primary);
    font-size: 28px;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    list-style: none;
}

.nav__link {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    padding: var(--space-2) 0;
    transition: color var(--transition);
    position: relative;
}

.nav__link:hover,
.nav__link--active {
    color: var(--text);
}

/* <button> variant of a nav link (e.g. "Talk to Us"): inherits link styling */
.nav__link--button {
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: 0;
    border-radius: 0;
    margin: 0;
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: inherit;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    text-align: left;
}

.nav__dropdown-heading {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: var(--space-2) var(--space-4) var(--space-1);
    margin: 0;
}

.nav__link--active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
}

.nav__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.nav__toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: var(--space-2);
}

/* Nav divider between auth and public links */
.nav__divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    align-self: center;
    list-style: none;
}

/* Secondary nav links (public pages in auth nav) */
.nav__link--secondary {
    opacity: 0.6;
    font-size: var(--font-size-sm);
}

.nav__link--secondary:hover {
    opacity: 1;
}

.nav__link--secondary.nav__link--active {
    opacity: 1;
}

/* Auth actions (sign out button) */
.nav__auth-actions {
    display: flex;
    align-items: center;
}

.btn--sign-out {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

/* Mobile auth items: hidden on desktop, shown in mobile menu */
.nav__mobile-auth {
    display: none;
    list-style: none;
}

/* "Talk to Us" chat trigger in nav */
.nav__chat,
.nav__mobile-chat {
    list-style: none;
}

.btn--block {
    display: block;
    width: 100%;
    text-align: center;
}

/* Mobile navigation. 1080px is the nav-collapse breakpoint: the only
   exception to the 480/768/1024 scale, because the full link row needs the
   width. */
@media (max-width: 1080px) {
    .nav__inner {
        padding: var(--space-3) var(--space-4);
        gap: var(--space-2);
    }

    .nav__actions {
        gap: var(--space-1);
    }

    .nav__brand {
        font-size: var(--font-size-lg);
    }

    /* All icon buttons: compact & borderless on mobile */
    .nav__search-btn,
    .nav__notif-btn,
    .nav__profile-btn,
    .nav__toggle,
    .theme-toggle {
        width: 36px;
        height: 36px;
        border-color: transparent;
        padding: var(--space-1);
    }

    /* Avatar circle: also borderless on mobile to reduce visual noise */
    .nav__avatar {
        border-color: transparent;
        background: transparent;
    }

    .nav__links {
        display: none;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex-direction: column;
        align-items: stretch;
        background: var(--bg-elev);
        border-bottom: 1px solid var(--nav-border);
        padding: var(--space-4) var(--space-6) var(--space-8);
        gap: var(--space-3);
        z-index: var(--z-nav);
    }

    .nav__links--open {
        display: flex;
    }

    /* backdrop-filter on .nav makes it the containing block for fixed
       descendants, so the full-height menu would collapse to the bar's
       height. Drop the blur on small screens and use a solid bar. */
    .nav {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--bg-elev);
    }

    .nav__toggle {
        display: block;
    }

    /* Hide desktop sign-in/join and sign-out on mobile */
    .nav__signin-group {
        display: none !important;
    }

    .nav__auth-actions {
        display: none;
    }

    /* Show mobile auth items in the dropdown */
    .nav__mobile-auth {
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
        padding-top: var(--space-3);
        border-top: 1px solid var(--nav-border);
        margin-top: var(--space-1);
    }

    .nav__mobile-auth-label {
        font-size: var(--font-size-xs);
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin: 0;
    }

    /* One full-width row per provider */
    .nav__mobile-auth-row {
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
    }

    .nav__mobile-auth-btn {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: var(--space-2);
        padding: var(--space-3) var(--space-4);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--card);
        color: var(--text);
        font-size: var(--font-size-sm);
        font-weight: 600;
        text-decoration: none;
        transition: background 0.15s, border-color 0.15s;
    }

    .nav__mobile-auth-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .nav__mobile-auth-btn:hover {
        background: var(--card-hover);
        border-color: var(--primary);
    }

    /* Hide voice-agent widget on mobile; users tap "Talk to Us" nav link instead */
    elevenlabs-convai {
        display: none !important;
    }

    /* Restore when triggered from menu */
    elevenlabs-convai.convai--active {
        display: block !important;
    }

    .btn--sign-out {
        font-size: var(--font-size-sm);
        padding: var(--space-2) var(--space-3);
    }

    .nav__divider {
        width: 100%;
        height: 1px;
        margin: var(--space-2) 0;
    }

    /* Profile dropdown: pin to viewport so it never overflows on mobile.
       The avatar is not the last element (hamburger follows), so absolute
       right:0 bleeds off-screen. Fixed positioning is the reliable fix. */
    .nav__profile-dropdown {
        position: fixed;
        top: var(--nav-height);
        right: var(--space-3);
        left: auto;
        width: min(260px, calc(100vw - var(--space-6)));
        min-width: 0;
    }
}

@media (max-width: 480px) {
    :root {
        --nav-height: 57px; /* 12px padding x2 + 32px controls + 1px border */
    }

    .nav__brand {
        font-size: var(--font-size-base);
        max-width: calc(100vw - 200px);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .nav__brand .material-icons {
        font-size: 22px;
    }

    /* Further tighten on very small phones */
    .nav__search-btn,
    .nav__notif-btn,
    .nav__profile-btn,
    .nav__toggle,
    .theme-toggle {
        width: 32px;
        height: 32px;
    }
}

/* ============================================================
   Theme Toggle
   ============================================================ */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: all var(--transition);
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--text);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

/* Default (no data-theme set yet) shows moon */
:root:not([data-theme]) .theme-toggle .icon-moon {
    display: block;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: var(--font-size-sm);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.4;
}

.btn--primary {
    background: var(--primary);
    color: var(--primary-text);
}

.btn--primary:hover {
    background: var(--primary-hover);
    color: var(--primary-text);
    box-shadow: var(--shadow);
}

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

.btn--secondary:hover {
    background: var(--card-hover);
    border-color: var(--primary);
    color: var(--text);
}

.btn--ghost {
    background: none;
    color: var(--muted);
    padding: var(--space-2) var(--space-4);
}

.btn--ghost:hover {
    color: var(--text);
}

.btn--lg {
    font-size: var(--font-size-base);
    padding: var(--space-4) var(--space-8);
}

.btn--sm {
    font-size: var(--font-size-sm);
    padding: 6px 12px;
}

.btn--xs {
    font-size: var(--font-size-xs);
    padding: 4px 10px;
    gap: var(--space-1);
}

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

.btn--outline:hover {
    border-color: var(--primary);
    color: var(--text);
}

.btn--danger {
    background: var(--danger);
    color: #fff;
}

.btn--danger:hover {
    filter: brightness(1.08);
    color: #fff;
}

.btn--icon {
    background: none;
    color: var(--muted);
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-full);
}

.btn--icon:hover {
    color: var(--text);
    background: var(--bg-subtle);
}

.btn--active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.btn--hidden {
    display: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: color var(--transition), background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.card:hover,
.card--link:hover {
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--primary) 50%, transparent);
}

.card__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: var(--space-4);
}

.card__icon .material-icons {
    color: var(--primary);
    font-size: 22px;
}

.card__title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.card__text {
    color: var(--muted);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    margin-bottom: var(--space-4);
}

.card--link {
    text-decoration: none;
    display: block;
}

/* Species profile cards (icon + badge inline header) */
.species-profile-card .species-profile-card__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.species-profile-card .species-profile-card__header .card__icon {
    margin-bottom: 0;
}

.species-profile-card .card__title {
    margin-bottom: var(--space-2);
}

.species-profile-card .card__text {
    margin-bottom: var(--space-4);
}

.species-profile-card .feature-list {
    margin-top: auto;
}

/* Species profile cards with images */
.species-profile-card__image {
    margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    position: relative;
    aspect-ratio: 3 / 2;
    background: var(--surface-alt);
}

.species-profile-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.species-profile-card:hover {
    border-color: color-mix(in srgb, var(--primary) 50%, transparent);
    box-shadow: var(--shadow-lg);
}

.species-profile-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.species-profile-card__placeholder .material-icons {
    font-size: 48px;
    color: var(--border);
}

.species-profile-card:has(.species-profile-card__image) {
    display: flex;
    flex-direction: column;
}

.species-profile-card__body {
    flex: 1;
}

.species-profile-card__body .card__title {
    margin-top: var(--space-4);
}

a.species-profile-card {
    color: inherit;
}

/* Stats row pinned to bottom of card */
.species-profile-card__stats {
    list-style: none;
    padding: var(--space-3) 0 0;
    margin: auto 0 0;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-direction: row;
    gap: 0;
}

.species-profile-card__stats li {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-1);
    flex: 1;
    padding: 0 var(--space-2);
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.3;
    min-width: 0;
}

.species-profile-card__stats li + li {
    border-left: 1px solid var(--card-border);
}

.species-profile-card__stats .material-icons {
    font-size: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

/* Featured species carousel */
.featured-species-carousel {
    position: relative;
}

.featured-species-carousel__track {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

/* Species detail hero — critical sizing to prevent CLS */
.spd-hero { display: grid; grid-template-columns: 300px 1fr; gap: var(--space-8, 2rem); align-items: start; }
.spd-hero__image { border-radius: var(--radius-lg, 12px); overflow: hidden; aspect-ratio: 1; background: var(--section-alt, #f8faf9); }
.spd-hero__image img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (max-width: 768px) {
    .spd-hero { grid-template-columns: 1fr; }
    .spd-hero__image { max-width: 240px; margin: 0 auto; }
}

@media (max-width: 768px) {
    .featured-species-carousel__track {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: var(--space-4);
        padding-bottom: var(--space-2);
    }

    .featured-species-carousel__track::-webkit-scrollbar {
        display: none;
    }

    .featured-species-carousel__track > .species-profile-card {
        flex: 0 0 80%;
        max-width: 300px;
        scroll-snap-align: center;
    }
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
    background: var(--hero-gradient);
    padding: var(--space-9) 0 var(--space-8);
}

.hero__tagline {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: var(--space-5);
}

.hero__title {
    font-size: clamp(1.6rem, 4.5vw, 3.5rem);
    font-weight: 600;
    line-height: 1.15;
    margin-bottom: var(--space-6);
}

.hero__title-break {
    display: none;
}

/* Keep each phrase on one line only when there is room; below 600px the
   phrases wrap normally so the h1 is never clipped on narrow phones. */
@media (min-width: 600px) {
    .hero__phrase {
        white-space: nowrap;
    }

    .hero__title-break {
        display: block;
    }
}

.hero__subtitle {
    font-size: var(--font-size-lg);
    color: var(--muted);
    max-width: 560px;
    margin: 0 auto var(--space-6);
    line-height: 1.6;
}

.hero__actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
}

/* Hero split layout — in critical CSS to prevent CLS */
.hero__split {
    display: flex;
    align-items: stretch;
    gap: var(--space-8);
}
.hero__copy {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.hero__video-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.hero__video-wrap {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    /* Dark fallback so the white overlay labels stay readable before the clip loads */
    background: #1a1f1a linear-gradient(160deg, #1f261f 0%, #1a1f1a 60%, #12160f 100%);
}
@media (max-width: 768px) {
    .hero__split { flex-direction: column; gap: var(--space-5); }
    .hero__video-col { order: -1; max-width: 100%; width: 100%; }
    .hero__video-wrap { flex: none; max-height: 45vh; }
}

@media (max-width: 768px) {
    .hero__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .hero__actions .btn {
        justify-content: center;
        width: 100%;
    }

    /* Soft-CTA button pairs (build, learn, about, connect, explore, pricing, etc.) */
    .section .text-center > div {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }

    .section .text-center > div > .btn {
        justify-content: center;
        width: 100%;
    }

    /* Center standalone buttons in section containers on mobile */
    .section .btn:not(.hero__actions .btn):not(.text-center .btn) {
        display: flex;
        justify-content: center;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ============================================================
   Type utilities (display serif + mono timestamps)
   ============================================================ */
.u-mono {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.u-display {
    font-family: var(--font-display);
    font-weight: 600;
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
