/*
 * Mesozoic Haven shared stylesheet
 * --------------------------------
 * This file is intentionally framework-free and heavily sectioned so it is
 * easy to read, learn from, and edit later.
 *
 * Most pages should be buildable by combining these shared classes instead of
 * adding page-specific CSS.
 */

/* ========================================================================== 
   1. Design tokens
   ========================================================================== */

:root {
    --mh-river-night: #172326;
    --mh-riptide-grey: #596468;
    --mh-sail-crimson: #7a2634;
    --mh-river-teal: #2f6f73;
    --mh-fern-green: #53684a;
    --mh-sandstone: #c8aa7a;
    --mh-fossil-bone: #f3e8d5;
    --mh-field-paper: #faf6ed;
    --mh-charcoal: #252a2b;

    --mh-page-bg: var(--mh-field-paper);
    --mh-surface: #fffaf2;
    --mh-surface-soft: #f3eadc;
    --mh-text: var(--mh-charcoal);
    --mh-muted: #626b6c;
    --mh-border: #d7c8b3;
    --mh-link: #245e62;

    --mh-site-width: 1240px;
    --mh-reading-width: 780px;
    --mh-radius-sm: 8px;
    --mh-radius-md: 14px;
    --mh-radius-lg: 22px;
    --mh-gap-sm: 12px;
    --mh-gap: 20px;
    --mh-gap-lg: 32px;

    --mh-font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ========================================================================== 
   2. Reset / base HTML
   ========================================================================== */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--mh-page-bg);
    color: var(--mh-text);
    font-family: var(--mh-font-sans);
    font-size: 16px;
    line-height: 1.65;
}

img,
video,
iframe {
    max-width: 100%;
}

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

a:hover {
    text-decoration-thickness: 2px;
}

h1,
h2,
h3,
h4 {
    line-height: 1.18;
}

p:first-child,
h1:first-child,
h2:first-child,
h3:first-child {
    margin-top: 0;
}

p:last-child {
    margin-bottom: 0;
}

/* Keyboard users can skip the whole header/navigation. */
.mh-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999;
    padding: 10px 14px;
    background: #fff;
    color: #000;
}

.mh-skip-link:focus {
    left: 12px;
    top: 12px;
}

/* ========================================================================== 
   3. Shared header / navigation
   ========================================================================== */

.mh-site-header {
    background: var(--mh-river-night);
    color: var(--mh-fossil-bone);
    border-bottom: 3px solid var(--mh-sail-crimson);
}

.mh-site-header__inner {
    max-width: var(--mh-site-width);
    margin: 0 auto;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mh-gap-lg);
}

.mh-brand {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    min-width: max-content;
}

.mh-brand__name {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.mh-brand__tagline {
    font-size: 0.78rem;
    color: #c9d0ce;
}

.mh-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex-wrap: wrap;
}

.mh-nav__group {
    position: relative;
}

.mh-nav__link,
.mh-nav__search {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--mh-radius-sm);
    color: var(--mh-fossil-bone);
    font-weight: 700;
    text-decoration: none;
}

.mh-nav__link:hover,
.mh-nav__link:focus-visible,
.mh-nav__link.is-active,
.mh-nav__search:hover,
.mh-nav__search:focus-visible {
    background: rgba(255, 255, 255, 0.10);
    text-decoration: none;
}

.mh-nav__search {
    margin-left: 6px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    font-size: 0.9rem;
}

/* Dropdowns appear on hover and keyboard focus-within. */
.mh-nav__dropdown {
    position: absolute;
    z-index: 50;
    top: calc(100% + 5px);
    left: 0;
    min-width: 200px;
    padding: 6px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-sm);
    background: var(--mh-surface);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.mh-nav__dropdown a {
    display: block;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--mh-text);
    text-decoration: none;
    white-space: nowrap;
}

.mh-nav__dropdown a:hover,
.mh-nav__dropdown a:focus-visible {
    background: var(--mh-surface-soft);
}

.mh-nav__group:hover .mh-nav__dropdown,
.mh-nav__group:focus-within .mh-nav__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ========================================================================== 
   4. Global page shell / footer
   ========================================================================== */

.mh-site-main {
    max-width: var(--mh-site-width);
    margin: 0 auto;
    padding: 28px 22px 52px;
}

.mh-site-footer {
    margin-top: 28px;
    background: var(--mh-river-night);
    color: var(--mh-fossil-bone);
}

