/*  Accessibility
----------------------------------------------------- */

/* 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;
}

/* Skip navigation link — visible on focus for keyboard users */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 12px 24px;
    background: #000;
    color: #fff;
    text-decoration: underline;
    border-radius: 0 0 4px 4px;
    font-size: 16px;
}

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

/* Focus styles for keyboard navigation */
a:focus-visible,
input:focus-visible,
button:focus-visible {
    outline: 2px solid var(--text-tertiary, rgba(255, 255, 255, 0.7));
    outline-offset: 2px;
    border-radius: 2px;
}

/* Remove default outline for mouse clicks but keep for keyboard */
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/*  Base Components
----------------------------------------------------- */
* {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    background: inherit;
}

body {
    background: #000;
    font-family: "Karla", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 18px;
    line-height: 30px;
    color: #fff;
    text-align: center;
    width: 100%;
    min-height: 100%;
    font-weight: 400;
    display: flex;
    flex-direction: column;
}

h1 {
    font-family: "Lobster", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 28px;
    line-height: 36px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.8));
    transition: color 0.2s ease-out;
}

h1:hover {
    color: #fff;
}

h2 {
    margin-top: 10px;
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    color: var(--text-tertiary, rgba(255, 255, 255, 0.7));
}

@media screen and (max-width: 480px) {
    /* Compact header on mobile to de-emphasize and let content shine */

    h1 {
        font-size: 24px;
        line-height: 30px;
    }

    h2 {
        margin-top: 5px;
        font-size: 14px;
        line-height: 20px;
    }
}

a,
a:hover {
    color: #fff;
    text-decoration: underline;
}

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

h2 a {
    font-weight: 700;
}

p {
    color: var(--text-primary, rgba(255, 255, 255, 0.9));
    font-size: 16px;
    line-height: 25px;
    font-weight: 400;
    text-align: center;
}

hr {
    background: #fff;
    background: var(--border-subtle, rgba(255, 255, 255, 0.25));
    height: 1px;
    border: 0;
    margin: 20px 0;
}

@media screen and (max-width: 480px) {
    hr {
        margin: 12px 0;
    }

    /* Hide the hr between header and username section on mobile */
    header + hr {
        display: none;
    }
}

/*  Wrapper - background color is set dynamically via JS
----------------------------------------------------- */
#wrap {
    padding: 0 30px;
    text-align: center;
    background: #000;
    min-height: 100vh;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/*  Header
----------------------------------------------------- */
header {
    margin: 35px 0 20px;
}

@media screen and (max-width: 480px) {
    header {
        margin: 30px 0 20px;
    }
}

/*  Music data content
----------------------------------------------------- */
.content {
    text-align: center;
    margin-top: 0px;
    margin-bottom: 50px;
    /* Limit to 4 tiles per row: 4 × (250px tile + 30px margin) = 1120px */
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
}

/*  Music Personality Headline - Hero element, larger than site title
----------------------------------------------------- */
.music-personality {
    font-family: "Lobster", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 50px;
    line-height: 1.2;
    text-align: center;
    margin: 50px auto 30px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.music-personality.loading,
.music-personality.visible {
    visibility: visible;
    opacity: 1;
}

.music-personality .personality-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: "Karla", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 20px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 400;
    white-space: nowrap;
    color: var(--text-secondary, rgba(255, 255, 255, 0.8));
    margin-bottom: 5px;
}

/* Decorative lines on either side of the label */
.music-personality .personality-label::before,
.music-personality .personality-label::after {
    content: "";
    flex-shrink: 1;
    width: 40px;
    height: 1px;
    background: var(--text-muted, rgba(255, 255, 255, 0.4));
}

/* Fixed-height container for rolling/text to prevent layout shift */
.music-personality .personality-content {
    display: block;
    min-height: 65px;
    padding: 0 10px;
}

/* Rolling text loading animation */
.music-personality .personality-rolling {
    display: inline-block;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-style: italic;
    font-size: 40px;
    transition: opacity 0.3s ease-out;
}

