/* ==========================================================================
   CAIS Glossary - ITI Brand Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (public site)
   Shared brand tokens (colors, spacing, font-family, --transition-fast,
   --radius-pill) live in css/tokens.css, loaded before this file. Only
   public-site-specific values live here.
   -------------------------------------------------------------------------- */
:root {
    /* Typography scale - ITI uses Source Sans Pro */
    --font-size-xs: 0.75rem;
    --font-size-sm: 13px;
    --font-size-base: 18px;
    --font-size-md: 20px;
    --font-size-lg: 24px;
    --font-size-xl: 36px;
    --font-size-2xl: 42px;

    /* Shadows - ITI uses subtle shadows */
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.14);

    /* Border radius - modern rounded look */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 50%;

    /* Transitions */
    --transition-base: 0.15s ease;

    /* Layout */
    --header-height: 80px;
    --nav-height: 56px;
    --container-max: 1200px;
}

/* --------------------------------------------------------------------------
   Reset & Base Styles
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + var(--nav-height) + var(--spacing-lg));
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}

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

button {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

/* Accessible focus ring — visible on keyboard navigation */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

ul,
ol {
    list-style: none;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.header {
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-bg-grey);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.logo {
    height: 56px;
    flex-shrink: 0;
    display: block;
}

.logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

/* Search */
.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 150px;
}

.search-container input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-lg);
    padding-left: 2.75rem;
    padding-right: 2.75rem;
    border: 1px solid var(--color-bg-grey);
    border-radius: var(--radius-pill);
    font-size: var(--font-size-base);
    background: var(--color-bg-white);
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

/* Hide the browser's native search clear/decoration — we use .search-clear */
.search-container input::-webkit-search-cancel-button,
.search-container input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.search-container input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 178, 184, 0.15);
}

.search-container input::placeholder {
    color: var(--color-text-light);
}

/* Loupe glyph sits 18px from the input's left edge … */
.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-text-light);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon svg {
    width: 100%;
    height: 100%;
}

/* … and the clear glyph 18px from the right edge: the 24px button centers a
   16px icon, so 4px of internal padding + 14px offset = 18px to match. */
.search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--color-text-light);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.search-clear:hover {
    background: var(--color-bg-grey);
    color: var(--color-text);
}

.search-clear svg {
    width: 16px;
    height: 16px;
}

/* Header Navigation Links */
.header-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-text-muted);
    font-weight: 400;
    font-size: var(--font-size-base);
    text-decoration: none;
    padding: 0 14px;
    height: 40px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.header-link:hover {
    color: var(--color-text);
    background: var(--color-bg-aquamarine);
    text-decoration: none;
}

.header-link:active {
    background: var(--color-bg-grey);
}

.header-link[aria-current="page"] {
    background: var(--color-bg-aquamarine);
    color: var(--color-primary);
    font-weight: 600;
}

.header-link .nav-icon {
    flex-shrink: 0;
    opacity: 0.7;
}

.header-link .external-icon {
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.header-link:hover .external-icon {
    opacity: 0.8;
}

/* Mobile header toggle buttons (search / menu) — hidden on desktop */
.header-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    background: none;
    padding: 0;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.header-toggle:hover {
    background: var(--color-bg-aquamarine);
    color: var(--color-text);
}

.header-toggle:active {
    background: var(--color-bg-grey);
}

/* --------------------------------------------------------------------------
   Main Content
   -------------------------------------------------------------------------- */
.main {
    flex: 1;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
    width: 100%;
}

/* No results */
.no-results {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-muted);
}

.no-results-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-lg);
    color: var(--color-border);
}

.no-results-icon svg {
    width: 100%;
    height: 100%;
}

.no-results h2 {
    font-size: var(--font-size-md);
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Search Results (cross-section)
   -------------------------------------------------------------------------- */
.search-results {
    display: none;
}

.search-results-meta {
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--spacing-sm);
}

/* Each result wraps a term pill and carries its domain accent (--accent) */
.search-result-item {
    display: contents;
}

/* Consistent hr styling */
hr {
    border: none;
    border-top: 1px solid var(--color-bg-grey);
    margin: var(--spacing-md) 0;
}

