:root {
    /* Deep Twilight Palette from krzak.org */
    --bg-gradient-1: #1a103c;
    --bg-gradient-2: #4a2c4e;
    --bg-gradient-3: #8b4789;
    --bg-gradient-4: #f4a261;

    /* Glass Effect Variables */
    --container-bg: rgba(30, 20, 60, 0.65);
    --container-border: rgba(255, 255, 255, 0.1);
    --container-highlight: rgba(255, 255, 255, 0.05);

    /* Text & Accents */
    --text-color: #fff0e0;
    --text-muted: #d0c0e0;
    --accent-color: #f4a261;
    --accent-glow: rgba(244, 162, 97, 0.5);

    /* Link Styles */
    --link-bg: rgba(255, 255, 255, 0.05);
    --link-hover-bg: rgba(255, 255, 255, 0.1);
    --link-border: rgba(255, 255, 255, 0.08);
    --link-hover-border: rgba(244, 162, 97, 0.5);
}

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

html {
    scroll-behavior: smooth;
    background-color: var(--bg-gradient-1);
}

body {
    background: linear-gradient(
        -45deg,
        var(--bg-gradient-1),
        var(--bg-gradient-2),
        var(--bg-gradient-3),
        var(--bg-gradient-4)
    );
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
    color: var(--text-color);
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.5;
}

img[src=""] {
  display: none;
}

/* Home View */
.view-home {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.view-home .container {
    background: var(--container-bg);
    border-radius: 24px;
    padding: 32px;
    border: 1px solid var(--container-border);
    border-top: 1px solid var(--container-highlight);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 700px;
    margin: auto;
    box-shadow:
        0 8px 32px 0 rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.view-home .hero-logo {
    margin: 0 0 32px 0;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--text-color);
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.view-home .hero-logo a {
    color: inherit;
    text-decoration: none;
}

.view-home .hero-logo span {
    color: var(--accent-color);
    text-shadow: 0 0 15px var(--accent-glow);
}

.view-home .search-input-wrapper {
    width: 100%;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
}

/* Search Box Styling */
.search-box {
    flex-grow: 1;
    padding: 16px 28px;
    border-radius: 99px;
    border: 1px solid var(--container-border);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    outline: none;
    font-size: 1.1rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.search-box::placeholder {
    color: rgba(255, 240, 224, 0.6);
}

.search-box:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 20px var(--accent-glow);
}

.view-home .btn-search {
    width: 56px;
    height: 56px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--accent-color);
    color: #1a103c;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(244, 162, 97, 0.3);
    transition: all 0.3s ease;
}

.view-home .btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
    filter: brightness(1.1);
}

.view-home .btn-search svg {
    width: 24px;
    height: 24px;
}

.view-home .buttons {
    display: none;
}

.view-home button, .overlay-btn, .pagination-btn {
    padding: 12px 28px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid transparent;
    touch-action: manipulation;
    text-decoration: none;
    display: inline-block;
}

.btn-primary, .overlay-btn.primary {
    background: var(--accent-color);
    color: #1a103c;
    box-shadow: 0 4px 15px rgba(244, 162, 97, 0.3);
}

.btn-primary:hover, .overlay-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
    filter: brightness(1.1);
}

.btn-secondary, .overlay-btn.secondary, .pagination-btn {
    background: var(--link-bg);
    color: var(--text-color);
    border: 1px solid var(--link-border);
    backdrop-filter: blur(4px);
}

.btn-secondary:hover, .overlay-btn.secondary:hover, .pagination-btn:hover {
    background: var(--link-hover-bg);
    border-color: var(--link-hover-border);
    transform: translateY(-2px);
}

/* Results View Header */
header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 60px;
    border-bottom: 1px solid var(--container-border);
    background: rgba(30, 20, 60, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.8rem;
    margin: 0;
    letter-spacing: -0.02em;
    font-weight: 800;
    white-space: nowrap;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

header h1 span {
    color: var(--accent-color);
}

.search-form {
    flex-grow: 1;
    max-width: 600px;
    display: flex;
    gap: 10px;
}

.search-form .search-box {
    padding: 12px 24px;
    font-size: 1rem;
}

.search-form .btn-search {
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--accent-color);
    color: #1a103c;
    border: none;
    cursor: pointer;
}