.music-personality .personality-rolling.fading-out {
    opacity: 0;
}

/* Actual headline text - starts hidden */
.music-personality .personality-text {
    display: none;
    opacity: 0;
}

/* When visible, hide rolling and show text with fade-in + glow */
.music-personality.visible .personality-rolling {
    display: none;
}

.music-personality.visible .personality-text {
    display: inline;
    color: #fff;
    animation: personalityReveal 2s ease-out forwards;
    /* Glow uses CSS variable set by JS, falls back to white */
    text-shadow:
        0 0 10px var(--personality-glow, rgba(255, 255, 255, 0.4)),
        0 0 30px var(--personality-glow, rgba(255, 255, 255, 0.4));
}

@keyframes personalityReveal {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@media screen and (max-width: 480px) {
    .music-personality {
        margin: 30px auto;
    }
    .music-personality .personality-label {
        font-size: 13px;
        gap: 8px;
        letter-spacing: 1px;
    }
    .music-personality .personality-label::before,
    .music-personality .personality-label::after {
        width: 20px;
        min-width: 0;
    }
    .music-personality .personality-content {
        min-height: auto;
    }
}

/*  Artist tiles
----------------------------------------------------- */

/* Anchor wrapper for artist tiles - needs block display for proper focus outline */
.content a:has(.artist) {
    display: inline-block;
    border-radius: 8px;
    margin: 15px;
    text-decoration: none;
}

/* Override default focus styles for artist tile links */
.content a:has(.artist):focus-visible {
    outline: 2px solid var(--text-tertiary, rgba(255, 255, 255, 0.7));
    outline-offset: 3px;
}

.artist {
    position: relative;
    display: block;
    width: 250px;
    height: 250px;
    background-color: rgba(0, 0, 0, 0.5);
    background-position: center center;
    background-size: cover;
    -webkit-box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.25);
    -moz-box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.25);
    box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.25);
    /* Prevent any layout shift during crossfade */
    overflow: hidden;
    border-radius: 8px;
    transition: box-shadow 0.2s ease-out;
}

/* Inset specular overlay — subtle light edge + soft inner glow (Layer 4)
   mix-blend-mode: screen lets the underlying image colors tint the glow,
   so bright/saturated image edges produce a colored specular highlight
   while dark edges keep the glow subtle and neutral. */
.artist::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 0 8px 2px rgba(255, 255, 255, 0.07),
        inset 0 1px 3px 0 rgba(255, 255, 255, 0.12);
    mix-blend-mode: screen;
    z-index: 3;
    pointer-events: none;
}

.artist.loading-image::before,
.artist.loading-active::before {
    box-shadow:
        inset 0 0 0 1px var(--border-specular, rgba(255, 255, 255, 0.12)),
        inset 0 0 6px 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 2px 0 rgba(255, 255, 255, 0.08);
    mix-blend-mode: normal;
}

/* Source layer divs for smooth crossfade transitions between image sources (Layers 6-8) */
.source-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-position: center center;
    background-size: cover;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    z-index: 1;
    pointer-events: none;
}

/* Active source layer is visible */
.source-layer.active {
    opacity: 1;
}

/* Star placeholder base styles (Layer 5) */
.artist.no-image::after,
.artist.loading-image::after,
.artist.loading-active::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    /* Standard 5-pointed star polygon, solid white */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon fill='white' points='50,5 61,40 98,40 68,62 79,97 50,75 21,97 32,62 2,40 39,40'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 150px 150px;
    z-index: 2;
}

/* Waiting in queue - static, very transparent star */
.artist.loading-image::after {
    opacity: 0.15;
}