/* Cross-reference links */
.cross-ref {
    color: var(--color-primary);
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.cross-ref:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}

/* Consistent heading colors */
h1,
h2,
h3 {
    color: var(--color-text);
}

/* Tags for synonyms - pill style */
.tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--color-bg-aquamarine);
    color: var(--color-secondary);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(0, 89, 155, 0.15);
}

/* Not to be confused with callout */
.confusion-callout {
    background: var(--color-bg);
    border-left: 2px solid var(--color-border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-top: var(--spacing-md);
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-start;
}

.confusion-callout-icon {
    color: var(--color-text-light);
    flex-shrink: 0;
    margin-top: 2px;
}

.confusion-callout-content {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.confusion-callout-label {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

/* Source citation */
.term-source {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Term Action Buttons (feedback / share / copy link)
   -------------------------------------------------------------------------- */
/* Utility actions group */
.term-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

/* Individual action buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: transparent;
    border: 1px solid var(--color-bg-grey);
    border-radius: var(--radius-pill);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.action-btn:hover {
    background: var(--color-bg-white);
    border-color: var(--color-primary);
    color: var(--color-primary);
    text-decoration: none;
}

.action-btn:active {
    background: var(--color-bg-aquamarine);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Share dropdown */
.share-dropdown-container {
    position: relative;
}

.share-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: var(--spacing-xs);
    background: var(--color-bg-white);
    border: 1px solid var(--color-bg-grey);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all var(--transition-fast);
}

.share-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-dropdown-header {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-bg-grey);
}

.share-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: none;
    border: none;
    color: var(--color-text);
    font-size: var(--font-size-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast);
}

.share-option:hover {
    background: var(--color-bg-aquamarine);
    text-decoration: none;
}

.share-option svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Copy link feedback */
.action-btn.copied {
    background: var(--color-bg-aquamarine);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.action-btn.copied span {
    display: none;
}

.action-btn .copy-feedback {
    display: none;
}

.action-btn.copied .copy-feedback {
    display: inline;
}

/* Term images — figures reused by the detail panel (.panel-images) */
.term-image {
    flex-shrink: 0;
    height: 150px;
    /* consistent height */
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-bg-grey);
    background: var(--color-bg-grey);
    position: relative;
    display: flex;
    flex-direction: column;
}

.term-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.term-image img:hover {
    opacity: 0.9;
}

.term-image figcaption {
    padding: var(--spacing-sm);
    background: var(--color-bg-grey);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Aspect ratio classes - width based on fixed 150px height */
.term-image.aspect-4-3 {
    width: 200px;
}

/* 150 * 4/3 = 200 */
.term-image.aspect-16-9 {
    width: 267px;
}

/* 150 * 16/9 ≈ 267 */
.term-image.aspect-3-1 {
    width: 450px;
}

/* 150 * 3/1 = 450 */
.term-image.aspect-1-1 {
    width: 150px;
}

/* 150 * 1/1 = 150 */

/* --------------------------------------------------------------------------
   Lightbox Modal
   -------------------------------------------------------------------------- */
.image-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-caption {
    color: white;
    font-size: var(--font-size-base);
    text-align: center;
    margin-top: var(--spacing-md);
    max-width: 600px;
}

.lightbox-counter {
    position: absolute;
    top: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: var(--font-size-sm);
    background: rgba(0, 0, 0, 0.5);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-pill);
}

.lightbox-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-close svg {
    width: 24px;
    height: 24px;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lightbox-nav svg {
    width: 24px;
    height: 24px;
}

.lightbox-prev {
    left: var(--spacing-lg);
}

.lightbox-next {
    right: var(--spacing-lg);
}

/* Lightbox responsive */
@media (max-width: 768px) {
    .lightbox-nav {
        width: 44px;
        height: 44px;
    }

    .lightbox-prev {
        left: var(--spacing-sm);
    }

    .lightbox-next {
        right: var(--spacing-sm);
    }

    .lightbox-close {
        top: max(var(--spacing-sm), env(safe-area-inset-top));
        right: max(var(--spacing-sm), env(safe-area-inset-right));
    }

    .lightbox-counter {
        top: max(var(--spacing-sm), env(safe-area-inset-top));
        font-size: var(--font-size-base);
    }
}

/* --------------------------------------------------------------------------
   Resources (inline cards in the detail panel)
   -------------------------------------------------------------------------- */
.resources-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Resource Card */
.resource-card {
    border: 1px solid var(--color-bg-grey);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow var(--transition-fast);
}

.resource-card:hover {
    box-shadow: var(--shadow-sm);
}

.resource-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--color-bg-grey);
    overflow: hidden;
}