.search-form .btn-search svg {
    width: 20px;
    height: 20px;
}

/* Navigation Tabs */
.nav-tabs {
    padding: 0 60px;
    border-bottom: 1px solid var(--container-border);
    background: rgba(30, 20, 60, 0.2);
    backdrop-filter: blur(8px);
}

.nav-container {
    display: flex;
    gap: 32px;
    max-width: 1200px;
}

.nav-tabs a {
    padding: 16px 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.nav-tabs a:hover {
    color: var(--text-color);
}

.nav-tabs a.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-glow);
}

/* Results Layout */
.content-layout {
    display: grid;
    grid-template-columns: 140px minmax(0, 700px) 450px;
    gap: 60px;
    padding: 40px 60px;
    position: relative;
    z-index: 1;
}

.results-container {
    grid-column: 2;
}

.result {
    margin-bottom: 40px;
    animation: fadeIn 0.6s ease-out forwards;
}

.result a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 6px;
    transition: all 0.2s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.result a:hover {
    text-decoration: underline;
    text-shadow: 0 0 15px var(--accent-glow);
}

.url {
    color: #ffffff;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 6px;
    opacity: 1;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.desc {
    color: #f0f0f0;
    line-height: 1.7;
    margin: 0;
    font-size: 1.05rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Infobox Styling */
.infobox {
    grid-column: 3;
    background: var(--container-bg);
    border: 1px solid var(--container-border);
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    align-self: start;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.infobox-header {
    padding: 24px;
    border-bottom: 1px solid var(--container-border);
}

.infobox-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    color: var(--accent-color);
}

.infobox-main {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.infobox-image {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
    border-bottom: 1px solid var(--container-border);
}

.infobox-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.infobox-summary {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0;
}

.read-more {
    color: var(--accent-color);
    font-weight: 700;
    text-decoration: none;
    font-size: 0.95rem;
}

.read-more:hover {
    text-decoration: underline;
}

/* Image Results */
.image-results-container {
    padding: 40px 60px;
    position: relative;
    z-index: 1;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.image-card {
    background: var(--container-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--container-border);
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.image-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent-color);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.image-wrapper {
    position: relative;
    aspect-ratio: 4/3;
    background: #000;
    overflow: hidden;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.image-card:hover .image-wrapper img {
    transform: scale(1.05);
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(30, 20, 60, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-card:hover .image-overlay {
    opacity: 1;
}

.overlay-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 80%;
}

.image-info {
    padding: 16px;
}

.image-caption {
    display: block;
    font-size: 0.9rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-weight: 600;
}

.image-source {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 60px;
    padding-bottom: 60px;
}

.pagination-current {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
}

/* Animations from krzak.org */
@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .content-layout {
        grid-template-columns: 1fr;
        padding: 30px;
        gap: 30px;
    }
    .results-container, .infobox-sidebar {
        grid-column: 1;
        max-width: 100%;
    }
    .infobox-sidebar {
        order: -1;
    }
    header, .nav-tabs, .image-results-container {
        padding-left: 30px;
        padding-right: 30px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 16px;
        padding: 20px 16px;
        text-align: center;
    }
    header h1 {
        font-size: 1.5rem;
    }
    .search-form {
        width: 100%;
    }
    .nav-tabs {
        padding: 0 16px;
        overflow-x: auto;
    }
    .nav-container {
        gap: 24px;
    }
    .content-layout {
        padding: 24px 16px;
    }
    .view-home .hero-logo {
        font-size: 3.5rem;
    }
    .view-home .container {
        padding: 24px 16px;
    }
}

@media (max-width: 480px) {
    .view-home .buttons {
        flex-direction: column;
    }
    .view-home button {
        width: 100%;
    }
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
}
