/* ==========================================================================
   owainj.co.uk – shared styles
   Colours are tokens so light and dark mode stay contrast-checked (WCAG AA).
   ========================================================================== */

:root {
    color-scheme: light dark;

    --bg: #f4f4f9;
    --surface: #ffffff;
    --surface-2: #f9f9fb;
    --ink: #1e293b;          /* strongest text */
    --text: #333333;         /* body text */
    --text-muted: #4b5563;
    --text-subtle: #5b6576;
    --heading: #556cd6;
    --link: #3f51b5;
    --accent: #3f51b5;       /* buttons */
    --accent-hover: #303f9f;
    --on-accent: #ffffff;
    --success: #047857;
    --success-hover: #065f46;
    --error: #b91c1c;
    --live: #c62828;
    --offline: #5f6368;
    --border: #dddddd;
    --border-soft: #e2e8f0;
    --border-strong: #767676;
    --focus: #1e293b;
    --shadow: rgba(0, 0, 0, 0.1);
    --radio-1: #f8f9ff;
    --radio-2: #eceffe;
    --radio-border: #d5dcff;
    --table-head: #f3f4f6;
    --table-border: #d1d5db;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #1e293b;
        --surface-2: #273449;
        --ink: #f1f5f9;
        --text: #e2e8f0;
        --text-muted: #cbd5e1;
        --text-subtle: #a9b6c8;
        --heading: #a5b4fc;
        --link: #a5b4fc;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --on-accent: #0f172a;
        --success: #34d399;
        --success-hover: #6ee7b7;
        --error: #fca5a5;
        --border: #334155;
        --border-soft: #334155;
        --border-strong: #94a3b8;
        --focus: #f1f5f9;
        --shadow: rgba(0, 0, 0, 0.4);
        --radio-1: #1e293b;
        --radio-2: #25304a;
        --radio-border: #3b4a6b;
        --table-head: #273449;
        --table-border: #475569;
    }
}

/* --- Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
[hidden] {
    display: none !important;
}
h1, h2, h3 {
    color: var(--heading);
    line-height: 1.3;
}
a {
    color: var(--link);
    text-decoration: underline;
}
a:hover {
    text-decoration-thickness: 2px;
}
code {
    font-size: 0.95em;
}

/* --- Accessibility helpers --- */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.skip-link {
    position: absolute;
    left: 1rem;
    top: -100px;
    background: #1e293b;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    z-index: 10002;
    text-decoration: none;
}
.skip-link:focus {
    top: 1rem;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}
main:focus {
    outline: none;
}

/* --- Site header & navigation --- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
}
.site-header__inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}
.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}
.site-brand img {
    width: 32px;
    height: 32px;
}
.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.25rem;
}
.site-nav a {
    display: inline-block;
    padding: 0.5rem 0.85rem;
    min-height: 44px;
    line-height: 28px;
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}
.site-nav a:hover {
    background: var(--surface-2);
    text-decoration: underline;
}
.site-nav a[aria-current="page"] {
    background: var(--accent);
    color: var(--on-accent);
}

/* --- Page layout --- */
.page-title {
    max-width: 800px;
    margin: 2rem auto 0;
    padding: 0 1rem;
    text-align: center;
}
.page-title h1 {
    margin: 0;
    font-size: 2rem;
    color: var(--ink);
}
.page-title p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}
.card {
    max-width: 800px;
    margin: 1.5rem auto 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow);
}
.card > h2:first-child {
    margin-top: 0;
}
@media (max-width: 832px) {
    .card {
        margin-left: 1rem;
        margin-right: 1rem;
    }
}
@media (max-width: 480px) {
    .card {
        padding: 1rem;
    }
}

/* --- Footer --- */
.site-footer {
    text-align: center;
    margin: 2rem 0;
    padding: 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.site-footer p {
    margin: 0.4rem 0;
}

/* --- Site announcement banner --- */
#site-popup-banner {
    background-color: #f39c12;
    color: #1a1a1a;
    padding: 8px 20px;
    text-align: center;
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
#site-popup-banner p {
    margin: 0;
    color: inherit;
}
#site-popup-banner .popup-content {
    display: flex;
    align-items: center;
    gap: 15px;
}
#site-popup-banner button {
    background: transparent;
    border: none;
    color: #1a1a1a;
    font-size: 20px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
}
#site-popup-banner button:focus-visible {
    outline-color: #1a1a1a;
}