.resource-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.resource-label {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--color-secondary);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.resource-card-content {
    padding: var(--spacing-md);
}

.resource-card-content h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-xs);
}

.resource-card-content p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: var(--spacing-md);
}

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-primary);
    color: var(--color-text);
    font-weight: 600;
    font-size: var(--font-size-sm);
    border-radius: var(--radius-pill);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.resource-link:hover {
    background: var(--color-secondary);
    color: white;
    text-decoration: none;
}

.resource-link svg {
    width: 14px;
    height: 14px;
}

/* Resources Responsive */
@media (max-width: 640px) {
    /* Full-width, comfortably tall CTA that's easy to tap on a phone */
    .resource-link {
        display: flex;
        width: 100%;
        justify-content: center;
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    .resource-card-content {
        padding: var(--spacing-sm);
    }
}

/* --------------------------------------------------------------------------
   Footer - ITI style (white, three-column)
   -------------------------------------------------------------------------- */
.footer {
    background: white;
    border-top: 1px solid var(--color-border);
    padding: 0 var(--spacing-lg);
    margin-top: auto;
}

.footer-content {
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: var(--spacing-lg);
}

.footer-copyright {
    font-size: var(--font-size-sm);
    color: var(--color-text);
    white-space: nowrap;
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    gap: var(--spacing-lg);
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    font-size: var(--font-size-sm);
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
}

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

.footer-social {
    display: flex;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

.footer-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e5f7f8;
    color: var(--color-secondary);
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}

.footer-social a:hover {
    background: var(--color-primary);
    color: white;
}

.footer-social svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

@media (max-width: 768px) {
    .footer-content {
        height: auto;
        flex-wrap: wrap;
        padding: var(--spacing-md) 0;
        gap: var(--spacing-md);
    }

    .footer-copyright {
        order: 1;
        flex-basis: 100%;
        text-align: center;
    }

    .footer-links {
        order: 3;
        flex-basis: 100%;
        justify-content: center;
    }

    .footer-social {
        order: 2;
        justify-content: center;
        flex-basis: 100%;
    }
}

@media (max-width: 480px) {
    .footer-links {
        gap: var(--spacing-sm);
    }
}

/* --------------------------------------------------------------------------
   About Page Styles
   -------------------------------------------------------------------------- */
.about-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.about-page .main {
    max-width: 800px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    margin-bottom: var(--spacing-lg);
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--color-secondary);
    text-decoration: none;
}

.back-link svg {
    width: 20px;
    height: 20px;
}

.about-content {
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-bg-grey);
    padding: var(--spacing-xl);
}

.about-content h1 {
    font-size: var(--font-size-lg);
    color: var(--color-text);
    margin-bottom: var(--spacing-xl);
}

.about-section {
    margin-bottom: var(--spacing-xl);
}

.about-section:last-child {
    margin-bottom: 0;
}

.about-section h2 {
    font-size: var(--font-size-md);
    color: var(--color-text);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--color-bg-grey);
}

.about-section p {
    color: var(--color-text);
    line-height: 1.7;
    margin-bottom: var(--spacing-md);
}

.about-section p:last-child {
    margin-bottom: 0;
}

.team-photo-placeholder {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--color-bg-grey);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-style: italic;
    margin-top: var(--spacing-md);
    background: var(--color-bg);
}

.team-photo {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin-top: var(--spacing-md);
}

