:root {
    --eclipse-0: #ffffff;
    --eclipse-1: #f8fafc;
    --eclipse-2: #f1f5f9;
    --eclipse-3: #e2e8f0;
    --eclipse-4: #cbd5e1;
    --eclipse-5: #94a3b8;
    --eclipse-6: #64748b;
    --eclipse-7: #475569;
    --eclipse-8: #334155;
    --eclipse-9: #1e293b;
    --eclipse-10: #0f172a;
    --eclipse-11: #020617;

    --font-size-displayLarge: 52px;
    --font-size-displayMedium: 46px;
    --font-size-displaySmall: 41px;
    --font-size-heading1: 36px;
    --font-size-heading2: 32px;
    --font-size-heading3: 29px;
    --font-size-heading4: 26px;
    --font-size-heading5: 23px;
    --font-size-heading6: 20px;
    --font-size-subtitle: 18px;
    --font-size-body: 16px;
    --font-size-caption: 14px;
    --font-size-label: 13px;
    --font-size-tagline: 11px;

    --mono: 'Roboto Mono', monospace;
    --sans: 'Figtree', sans-serif;
}

/* Reset and Base Styles */
* {
    font-family: var(--sans);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    color: var(--eclipse-11);
    line-height: 1.6;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-optical-sizing: auto;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    background-color: var(--eclipse-1);
    overflow: visible;
    width: 100%;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
}

header {
    background-color: var(--eclipse-0);
    padding: 24px 0;
    box-shadow: 0 1px 0px 0 var(--eclipse-2);
    margin-bottom: 0;
    width: 100%;
}

.header-container {
    margin: 0 auto;
    max-width: 1280px;
}

header h1 {
    font-size: var(--font-size-heading2);
    text-align: left;
    color: var(--eclipse-11);
    line-height: 1.2;
}

header p {
    font-size: var(--font-size-subtitle);
    color: var(--eclipse-10);
    font-weight: 400;
    margin-top: 4px;
}

a {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 6px;
    text-decoration-color: var(--eclipse-4);
    color: var(--eclipse-11);
    transition: color 0.3s ease-in-out, text-decoration-color 0.3s ease-in-out;
    word-wrap: break-word;
    white-space: normal;
}

a:hover {
    color: var(--eclipse-9);
    text-decoration-color: var(--eclipse-7);
}

.header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 158px;
    margin-bottom: 24px;
    width: 100%;
}

.nav-link {
    display: flex;
    flex-direction: row;
    gap: 6px;
    white-space: nowrap;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: var(--font-size-caption);
    font-weight: 600;
    color: var(--eclipse-11);
    transition: 0.2s ease;
}

.nav-link:hover {
    transform: translateX(-4px);
}

.ph-list-magnifying-glass {
    font-size: 20px;
}

#search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: var(--font-size-body);
    border: 2px solid var(--eclipse-2);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: border 0.2s ease, background-color 0.2s ease;
}

#search-input:hover {
    border: 2px solid var(--eclipse-3);
    background-color: var(--eclipse-1);
}

#search-input:focus-visible,
#search-input:active {
    border: 2px solid var(--eclipse-5);
    background-color: var(--eclipse-2);
    outline: none;
}

.filter-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
    gap: 16px;
}

.filter-group select {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--eclipse-2);
    border-radius: 12px;
    background-color: var(--eclipse-0);
    font-size: var(--font-size-body);
    cursor: pointer;
    transition: border 0.2s ease, background-color 0.2s ease;
}

.filter-group select:hover {
    border: 2px solid var(--eclipse-3);
    background-color: var(--eclipse-1);
}

.filter-group select:focus-visible,
.filter-group select:active {
    border: 2px solid var(--eclipse-5);
    background-color: var(--eclipse-2);
    outline: none;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, auto);
    justify-items: stretch;
    gap: 16px;
    width: 100%;
    justify-content: center;
    min-height: 200px;
    will-change: transform;
    contain: content;
    transform: translateZ(0);
    position: relative;
    overflow: visible;
    padding: 0;
    box-shadow: none;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
    padding: 24px 0;
}

.animal-card.hidden {
    display: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.animal-card {
    background-color: var(--eclipse-0);
    border-radius: 16px;
    border: 2px solid var(--eclipse-2);
    padding: 24px;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
    overflow: visible;
    contain: content;
    will-change: transform;
    transform: translateZ(0);
    z-index: 2;
    opacity: 1;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 308px;
}

.animal-card:hover,
.animal-card:active {
    transform: scale(.96);
    box-shadow: 0 4px 10px var(--eclipse-3);
    z-index: 10;
}

.animal-card h3 {
    color: var(--eclipse-10);
    font-size: var(--font-size-heading6);
    font-weight: 600;
    line-height: 1.2;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px dotted var(--eclipse-3);
}

.card-body {
    padding-top: 12px;
}

.monospace {
    font-family: var(--mono);
    font-size: var(--font-size-caption) !important;
    color: var(--eclipse-9) !important;
    margin: 0 !important;
    font-weight: 400 !important;
}

.animal-card p {
    margin-top: 4px;
    font-size: var(--font-size-body);
    color: var(--eclipse-11);
    font-weight: 500;
}

.animal-card strong {
    color: var(--eclipse-8);
    font-weight: 400;
}

/* Update the existing card body styling */
.card-body p strong {
    min-width: 76px;
    display: inline-block;
    color: var(--eclipse-8);
    font-weight: 400;
}

.card-body p {
    display: flex;
    align-items: flex-start;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 24px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    margin: 5% auto;
    width: 90%;
    max-width: 800px;
    background-color: var(--eclipse-0);
    border-radius: 24px;
    max-height: 90vh;
}

.modal-header {
    background-color: var(--eclipse-2);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-heading5);
    font-weight: 600;
    line-height: 1.2;
}