/* Currently loading - pulsing star animation */
.artist.loading-active::after {
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* No image found - star uses CSS variable for background color (set by JS) */
.artist.no-image::after {
    opacity: 1;
    /* Star color comes from CSS variable --bg-color set by JS, fallback to dark */
    background-image: var(
        --star-bg,
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon fill='%23333' points='50,5 61,40 98,40 68,62 79,97 50,75 21,97 32,62 2,40 39,40'/%3E%3C/svg%3E")
    );
}

/*  Hover effect on artist tiles (Layer 3)
----------------------------------------------------- */
.artist .dark {
    opacity: 0;
    position: absolute;
    bottom: 0;
    right: 0;
    top: 0;
    left: 0;
    z-index: 4;
    border-radius: 8px;
    background: #000;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.artist:hover .dark {
    opacity: 0.35;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 0 8px 2px rgba(0, 0, 0, 0.15);
}

/*  Boxed title styling (Layers 1-2: title text + backdrop blur)
----------------------------------------------------- */
.title {
    z-index: 5;
    position: absolute;
    bottom: 0;
    right: 0;
    left: auto;
    opacity: 0;
    background: none;
    -webkit-backdrop-filter: blur(8px) saturate(200%);
    backdrop-filter: blur(8px) saturate(200%);
    margin: 0 10px 10px;
    padding: 5px 10px;
    text-decoration: none;
    text-align: right;
    font-weight: 400;
    font-size: 20px;
    line-height: 25px;
    color: #fff;
    border-radius: 4px;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.title::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Intentionally use white for blur behavior */
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: -1;
    /* Ease backdrop color/border with the same 0.8s ease-in-out window as
       .source-layer's opacity crossfade above, so the title theme transition
       feels cohesive with the underlying image change rather than snapping. */
    transition:
        background-color 0.8s ease-in-out,
        border-color 0.8s ease-in-out;
}

.title:hover {
    opacity: 0.8;
    text-decoration: none;
}

.title span {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    line-height: 18px;
    font-style: italic;
    opacity: 0.8;
    margin-bottom: 4px;
}

.artist:hover .title,
.content a:has(.artist):focus-visible .title {
    opacity: 1;
}

@media screen and (max-width: 480px) {
    /* On mobile, dark overlay only shows on hover (via :hover rule above) */
    .title {
        opacity: 1;
    }
}

.artist.light-image .title {
    /* text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); */
}

.artist.light-image .title::before {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.artist.light-image .title span {
    /* text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); */
}

/*  Username Section (sticky on desktop only)
----------------------------------------------------- */
.username-section {
    padding: 15px 0 20px;
    margin: -15px 0 0;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.25));
}

.username-section p {
    margin: 0;
    line-height: 40px;
}

.username-section a {
    font-weight: 700;
}

/* Sticky only on larger viewports */
@media screen and (min-width: 481px) {
    .username-section {
        position: sticky;
        top: 0;
        z-index: 20;
        background: inherit;
    }
}

/* Compact username section on mobile to de-emphasize */
@media screen and (max-width: 480px) {
    .username-section {
        padding: 10px 0 20px;
    }

    .username-section p {
        font-size: 13px;
        line-height: 28px;
        color: var(--text-muted, rgba(255, 255, 255, 0.5));
    }
}

/*  Form fields
----------------------------------------------------- */
input[type="text"] {
    border: 1px solid var(--input-border, rgba(255, 255, 255, 0.6));
    background: var(--input-bg, rgba(255, 255, 255, 0.15));
    font-family: "Karla", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 15px;
    padding: 10px 12px;
    min-height: 44px;
    margin: 0 5px;
    min-width: 150px;
    color: #fff;
    text-align: left;
    font-weight: 400;
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

input[type="text"]:focus {
    border: 1px solid var(--input-border-focus, rgba(255, 255, 255, 0.8));
    background: var(--input-bg-focus, rgba(255, 255, 255, 0.3));
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.2),
        0 0 12px var(--personality-glow, rgba(255, 255, 255, 0.2));
}

input[type="text"]::placeholder {
    color: var(--text-tertiary, rgba(255, 255, 255, 0.7));
}

@media screen and (max-width: 480px) {
    input[type="text"] {
        display: block;
        margin: 0 auto;
        width: 65%;
        /* Prevent Safari iOS auto-zoom on focus - requires 16px minimum */
        font-size: 16px;
    }
}