.mh-site-footer__inner {
    max-width: var(--mh-site-width);
    margin: 0 auto;
    padding: 28px 22px;
    display: flex;
    justify-content: space-between;
    gap: var(--mh-gap-lg);
    flex-wrap: wrap;
}

.mh-site-footer .mh-muted {
    color: #c5cecb;
}

.mh-footer-links {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.mh-footer-links a {
    color: var(--mh-fossil-bone);
}

/* ========================================================================== 
   5. Hero
   ========================================================================== */

.mh-hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 32px;
    padding: clamp(42px, 7vw, 78px) clamp(24px, 5vw, 58px);
    border-radius: var(--mh-radius-lg);
    background:
        radial-gradient(circle at 84% 20%, rgba(122, 38, 52, 0.34), transparent 34%),
        linear-gradient(145deg, var(--mh-river-night), #24383b);
    color: var(--mh-fossil-bone);
}

.mh-hero__content {
    max-width: 820px;
}

.mh-eyebrow,
.mh-card__eyebrow {
    margin-bottom: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mh-eyebrow {
    color: var(--mh-sandstone);
}

.mh-hero__title {
    margin: 0;
    font-size: clamp(2.2rem, 6vw, 4.4rem);
    letter-spacing: -0.04em;
}

.mh-hero__text {
    max-width: 700px;
    margin-top: 18px;
    color: #d9dfdc;
    font-size: 1.1rem;
}

.mh-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* ========================================================================== 
   6. 70/30 main + sidebar shell
   ========================================================================== */

.mh-page-split {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(260px, 3fr);
    gap: var(--mh-gap-lg);
    align-items: start;
}

.mh-main-column,
.mh-sidebar {
    min-width: 0;
}

.mh-sidebar {
    display: grid;
    gap: var(--mh-gap);
}

/* Sticky is optional but useful on long pages. It only applies on roomy screens. */
@media (min-width: 981px) {
    .mh-sidebar {
        position: sticky;
        top: 20px;
    }
}

/* ========================================================================== 
   7. General sections / reading widths
   ========================================================================== */

.mh-section {
    margin-bottom: 42px;
}

.mh-section--narrow {
    max-width: var(--mh-reading-width);
}

.mh-section--center {
    max-width: var(--mh-reading-width);
    margin-inline: auto;
    text-align: center;
}

.mh-section__header {
    margin-bottom: 18px;
}

.mh-section__title {
    margin: 0 0 8px;
    font-size: clamp(1.55rem, 3vw, 2.1rem);
}

.mh-lead {
    font-size: 1.1rem;
}

.mh-muted {
    color: var(--mh-muted);
}

/* ========================================================================== 
   8. Reusable column ratios
   ========================================================================== */

.mh-columns {
    display: grid;
    gap: var(--mh-gap);
    align-items: start;
    margin-bottom: var(--mh-gap-lg);
}

.mh-columns--25-75 { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); }
.mh-columns--33-66 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.mh-columns--50-50 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mh-columns--66-33 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mh-columns--75-25 { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }

/*
 * Card-column mode:
 * Instead of adding .mh-card manually to each direct child, this variant makes
 * the immediate children use the same shared card surface. Handy for editable
 * page sections where both halves should look intentionally separated.
 */
.mh-columns--cards > * {
    padding: 24px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-md);
    background: var(--mh-surface);
}

/* ========================================================================== 
   9. Cards
   ========================================================================== */

.mh-card {
    padding: 24px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-md);
    background: var(--mh-surface);
}

.mh-card--soft {
    background: var(--mh-surface-soft);
}

.mh-card--featured {
    border-top: 4px solid var(--mh-river-teal);
}

.mh-card--note {
    border-left: 5px solid var(--mh-sandstone);
}

.mh-card--riptide {
    border-color: color-mix(in srgb, var(--mh-sail-crimson) 45%, var(--mh-border));
    background: color-mix(in srgb, var(--mh-sail-crimson) 7%, var(--mh-surface));
}

.mh-card--riptide .mh-card__eyebrow {
    color: var(--mh-sail-crimson);
}

.mh-card--interactive {
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.mh-card--interactive:hover,
.mh-card--interactive:focus-within {
    transform: translateY(-2px);
    border-color: var(--mh-river-teal);
    box-shadow: 0 10px 28px rgba(23, 35, 38, 0.10);
}

.mh-card__title {
    margin: 0 0 10px;
    font-size: 1.2rem;
}

.mh-card__eyebrow {
    color: var(--mh-river-teal);
}

.mh-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--mh-gap);
}

