/* ---
Design System & Style Guide
--- */

/* 3.1. Color Palette */
:root {
    --color-black: #000000;
    --color-white: #FFFFFF;
    --color-gray-dark: #444444;
    --color-gray-light: #eeeeee;
    --color-accent: #FFF9C4; /* Using this as pale yellow for consistency with docs */
    --color-highlight: #0056b3;
}

html {
    box-sizing: border-box;
    font-size: 15px; /* Base font size for rem units (1rem = 15px) */
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* 3.2. Typography */
body {
    font-family: "Martian Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "wdth" 87.5;
    background-color: var(--color-black);
    color: var(--color-white);
    font-size: 1rem; /* 15px */
    line-height: 1.6; /* 24px */
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3 {
    font-weight: 500;
}

h1 { font-size: 2.2rem; line-height: 1.2; }
h2 { font-size: 1.8rem; line-height: 1.25; }
h3 { font-size: 1.4rem; line-height: 1.3; }

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

a:hover {
    color: var(--color-white);
    background-color: var(--color-highlight);
}

/* ---
Layout & Components
--- */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0rem 2rem;
    border-bottom: 2px solid var(--color-gray-dark);
}

header h1 a {
    color: var(--color-white);
}
header h1 a:hover {
    background-color: transparent;
}

nav a {
    margin-left: 1.5rem;
    font-size: 1.1rem; /* 16.5px */
}

main {
    flex-grow: 1;
    padding-top: 1rem;
    padding-right: 0px;
    padding-bottom: 4rem;
    padding-left: 0px;
}

footer {
    text-align: center;
    padding: 1rem;
    border-top: 2px solid var(--color-gray-dark);
    font-size: 0.85rem; /* 12.75px */
    line-height: 1.4; /* ~18px */
    color: var(--color-gray-light);
}

footer p {
    margin: 0.25rem 0; /* tighten default paragraph margins in footer */
}

/* Footer support line */
.footer-support {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* allow wrapping on narrow screens */
    white-space: normal;
    justify-content: center;
}

.footer-support .bmc-wrapper {
    display: inline-block;
    transform: scale(0.5);
    transform-origin: left center;
    filter: grayscale(35%);
}

@media (max-width: 480px) {
    footer {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        line-height: 1.3;
    }
    .footer-support {
        display: inline-flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: center;
        align-items: center;
        line-height: 1.1; /* tighten vertical spacing between wrapped rows */
    }
    .footer-support .preface-text { flex-basis: 100%; }
    .footer-support .bmc-wrapper {
        transform: scale(0.4);
    }
}

pre {
    font-family: "Martian Mono", monospace;
    font-variation-settings: "wdth" 87.5;
    white-space: pre-wrap;
    background: var(--color-gray-dark);
    padding: 1rem;
    border: 2px solid var(--color-gray-light);
    /* box-shadow: 5px 5px 0 var(--color-gray-light); */
}

button, .button {
    font-family: "Martian Mono", monospace;
    font-variation-settings: "wdth" 87.5;
    background-color: var(--color-black);
    color: var(--color-white);
    border: 2px solid var(--color-accent);
    padding: 0.5rem 1rem;
    font-size: 1rem; /* 15px */
    line-height: 1.33; /* 20px */
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover, .button:hover {
    background-color: var(--color-accent);
    color: var(--color-black);
    border-color: var(--color-white);
}

.button-small {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* ---
Quest Page Specifics
--- */
.quest-container {
    max-width: 1600px; /* Wider for two columns */
    text-align: center;
}

.quest-main-layout {
    display: flex;
    flex-direction: column; /* Mobile-first layout */
    gap: 2rem;
    align-items: stretch;
}

@media (min-width: 1200px) {
    .quest-main-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .quest-left-panel {
        flex: 0 0 650px; /* Fixed width, no grow/shrink */
        position: sticky;
        top: 2rem;
        box-shadow: 0 0 15px rgba(255, 249, 196, 0.3);
    }
    .quest-right-panel {
        flex: 1; /* Grow to fill remaining space */
    }
    .encounter-cards {
        min-height: 420px; /* Reserve space for cards to prevent layout shifts */
    }
}

@media (max-width: 1200px) {
.quest-left-panel {
    /* Base styles for mobile-first */
    flex: 1 1 auto;
}
}

.quest-right-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.narrative-block {
    background: var(--color-black);
    border: 2px solid var(--color-accent);
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-white);
    min-height: 120px; /* Avoid layout shifts */
}
.narrative-block p { margin: 0 0 1em 0; }
.narrative-block p:last-child { margin-bottom: 0; }

.mobile-saved-figures {
    display: none; /* Hidden by default, shown on mobile */
    border: 2px solid var(--color-gray-dark);
    padding: 1rem;
    margin-bottom: 2rem;
}
.mobile-saved-figures h4 {
    margin: 0 0 0.5rem 0;
    border-bottom: 1px solid var(--color-gray-dark);
    padding-bottom: 0.5rem;
}
.mobile-saved-figures ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.mobile-saved-figures li {
    background-color: var(--color-gray-dark);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.mobile-boat-container {
    display: none; /* Hidden by default */
}
.boat-small {
    font-size: 1.5rem;
    text-align: center;
    line-height: 1.1;
    color: var(--color-gray-light);
    background: none;
    border: none;
    padding: 1rem 0;
}

/* --- VFX Animations --- */
@keyframes squiggly-anim {
  0% {
    filter: url('#squiggly-0');
  }
  25% {
    filter: url('#squiggly-1');
  }
  50% {
    filter: url('#squiggly-2');
  }
  75% {
    filter: url('#squiggly-3');
  }
  100% {
    filter: url('#squiggly-4');
  }
}

.vfx-water {
  animation: squiggly-anim 1.5s linear infinite;
}

/* --- Mobile Choice Button --- */
.mobile-choice-trigger {
    font-size: 1.2rem;
    padding: 1rem 2rem;
    margin: 2rem auto;
    display: block;
    min-width: 200px;
    text-align: center;
    background-color: var(--color-black);
    border: 3px solid var(--color-accent);
    color: var(--color-accent);
    transition: all 0.3s ease;
}

.mobile-choice-trigger:hover {
    background-color: var(--color-accent);
    color: var(--color-black);
    border-color: var(--color-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 249, 196, 0.3);
}

/* --- Mobile Choice Overlay --- */
.mobile-choice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.mobile-choice-overlay.visible {
    display: block;
    opacity: 1;
}
.mobile-choice-header {
    text-align: center;
    margin-bottom: 2rem;
}
.mobile-choice-header h3 {
    font-size: 1.5rem;
    color: var(--color-accent);
}
.mobile-choice-cards-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

/* --- Responsive Breakpoint --- */
@media (max-width: 1199px) {
    /* --- Quest Page Mobile Layout --- */
    .quest-left-panel {
        position: static;
        top: auto;
        min-width: unset;
        flex-basis: auto;
    }
    .quest-right-panel {
        margin-top: 0; /* No more top margin needed */
    }
    .encounter-cards {
        padding-bottom: 1rem;
        min-height: 120px; /* Reserve space for choice button to prevent layout shifts */
        align-items: center; /* Vertically center the button */
        justify-content: center; /* Horizontally center the button */
        display: flex;
    }
    .character-card {
        width: 100%;
        max-width: 350px; /* Limit width on tablet-ish sizes */
        margin: 0 auto;
    }

    /* Toggle visibility of boat/figure elements */
    .boat-container {
        display: none;
    }
    .mobile-boat-container {
        display: block;
    }
    .mobile-saved-figures {
        display: block;
    }
}

@media (max-width: 1200px) {
    .quest-main-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    .quest-left-panel {
        position: static;
        top: auto;
        min-width: unset;
        flex-basis: auto;
    }
    .quest-right-panel {
        margin-top: 2rem;
    }
}

/* Further compaction for small mobile screens */
@media (max-width: 480px) {
    .character-card {
        padding: 1rem;
    }
    .character-card h3 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }
    .character-quote {
        font-size: 0.9rem;
        padding-left: 0.75rem;
        margin: 0.75rem 0;
    }
    
    .mobile-choice-trigger {
        font-size: 1.1rem;
        padding: 0.8rem 1.5rem;
        min-width: 180px;
        margin: 1.5rem auto;
    }
}

.progress-indicator span {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #444444;
    color: #eeeeee;
    border: 2px solid #444444;
    margin: 0 0.25rem;
    border-radius: 4px;
    font-size: 0.8rem; /* 12px */
    transition: all 0.3s ease;
    text-align: center;
}

.progress-indicator span.active {
    background-color: #fff9c4;
    color: #000000;
    border-color: #fff9c4;
    font-weight: bold;
}

.progress-indicator span.completed {
    background-color: transparent;
    border-color: #444444;
    color: #444444;
    opacity: 0.7;
}

.boat-container {
    position: relative;
    margin-bottom: 2rem;
}

.boat { /* was .act-panel .boat */
    width: 100%;
    font-size: 0.9rem; /* 13.5px */
    text-align: left;
    margin: 0;
    line-height: 1.2;
    overflow-x: auto;
}

.boat-container .seat {
    position: absolute;
    font-family: "Martian Mono", monospace;
    font-variation-settings: "wdth" 87.5;
    font-size: 0.9rem; /* Match the boat pre's font-size */
    line-height: 1.2; /* Match the boat pre's line-height */
    color: var(--color-accent);
    background: var(--color-black); 
    padding: 0 0.2ch;
    font-weight: 600;
}

#seat-1 { top: 17.2em; left: 15ch; }
#seat-2 { top: 17.7em; left: 30ch; }
#seat-3 { top: 20.5em; left: 16.5ch; }
#seat-4 { top: 21em; left: 31.5ch; }

.act-panel .boat .seat {
    color: var(--color-accent);
}

.encounter-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    align-items: stretch;
    width: 100%;
}

@media (min-width: 1200px) {
    .encounter-cards {
        min-height: 420px; /* Reserve space for cards to prevent layout shifts */
    }
}

.character-card {
    border: 2px solid var(--color-gray-dark);
    padding: 1.5rem;
    width: 280px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.character-card:hover {
    border-color: var(--color-accent);
}

.character-card h3 {
    margin-top: 0;
}

.character-quote {
    font-style: italic;
    color: var(--color-gray-light);
    border-left: 3px solid var(--color-accent);
    padding: 0.5rem 0 0.5rem 1rem;
    margin: 1.5rem 0;
    text-align: left;
    font-size: 1rem; /* 15px */
    line-height: 1.4; /* 21px */
    flex-grow: 1;
}

.dilemma-card {
    border-color: var(--color-accent);
    box-shadow: 0 0 15px var(--color-accent);
}

.dilemma-buttons {
    margin-top: 1rem;
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.dilemma-buttons .button {
    width: 45%;
    font-size: 0.9rem; /* 13.5px */
}

.error {
    color: #e95454;
    text-align: center;
    font-weight: bold;
}

/* --- Modal & Sacrifice Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.visible {
    opacity: 1;
}

.modal-content {
    background-color: var(--color-black);
    padding: 2rem;
    border: 2px solid var(--color-accent);
    box-shadow: 0 0 20px var(--color-accent);
    text-align: center;
    max-width: 500px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative; /* For positioning close button */
}

.modal-overlay.visible .modal-content {
    transform: scale(1);
}

.close-modal-button {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--color-gray-light);
    font-size: 2.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}
.close-modal-button:hover {
    color: var(--color-accent);
}

.modal-content h2 {
    margin-top: 0;
}

.sacrifice-list {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.sacrifice-item button {
    width: 100%;
    padding: 1.5rem 1rem;
}

#restart-button {
    margin-top: 1rem;
}

.ascii-spinner {
    font-size: 1.8rem; /* 27px */
    text-align: center;
    background: none;
    border: none;
    box-shadow: none;
    padding: 2rem;
    display: inline-block;
}

/* ---
Entity Detail Page
--- */
.entity-container {
    text-align: center;
}

#loading-container .entity-header {
    margin-bottom: 1rem;
}

