/* ==========================================================================
   AuxControl — shared stylesheet
   One file for every view so the look and feel stays consistent app-wide.
   ========================================================================== */

:root {
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --bg: #121212;
    --surface: #181818;      /* cards */
    --surface-alt: #282828;  /* rows, inputs, thumbnails */
    --border: #333;

    --accent: #1DB954;
    --accent-hover: #1ed760;

    --text: #fff;
    --text-muted: #b3b3b3;
    --text-faint: #666;
    --text-dim: #555;
    --error: #e05555;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 24px;

    /* Content width for list-style pages; widens on larger screens so the
       layout uses more of the available space instead of a fixed narrow column. */
    --container: 600px;
    --tap-target: 44px; /* comfortable minimum touch target */
}

@media (min-width: 720px)  { :root { --container: 760px; } }
@media (min-width: 960px)  { :root { --container: 920px; } }
@media (min-width: 1280px) { :root { --container: 1100px; } }

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}

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

/* ---- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--tap-target); padding: 0.75rem 1.6rem;
    background: var(--accent); color: #000; font-weight: 700;
    border-radius: var(--radius-pill); text-decoration: none; font-size: 0.95rem;
    border: none; cursor: pointer; font-family: inherit;
    text-align: center;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.ghost {
    background: transparent; color: var(--accent); border: 1px solid var(--accent);
}
.btn.ghost:hover { background: rgba(29, 185, 84, 0.1); }
.btn:disabled { background: #444; color: var(--text-muted); cursor: default; }

/* ---- Cards & text inputs ------------------------------------------------- */

.card {
    background: var(--surface); border-radius: var(--radius-lg); padding: 2rem 1.8rem;
    width: 100%; max-width: 400px;
    display: flex; flex-direction: column; gap: 1.2rem;
}

input[type=text] {
    width: 100%; min-height: var(--tap-target); padding: 0.75rem 1rem;
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-pill);
    color: var(--text); font-size: 1rem; font-family: inherit; outline: none;
}
input[type=text]::placeholder { color: var(--text-faint); }
input[type=text]:focus { border-color: var(--accent); }

/* Game-join code field: bigger, spaced-out, uppercase */
.code-input {
    border-radius: var(--radius-md);
    text-align: center; letter-spacing: 0.15em; text-transform: uppercase;
}
.code-input::placeholder { letter-spacing: normal; text-transform: none; }

.error-text { color: var(--error); font-size: 0.85rem; }

/* ---- Page header (game code + title) ------------------------------------ */

header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem 1rem;
    max-width: var(--container); margin: 0 auto 1.6rem;
}
h1 { color: var(--accent); font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem); }
.game-code { font-family: monospace; color: var(--text-muted); font-size: 0.85rem; letter-spacing: 0.2em; }

/* ---- Track list (search results / queue votes) --------------------------- */