/*  Transitions
----------------------------------------------------- */
a,
.title,
.dark,
input {
    -webkit-transition: all 0.2s ease-out;
    -moz-transition: all 0.2s ease-out;
    -ms-transition: all 0.2s ease-out;
    -o-transition: all 0.2s ease-out;
    transition: all 0.2s ease-out;
}

/*  Error States
----------------------------------------------------- */
.error-state {
    text-align: center;
    padding: 150px 30px;
    max-width: 700px;
    margin: 0 auto;
}

.error-state p {
    margin-bottom: 10px;
    font-size: 18px;
    line-height: 30px;
    color: var(--text-tertiary, rgba(255, 255, 255, 0.7));
}

/*  Loading State for Artist Images - plain background only
----------------------------------------------------- */
/* No shimmer or special effects during loading */

/* Fade-in animation for images */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.artist.image-loaded {
    animation: fadeIn 0.5s ease-in-out;
}

/*  Footer
----------------------------------------------------- */
footer {
    padding: 20px 30px;
    margin: 0 -30px;
    background: linear-gradient(to top, transparent 0%, rgba(0, 0, 0, 0.35) 60%, rgba(0, 0, 0, 0.5) 100%);
    text-align: center;
}

footer hr {
    margin: 15px 0;
}

footer p {
    font-size: 14px;
    line-height: 22px;
    margin: 0;
}

.footer-content {
    text-align: center;
}

.footer-copyright {
    margin-bottom: 5px;
}

/* Small viewports: stack credit line below copyright */
@media screen and (max-width: 480px) {
    .footer-copyright .credit-sep {
        display: none;
    }

    .footer-copyright .credit-line {
        display: block;
        margin-top: 2px;
    }
}

.footer-data {
    color: var(--text-secondary, rgba(255, 255, 255, 0.8));
}

/* Large viewports: inline with middot separators */
@media screen and (min-width: 769px) {
    .footer-data .data-group {
        white-space: nowrap;
    }

    .footer-data .data-sep {
        color: var(--text-muted, rgba(255, 255, 255, 0.5));
    }
}

/* Small/Medium viewports: wrap naturally, hide main separator */
@media screen and (max-width: 768px) {
    .footer-data {
        line-height: 1.8;
    }

    .footer-data .data-sep {
        display: none;
    }

    .footer-data .data-group {
        display: inline;
    }

    /* Stack artist-data on its own line */
    .footer-data .data-group.artist-data {
        display: block;
        margin-top: 3px;
    }
}

/*  Image Sources Config
----------------------------------------------------- */
.image-sources-config {
    border: none;
    margin: 0;
    padding: 10px 0;
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.image-sources-config .config-label {
    font-weight: normal;
    padding: 0;
    margin: 0;
    color: var(--text-tertiary, rgba(255, 255, 255, 0.7));
}

.image-sources-config label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-tertiary, rgba(255, 255, 255, 0.7));
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition:
        color 0.2s ease-out,
        background-color 0.2s ease-out,
        border-color 0.2s ease-out;
}

.image-sources-config label:hover {
    color: var(--text-secondary, rgba(255, 255, 255, 0.85));
    background-color: var(--bg-subtle, rgba(255, 255, 255, 0.08));
}

.image-sources-config label:has(input:checked) {
    color: #fff;
    background-color: var(--bg-medium, rgba(255, 255, 255, 0.12));
    border-color: var(--border-subtle, rgba(255, 255, 255, 0.25));
}

/* Show focus outline on label when radio is keyboard-focused */
.image-sources-config label:has(input:focus-visible) {
    outline: 2px solid var(--text-tertiary, rgba(255, 255, 255, 0.7));
    outline-offset: 2px;
    border-radius: 2px;
}

/* Visually hide radio buttons but keep them accessible */
.image-sources-config input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile: horizontal row with tighter spacing */
@media screen and (max-width: 480px) {
    .image-sources-config {
        gap: 8px;
        padding: 8px 0;
    }

    .image-sources-config .config-label {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }

    .image-sources-config label {
        padding: 6px 10px;
        font-size: 13px;
    }
}