.entity-id-display {
    font-size: 0.85rem; /* 12.75px */
    color: var(--color-gray-dark);
    margin-top: 2rem;
}

.entity-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--color-gray-dark);
    padding-bottom: 2rem;
}

#portrait-image-container {
    width: 100%;
    max-width: 400px;
}

.entity-header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    width: 100%;
}

.entity-header h1 {
    margin-bottom: 0;
}

.entity-details-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

@media (min-width: 768px) {
    .entity-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 2rem;
    }

    #portrait-image-container {
        flex: 0 0 250px;
        max-width: 250px;
    }

    .entity-header-text {
        text-align: left;
        align-items: flex-start;
        flex: 1;
    }

    .entity-details-group {
        flex: 1 1 55%;
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .entity-header h1 {
        font-size: 1.8rem;
    }
}

.source-figures-label {
    color: var(--color-accent);
    font-weight: 500;
    margin-right: 0.25rem;
}

.source-figures {
    color: var(--color-white);
}

.source-figures .figure-name {
    color: var(--color-white);
    font-weight: 400;
}

.source-figures .figure-separator {
    color: var(--color-accent);
    margin: 0 0.25rem;
    font-weight: 500;
}

/* Evil Score Bar */
.evil-score-container {
    margin-top: 0;
    max-width: 350px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.evil-score-descriptor {
    font-size: 1rem; /* 15px */
    color: var(--color-accent);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#evil-score-bar-container {
    width: 100%;
    height: 12px;
    background-color: var(--color-gray-dark);
    border: 2px solid var(--color-gray-light);
    margin-bottom: 0.5rem;
}

#evil-score-bar {
    width: 0%; /* Set by JS */
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent) 0%, #e95454 100%);
    transition: width 1s ease-out;
}

