/* User Provided Stylesheet */

/* Hide right TOC ONLY on the home page */
body.index .bd-toc,
body[data-page-slug="index"] .bd-toc,
body.index .outline,
body[data-page-slug="index"] .outline,
body.index nav.outline,
body[data-page-slug="index"] nav.outline {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
}

/* Hide left sidebar ONLY on the home page */
body.index .bd-sidebar,
body[data-page-slug="index"] .bd-sidebar,
body.index .sidebar,
body[data-page-slug="index"] .sidebar {
    display: none !important;
}

/* Adjust layout ONLY on the home page to take up full width */
body.index .bd-page,
body[data-page-slug="index"] .bd-page,
body.index main,
body[data-page-slug="index"] main {
    grid-template-columns: 1fr !important;
    max-width: 100% !important;
    margin: 0 auto !important;
}

body.index .bd-content,
body[data-page-slug="index"] .bd-content {
    max-width: 100% !important;
}

/* Home page: drop the article grid so the splash sections span one centered column */
body:has(.home-hero) main.article-grid {
    display: block !important;
    width: 100% !important;
    max-width: 1240px !important;
    margin: 0 auto !important;
    padding: 1.5rem 1.5rem 0 1.5rem !important;
}

body:has(.home-hero) article.article-grid {
    display: block !important;
    max-width: 100% !important;
}

/* Home page: hide the heading-generated duplicate title */
body:has(.home-hero) h2#cuahsi-water-content-portal,
body:has(.home-hero) h2#cuahsi-water-content-portal * {
    display: none !important;
}

/* Home page: the hero replaces the default title/author/date block */
body:has(.home-hero) #skip-to-frontmatter {
    display: none !important;
}

/* Enlarge CUAHSI logo in header */
.myst-home-link-logo img {
    height: 52px !important;
    width: auto !important;
}
.myst-top-nav {
    height: 72px !important;
}

/* Hide sidebars on Community pages: Building Locally + How to Contribute */
body:has(.no-sidebar-marker) .myst-primary-sidebar-nav,
body:has(.no-sidebar-marker) .myst-primary-sidebar-pointer {
    display: none !important;
}

/* Home page (splash) */
.home-hero,
.home-stats,
.home-section,
.home-impact {
    --home-ink: #15212b;
    --home-navy: #0f2e44;
    --home-navy-deep: #0a2032;
    --home-water: #1f6fb2;
    --home-water-soft: #7fc0ee;
    --home-clay: #c0603c;
    --home-muted: #5c6e78;
    --home-surface: #ffffff;
    --home-sand: #f3eee4;
    --home-line: rgba(15, 33, 43, 0.1);
    --home-display: "Schibsted Grotesk", ui-sans-serif, system-ui, sans-serif;
    --home-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dark .home-hero,
.dark .home-stats,
.dark .home-section,
.dark .home-impact {
    --home-ink: #e2e8f0;
    --home-navy: #e2e8f0;
    --home-water: #7fc0ee;
    --home-clay: #e39a7c;
    --home-muted: #a9b9c4;
    --home-surface: #0f1c28;
    --home-sand: #0f1c28;
    --home-line: rgba(226, 232, 240, 0.14);
}

.home-hero p,
.home-stats p,
.home-section p,
.home-impact p {
    margin: 0;
}

.home-kicker,
.home-step,
.card-kicker {
    display: block;
    font-family: var(--home-mono);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--home-clay);
}

.home-heading {
    margin: 0.75rem 0 0 0 !important;
    max-width: 22ch;
    font-family: var(--home-display);
    font-size: clamp(1.75rem, 3.2vw, 2.5rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.018em;
    color: var(--home-navy);
    text-wrap: balance;
}

.home-arrow {
    display: inline-block;
    transition: transform 0.2s ease;
}

a:hover > .home-arrow,
.resource-card:hover .home-arrow {
    transform: translateX(4px);
}

/* Hero */
.home-hero {
    position: relative;
    overflow: hidden;
    margin: 0;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(155deg, #0a2032 0%, #10324c 45%, #236193 100%);
    color: #ffffff;
}

.home-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.home-hero-inner {
    position: relative;
    max-width: 52rem;
    margin: 0 auto;
    padding: clamp(3rem, 8vw, 6rem) 1.5rem;
    text-align: center;
}

.home-hero .home-kicker {
    color: var(--home-water-soft);
}

.home-title {
    margin: 1.1rem 0 0 0 !important;
    font-family: var(--home-display);
    font-size: clamp(2.4rem, 5.4vw, 4rem);
    font-weight: 700;
    line-height: 1.03;
    letter-spacing: -0.022em;
    color: #ffffff;
    text-wrap: balance;
}

.home-title-accent {
    color: #7fc0ee;
}

.home-blurb {
    max-width: 40rem;
    margin: 1.4rem auto 0 auto !important;
    font-size: 1.2rem;
    line-height: 1.55;
    color: #d3e3ef;
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 2rem;
}

.home-hero .home-actions {
    justify-content: center;
}

.home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.9rem 1.6rem;
    border: 1.5px solid transparent;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none !important;
}

.home-btn-primary {
    background: var(--home-navy);
    color: #ffffff !important;
}

.home-btn-ghost {
    border-color: rgba(15, 46, 68, 0.22);
    color: var(--home-navy) !important;
}

.home-hero .home-btn-primary {
    background: #ffffff;
    color: #0f2e44 !important;
}

.home-hero .home-btn-ghost,
.dark .home-btn-ghost {
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff !important;
}

.dark .home-impact .home-btn-primary {
    background: #7fc0ee;
    color: #0a2032 !important;
}

.home-btn:focus-visible,
.resource-card a:focus-visible {
    outline: 3px solid #7fc0ee;
    outline-offset: 3px;
}

/* Stats band */
.home-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1.25rem 0;
    margin: 0 0 4rem 0;
    padding: 2.25rem 1rem;
    border-radius: 0 0 16px 16px;
    background: #0a2032;
    color: #ffffff;
}