.papers-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.paper-item {
    padding: var(--spacing-md) var(--spacing-lg);
    border-left: 3px solid var(--color-primary);
    background: var(--color-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.paper-item h3 {
    font-size: var(--font-size-base);
    color: var(--color-text);
    margin-bottom: var(--spacing-xs);
}

.paper-item p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

.paper-item a {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-primary);
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.paper-item a svg {
    width: 14px;
    height: 14px;
}

.citation-box {
    background: var(--color-bg-aquamarine);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    position: relative;
}

.citation-box pre {
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    color: var(--color-text);
}

.citation-copy-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-white);
    border: 1px solid var(--color-bg-grey);
    border-radius: var(--radius-pill);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.citation-copy-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.citation-copy-btn.copied {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.citation-copy-btn svg {
    width: 16px;
    height: 16px;
}


/* --------------------------------------------------------------------------
   Scroll to Top Button - ITI circular style
   -------------------------------------------------------------------------- */
.scroll-top {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    width: 44px;
    height: 44px;
    background: var(--color-bg-white);
    color: var(--color-text-muted);
    border: 1px solid var(--color-bg-grey);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    z-index: 50;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top:hover {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: white;
}

.scroll-top svg {
    width: 24px;
    height: 24px;
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */

/* Tablet */
@media (max-width: 768px) {
    :root {
        --header-height: auto;
    }

    /* Single-row compact navbar: logo left, toggle buttons right */
    .header-content {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: var(--spacing-sm);
    }

    .logo {
        height: 40px;
        margin: 0;
    }

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

    /* Group the toggles together on the right (the auto margin absorbs the
       free space, so the search icon no longer floats in the middle). */
    .search-toggle {
        margin-left: auto;
    }

    /* Nav + search collapse into panels revealed by the toggles */
    .header-nav,
    .search-container {
        display: none;
    }

    /* Expanded search — full-width bar anchored below the navbar */
    .header.search-open .search-container {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-width: none;
        min-width: 0;
        padding: var(--spacing-md);
        background: var(--color-bg-white);
        border-bottom: 1px solid var(--color-bg-grey);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
        z-index: 99;
    }

    /* The icons anchor to the padded container, so add the container's padding
       back in to keep the glyphs 18px from the input edges (matching desktop). */
    .header.search-open .search-icon {
        left: calc(18px + var(--spacing-md));
    }

    .header.search-open .search-clear {
        right: calc(14px + var(--spacing-md));
    }

    /* Expanded menu — dropdown panel anchored top-right below the navbar */
    .header.menu-open .header-nav {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-xs);
        position: absolute;
        top: 100%;
        right: 0;
        min-width: 200px;
        padding: var(--spacing-sm);
        background: var(--color-bg-white);
        border: 1px solid var(--color-bg-grey);
        border-radius: var(--radius-md);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
        z-index: 99;
    }

    .header.menu-open .header-nav .header-link {
        height: 44px;
        padding: 0 var(--spacing-md);
        font-size: var(--font-size-base);
    }

    /* Links in the open menu always show their text labels */
    .header.menu-open .header-nav .nav-label {
        display: inline;
    }

    /* About page tablet */
    .about-content {
        padding: var(--spacing-lg);
    }

    .scroll-top {
        bottom: var(--spacing-lg);
        right: var(--spacing-lg);
    }
}

/* Mobile */
@media (max-width: 480px) {
    .main {
        padding: var(--spacing-md);
    }

    /* Term actions - mobile */
    .term-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* About page mobile */
    .about-content {
        padding: var(--spacing-md);
    }

    .about-content h1 {
        font-size: var(--font-size-md);
    }

    .about-section h2 {
        font-size: var(--font-size-base);
    }

    .team-photo-placeholder {
        height: 150px;
    }
}

/* --------------------------------------------------------------------------
   Domain Explorer View (F2)
   -------------------------------------------------------------------------- */
.explorer-view {
    display: none;
    padding: var(--spacing-xl) 0 var(--spacing-2xl);
}

.explorer-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    animation: gatewayFadeIn 0.3s ease both;
}

/* Domain accent colors per section */
.explorer-section-a { --accent: #00b2b8; --accent-bg: #e5f7f8; --accent-dark: #007a7f; }
.explorer-section-b { --accent: #00599b; --accent-bg: #e9f5ff; --accent-dark: #003f72; }
.explorer-section-c { --accent: #641496; --accent-bg: #f0e6f8; --accent-dark: #4a0e70; }
.explorer-section-d { --accent: #a11761; --accent-bg: #f8e5ef; --accent-dark: #7a1148; }
.explorer-section-e { --accent: #e74f52; --accent-bg: #fde8e8; --accent-dark: #c03538; }

/* Explorer header */
.explorer-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.explorer-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--accent-bg, var(--color-bg-aquamarine));
    border: 1.5px solid var(--accent, var(--color-primary));
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--accent-dark, var(--color-primary-dark));
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 4px;
}

.explorer-back-btn:hover {
    background: var(--accent, var(--color-primary));
    border-color: var(--accent, var(--color-primary));
    color: white;
}

.explorer-back-btn svg {
    width: 16px;
    height: 16px;
}

.explorer-header-info {
    flex: 1;
    min-width: 0;
}

.explorer-breadcrumb {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.explorer-breadcrumb-sep {
    opacity: 0.5;
}

.explorer-title-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.explorer-section-badge {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent, var(--color-primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    flex-shrink: 0;
}

.explorer-title {
    font-size: clamp(18px, 2.5vw, 26px);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.explorer-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    margin-top: 4px;
}

.explorer-term-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}

.explorer-progress-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--accent, var(--color-primary));
}

.explorer-progress-sep {
    color: var(--color-text-muted);
    margin: 0 4px;
}

.explorer-reset-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

.explorer-reset-btn:hover {
    color: var(--color-primary);
}

/* Progress bar */
.explorer-progress-bar-wrap {
    height: 6px;
    background: var(--accent-bg, var(--color-bg-aquamarine));
    border-radius: 3px;
    overflow: hidden;
}

.explorer-progress-bar-fill {
    height: 100%;
    background: var(--accent, var(--color-primary));
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* In-domain filter */
.explorer-filter-wrap {
    position: relative;
}

.explorer-filter-input {
    width: 100%;
    max-width: 360px;
    padding: 9px 16px 9px 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: var(--font-size-sm);
    background: var(--color-bg-white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.explorer-filter-input:focus {
    outline: none;
    border-color: var(--accent, var(--color-primary));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #00b2b8) 15%, transparent);
}

.explorer-filter-input::placeholder {
    color: var(--color-text-light);
}

.explorer-filter-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-light);
    pointer-events: none;
}

/* Terms grid */
.explorer-terms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--spacing-sm);
}

/* Term pill */
.explorer-term-pill {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 12px 14px;
    background: var(--color-bg-white);
    border: 1.5px solid var(--color-bg-grey);
    /* Slim domain-accent edge replaces the removed id badge as the color cue */
    border-left: 3px solid var(--accent, var(--color-primary));
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
    width: 100%;
    min-height: 56px;
    position: relative;
}

.explorer-term-pill:hover {
    border-color: var(--accent, var(--color-primary));
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent, #00b2b8) 15%, transparent);
    transform: translateY(-1px);
    background: var(--accent-bg, var(--color-bg-aquamarine));
}

/* Touch press feedback (no hover on touch devices) */
.explorer-term-pill:active {
    border-color: var(--accent, var(--color-primary));
    background: var(--accent-bg, var(--color-bg-aquamarine));
    transform: translateY(0) scale(0.99);
}

.explorer-term-pill.explored {
    border-color: color-mix(in srgb, var(--accent, #00b2b8) 40%, transparent);
    background: var(--accent-bg, var(--color-bg-aquamarine));
}

.explorer-term-pill.hidden {
    display: none;
}

.explorer-term-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.explorer-term-icons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 4px;
}

.explorer-term-icon {
    width: 16px;
    height: 16px;
    color: var(--color-text-light);
    opacity: 0.6;
}

.explorer-explored-check {
    width: 16px;
    height: 16px;
    color: var(--accent, var(--color-primary));
    flex-shrink: 0;
}

.explorer-no-results {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    display: none;
    grid-column: 1 / -1;
}

/* Mobile */
@media (max-width: 640px) {
    .explorer-terms-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .explorer-section-badge {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .explorer-title {
        font-size: 18px;
    }
}

@media (max-width: 360px) {
    /* Single column so pills aren't squeezed into a cramped 2-up */
    .explorer-terms-grid {
        grid-template-columns: 1fr;
    }
}

/* --------------------------------------------------------------------------
   F3: Term Detail Panel (slide-in drawer)
   -------------------------------------------------------------------------- */
.term-detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 52, 85, 0.35);
    z-index: 200;
    backdrop-filter: blur(2px);
}

.term-detail-overlay.active {
    display: block;
}

.term-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 42%;
    min-width: 340px;
    max-width: 640px;
    background: var(--color-bg-white);
    z-index: 201;
    overflow-y: auto;
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.15);
    transform: translateX(105%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.term-detail-panel.active {
    transform: translateX(0);
}

/* Panel sticky header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-white);
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}

.panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s;
}

.panel-close:hover {
    background: var(--color-bg-grey);
    color: var(--color-text-primary);
}

.panel-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text-primary);
    transition: background 0.15s, border-color 0.15s;
}

.panel-nav-btn:hover:not(:disabled) {
    background: var(--color-bg-grey);
    border-color: var(--color-primary);
}

.panel-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.panel-nav-count {
    font-size: 12px;
    color: var(--color-text-muted);
    min-width: 36px;
    text-align: center;
}

/* Term title row */
.panel-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    padding: 20px 24px 12px;
    flex-shrink: 0;
}

/* Consolidated action row directly under the title: feedback + share + copy.
   Sits outside the scrollable body so it stays visible without scrolling. */
.panel-actions {
    padding: 0 24px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border);
}