.evil-score-badge {
    display: inline-block;
    color: var(--color-gray-light);
    font-size: 0.8rem; /* 12px */
}

.content-columns {
    display: flex;
    flex-direction: column; /* Mobile-first: stack columns */
    gap: 2rem;
    align-items: flex-start;
}

/* Desktop layout */
@media (min-width: 992px) {
    .content-columns {
        flex-direction: row; /* Two columns on larger screens */
        gap: 3rem;
    }
    .left-column {
        flex: 1;
        position: sticky;
        top: 2rem;
    }
    .right-column {
        flex: 2;
    }
}

.left-column {
    width: 100%; /* Take full width on mobile */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.right-column {
    width: 100%; /* Take full width on mobile */
}

.manifest-card {
    background-color: var(--color-black);
    border: 2px solid var(--color-gray-dark);
    padding: 0;
    text-align: left;
    overflow: hidden; /* To contain child border-radius */
}

.manifest-card h3 {
    margin-top: 0;
    margin-bottom: 0;
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-gray-dark);
}

.manifest-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-gray-dark);
}

.tab-button {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem; /* 15px */
    background-color: var(--color-black);
    border: none;
    border-right: 2px solid var(--color-gray-dark);
    cursor: pointer;
    color: var(--color-gray-light);
    transition: all 0.2s ease-in-out;
}

.tab-button:last-child {
    border-right: none;
}

.tab-button:hover {
    background-color: var(--color-gray-dark);
}

.tab-button.active {
    background-color: var(--color-accent);
    color: var(--color-black);
    font-weight: bold;
}

.tab-pane {
    display: none;
    padding: 1.5rem;
}

.tab-pane.active {
    display: block;
}

.manifest-card ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.manifest-card ul li {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
    position: relative;
    line-height: 1.5; /* 22.5px */
}

.manifest-card ul li::before {
    content: '■';
    position: absolute;
    left: 0;
    font-size: 0.6rem; /* 9px */
    color: var(--color-accent);
}

#portrait-image-container img {
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

/* Legacy support for non-VHS portraits */
#portrait-image-container > img {
    border-bottom: 1px solid var(--color-gray-dark);
}

.ascii-glitch {
    background-color: var(--color-black);
    color: var(--color-accent);
    text-align: center;
    padding: 3rem 1rem;
    font-size: 1.4rem; /* 21px */
    line-height: 1.2;
}

#share-widget .share-buttons {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1.5rem;
}

#share-widget .share-buttons button {
    flex-grow: 1;
}

/* Timeline Accordion */
#timeline-section h2 {
    text-align: left;
    margin-bottom: 1.5rem;
}

.timeline-loading p {
    font-size: 1.1rem; /* 16.5px */
}
.timeline-loading .ascii-spinner {
    padding-top: 1rem;
    padding-bottom: 0;
}

