/* MMA News - Mobile-First Design */

:root {
    --mma: #ff6b35;      /* MMA orange */
    --ink: #0f172a;      /* dark text */
    --ink-soft: #1f2937; /* softer dark text */
    --muted: #6b7280;    /* muted gray */
    --line: #e5e7eb;     /* borders */
    --card: #ffffff;     /* card background */
    --bg: #f9fafb;       /* page background */
    --r: 12px;           /* border radius */
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* HEADER - Sticky */
header.site {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: none;
    transition: box-shadow 0.2s ease;
}

header.site.shadow {
    box-shadow: var(--shadow);
}

.site-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 641px) {
    .site-inner {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
}

header.site h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.grow {
    flex: 1;
}

.hdr-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

@media (min-width: 641px) {
    .hdr-actions {
        width: auto;
    }
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: none;
}

@media (min-width: 641px) {
    .search {
        max-width: 400px;
    }
}

.search input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.95rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    transition: border-color 0.2s, background 0.2s;
}

.search input:focus {
    outline: none;
    border-color: var(--mma);
    background: var(--card);
}

.search input::placeholder {
    color: var(--muted);
}

.search input::-webkit-search-cancel-button {
    display: none;
}

.clear-search-btn {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.clear-search-btn:hover {
    color: var(--mma);
}

/* MAIN CONTENT */
#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

#mma-news {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: calc(var(--r) + 2px);
    padding: 1rem;
    box-shadow: var(--shadow);
}

#loading {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 1rem;
}

/* ARTICLE GRID - Mobile First */
.items {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr;
}

/* ARTICLE CARDS */
article {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 0.75rem;
    transition: transform 0.06s ease, box-shadow 0.12s ease;
    will-change: transform;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
}

article:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Article thumbnail */
.article-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg);
    display: block;
}

/* Article content */
.article-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.article-source {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--mma);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.article-title {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.article-title a {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.15s ease;
}

.article-title a:hover {
    color: var(--mma);
}

.article-description {
    font-size: 0.9rem;
    color: var(--muted);
    margin: 0 0 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Article footer (date + link) */
.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--line);
    margin-top: auto;
}

.article-date {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.article-link {
    display: inline-block;
    background: var(--mma);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.article-link:hover {
    background: #e55a24;
}

/* FOOTER */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 2rem;
    border-top: 1px solid var(--line);
}

/* DESKTOP LAYOUT - 640px+ */
@media (min-width: 641px) {
    .items {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    article {
        flex-direction: row;
        gap: 1rem;
    }

    .article-thumb {
        width: 140px;
        height: auto;
        aspect-ratio: 16 / 9;
        flex-shrink: 0;
        align-self: flex-start;
    }

    .article-footer {
        flex-direction: column;
        align-items: flex-start;
        border-top: none;
        padding-top: 0;
        margin-top: auto;
        gap: 0.5rem;
    }

    .article-date {
        width: 100%;
        font-size: 0.75rem;
    }

    .article-link {
        width: 100%;
        text-align: center;
    }
}

/* DESKTOP LAYOUT - 1024px+ */
@media (min-width: 1024px) {
    #app {
        padding: 2rem 1rem;
    }

    #mma-news {
        padding: 1.5rem;
    }

    .items {
        gap: 1.25rem;
    }

    article {
        gap: 1.25rem;
    }
}

/* Scroll behavior for sticky header */
@supports (scroll-behavior: smooth) {
    html {
        scroll-behavior: smooth;
    }
}

/* Utility classes */
#search-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
}


/* Header meta (tagline + date) */
.hdr-meta {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.tagline {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.hdr-date {
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--bg);
}

@media (min-width: 641px) {
    .hdr-meta {
        margin-left: 0.75rem;
    }
}


/* --- Video thumbnail overlay (non-intrusive) --- */
.thumb-wrap { position: relative; display: block; border-radius: 8px; overflow: hidden; }
.thumb-wrap > img { display: block; width: 100%; height: auto; object-fit: cover; }
.thumb-wrap .play-badge {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 48px; line-height: 1; color: #fff;
  background: rgba(0,0,0,0.18); opacity: 0.7; transition: opacity .15s ease-in-out;
  pointer-events: none;
}
.thumb-wrap:hover .play-badge, .thumb-wrap:focus-within .play-badge { opacity: 1; }
.thumb-wrap .duration {
  position: absolute; right: 8px; bottom: 8px;
  font: 600 12px/1 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #fff; background: rgba(0,0,0,.8);
  padding: 2px 6px; border-radius: 6px;
}
/* Make whole image keyboard-focusable */
.thumb-link { display: block; outline: none; }
.thumb-link:focus .play-badge { opacity: 1; }

/* --- Video thumbnail overlay: small enhancements --- */
.thumb-wrap { aspect-ratio: 16 / 9; cursor: pointer; }
.thumb-wrap .play-badge { mix-blend-mode: normal; }
@media (min-width: 641px) {
  /* Keep consistent width in row layout when images are 140px wide */
  article .thumb-wrap { width: 140px; flex-shrink: 0; align-self: flex-start; }
}
@media (min-width: 641px) {
  article .thumb-wrap > img { width: 100%; height: auto; }
}

/* --- New CSS for Article Actions/Share Buttons --- */

.article-actions {
    display: flex;
    justify-content: flex-end; /* Pushes buttons to the right */
    gap: 6px; /* Reduced gap slightly for mobile fit */
    flex-shrink: 0; 
    align-self: flex-end; 
}

.article-actions button {
    cursor: pointer;
    font-size: 0.68rem; /* 20% smaller for mobile (and now desktop) */
    font-weight: 600;
    padding: 0.4rem 0.8rem; /* 20% smaller for mobile (and now desktop) */
    border-radius: 999px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    border: 1px solid var(--line);
    flex-shrink: 0;
}

/* Specific Style for Share to X */
.article-actions .share-x {
    color: #fff;
    background-color: #000;
    border-color: #000;
}
.article-actions .share-x:hover {
    background-color: #333;
}

/* Specific Style for Copy URL */
.article-actions .copy-url {
    color: var(--ink);
    background-color: var(--card);
}
.article-actions .copy-url:hover {
    background-color: var(--line);
    border-color: var(--muted);
}

@media (min-width: 641px) {
    /* On desktop, the article-footer is flex-direction: column. */
    .article-actions {
        width: auto; /* Allow content to define width */
        margin-top: 0.5rem;
    }

    .article-actions button {
        flex-grow: 0; /* Stops stretching */
        min-width: 120px; /* Enforces equal width */
        text-align: center;
    }
}
