/* Flanderize - Simpsons Scene Search */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --yellow: #FFC20E;
    --pink: #FF6B9D;
    --blue: #0F4C81;
    --orange: #F47920;
    --teal: #4ECDC4;
    --cream: #FFF8E7;
    --dark: #1a1a2e;
}

/* Fun subtle animations */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-2deg); }
    75% { transform: rotate(2deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

body {
    font-family: 'Arial Black', 'Helvetica Neue', sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: var(--blue);
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(255, 194, 14, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(244, 121, 32, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(255, 107, 157, 0.15) 0%, transparent 40%);
    color: #fff;
    line-height: 1.5;
    min-height: 100vh;
}

/* Landing state */
body:not(.searched) {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

body.searched {
    display: block;
    padding-top: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

body.searched header {
    cursor: pointer;
    display: inline-block;
    margin-bottom: 15px;
    padding: 8px 20px;
    background: rgba(255, 194, 14, 0.15);
    border: 3px solid var(--yellow);
    border-radius: 12px;
}

body.searched header:hover {
    background: rgba(255, 194, 14, 0.25);
}

/* Top row: FLANDERIZE title + About link side by side in searched state */
.top-row {
    display: contents; /* transparent in landing state — children flow normally */
}

body.searched .top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

body.searched .top-row header {
    margin-bottom: 0;
}

.about-link {
    display: none;
}

body.searched .about-link {
    display: block;
    color: rgba(255, 194, 14, 0.7);
    text-decoration: none;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    white-space: nowrap;
}

body.searched .about-link:hover {
    color: var(--yellow);
    text-decoration: underline;
}

h1 {
    font-size: 7rem;
    font-weight: 900;
    letter-spacing: -4px;
    color: var(--yellow);
    text-shadow:
        4px 4px 0 var(--orange),
        8px 8px 0 rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    cursor: default;
    transition: transform 0.2s ease;
}

h1:hover {
    animation: wiggle 0.4s ease-in-out;
}

body.searched h1 {
    font-size: 1.8rem;
    letter-spacing: -1px;
    text-shadow:
        2px 2px 0 var(--orange),
        4px 4px 0 rgba(0, 0, 0, 0.2);
    margin-bottom: 0;
}

.subtitle {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: lowercase;
    letter-spacing: 4px;
}

body.searched .subtitle {
    display: none;
}

/* Search Container */
.search-container {
    width: 100%;
    max-width: 650px;
    margin: 0 auto 20px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 194, 14, 0.4);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 200;
}

body.searched .search-container {
    max-width: 100%;
    padding: 12px 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
}

body.searched .search-box {
    margin-bottom: 10px;
}

input {
    flex: 1;
    padding: 16px 20px;
    font-size: 16px;
    font-family: 'Arial', sans-serif;
    border: 3px solid var(--yellow);
    border-radius: 12px;
    background: #fff;
    color: var(--dark);
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

input:focus {
    border-color: var(--pink);
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4), 0 0 0 4px rgba(255, 107, 157, 0.2);
}

input::placeholder {
    color: #999;
}

button {
    padding: 16px 28px;
    font-size: 14px;
    font-family: 'Arial Black', sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--yellow) 0%, var(--orange) 100%);
    color: var(--dark);
    border: 3px solid var(--orange);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 0 #c45e10, 0 6px 20px rgba(0, 0, 0, 0.3);
}

button:hover {
    background: linear-gradient(135deg, var(--pink) 0%, #ff4777 100%);
    border-color: #d44;
    box-shadow: 0 6px 0 #b33, 0 8px 25px rgba(0, 0, 0, 0.35);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #c45e10, 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* Button Row */
.button-row {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.random-btn {
    background: transparent;
    color: var(--yellow);
    border: 2px dashed rgba(255, 194, 14, 0.6);
    padding: 12px 24px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    text-transform: lowercase;
    box-shadow: none;
    border-radius: 25px;
    transition: all 0.2s ease;
}

.random-btn:hover {
    background: rgba(255, 194, 14, 0.2);
    border-style: solid;
    border-color: var(--yellow);
    box-shadow: 0 4px 20px rgba(255, 194, 14, 0.3);
    transform: scale(1.05);
    animation: wiggle 0.5s ease-in-out;
}

body.searched .button-row {
    display: none;
}

.results-random {
    display: none;
    text-align: center;
    margin: 30px 0;
}

body.searched .results-random {
    display: block;
}

/* Examples */
.examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.example-btn {
    padding: 10px 16px;
    font-size: 12px;
    font-family: 'Arial', sans-serif;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 25px;
    box-shadow: none;
    transition: all 0.2s ease;
}

.example-btn:hover {
    background: var(--yellow);
    color: var(--dark);
    border-color: var(--yellow);
    box-shadow: 0 4px 15px rgba(255, 194, 14, 0.4);
    transform: translateY(-2px);
}

.example-btn:nth-child(1):hover { transform: translateY(-2px) rotate(-2deg); }
.example-btn:nth-child(2):hover { transform: translateY(-3px) rotate(1deg); }
.example-btn:nth-child(3):hover { transform: translateY(-2px) rotate(-1deg); }
.example-btn:nth-child(4):hover { transform: translateY(-3px) rotate(2deg); }
.example-btn:nth-child(5):hover { transform: translateY(-2px) rotate(-1deg); }

body.searched .examples {
    display: none;
}

/* Filters */
.filters {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 15px;
    border: 2px solid rgba(255, 194, 14, 0.3);
    border-radius: 12px;
    margin-bottom: 12px;
}

.filters-title {
    font-size: 10px;
    font-family: 'Courier New', monospace;
    color: var(--yellow);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.filter-group {
    margin-bottom: 8px;
}

.filter-label {
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
    display: block;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-pill {
    padding: 6px 14px;
    font-size: 11px;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: none;
}

.filter-pill:hover {
    background: rgba(255, 194, 14, 0.3);
    border-color: var(--yellow);
}

.filter-pill.active {
    background: var(--yellow);
    color: var(--dark);
    border-color: var(--orange);
}

body:not(.searched) .filters {
    display: none;
}

body.searched .filters {
    padding: 10px;
}

body.searched .filters-title {
    display: none;
}

body.searched .filter-group {
    margin-bottom: 0;
}

body.searched .filter-label {
    display: inline;
    margin-right: 8px;
}

body.searched .filter-pills {
    display: inline-flex;
}

/* Active Filters */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 15px;
    border: 2px solid #c45e10;
}

.active-filter-tag button {
    background: none;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    width: 14px;
    height: 14px;
    box-shadow: none;
    border-radius: 0;
}

.active-filter-tag button:hover {
    transform: none;
    box-shadow: none;
}

/* Stats */
.stats {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 15px;
}

body.searched .stats {
    display: none;
}

/* Results Grid */
#results {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

@media (max-width: 1000px) {
    #results { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    #results { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
    #results { grid-template-columns: 1fr; }
}

/* Result Card */
.result {
    position: relative;
    background: var(--cream);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 4px 0 var(--orange),
        0 8px 20px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--yellow);
    contain: paint;
}

.result:hover {
    transform: translateY(-5px) rotate(-1deg);
    box-shadow:
        0 8px 0 var(--orange),
        0 15px 35px rgba(0, 0, 0, 0.4);
}

.result:nth-child(even):hover {
    transform: translateY(-5px) rotate(1deg);
}

.result img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.result img.loaded {
    opacity: 1;
}

.result-info {
    padding: 10px 12px;
    background: #fff;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.episode {
    font-size: 11px;
    font-weight: bold;
    color: var(--blue);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.time {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #999;
}

.result-buttons {
    display: none;
}

/* Delete & Checkbox */
.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--pink);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    user-select: none;
}

.result:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background: #ff4757;
}

.frame-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    z-index: 10;
    accent-color: var(--orange);
    opacity: 0;
    transition: opacity 0.15s;
}

.result:hover .frame-checkbox,
.frame-checkbox:checked {
    opacity: 1;
}

/* Similar Header */
.similar-header {
    grid-column: 1 / -1;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 194, 14, 0.4);
    border-radius: 12px;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.similar-header span {
    color: var(--yellow);
}

.back-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    font-size: 12px;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
}

.back-btn:hover {
    background: var(--yellow);
    color: var(--dark);
    border-color: var(--yellow);
    box-shadow: 0 3px 12px rgba(255, 194, 14, 0.3);
    transform: translateX(-3px);
}

/* Select FAB - visible after search */
.select-fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--yellow);
    color: var(--dark);
    border: none;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: bold;
    font-family: inherit;
    border-radius: 24px;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: background 0.15s, transform 0.15s;
}