.accordion-item {
    border: 2px solid var(--color-gray-dark);
    margin-bottom: 1rem;
    background-color: #111;
}

.accordion-header {
    background-color: transparent;
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.accordion-header:hover {
    background-color: var(--color-gray-dark);
}

.accordion-header h4 {
    margin: 0;
    font-size: 1.1rem; /* 16.5px */
}

.accordion-toggle {
    font-size: 1.8rem; /* 27px */
    font-weight: bold;
    transform: rotate(0deg);
    transition: transform 0.3s ease-out;
}

.accordion-toggle.expanded {
    transform: rotate(45deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 1.5rem;
    text-align: left;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
}

.accordion-content.expanded {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.accordion-content ul {
    padding-top: 1.5rem;
    border-top: 1px dashed var(--color-gray-dark);
    list-style-position: outside;
    padding-left: 1.5rem;
}

.accordion-content ul li {
    margin-bottom: 0.5rem;
    line-height: 1.6; /* 24px */
}

/* ---
Gallery Page
--- */
.gallery-container h2 {
    text-align: center;
}
.gallery-container p {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 2rem auto;
    color: var(--color-gray-light);
}

.filter-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-dropdown {
    position: relative;
}

#filter-button {
    min-width: 200px;
}

.filter-options-panel {
    display: none;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-gray-dark);
    border: 2px solid var(--color-accent);
    z-index: 10;
    padding: 1rem;
    width: 300px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.filter-options-panel.visible {
    display: block;
}

.filter-options-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.filter-options-list li {
    margin-bottom: 0.5rem;
}

.filter-options-list label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.filter-options-list input[type="checkbox"] {
    margin-right: 0.75rem;
    /* Basic custom checkbox styling */
    appearance: none;
    background-color: var(--color-black);
    border: 2px solid var(--color-gray-light);
    width: 1.2rem;
    height: 1.2rem;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    top: -1px;
}

.filter-options-list input[type="checkbox"]:checked {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

.filter-options-list input[type="checkbox"]:checked::after {
    content: 'X';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-black);
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--color-gray-light);
    padding-top: 1rem;
}

.active-filters-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.active-filter-tag {
    background-color: var(--color-gray-dark);
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.active-filter-tag button {
    background: none;
    border: none;
    color: var(--color-accent);
    margin-left: 0.5rem;
    padding: 0;
    font-size: 1.2em;
    cursor: pointer;
    line-height: 1;
}

.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .entity-grid {
        gap: 1.5rem;
    }
}

@media (max-width: 600px) {
    .entity-grid {
        /* As per frontend.md, 2 per row on mobile */
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .gallery-card-info h3 {
        font-size: 1rem;
    }
}

.gallery-card {
    border: 2px solid var(--color-gray-dark);
    text-decoration: none;
    color: var(--color-white);
    background-color: #111;
    transition: all 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
    animation: squiggly-anim 2.5s linear infinite;
}

.gallery-card:hover {
    border-color: var(--color-accent);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 249, 196, 0.1);
}

.gallery-card-portrait {
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    position: relative;
    background-color: var(--color-black);
}

.gallery-card-portrait img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.ascii-glitch-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem; /* 16.5px */
    color: var(--color-gray-light);
    background: none;
    border: none;
    box-shadow: none;
}

.gallery-card-info {
    padding: 1rem;
    text-align: center;
    /* Prevents long words from breaking the layout */
    overflow-wrap: break-word;
    word-break: break-word; /* Fallback */
}

.gallery-card-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem; /* 16.5px */
}

.evil-score-badge-small {
    font-size: 0.8rem; /* 12px */
    background-color: var(--color-gray-dark);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
}

.pagination-controls {
    text-align: center;
    margin-top: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.pagination-controls button {
    font-size: 0.9rem; /* 13.5px */
    padding: 0.25rem 0.75rem;
}

.pagination-controls button.active {
    background-color: var(--color-accent);
    color: var(--color-black);
    border-color: var(--color-accent);
    cursor: default;
}

.pagination-controls span {
    padding: 0 0.5rem;
}

/* ---
Glitch Text Effect for Loaders
--- */
.glitch-effect-container {
    text-align: center;
    width: 100%;
    margin: auto;
    overflow: hidden;
    padding: 2rem 0;
    position: relative; /* Allow absolute positioning of children */
    height: 200px; /* Give the roaming names a space to roam in */
}

.glitch-effect-container .loading-glitch-text {
    font-family: 'Martian Mono', monospace;
    font-size: 1.5rem; /* 22.5px */
    text-align: center;
    position: absolute; /* Changed for roaming */
    color: var(--color-white);
    z-index: 1;
    animation: noise-3 2s linear infinite; /* Slowed down animation */
    overflow: visible;
    transition: top 1s ease-in-out, left 1s ease-in-out; /* Smooth transitions for roaming */
}

.loading-glitch-text::before,
.loading-glitch-text::after {
    content: attr(data-text);
    font-family: 'Martian Mono', monospace;
    font-size: 1.5rem; /* 22.5px */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-black);
    overflow: hidden;
    clip: rect(0, 900px, 0, 0);
    opacity: 0;
    color: var(--color-white);
}

.loading-glitch-text::before {
    left: -2px;
    text-shadow: 1px 0 var(--color-accent);
    animation: noise-1 2s linear infinite alternate-reverse;
}

.loading-glitch-text::after {
    left: 2px;
    text-shadow: -1px 0 #e95454;
    animation: noise-2 2s linear infinite alternate-reverse;
}