.home-stat {
    padding: 0.35rem 1.75rem;
    border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.home-stat:first-child {
    border-left-color: transparent;
}

.home-stat-number {
    font-family: var(--home-display);
    font-size: clamp(2.1rem, 3.6vw, 2.9rem);
    font-weight: 700;
    line-height: 1;
    color: #7fc0ee;
    white-space: nowrap;
}

.home-stat-label {
    margin-top: 0.5rem;
    font-family: var(--home-mono);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: #bcd4e6;
}

/* Content sections */
.home-section {
    margin: 0 0 4.5rem 0;
}

.home-audience {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.15rem;
    margin-top: 2.25rem;
}

.home-audience-card {
    padding: 1.6rem 1.5rem;
    border-top: 3px solid var(--home-water);
    border-radius: 0 0 14px 14px;
    background: var(--home-sand);
}

.home-card-title {
    margin: 0.85rem 0 0.5rem 0 !important;
    font-family: var(--home-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--home-navy);
}

.home-audience-card p:last-child {
    color: var(--home-muted);
    line-height: 1.5;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.15rem;
    margin-top: 2.25rem;
}

.resource-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 13.5rem;
    padding: 1.5rem 1.4rem 1.4rem;
    border: 1px solid var(--home-line);
    border-radius: 14px;
    background: var(--home-surface);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.resource-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 32px -18px rgba(15, 46, 68, 0.45);
}

.resource-card-disabled {
    filter: grayscale(1);
    background: var(--home-sand);
    cursor: not-allowed;
}

.resource-card-disabled:hover {
    transform: none;
    box-shadow: none;
}

.resource-card .card-kicker {
    font-size: 0.69rem;
    letter-spacing: 0.06em;
}

.resource-card .card-title {
    margin: 0.85rem 0 0.5rem 0;
    font-family: var(--home-display);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--home-navy);
}

.resource-card .card-title a {
    color: inherit;
    text-decoration: none;
}

.resource-card a::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 14px;
}