/* ========================================================================== 
   10. Buttons / small utilities
   ========================================================================== */

.mh-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-sm);
    background: var(--mh-surface);
    color: var(--mh-text);
    font-weight: 750;
    text-decoration: none;
}

.mh-button:hover,
.mh-button:focus-visible {
    background: var(--mh-surface-soft);
    text-decoration: none;
}

.mh-button--primary {
    border-color: var(--mh-sail-crimson);
    background: var(--mh-sail-crimson);
    color: #fff;
}

.mh-button--primary:hover,
.mh-button--primary:focus-visible {
    background: #67202c;
}

.mh-link-list {
    margin: 0;
    padding-left: 1.25rem;
}

.mh-link-list li + li {
    margin-top: 7px;
}

.mh-placeholder {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 24px;
    border: 2px dashed var(--mh-border);
    border-radius: var(--mh-radius-md);
    background: color-mix(in srgb, var(--mh-surface-soft) 65%, transparent);
    text-align: center;
    color: var(--mh-muted);
}

/* ========================================================================== 
   11. Tables
   ========================================================================== */

.mh-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.mh-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--mh-surface);
}

.mh-table caption {
    padding: 10px 0;
    text-align: left;
    font-weight: 800;
}

.mh-table th,
.mh-table td {
    padding: 11px 13px;
    border: 1px solid var(--mh-border);
    vertical-align: top;
    text-align: left;
}

.mh-table thead th {
    background: var(--mh-river-night);
    color: var(--mh-fossil-bone);
}

.mh-table tbody th {
    background: var(--mh-surface-soft);
    font-weight: 750;
}

.mh-table--facts tbody th {
    width: 42%;
}

/* ========================================================================== 
   12. Journal / article helpers
   ========================================================================== */

.mh-article-header {
    max-width: 900px;
    margin-bottom: 28px;
}

.mh-article-title {
    margin-bottom: 10px;
    font-size: clamp(2.1rem, 5vw, 3.8rem);
    letter-spacing: -0.035em;
}

.mh-article-meta {
    display: flex;
    gap: 10px 18px;
    flex-wrap: wrap;
    color: var(--mh-muted);
    font-size: 0.93rem;
}

.mh-reading-content {
    max-width: var(--mh-reading-width);
}

.mh-reading-content > * + * {
    margin-top: 1.2em;
}

.mh-feature-media {
    overflow: hidden;
    margin-bottom: 28px;
    border-radius: var(--mh-radius-md);
    background: var(--mh-surface-soft);
}

/* ========================================================================== 
   13. Visual exploration cards
   ========================================================================== */

.mh-explore-card {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: end;
    overflow: hidden;
    padding: 24px;
    border-radius: var(--mh-radius-lg);
    background:
        linear-gradient(to top, rgba(23, 35, 38, 0.88), rgba(23, 35, 38, 0.12)),
        var(--mh-riptide-grey);
    color: #fff;
    text-decoration: none;
}

.mh-explore-card:hover {
    text-decoration: none;
}

.mh-explore-card__title {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2.4rem);
}

/* ========================================================================== 
   14. Responsive behavior
   ========================================================================== */

@media (max-width: 980px) {
    .mh-site-header__inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .mh-nav {
        justify-content: flex-start;
    }

    .mh-page-split,
    .mh-columns--25-75,
    .mh-columns--33-66,
    .mh-columns--50-50,
    .mh-columns--66-33,
    .mh-columns--75-25 {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 680px) {
    .mh-site-main {
        padding-inline: 14px;
    }

    .mh-site-header__inner,
    .mh-site-footer__inner {
        padding-inline: 14px;
    }

    .mh-nav {
        width: 100%;
    }

    .mh-nav__link,
    .mh-nav__search {
        padding-inline: 9px;
        font-size: 0.9rem;
    }

    /* Dropdowns become normal flow blocks on very small screens when focused. */
    .mh-nav__dropdown {
        left: 0;
        min-width: 185px;
    }

    .mh-card-grid {
        grid-template-columns: 1fr;
    }

    .mh-hero {
        border-radius: var(--mh-radius-md);
    }
}

/* Respect the user's reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

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