@keyframes noise-1 {
  0% { clip: rect(29px, 9999px, 31px, 0); transform: skew(0.2deg); opacity: 1;}
  5% { clip: rect(4px, 9999px, 89px, 0); transform: skew(0.51deg); }
  10% { clip: rect(22px, 9999px, 86px, 0); transform: skew(0.79deg); }
  15% { clip: rect(8px, 9999px, 35px, 0); transform: skew(0.55deg); }
  20% { clip: rect(79px, 9999px, 88px, 0); transform: skew(0.8deg); opacity: 1;}
  25% { clip: rect(4px, 9999px, 73px, 0); transform: skew(0.96deg); }
  30% { clip: rect(21px, 9999px, 57px, 0); transform: skew(0.79deg); }
  35% { clip: rect(4px, 9999px, 12px, 0); transform: skew(0.74deg); }
  40% { clip: rect(72px, 9999px, 86px, 0); transform: skew(0.99deg); opacity: 1;}
  45% { clip: rect(43px, 9999px, 78px, 0); transform: skew(0.38deg); }
  50% { clip: rect(10px, 9999px, 84px, 0); transform: skew(0.22deg); }
  55% { clip: rect(61px, 9999px, 79px, 0); transform: skew(0.12deg); }
  60% { clip: rect(14px, 9999px, 79px, 0); transform: skew(0.34deg); opacity: 1;}
  65% { clip: rect(38px, 9999px, 89px, 0); transform: skew(0.67deg); }
  70% { clip: rect(3px, 9999px, 45px, 0); transform: skew(0.83deg); }
  75% { clip: rect(20px, 9999px, 5px, 0); transform: skew(0.1deg); }
  80% { clip: rect(84px, 9999px, 20px, 0); transform: skew(0.4deg); opacity: 1;}
  85% { clip: rect(54px, 9999px, 84px, 0); transform: skew(0.35deg); }
  90% { clip: rect(28px, 9999px, 69px, 0); transform: skew(0.88deg); }
  95% { clip: rect(10px, 9999px, 59px, 0); transform: skew(0.31deg); }
  100% { clip: rect(8px, 9999px, 49px, 0); transform: skew(0.36deg); opacity: 1;}
}

@keyframes noise-2 {
    0% { clip: rect(83px, 9999px, 32px, 0); transform: skew(0.31deg); opacity: 1;}
    5% { clip: rect(18px, 9999px, 51px, 0); transform: skew(0.7deg); }
    10% { clip: rect(84px, 9999px, 93px, 0); transform: skew(0.77deg); }
    15% { clip: rect(4px, 9999px, 22px, 0); transform: skew(0.2deg); }
    20% { clip: rect(29px, 9999px, 8px, 0); transform: skew(0.48deg); opacity: 1;}
    25% { clip: rect(23px, 9999px, 80px, 0); transform: skew(0.65deg); }
    30% { clip: rect(2px, 9999px, 72px, 0); transform: skew(0.43deg); }
    35% { clip: rect(39px, 9999px, 50px, 0); transform: skew(0.79deg); }
    40% { clip: rect(81px, 9999px, 50px, 0); transform: skew(0.63deg); opacity: 1;}
    45% { clip: rect(4px, 9999px, 50px, 0); transform: skew(0.12deg); }
    50% { clip: rect(31px, 9999px, 88px, 0); transform: skew(0.52deg); }
    55% { clip: rect(74px, 9999px, 7px, 0); transform: skew(0.88deg); }
    60% { clip: rect(13px, 9999px, 4px, 0); transform: skew(0.53deg); opacity: 1;}
    65% { clip: rect(2px, 9999px, 75px, 0); transform: skew(0.11deg); }
    70% { clip: rect(50px, 9999px, 2px, 0); transform: skew(0.8deg); }
    75% { clip: rect(81px, 9999px, 53px, 0); transform: skew(0.24deg); }
    80% { clip: rect(1px, 9999px, 72px, 0); transform: skew(0.3deg); opacity: 1;}
    85% { clip: rect(24px, 9999px, 33px, 0); transform: skew(0.73deg); }
    90% { clip: rect(30px, 9999px, 58px, 0); transform: skew(0.45deg); }
    95% { clip: rect(84px, 9999px, 28px, 0); transform: skew(0.68deg); }
    100% { clip: rect(4px, 9999px, 72px, 0); transform: skew(0.97deg); opacity: 1;}
}

@keyframes noise-3 {
  0%,3%,5%,42%,44%,100% {opacity: 1; transform: scaleY(1);}
  4.3% {opacity: 1; transform: scaleY(1.5);} /* Toned down from 4 */
  43% {opacity: 1; transform: scaleX(1.5);} /* Toned down from 10 and removed rotate */
}

/* Share widget mobile overrides */
@media (max-width: 991px) {
    main {
        /* Add padding to prevent last elements from being hidden by the fixed bar */
        padding-bottom: 90px;
    }
    #share-widget {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 100;
        
        /* Restyle from a card to a bar */
        background-color: var(--color-gray-dark);
        border: none;
        border-top: 2px solid var(--color-accent);
        border-radius: 0;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.4);
        
        /* Adjust inner layout */
        padding: 0.75rem 1rem;
    }

    #share-widget h3 {
       display: none;
    }
    
    #share-widget .share-buttons {
        padding: 0;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    #share-widget .share-buttons button {
        flex-grow: 1;
        max-width: 400px;
    }
}

/* ---
VHS Glitch Effect for Entity Portraits
--- */
.portrait-vhs-container {
    position: relative;
    width: 100%;
    height: auto;
    overflow: hidden;
}