.select-fab:hover {
    background: var(--orange);
    transform: scale(1.05);
}

body.searched .select-fab {
    display: block;
}

body.select-mode .select-fab {
    display: none;
}

/* Bulk Actions */
.bulk-actions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: #fff;
    padding: 12px 20px;
    border: 3px solid var(--yellow);
    border-radius: 30px;
    display: none;
    align-items: center;
    gap: 12px;
    font-weight: bold;
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

body.select-mode .bulk-actions {
    display: flex;
}

.bulk-delete-btn {
    background: var(--pink);
    color: #fff;
    border: none;
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 15px;
    box-shadow: none;
}

.bulk-delete-btn:hover {
    background: #ff4757;
    transform: none;
    box-shadow: none;
}

.bulk-clear-btn {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 8px 12px;
    font-size: 12px;
    box-shadow: none;
}

.bulk-clear-btn:hover {
    color: #fff;
    transform: none;
    box-shadow: none;
}

.bulk-done-btn {
    background: var(--yellow);
    color: var(--dark);
    border: none;
    padding: 8px 16px;
    font-size: 12px;
    font-family: inherit;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: none;
}

.bulk-done-btn:hover {
    background: var(--orange);
    transform: none;
    box-shadow: none;
}

/* Select mode styles */
body.select-mode .result {
    cursor: pointer;
}