.modal-close {
    background: none;
    border: none;
    color: var(--eclipse-11);
    font-size: 2em;
    cursor: pointer;
    line-height: 1.0;
}

.modal-body {
    padding: 24px;
    background-color: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 80vh;
}


.modal-section {
    margin-bottom: 32px;
    padding: 0;
}

.modal-section h3 {
    padding-top: 16px;
    padding-bottom: 8px;
    color: var(--eclipse-11);
    font-size: var(--font-size-caption);
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-section ul {
    list-style-type: none;
}

.modal-section ul li {
    padding: 16px 0;
    border-bottom: 1px dashed var(--eclipse-3);
    color: var(--eclipse-11);
    font-weight: 500;
    display: flex;
    align-items: flex-start;
}

.modal-section ul li strong {
    color: var(--eclipse-8);
    font-weight: 400;
    min-width: 180px;
    display: inline-block;
    vertical-align: top;
}

.image-search-buttons p {
    font-family: var(--mono);
    color: var(--eclipse-10);
    font-weight: 400;
    font-size: var(--font-size-caption);
    padding-bottom: 4px;
}

/* Image Search Buttons */
.image-search-buttons {
    margin-bottom: 20px;
}

.horizontal {
    display: flex;
    flex-direction: row;
    gap: 64px;
}

.image-search-buttons h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.image-search-buttons button,
.image-search-buttons a {
    display: inline-block;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: none;
    background: none;
    padding-right: 20px;
    padding-top: 8px;
}

.image-search-buttons a {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.image-search-buttons button:hover,
.image-search-buttons a:hover {
    transform: scale(.94);
}

.card-hover-buttons {
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    background: rgba(100, 116, 139, 0.9);
    padding: 10px;
    display: flex;
    justify-content: center;
    gap: 12px;
    transition: bottom 0.3s ease;
    transform: translateZ(0);
    will-change: transform;
}

.animal-card:hover .card-hover-buttons {
    bottom: 0;
}

.card-hover-buttons button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--eclipse-0);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-hover-buttons button:hover {
    transform: scale(1.1);
}

/* Add loading state */
.cards-grid.loading {
    opacity: 0.7;
    pointer-events: none;
}


/* Remove scrollbar from modal content */
.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-body::-webkit-scrollbar {
    width: 10px;
    height: 12px;
    transition: background-color 0.2s ease;
}

.modal-body::-webkit-scrollbar-thumb {
    background-color: var(--eclipse-3);
    border-radius: 10px;
    transition: background-color 0.2s ease;
    scroll-behavior: smooth;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background-color: var(--eclipse-5);
}

.modal-body::-webkit-scrollbar-track {
    background-color: none;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

.not-specified {
    font-family: var(--mono);
    font-style: italic;
    font-weight: 400;
    color: var(--eclipse-5);
    font-size: inherit;
}

/* When modal is open, prevent body scrolling */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.modal-image-container {
    width: 100%;
    height: 360px;
    background-color: var(--eclipse-2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.modal-image-placeholder {
    color: var(--eclipse-6);
    font-family: var(--mono);
    font-size: var(--font-size-caption);
}

.modal-description {
    padding: 24px;
    background-color: var(--eclipse-1);
    border-top: 2px solid var(--eclipse-2);
    margin: 0 0 16px;
}

.description-text {
    font-family: var(--sans);
    font-size: var(--font-size-body);
    color: var(--eclipse-10);
    line-height: 1.4;
}

.wiki-info-monospace {
    font-family: var(--mono);
    font-size: var(--font-size-tagline);
    color: var(--eclipse-9);
    line-height: 1.7;
    padding: 12px 24px;
}

footer {
    font-family: var(--mono);
    font-size: var(--font-size-caption);
    color: var(--eclipse-10);
    font-weight: 400;
    margin: 32px 0 48px;
    line-height: 1.8;
}


/* Responsive Adjustments */

@media (max-width: 1280px) {
    .container {
        max-width: 100%;
    }

    .header-container {
        max-width: 100%;
    }

    .cards-grid {
        grid-template-columns: repeat(3, auto);
    }

    .header-wrapper {
        gap: 100px;
    }
}


@media (max-width: 1024px) {

    header {
        padding: 0;
    }

    .header-container {
        padding: 24px;
    }

    .header-wrapper {
        gap: 40px;
    }

    header h1 {
        font-size: var(--font-size-heading4);
    }

    .nav-link {
        font-size: var(--font-size-body);
    }

    .container {
        padding: 0 24px;
    }

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

    .animal-card {
        min-width: 220px;
    }
}


@media (max-width: 768px) {

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

    .modal-header {
        padding: 12px 20px;
    }

    .modal-header h2 {
        font-size: var(--font-size-heading5);
    }

    .modal-description,
    .wiki-info-monospace {
        padding: 20px;
        margin-bottom: 0;
    }

    .modal-body {
        padding: 24px 20px 8px;
    }

    .horizontal {
        flex-direction: column;
        gap: 20px;
        margin-bottom: 24px;
    }

    .image-search-buttons {
        margin-bottom: 0;
    }

    .modal-section ul li {
        flex-direction: column;
    }

    .modal-section ul li strong {
        margin-bottom: 2px;
    }
}

@media (max-width: 640px) {

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

    header {
        padding: 0;
    }

    .header-wrapper {
        gap: 16px;
        flex-direction: column;
        margin-bottom: 32px;
    }
}

@media screen and (max-width: 480px) {

    .cards-grid {
        grid-template-columns: repeat(1, minmax(128px, 1fr));
    }

    .filter-group {
        grid-template-columns: repeat(2, minmax(128px, 1fr));
    }

    .animal-card {
        min-width: 342px;
    }
}