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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e0f2f7 0%, #fff9e6 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
}

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

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

header {
    background: linear-gradient(135deg, #4A90A4 0%, #5FA8BE 100%);
    padding: 1rem 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.logo img {
    display: block;
    height: 150px;
    width: auto;
}

/* ── Search bar ──────────────────────────────────────────────────── */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 220px;
    max-width: 340px;
}

.header-search input[type="search"] {
    width: 100%;
    padding: 0.55rem 2.2rem 0.55rem 1rem;
    border: 2px solid rgba(255,255,255,0.45);
    border-radius: 25px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: background 0.25s, border-color 0.25s;
    /* Remove native clear button — we use our own */
    -webkit-appearance: none;
    appearance: none;
}

.header-search input[type="search"]::-webkit-search-cancel-button {
    display: none;
}

.header-search input[type="search"]::placeholder {
    color: rgba(255,255,255,0.75);
}

.header-search input[type="search"]:focus {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.8);
}

.search-clear {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem 0.3rem;
    line-height: 1;
    transition: color 0.2s;
}

.search-clear:hover {
    color: #fff;
}

/* Search notice banner */
.search-notice {
    text-align: center;
    padding: 0.6rem 1.5rem;
    margin-bottom: 1rem;
    background: rgba(74,144,164,0.12);
    border-radius: 8px;
    font-size: 0.92rem;
    color: #3a7a8e;
    font-weight: 500;
}

/* No-results state */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
    color: #6b7f8e;
    font-size: 1rem;
}

/* ── Mix it up! button ───────────────────────────────────────────── */
.mix-btn {
    background: linear-gradient(135deg, #ffd166 0%, #ffc145 100%);
    color: #333;
    border: none;
    padding: 0.65rem 1.35rem;
    border-radius: 25px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

.mix-btn:hover,
.mix-btn:focus {
    background: linear-gradient(135deg, #ffc145 0%, #ffb524 100%);
    transform: translateY(-2px) rotate(-1deg);
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
}

.mix-btn:active {
    transform: translateY(0) rotate(0deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Spin animation triggered by JS */
@keyframes mixSpin {
    0%   { transform: rotate(0deg) scale(1); }
    30%  { transform: rotate(-5deg) scale(1.06); }
    70%  { transform: rotate(4deg) scale(1.04); }
    100% { transform: rotate(0deg) scale(1); }
}
.mix-btn.mixing {
    animation: mixSpin 0.4s ease;
}

/* ── Favorites button styles (kept for backwards compat) ─────────── */
.favorites-button {
    background: linear-gradient(135deg, #ffd166 0%, #ffc145 100%);
    color: #333;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    margin-left: auto;
}

.favorites-button:hover,
.favorites-button:focus {
    background: linear-gradient(135deg, #ffc145 0%, #ffb524 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
}

.favorites-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.favorites-button .star-icon {
    font-size: 1.2rem;
}

/* Success message */
.favorites-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4A90A4 0%, #5FA8BE 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.favorites-message.show {
    display: flex;
}

.favorites-message .checkmark {
    font-size: 1.5rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.hamburger {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    transition: opacity 0.3s;
}

.hamburger:hover,
.hamburger:focus {
    opacity: 0.8;
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 4px;
}

.hamburger span {
    width: 30px;
    height: 3px;
    background: white;
    margin: 4px 0;
    transition: 0.3s;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-6px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(45deg) translate(-6px, -6px);
}

.mobile-menu {
    display: none;
    background: #5FA8BE;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.mobile-menu.active {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mobile-menu a {
    color: white;
    text-decoration: none;
    padding: 0.75rem;
    border-radius: 4px;
    transition: background 0.3s;
}

.mobile-menu a:hover,
.mobile-menu a:focus {
    background: rgba(255,255,255,0.2);
    outline: 2px solid rgba(255,255,255,0.3);
    outline-offset: 2px;
}

main {
    flex: 1;
    padding: 3rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    justify-items: center;
}

.tile {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    max-width: 320px;
    width: 100%;
    cursor: pointer;
}

.tile:hover,
.tile:focus {
    transform: translateY(-8px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    outline: 3px solid #4A90A4;
    outline-offset: 2px;
}

/* Remove outline on mouse click but keep for keyboard */
.tile:focus:not(:focus-visible) {
    outline: none;
}

.tile:focus-visible {
    outline: 3px solid #4A90A4;
    outline-offset: 2px;
}

.tile-image {
    width: 100%;
    max-width: 320px;
    height: 240px;
    object-fit: cover;
    display: block;
}

.tile-image img[src*="cshow.php"] {
    width: 320px !important;
    height: 240px !important;
    background: #e0e0e0;
    object-fit: contain;
}

.tile-content {
    padding: 1.25rem;
}

.tile-content h2 {
    color: #4A90A4;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.tile-content p {
    color: #666;
    line-height: 1.6;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.tile-tag {
    display: inline-block;
    background: #E8F5F7;
    color: #4A90A4;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

/* Highlight matching tag text during search */
.tile-tag mark {
    background: #ffd166;
    color: #333;
    border-radius: 3px;
    padding: 0 2px;
}

/* Link styling for noscript fallback */
.tile-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: #4A90A4;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.3s;
}

.tile-link:hover,
.tile-link:focus {
    background: #5FA8BE;
    outline: 2px solid #4A90A4;
    outline-offset: 2px;
}

footer {
    background: linear-gradient(135deg, #4A90A4 0%, #5FA8BE 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
    padding: 0.25rem 0.5rem;
}

.footer-links a:hover,
.footer-links a:focus {
    opacity: 0.8;
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .tile-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .tile-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .header-search {
        order: 3;
        max-width: 100%;
        flex: 1 1 100%;
    }

    .mix-btn {
        order: 4;
        width: 100%;
        text-align: center;
    }

    .header-container {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .logo {
        order: 1;
    }

    .hamburger {
        order: 2;
    }

    .footer-links.desktop-nav {
        display: none;
    }

    main {
        padding: 2rem 1rem;
    }
}

@media (max-width: 600px) {
    .tile-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    header {
        padding: 1rem 1.5rem;
    }
    
    .tile-content h2 {
        font-size: 1.1rem;
    }
    
    .tile-content p {
        font-size: 0.9rem;
    }
}

/* Print styles for better print output */
@media print {
    header,
    footer,
    .hamburger,
    .mobile-menu,
    .favorites-button,
    .favorites-message,
    .mix-btn,
    .header-search {
        display: none;
    }
    
    .tile {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tile:focus {
        outline-width: 4px;
    }
    
    .favorites-button:focus {
        outline-width: 4px;
    }
}

/* Reduced motion support for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tile:hover {
        transform: none;
    }
    
    .mix-btn:hover,
    .mix-btn:focus {
        transform: none;
    }

    .favorites-button:hover,
    .favorites-button:focus {
        transform: none;
    }
    
    @keyframes slideIn {
        from { transform: none; opacity: 1; }
        to   { transform: none; opacity: 1; }
    }
}