.panel-actions .term-actions {
    gap: var(--spacing-sm);
}

/* Relocated actions read as accent-styled but compact — present, not dominant. */
.panel-actions .action-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.panel-actions .action-btn:hover {
    background: var(--color-primary);
    color: white;
}

.panel-actions .action-btn svg {
    width: 14px;
    height: 14px;
}

/* Feedback stands out as the encouraged action: filled accent. */
.panel-actions .action-feedback {
    background: var(--color-primary);
    color: white;
}

.panel-actions .action-feedback:hover {
    background: var(--color-secondary);
    color: white;
}

.panel-term-id {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 4px 10px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.panel-term-title {
    font-size: clamp(18px, 5vw, 22px);
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.25;
    margin: 0;
    flex: 1;
}

.panel-term-abbr {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg-grey);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    flex-shrink: 0;
    align-self: center;
}

/* Scrollable body */
.panel-body {
    padding: 0 24px 32px;
    flex: 1;
    overflow-y: auto;
}

.panel-section {
    padding: 16px 0;
}

/* Draw a separator only *between* two present sections — never above the first,
   below the last, or for a section that isn't rendered. */
.panel-section + .panel-section {
    border-top: 1px solid var(--color-bg-grey);
}

.panel-description {
    font-size: 16px;
    line-height: 1.7;
    color: var(--color-text-primary);
}