.portrait-vhs-container img {
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    filter: brightness(1.1) contrast(1.05) saturate(1.1);
    will-change: transform, filter;
    animation: vhs-subtle-drift 6s linear infinite;
}

/* Scanlines overlay */
.portrait-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        transparent 50%,
        rgba(0, 0, 0, 0.15) 50%
    );
    background-size: 100% 3px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
    animation: vhs-scanlines-drift 7s linear infinite;
}

/* Static noise overlay for intense glitches */
.portrait-static {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0.1) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px
        );
    will-change: opacity;
}

/* VHS tracking issues - horizontal lines that occasionally appear */
.portrait-tracking {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 6;
    opacity: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 8px,
        rgba(255, 255, 255, 0.1) 8px,
        rgba(255, 255, 255, 0.1) 10px,
        transparent 10px,
        transparent 25px,
        rgba(0, 0, 0, 0.2) 25px,
        rgba(0, 0, 0, 0.2) 27px
    );
    animation: vhs-tracking-drift 16s linear infinite;
    will-change: opacity, transform;
}

/* Vignette effect */
.portrait-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.2) 100%
    );
    pointer-events: none;
    z-index: 2;
    animation: vhs-vignette-pulse 11s ease-in-out infinite;
}

/* RGB separation glitch effect */
.portrait-glitch-red,
.portrait-glitch-blue {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Subtle continuous glitch layers */
.portrait-glitch-red {
    animation: vhs-subtle-red-drift 9s linear infinite;
}

.portrait-glitch-blue {
    animation: vhs-subtle-blue-drift 13s linear infinite;
}

.portrait-glitch-red {
    z-index: 3;
    mix-blend-mode: screen;
    filter: sepia(1) hue-rotate(320deg) saturate(3);
}

.portrait-glitch-blue {
    z-index: 4;
    mix-blend-mode: screen;
    filter: sepia(1) hue-rotate(180deg) saturate(3);
}

/* Dynamic continuous VHS effects */
@keyframes vhs-subtle-drift {
    0% {
        transform: translateX(0) translateY(0) scaleY(1);
        filter: brightness(1.1) contrast(1.05) saturate(1.1) hue-rotate(0deg);
    }
    8% {
        transform: translateX(1px) translateY(-0.5px) scaleY(0.998);
        filter: brightness(1.15) contrast(1.1) saturate(0.95) hue-rotate(1deg);
    }
    15% {
        transform: translateX(-0.8px) translateY(0.3px) scaleY(1.002);
        filter: brightness(1.05) contrast(1.15) saturate(1.2) hue-rotate(-1deg);
    }
    23% {
        transform: translateX(0.5px) translateY(-0.2px) scaleY(0.999);
        filter: brightness(1.2) contrast(0.95) saturate(1.05) hue-rotate(2deg);
    }
    31% {
        transform: translateX(-1.2px) translateY(0.7px) scaleY(1.001);
        filter: brightness(0.95) contrast(1.2) saturate(1.15) hue-rotate(-0.5deg);
    }
    42% {
        transform: translateX(0.3px) translateY(-0.4px) scaleY(0.997);
        filter: brightness(1.18) contrast(1.08) saturate(0.9) hue-rotate(1.5deg);
    }
    54% {
        transform: translateX(-0.6px) translateY(0.1px) scaleY(1.003);
        filter: brightness(1.02) contrast(1.18) saturate(1.25) hue-rotate(-2deg);
    }
    67% {
        transform: translateX(0.9px) translateY(-0.6px) scaleY(0.998);
        filter: brightness(1.22) contrast(0.9) saturate(1.1) hue-rotate(0.8deg);
    }
    78% {
        transform: translateX(-0.4px) translateY(0.5px) scaleY(1.001);
        filter: brightness(0.98) contrast(1.22) saturate(1.18) hue-rotate(-1.2deg);
    }
    89% {
        transform: translateX(0.7px) translateY(-0.1px) scaleY(0.999);
        filter: brightness(1.16) contrast(1.06) saturate(0.98) hue-rotate(0.5deg);
    }
    100% {
        transform: translateX(0) translateY(0) scaleY(1);
        filter: brightness(1.1) contrast(1.05) saturate(1.1) hue-rotate(0deg);
    }
}

@keyframes vhs-scanlines-drift {
    0% {
        transform: translateY(0) scaleX(1);
        opacity: 0.4;
        background-size: 100% 3px;
    }
    12% {
        transform: translateY(0.5px) scaleX(1.001);
        opacity: 0.5;
        background-size: 100% 2.8px;
    }
    25% {
        transform: translateY(-0.3px) scaleX(0.999);
        opacity: 0.3;
        background-size: 100% 3.2px;
    }
    38% {
        transform: translateY(0.8px) scaleX(1.002);
        opacity: 0.6;
        background-size: 100% 2.5px;
    }
    50% {
        transform: translateY(-0.2px) scaleX(0.998);
        opacity: 0.35;
        background-size: 100% 3.5px;
    }
    63% {
        transform: translateY(0.4px) scaleX(1.001);
        opacity: 0.45;
        background-size: 100% 2.9px;
    }
    75% {
        transform: translateY(-0.6px) scaleX(0.999);
        opacity: 0.25;
        background-size: 100% 3.3px;
    }
    88% {
        transform: translateY(0.1px) scaleX(1.002);
        opacity: 0.55;
        background-size: 100% 2.7px;
    }
    100% {
        transform: translateY(0) scaleX(1);
        opacity: 0.4;
        background-size: 100% 3px;
    }
}

@keyframes vhs-subtle-red-drift {
    0% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
    7% {
        opacity: 0.15;
        transform: translateX(-1.5px) scaleY(0.998);
    }
    14% {
        opacity: 0.05;
        transform: translateX(-0.3px) scaleY(1.001);
    }
    22% {
        opacity: 0.2;
        transform: translateX(-2px) scaleY(0.997);
    }
    29% {
        opacity: 0.08;
        transform: translateX(-0.7px) scaleY(1.002);
    }
    37% {
        opacity: 0.18;
        transform: translateX(-1.8px) scaleY(0.999);
    }
    45% {
        opacity: 0.03;
        transform: translateX(-0.1px) scaleY(1.001);
    }
    53% {
        opacity: 0.22;
        transform: translateX(-2.2px) scaleY(0.996);
    }
    61% {
        opacity: 0.1;
        transform: translateX(-0.9px) scaleY(1.003);
    }
    69% {
        opacity: 0.16;
        transform: translateX(-1.6px) scaleY(0.998);
    }
    77% {
        opacity: 0.06;
        transform: translateX(-0.4px) scaleY(1.001);
    }
    85% {
        opacity: 0.19;
        transform: translateX(-1.9px) scaleY(0.997);
    }
    93% {
        opacity: 0.09;
        transform: translateX(-0.6px) scaleY(1.002);
    }
    100% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
}

@keyframes vhs-subtle-blue-drift {
    0% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
    9% {
        opacity: 0.12;
        transform: translateX(1.3px) scaleY(1.001);
    }
    18% {
        opacity: 0.04;
        transform: translateX(0.2px) scaleY(0.999);
    }
    27% {
        opacity: 0.17;
        transform: translateX(1.7px) scaleY(1.002);
    }
    36% {
        opacity: 0.07;
        transform: translateX(0.5px) scaleY(0.998);
    }
    45% {
        opacity: 0.14;
        transform: translateX(1.4px) scaleY(1.001);
    }
    54% {
        opacity: 0.02;
        transform: translateX(0.1px) scaleY(0.999);
    }
    63% {
        opacity: 0.19;
        transform: translateX(1.9px) scaleY(1.003);
    }
    72% {
        opacity: 0.09;
        transform: translateX(0.7px) scaleY(0.997);
    }
    81% {
        opacity: 0.15;
        transform: translateX(1.5px) scaleY(1.002);
    }
    90% {
        opacity: 0.05;
        transform: translateX(0.3px) scaleY(0.999);
    }
    100% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
}

@keyframes vhs-vignette-pulse {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    15% {
        opacity: 0.9;
        transform: scale(1.008) rotate(0.1deg);
    }
    30% {
        opacity: 0.75;
        transform: scale(1.015) rotate(-0.05deg);
    }
    45% {
        opacity: 0.95;
        transform: scale(1.005) rotate(0.08deg);
    }
    60% {
        opacity: 0.8;
        transform: scale(1.012) rotate(-0.03deg);
    }
    75% {
        opacity: 0.88;
        transform: scale(1.007) rotate(0.06deg);
    }
    90% {
        opacity: 0.92;
        transform: scale(1.003) rotate(-0.02deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes vhs-tracking-drift {
    0%, 85%, 100% {
        opacity: 0;
        transform: translateY(0) scaleY(1);
    }
    5% {
        opacity: 0.3;
        transform: translateY(-2px) scaleY(0.95);
    }
    8% {
        opacity: 0.6;
        transform: translateY(-1px) scaleY(0.98);
    }
    12% {
        opacity: 0.2;
        transform: translateY(1px) scaleY(1.02);
    }
    15% {
        opacity: 0;
        transform: translateY(0) scaleY(1);
    }
    45% {
        opacity: 0.4;
        transform: translateY(1px) scaleY(0.97);
    }
    48% {
        opacity: 0.7;
        transform: translateY(-0.5px) scaleY(1.01);
    }
    52% {
        opacity: 0.1;
        transform: translateY(0.5px) scaleY(0.99);
    }
    55% {
        opacity: 0;
        transform: translateY(0) scaleY(1);
    }
}

/* Glitch animation keyframes */
@keyframes vhs-glitch-red {
    0%, 85%, 100% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
    5% {
        opacity: 0.7;
        transform: translateX(-4px) scaleY(0.95);
    }
    15% {
        opacity: 0.5;
        transform: translateX(-2px) scaleY(1.02) skewX(1deg);
    }
    25% {
        opacity: 0.8;
        transform: translateX(-6px) scaleY(0.98);
    }
    35% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
}

@keyframes vhs-glitch-blue {
    0%, 85%, 100% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
    10% {
        opacity: 0.6;
        transform: translateX(3px) scaleY(1.03);
    }
    20% {
        opacity: 0.4;
        transform: translateX(5px) scaleY(0.97) skewX(-0.5deg);
    }
    30% {
        opacity: 0.7;
        transform: translateX(2px) scaleY(1.01);
    }
    40% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
}

@keyframes vhs-image-glitch {
    0%, 85%, 100% {
        transform: translateX(0) scaleY(1);
        filter: brightness(1.1) contrast(1.05) saturate(1.1);
    }
    5% {
        transform: translateX(1px) scaleY(0.98);
        filter: brightness(1.4) contrast(1.3) saturate(0.7);
    }
    15% {
        transform: translateX(-2px) scaleY(1.02) skewX(-0.8deg);
        filter: brightness(0.8) contrast(1.4) saturate(1.5);
    }
    25% {
        transform: translateX(2px) scaleY(0.99) skewX(0.5deg);
        filter: brightness(1.3) contrast(0.8) saturate(1.2);
    }
    35% {
        transform: translateX(-1px) scaleY(1.01);
        filter: brightness(1.1) contrast(1.1) saturate(1.0);
    }
}

@keyframes vhs-static-lines {
    0%, 85%, 100% {
        opacity: 0.4;
    }
    10%, 30% {
        opacity: 1;
    }
}

@keyframes vhs-static-noise {
    0%, 85%, 100% {
        opacity: 0;
    }
    5%, 15%, 25%, 35% {
        opacity: 0.6;
    }
    8%, 18%, 28%, 38% {
        opacity: 0.3;
    }
}

/* Apply glitch animation with random delays - these override the subtle animations */
.portrait-vhs-container.glitching .portrait-glitch-red {
    animation: vhs-glitch-red 1200ms ease-out !important;
}

.portrait-vhs-container.glitching .portrait-glitch-blue {
    animation: vhs-glitch-blue 1200ms ease-out !important;
}

.portrait-vhs-container.glitching img {
    animation: vhs-image-glitch 1200ms ease-out !important;
}

.portrait-vhs-container.glitching .portrait-scanlines {
    animation: vhs-static-lines 1200ms ease-out;
}

.portrait-vhs-container.glitching .portrait-static {
    animation: vhs-static-noise 1200ms ease-out;
}

/* Micro-glitch effects - quick, subtle disruptions */
.portrait-vhs-container.micro-glitching img {
    animation: vhs-micro-glitch 300ms ease-out !important;
}

.portrait-vhs-container.micro-glitching .portrait-glitch-red {
    animation: vhs-micro-red 300ms ease-out !important;
}

.portrait-vhs-container.micro-glitching .portrait-glitch-blue {
    animation: vhs-micro-blue 300ms ease-out !important;
}

.portrait-vhs-container.micro-glitching .portrait-scanlines {
    animation: vhs-micro-scanlines 300ms ease-out !important;
}

/* Micro-glitch keyframes */
@keyframes vhs-micro-glitch {
    0%, 70%, 100% {
        transform: translateX(0) scaleY(1);
        filter: brightness(1.1) contrast(1.05) saturate(1.1) hue-rotate(0deg);
    }
    10% {
        transform: translateX(0.5px) scaleY(0.999);
        filter: brightness(1.2) contrast(1.15) saturate(0.9) hue-rotate(1deg);
    }
    30% {
        transform: translateX(-0.3px) scaleY(1.001);
        filter: brightness(0.95) contrast(1.2) saturate(1.3) hue-rotate(-0.5deg);
    }
    50% {
        transform: translateX(0.2px) scaleY(0.998);
        filter: brightness(1.15) contrast(0.9) saturate(1.1) hue-rotate(0.8deg);
    }
}

@keyframes vhs-micro-red {
    0%, 70%, 100% {
        opacity: 0;
        transform: translateX(0);
    }
    20% {
        opacity: 0.15;
        transform: translateX(-1px);
    }
    40% {
        opacity: 0.08;
        transform: translateX(-0.5px);
    }
}

@keyframes vhs-micro-blue {
    0%, 70%, 100% {
        opacity: 0;
        transform: translateX(0);
    }
    15% {
        opacity: 0.12;
        transform: translateX(0.8px);
    }
    35% {
        opacity: 0.06;
        transform: translateX(0.4px);
    }
}

@keyframes vhs-micro-scanlines {
    0%, 70%, 100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    25% {
        opacity: 0.7;
        transform: translateY(0.5px);
    }
    50% {
        opacity: 0.2;
        transform: translateY(-0.3px);
    }
}

/* Mobile optimization - reduce effects on smaller screens */
@media (max-width: 768px) {
    .portrait-scanlines {
        opacity: 0.25;
        background-size: 100% 4px;
    }
    
    .portrait-vignette {
        opacity: 0.8;
    }
    
    .portrait-glitch-red,
    .portrait-glitch-blue {
        opacity: 0.3;
    }
    
    /* Reduce subtle animation intensity on mobile */
    .portrait-vhs-container img {
        animation: vhs-subtle-drift-mobile 10s ease-in-out infinite;
    }
    
    .portrait-glitch-red {
        animation: vhs-subtle-red-drift-mobile 18s ease-in-out infinite;
    }
    
    .portrait-glitch-blue {
        animation: vhs-subtle-blue-drift-mobile 22s ease-in-out infinite;
    }
}

/* Mobile-specific subtle animations (less intense) */
@keyframes vhs-subtle-drift-mobile {
    0%, 100% {
        transform: translateX(0) translateY(0);
        filter: brightness(1.08) contrast(1.03) saturate(1.05);
    }
    50% {
        transform: translateX(0.2px) translateY(0.1px);
        filter: brightness(1.1) contrast(1.05) saturate(1.08);
    }
}

@keyframes vhs-subtle-red-drift-mobile {
    0%, 100% {
        opacity: 0;
        transform: translateX(0);
    }
    50% {
        opacity: 0.05;
        transform: translateX(-0.5px);
    }
}

@keyframes vhs-subtle-blue-drift-mobile {
    0%, 100% {
        opacity: 0;
        transform: translateX(0);
    }
    50% {
        opacity: 0.04;
        transform: translateX(0.4px);
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .portrait-vhs-container img,
    .portrait-glitch-red,
    .portrait-glitch-blue,
    .portrait-scanlines,
    .portrait-vignette {
        animation: none !important;
        will-change: auto;
    }
    
    .portrait-scanlines {
        opacity: 0.2;
    }
    
    .portrait-vignette {
        opacity: 0.9;
    }
} 