/* --- Contact list with copy buttons --- */
.contact-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.contact-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.5rem 0;
    padding: 0.35rem 0.35rem 0.35rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow-wrap: anywhere;
}
.copy-btn {
    flex-shrink: 0;
    min-width: 72px;
    min-height: 36px;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
.copy-btn:hover {
    border-color: var(--accent);
}
.copy-btn.is-copied {
    background: var(--success);
    border-color: var(--success);
    color: var(--surface);
}

/* --- Radio widget --- */
.radio-widget {
    background: linear-gradient(135deg, var(--radio-1) 0%, var(--radio-2) 100%);
    border: 1px solid var(--radio-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    margin-top: 1.5rem;
    box-shadow: 0 8px 20px rgba(85, 108, 214, 0.08);
}
@media (max-width: 480px) {
    .radio-widget {
        padding: 1rem;
    }
}
.live-indicator {
    display: inline-block;
    background-color: #3f51b5;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    transition: background-color 0.3s ease;
}
.live-indicator.is-live {
    background-color: var(--live);
}
.live-indicator.is-offline {
    background-color: var(--offline);
}
.player-card {
    display: flex;
    align-items: center;
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    text-align: left;
    gap: 16px;
    overflow: hidden;
}
.art-wrapper {
    width: 75px;
    height: 75px;
    flex-shrink: 0;
}
#np-art {
    width: 75px;
    height: 75px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
.art-placeholder {
    width: 75px;
    height: 75px;
    border-radius: 8px;
    background: #556cd6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.5rem;
}
.np-info {
    flex-grow: 1;
    min-width: 0;
}
.np-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 2px 0;
}
.np-artist,
.np-next {
    font-size: 0.9rem;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 6px 0;
}
.np-next {
    font-size: 0.8rem;
}
.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}
#play-btn {
    background-color: var(--accent);
    color: var(--on-accent);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: transform 0.2s ease, background-color 0.2s ease;
    flex-shrink: 0;
}
#play-btn:hover {
    background-color: var(--accent-hover);
    transform: scale(1.05);
}
.volume-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-subtle);
}
.volume-container input[type="range"] {
    width: 90px;
    accent-color: var(--accent);
    cursor: pointer;
}
.request-section {
    margin-top: 15px;
    background: var(--surface);
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    text-align: left;
}
.request-section h3 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: var(--ink);
}
.request-row {
    display: flex;
    gap: 8px;
    width: 100%;
}
.request-row select {
    flex-grow: 1;
    width: 0;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    font-size: 0.85rem;
    background: var(--surface-2);
    color: var(--ink);
}
.request-row button {
    background-color: #047857;
    color: #ffffff;
    border: none;
    padding: 8px 14px;
    min-height: 40px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s;
    flex-shrink: 0;
}
.request-row button:hover {
    background-color: #065f46;
}
.request-row button:disabled {
    cursor: wait;
    opacity: 0.8;
}
#request-message {
    font-size: 0.85rem;
    margin: 6px 0 0;
    color: var(--text-subtle);
    min-height: 1.2em;
}
#request-message.is-error {
    color: var(--error);
}
#request-message.is-success {
    color: var(--success);
}

/* --- Privacy policy --- */
.policy h2 {
    font-size: 1.25rem;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.35rem;
}
.policy h2:first-of-type {
    margin-top: 0;
}
.policy h3 {
    font-size: 1.05rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}
.policy p,
.policy ul {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-muted);
}
.policy ul {
    padding-left: 1.5rem;
    list-style-type: disc;
}
.policy li {
    margin: 0.5rem 0;
}
.policy strong {
    color: var(--ink);
}
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}
th, td {
    text-align: left;
    vertical-align: top;
    padding: 0.5rem;
    border: 1px solid var(--table-border);
}
th {
    background: var(--table-head);
    color: var(--ink);
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
    #play-btn:hover {
        transform: none;
    }
}

/* --- Now listening (from Last.fm / Discord) --- */
.listening {
    margin: 0.5rem 0 1rem;
}
.listening h2 {
    margin-bottom: 0.6rem;
}
.listening-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--radio-border);
    background: linear-gradient(135deg, var(--radio-1) 0%, var(--radio-2) 100%);
}
.listening-art,
.listening-art-ph {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
.listening-art-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #556cd6;
    color: #ffffff;
    font-size: 1.6rem;
}
.listening-info {
    flex: 1;
    min-width: 0;
}
.listening-info p {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#listening-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
}
#listening-title a {
    color: inherit;
}
#listening-artist {
    color: var(--text-muted);
}
.listening-meta {
    font-size: 0.8rem;
    color: var(--text-subtle);
}
.listening-progress {
    height: 5px;
    margin: 6px 0 2px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
}
.listening-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 1s linear;
}
.eq {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 28px;
    flex-shrink: 0;
}
.eq span {
    width: 4px;
    height: 30%;
    border-radius: 2px;
    background: var(--accent);
    animation: eq-bounce 0.9s ease-in-out infinite;
}
.eq span:nth-child(2) { animation-delay: -0.3s; }
.eq span:nth-child(3) { animation-delay: -0.6s; }
.eq span:nth-child(4) { animation-delay: -0.15s; }
@keyframes eq-bounce {
    0%, 100% { height: 25%; }
    50% { height: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .eq span {
        animation: none;
        height: 60%;
    }
    .listening-progress span {
        transition: none;
    }
}
@media (max-width: 420px) {
    .eq {
        display: none;
    }
}
/* Paused: freeze the equaliser */
.listening.is-paused .eq span {
    animation: none;
    height: 20%;
}
/* Quick fade when the song changes */
.listening-card.is-changing {
    animation: listening-swap 0.5s ease-out;
}
@keyframes listening-swap {
    from { opacity: 0.2; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .listening-card.is-changing {
        animation: none;
    }
}