body.select-mode .result::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
    z-index: 5;
}

body.select-mode .result.selected::after {
    content: '\2713';
    background: var(--pink);
    border-color: var(--pink);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result.selected {
    border-color: var(--pink);
    box-shadow: 0 0 0 3px var(--pink), 0 4px 0 #c44, 0 8px 20px rgba(255, 107, 157, 0.4);
}

.result.selected .frame-checkbox {
    opacity: 1;
}

/* Loading & Error States */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    font-family: 'Arial Black', sans-serif;
    font-size: 18px;
    color: var(--yellow);
    padding: 80px 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

.error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    background: rgba(255, 107, 157, 0.2);
    border: 3px solid var(--pink);
    border-radius: 15px;
    max-width: 500px;
    margin: 20px auto;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, 0.9);
}

.empty-state-icon {
    font-size: 72px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.reaction-img {
    width: 200px;
    height: auto;
    border-radius: 12px;
    border: 3px solid var(--yellow);
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--yellow);
}

.empty-state p {
    font-family: 'Courier New', monospace;
    opacity: 0.7;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 76, 129, 0.97);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    border: 4px solid var(--yellow);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: -16px;
    right: -16px;
    background: #dc3545;
    color: #fff;
    border: 2px solid #a71d2a;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s, transform 0.15s;
}

.modal-close:hover {
    background: #bb2d3b;
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}

.modal-info {
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 100%);
    padding: 15px 20px;
    border-radius: 0 0 12px 12px;
    margin-top: -8px;
}

.modal-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-episode {
    color: var(--yellow);
    font-weight: bold;
    font-size: 15px;
}

.modal-time {
    color: #fff;
    font-family: 'Courier New', monospace;
}

.modal-path {
    color: #999;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    margin-bottom: 10px;
    word-break: break-all;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    padding: 10px 18px;
    font-size: 12px;
    background: linear-gradient(135deg, var(--yellow) 0%, var(--orange) 100%);
    color: var(--dark);
    border: 2px solid var(--orange);
    border-radius: 8px;
    box-shadow: 0 3px 0 #c45e10;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #c45e10;
}

.modal-delete {
    background: #dc3545;
    color: #fff;
    border-color: #a71d2a;
    box-shadow: 0 3px 0 #a71d2a;
}

.modal-delete:hover {
    background: #bb2d3b;
    box-shadow: 0 5px 0 #a71d2a;
}

.modal-nav {
    background: transparent;
    color: var(--yellow);
    border: 2px solid var(--yellow);
    box-shadow: none;
}

.modal-nav:hover {
    background: rgba(255, 194, 14, 0.2);
    box-shadow: none;
}

/* Search History Dropdown */
.search-history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 80px;
    background: #fff;
    border: 3px solid var(--yellow);
    border-top: none;
    border-radius: 0 0 12px 12px;
    z-index: 100;
    display: none;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.search-history-dropdown.visible {
    display: block;
}

.history-item {
    padding: 12px 16px;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    color: var(--dark);
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.history-item:hover {
    background: var(--yellow);
}

.history-item:last-child {
    border-bottom: none;
    border-radius: 0 0 10px 10px;
}

/* Footer */
.disclaimer {
    margin-top: 50px;
    padding: 25px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(255, 194, 14, 0.2);
}

body:not(.searched) .disclaimer {
    display: none;
}

.disclaimer .keyboard-hint {
    margin-bottom: 15px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.disclaimer .keyboard-hint kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
}

.disclaimer p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.disclaimer-links a {
    color: var(--yellow);
    text-decoration: none;
    opacity: 0.8;
}

.disclaimer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 4rem;
    }

    body.searched h1 {
        font-size: 1.5rem;
    }

    .search-box {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .search-container {
        padding: 20px 15px;
    }
}

/* Hidden utilities */
.caption, .characters, .character-count, .expand-btn, .mode-btn, .results-mode-toggle, .caption-overlay {
    display: none;
}