.resource-card p {
    flex: 1;
    color: var(--home-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.resource-card .card-go {
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--home-water);
}

.resource-card-disabled .card-go {
    color: var(--home-muted);
    font-family: var(--home-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Authorship impact */
.home-impact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
    align-items: center;
    margin: 0 0 2rem 0;
    padding: clamp(1.75rem, 4vw, 3rem);
    border-radius: 16px;
    background: var(--home-sand);
}

.home-impact-text > p:not(.home-heading) {
    margin-top: 1.1rem;
    max-width: 34rem;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--home-muted);
}

.home-impact-item {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    align-items: baseline;
    padding: 1.1rem 0;
    border-top: 1px solid var(--home-line);
}

.home-impact-item:last-child {
    border-bottom: 1px solid var(--home-line);
}

.home-impact-item p {
    line-height: 1.5;
    color: var(--home-muted);
}

.home-impact-item strong {
    color: var(--home-navy);
}

@media (max-width: 640px) {
    .home-stat {
        padding: 0.35rem 1rem;
        border-left: none;
    }

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

@media (prefers-reduced-motion: reduce) {
    .home-arrow,
    .resource-card {
        transition: none;
    }

    .resource-card:hover {
        transform: none;
    }
}

/*
  Disable MyST's built-in hover-card link previews (the floating thumbnail +
  title popup shown when hovering internal links, e.g. the hero "Explore
  resources" button or the resource cards). Links remain fully clickable;
  only the popup preview is suppressed.
*/
.hover-card-content {
    display: none !important;
    pointer-events: none !important;
}

/*"Available Resources" gallery */
.resource-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: 1fr;
    gap: 1rem;
    margin: 1.25rem 0 2rem 0;
}

/* Suppress MyST's page-preview popup while it belongs to a gallery card */
body:has(.resource-gallery > span[data-state="open"]) [data-radix-popper-content-wrapper]:has(.hover-card-content) {
    display: none !important;
}

.gallery-card {
    display: flex;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    flex-direction: column;
    padding: 0.5rem 1rem 0.75rem;
    border: 1px solid rgba(15, 33, 43, 0.15);
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 33, 43, 0.12);
    color: inherit !important;
    font-weight: normal;
    text-decoration: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.gallery-card:focus-visible {
    outline: 3px solid #7fc0ee;
    outline-offset: 3px;
}

.gallery-cover {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 160px;
    flex-shrink: 0;
    margin: 0 0 0.5rem 0 !important;
    padding: 0.6rem;
    border-radius: 8px;
}

/* MyST renders the cover as <picture class="gallery-cover"><img></picture> */
img.gallery-cover,
.gallery-cover img {
    object-fit: contain;
    object-position: center;
}

.gallery-cover img {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-title {
    margin: 0 0 0.25rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
}

.gallery-description {
    display: -webkit-box;
    margin: 0.25rem 0;
    overflow: hidden;
    opacity: 0.8;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.gallery-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    max-height: 1.2rem;
    margin-top: 0.4rem;
    overflow: hidden;
}

.gallery-description .gallery-tags {
    margin-top: auto;
    padding-top: 0.4rem;
    max-height: 1.6rem;
}

.gallery-tag {
    padding: 0 0.4rem;
    border-radius: 4px;
    background: rgba(128, 128, 128, 0.18);
    font-size: 0.7rem;
    line-height: 1.2rem;
    white-space: nowrap;
    opacity: 0.85;
}

.gallery-tag-tool {
    background: rgba(56, 139, 253, 0.2);
}

.dark .gallery-card {
    border-color: rgba(226, 232, 240, 0.14);
    background: #0f1c28;
    box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.6);
}

.dark .gallery-card:hover {
    border-color: #7fc0ee;
}

.dark .gallery-cover {
    background: rgba(255, 255, 255, 0.7);
}

@media (prefers-reduced-motion: reduce) {
    .gallery-card {
        transition: none;
    }
}

/* Frontmatter Scoped by .portal-page-marker so externally sourced books keep the default header. */
body:has(.portal-page-marker) #skip-to-frontmatter {
    --fm-ink: #0f2e44;
    --fm-muted: #5c6e78;
    --fm-accent: #1f6fb2;
    --fm-surface: linear-gradient(180deg, #f3f8fc 0%, #e8f1f9 100%);
    --fm-line: rgba(15, 46, 68, 0.1);
    --fm-pill: rgba(31, 111, 178, 0.1);
    margin: 0 0 2rem 0;
    margin-top: 2rem !important;
    padding: 1rem 1.5rem 1.25rem;
    border: 1px solid var(--fm-line);
    border-top: 4px solid var(--fm-accent);
    border-radius: 12px;
    background: var(--fm-surface);
}

.dark body:has(.portal-page-marker) #skip-to-frontmatter {
    --fm-ink: #e2e8f0;
    --fm-muted: #a9b9c4;
    --fm-accent: #7fc0ee;
    --fm-surface: linear-gradient(180deg, #11273a 0%, #0f1c28 100%);
    --fm-line: rgba(226, 232, 240, 0.12);
    --fm-pill: rgba(127, 192, 238, 0.14);
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-block-header {
    margin-bottom: 0.6rem;
    color: var(--fm-muted);
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-block-subject {
    font-size: 0.75rem;
    font-variant: normal;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fm-accent);
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-block-title {
    margin: 0 !important;
    font-size: clamp(1.6rem, 2.6vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--fm-ink);
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-block-subtitle {
    margin: 0.35rem 0 0 0 !important;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--fm-muted);
}

/* Author and date as pills on one row */
body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-authors-affiliations,
body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-block-date-doi {
    display: inline-flex;
    margin: 1rem 0.4rem 0 0 !important;
    vertical-align: middle;
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-authors-grid {
    display: flex;
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-affiliation-col {
    display: none;
}

body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-author,
body:has(.portal-page-marker) #skip-to-frontmatter .myst-fm-date-string {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: var(--fm-pill);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--fm-ink);
}

@media (max-width: 640px) {
    body:has(.portal-page-marker) #skip-to-frontmatter {
        padding: 0.9rem 1rem 1rem;
    }
}