.panel-meta-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.panel-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.panel-images {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-resources .resources-list {
    margin-top: 4px;
}

@media (max-width: 767px) {
    .term-detail-panel {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        border-radius: 0;
    }

    /* Reclaim horizontal space on narrow phones */
    .panel-body {
        padding: 0 16px 24px;
    }

    /* Fixed-width aspect images would overflow the full-width mobile panel */
    .term-detail-panel .term-image {
        width: 100%;
        max-width: 100%;
    }
}

/* --------------------------------------------------------------------------
   Gateway View (Explorer Mode)
   -------------------------------------------------------------------------- */
.gateway {
    display: none;
    padding: var(--spacing-xl) 0 var(--spacing-2xl);
}

.gateway-inner {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

/* Top banner — Section A */
.gateway-top-banner {
    background: #00b2b8;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 28px 40px;
    text-align: center;
    cursor: pointer;
    font-family: var(--font-family);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    animation: gatewayFadeIn 0.5s ease both;
    width: 100%;
}

.gateway-top-banner:hover {
    background: #007a7f;
    box-shadow: 0 8px 28px rgba(0, 178, 184, 0.35);
}

.gateway-banner-title {
    font-size: clamp(18px, 2.5vw, 26px);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.gateway-banner-section-badge {
    font-size: clamp(14px, 2vw, 20px);
    font-weight: 600;
    opacity: 0.8;
}

.gateway-banner-count {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 100px;
    padding: 3px 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* Connector arrows */
.gateway-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 44px;
    position: relative;
    pointer-events: none;
    animation: gatewayFadeIn 0.5s ease 0.1s both;
}

.gateway-connector::before {
    content: '';
    display: block;
    width: 2px;
    height: 32px;
    background: #00b2b8;
    opacity: 0.5;
}

.gateway-connector::after {
    content: '';
    display: block;
    width: 9px;
    height: 9px;
    border-right: 2px solid #00b2b8;
    border-bottom: 2px solid #00b2b8;
    transform: rotate(45deg);
    opacity: 0.5;
    margin-top: -5px;
}

/* Split connector (B → Non-guided + Guided CAIS) — mirrors gateway-middle grid */
.gateway-connector-split {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--spacing-lg);
    pointer-events: none;
    animation: gatewayFadeIn 0.5s ease 0.15s both;
}

/* Bottom connector (Non-guided + C + D + E → Implant Placement) */
.gateway-connector-bottom {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--spacing-lg);
    pointer-events: none;
    animation: gatewayFadeIn 0.5s ease 0.35s both;
}

.gateway-connector-bottom-right {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

/* Individual arrow cell used in split and bottom connectors */
.gateway-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 44px;
}

.gateway-arrow::before {
    content: '';
    width: 2px;
    flex: 1;
    background: #00b2b8;
    opacity: 0.5;
}

.gateway-arrow::after {
    content: '';
    width: 9px;
    height: 9px;
    border-right: 2px solid #00b2b8;
    border-bottom: 2px solid #00b2b8;
    transform: rotate(45deg);
    opacity: 0.5;
    margin-top: -5px;
    flex-shrink: 0;
}

/* Middle row: B (left) + Guided CAIS (right) */
.gateway-middle {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--spacing-lg);
    animation: gatewayFadeIn 0.5s ease 0.2s both;
}