.track {
    display: flex; align-items: center; gap: 0.85rem;
    background: var(--surface-alt); border-radius: var(--radius-md); padding: 0.6rem 0.8rem;
    text-decoration: none; color: inherit;
    border: 1px solid transparent; transition: border-color 0.15s;
    font: inherit; text-align: left; cursor: pointer; width: 100%; box-sizing: border-box;
}
a.track:hover { border-color: var(--accent); text-decoration: none; }
.track img { width: 50px; height: 50px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.track-info { display: flex; flex-direction: column; gap: 0.15rem; overflow: hidden; }
.track-name   { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-user   { color: var(--accent); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

.track.selected { background: #1a3324; border-color: var(--accent); }
.track.mine     { background: #1c2a3d; border-color: #3b82f6; cursor: default; margin-bottom: 0.6rem; }
.track.mine .track-user { color: #3b82f6; }
.track.voted     { background: #2a1c3d; border-color: #a855f7; cursor: default; }
.track.voted .track-user { color: #a855f7; }

.empty { text-align: center; color: var(--text-dim); margin-top: 3rem; font-size: 0.95rem; }

/* ==========================================================================
   Page-specific layout
   ========================================================================== */

/* ---- Home ----------------------------------------------------------------- */

body.home {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 100vh; padding: 2rem;
    text-align: center;
}
body.home h1 { font-size: clamp(1.8rem, 1.4rem + 2vw, 2.6rem); margin-bottom: 0.4rem; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 2.2rem; }
.card.home-card { max-width: 320px; }
.about { color: var(--text-dim); font-size: 0.82rem; max-width: 320px; margin-top: 1.6rem; line-height: 1.5; }

.divider {
    display: flex; align-items: center; gap: 0.8rem;
    color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.divider::before, .divider::after {
    content: ""; flex: 1; height: 1px; background: var(--border);
}
.join-form { display: flex; flex-direction: column; gap: 0.8rem; }

/* ---- Error page ------------------------------------------------------------ */

body.error-page {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 100vh; gap: 1rem; padding: 2rem;
    text-align: center;
}
body.error-page .error-text { font-size: 1rem; max-width: 480px; }

/* ---- Set name page --------------------------------------------------------- */

body.set-name {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
}
body.set-name .card p { color: var(--text-muted); font-size: 0.9rem; }
body.set-name form > div { display: flex; flex-direction: column; gap: 0.8rem; }

/* ---- Watch-ad page ------------------------------------------------------------ */

body.watch-ad {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
}
body.watch-ad .card { max-width: 480px; text-align: center; }
#ad-status { color: var(--text-muted); font-size: 0.9rem; min-height: 1.1em; }

/* ---- Search page ------------------------------------------------------------ */

body.search-page { min-height: 100vh; padding: 2rem 1rem; }
.search-form { display: flex; gap: 0.5rem; max-width: var(--container); margin: 0 auto 1.6rem; }
.search-form input[type=text] { flex: 1; min-width: 0; }
.results {
    max-width: var(--container); margin: 0 auto;
    display: flex; flex-direction: column; gap: 0.4rem;
}

@media (min-width: 640px) {
    .results {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        align-items: start; gap: 0.6rem;
    }
    .results .empty { grid-column: 1 / -1; }
}

/* ---- Queue page --------------------------------------------------------------- */

body.queue-page { min-height: 100vh; padding: 2rem 1rem; }
.winner-banner {
    max-width: var(--container); margin: 0 auto 1.6rem;
    background: linear-gradient(135deg, rgba(29, 185, 84, 0.22), rgba(29, 185, 84, 0.06));
    border: 1px solid var(--accent); box-shadow: 0 0 24px rgba(29, 185, 84, 0.25);
    text-align: center; padding: 1.1rem 1.2rem; border-radius: var(--radius-lg);
    animation: winner-pop 0.35s ease-out;
}
.winner-badge {
    display: inline-block; background: var(--accent); color: #000;
    font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 0.25rem 0.7rem; border-radius: var(--radius-pill); margin-bottom: 0.6rem;
}
.winner-message {
    color: var(--text); font-weight: 700; font-size: 1.05rem; line-height: 1.35;
}
.winner-track {
    display: flex; align-items: center; justify-content: center; gap: 0.75rem;
    margin-top: 0.9rem; text-align: left;
}
.winner-track img {
    width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0;
    border: 2px solid var(--accent);
}
.winner-track .track-name { color: var(--text); font-size: 1rem; }
.winner-track .track-artist { color: var(--text-muted); }

@keyframes winner-pop {
    from { opacity: 0; transform: scale(0.92) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.nav { display: flex; gap: 0.75rem; }
.your-track-section, .your-vote-section { max-width: var(--container); margin: 0 auto 1.6rem; }
.tracks { max-width: var(--container); margin: 0 auto; }
body.queue-page .invite { max-width: var(--container); margin: 2rem auto 0; }
.tracks h2, .your-track-section h2, .your-vote-section h2 {
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.5rem;
}
.track-grid { display: flex; flex-direction: column; gap: 0.4rem; }

@media (min-width: 640px) {
    .track-grid {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        align-items: start; gap: 0.6rem;
    }
}

/* ---- Player page ---------------------------------------------------------------- */

body.player-page {
    display: flex; flex-direction: column; align-items: center;
    gap: 1.2rem; padding: 2rem 1rem;
    text-align: center;
}
.album-art {
    width: 240px; height: 240px; max-width: 60vw; max-height: 60vw;
    border-radius: var(--radius-md);
    object-fit: cover; background: var(--surface-alt);
}
.player-card {
    background: var(--surface-alt); border-radius: var(--radius-lg);
    padding: 1.2rem 1.6rem; width: 100%; max-width: 400px;
    border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 0.9rem;
}
.now-playing { display: flex; flex-direction: column; gap: 0.2rem; text-align: left; }
#track-name   { font-weight: 700; font-size: 1rem; }
#track-artist { color: var(--text-muted); font-size: 0.85rem; }
.controls { display: flex; align-items: center; gap: 1rem; }
#skip-btn { flex-shrink: 0; }
#volume { flex: 1; accent-color: var(--accent); }
#status { color: var(--text-muted); font-size: 0.8rem; min-height: 1.2em; text-align: left; }

.invite { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.invite img { border: 3px solid var(--accent); border-radius: var(--radius-md); width: 160px; height: 160px; }
.invite-label { color: var(--text-muted); font-size: 0.8rem; }
.invite-code { color: var(--text-dim); font-size: 0.72rem; font-family: monospace; }

#queue-section {
    width: 100%; max-width: 400px;
    display: none; flex-direction: column; gap: 0.5rem; text-align: left;
}
#queue-section h2 {
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-muted);
}
.queue-item {
    display: flex; align-items: center; gap: 0.75rem;
    background: var(--surface-alt); border-radius: var(--radius-md); padding: 0.5rem 0.75rem;
}
.queue-thumb {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    object-fit: cover; flex-shrink: 0; background: var(--border);
}
.queue-info { display: flex; flex-direction: column; gap: 0.1rem; overflow: hidden; }
.queue-track-name   { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-track-artist { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* On wider screens the player becomes a two-column dashboard instead of a
   narrow centered strip, so it actually uses the extra screen real estate. */
@media (min-width: 900px) {
    body.player-page {
        display: grid;
        grid-template-columns: minmax(280px, 380px) minmax(340px, 480px);
        justify-content: center; align-content: start;
        gap: 1.5rem 2.5rem;
        max-width: 900px; margin: 0 auto;
        padding: 3rem 2rem;
        text-align: left;
    }
    body.player-page .game-code { grid-column: 1 / -1; text-align: center; }
    body.player-page .album-art {
        grid-column: 1; grid-row: span 2; align-self: start; justify-self: center;
        width: 100%; height: auto; max-width: 380px; max-height: none; aspect-ratio: 1 / 1;
    }
    body.player-page .player-card { grid-column: 2; max-width: none; }
    body.player-page #queue-section { grid-column: 2; max-width: none; }
    body.player-page .invite { grid-column: 1 / -1; justify-self: center; }
}

/* Small phones: claw back edge padding so content isn't squeezed. */
@media (max-width: 420px) {
    body.home, body.error-page { padding: 1.5rem 1rem; }
    body.set-name, body.search-page, body.queue-page, body.player-page { padding: 1.5rem 0.75rem; }
    .card { padding: 1.6rem 1.3rem; }
    .player-card { padding: 1rem 1.2rem; }
}