.gateway-col-left {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.gateway-col-left .gateway-guided-header {
    flex: 1;
}

.gateway-col-right {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Section B box — full-width banner */
.gateway-domain-b {
    background: #00599b;
    color: white;
    border: none;
    border-radius: 16px;
    padding: var(--spacing-lg) var(--spacing-xl);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--spacing-xl);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.gateway-domain-b-label-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
    flex-shrink: 0;
}

.gateway-domain-b .gateway-domain-items {
    flex: 1;
    margin: 0;
}

.gateway-domain-b .gateway-domain-count {
    align-self: flex-end;
    flex-shrink: 0;
}

.gateway-domain-b:hover {
    background: #003f72;
    box-shadow: 0 8px 28px rgba(0, 89, 155, 0.35);
}

.gateway-domain-label {
    font-size: clamp(15px, 1.8vw, 20px);
    font-weight: 700;
    line-height: 1.25;
    color: white;
}

.gateway-domain-section {
    font-size: 15px;
    font-weight: 600;
    opacity: 0.65;
    margin-top: 2px;
}

.gateway-domain-items {
    list-style: none;
    padding: 0;
    margin: var(--spacing-sm) 0 var(--spacing-xs);
    font-size: 12px;
    opacity: 0.75;
    column-count: 2;
    column-gap: 10px;
}

.gateway-domain-items li {
    padding: 1px 0;
    break-inside: avoid;
    line-height: 1.4;
}

.gateway-domain-count {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 100px;
    padding: 3px 11px;
    font-size: 12px;
    font-weight: 700;
    margin-top: var(--spacing-xs);
    align-self: flex-start;
    letter-spacing: 0.02em;
}


/* Guided CAIS header label */
.gateway-guided-header {
    background: #00599b;
    color: white;
    border-radius: 14px;
    padding: var(--spacing-md) var(--spacing-xl);
    text-align: center;
    font-size: clamp(16px, 2vw, 20px);
    font-weight: 700;
    animation: gatewayFadeIn 0.5s ease 0.25s both;
}

/* s-CAIS / d-CAIS / r-CAIS row */
.gateway-domains-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    flex: 1;
}

.gateway-domain-c,
.gateway-domain-d,
.gateway-domain-e {
    color: white;
    border: none;
    border-radius: 14px;
    padding: var(--spacing-md) var(--spacing-md);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    animation: gatewayFadeIn 0.5s ease 0.3s both;
}

/* Section C — s-CAIS (violet) */
.gateway-domain-c { background: #641496; }
.gateway-domain-c:hover {
    background: #4a0e70;
    box-shadow: 0 8px 28px rgba(100, 20, 150, 0.35);
}

/* Section D — d-CAIS (berry) */
.gateway-domain-d { background: #a11761; }
.gateway-domain-d:hover {
    background: #7a1148;
    box-shadow: 0 8px 28px rgba(161, 23, 97, 0.35);
}

/* Section E — r-CAIS (coral) */
.gateway-domain-e { background: #e74f52; }
.gateway-domain-e:hover {
    background: #c03538;
    box-shadow: 0 8px 28px rgba(231, 79, 82, 0.35);
}

.gateway-domain-abbr {
    font-size: clamp(14px, 1.6vw, 18px);
    font-weight: 700;
    color: white;
}

.gateway-domain-c .gateway-domain-section,
.gateway-domain-d .gateway-domain-section,
.gateway-domain-e .gateway-domain-section {
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
}

.gateway-domain-c .gateway-domain-items,
.gateway-domain-d .gateway-domain-items,
.gateway-domain-e .gateway-domain-items {
    column-count: 1;
    color: rgba(255, 255, 255, 0.7);
    margin: 4px 0;
}

.gateway-domain-c .gateway-domain-count,
.gateway-domain-d .gateway-domain-count,
.gateway-domain-e .gateway-domain-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Bottom static banner */
.gateway-bottom-banner {
    background: #00599b;
    color: white;
    border-radius: 20px;
    padding: 22px 40px;
    text-align: center;
    font-size: clamp(16px, 2.5vw, 24px);
    font-weight: 700;
    animation: gatewayFadeIn 0.5s ease 0.4s both;
    letter-spacing: 0.01em;
}

/* Gateway entry animation */
@keyframes gatewayFadeIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile: stack columns */
@media (max-width: 640px) {
    .gateway {
        padding: var(--spacing-lg) 0 var(--spacing-xl);
    }

    .gateway-inner {
        padding: 0 var(--spacing-md);
    }

    .gateway-middle {
        grid-template-columns: 1fr;
    }

    .gateway-domains-row {
        grid-template-columns: 1fr;
    }

    .gateway-top-banner {
        padding: var(--spacing-lg) var(--spacing-xl);
    }

    .gateway-domain-items {
        column-count: 1;
    }

    .gateway-domain-b {
        flex-direction: column;
    }

    .gateway-domain-b-label-group {
        min-width: unset;
    }

    .gateway-bottom-banner {
        padding: var(--spacing-md) var(--spacing-xl);
    }
}

/* Narrow phones: tighten padding so a ~320px viewport keeps usable width */
@media (max-width: 480px) {
    .gateway-inner {
        padding: 0 var(--spacing-sm);
    }

    .gateway-top-banner {
        padding: var(--spacing-md);
    }

    .gateway-bottom-banner {
        padding: var(--spacing-md);
    }
}

/* --------------------------------------------------------------------------
   Print Styles
   -------------------------------------------------------------------------- */
@media print {

    .header,
    .footer,
    .scroll-top,
    .search-container,
    .image-lightbox {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .main {
        max-width: none;
        padding: 0;
    }

    a {
        color: inherit;
        text-decoration: underline;
    }

    .cross-ref::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

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

    html {
        scroll-behavior: auto;
    }
}

/* Focus styles - ITI teal */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-pill);
    z-index: 1000;
}

.skip-link:focus {
    top: 0;
}