/* League news — homepage hero, story cards, article modal, and the admin
   News editor. Colors, fonts, radii and shadows all come from theme.css
   variables so a palette swap (data-theme) restyles this too. */

/* The shell caps pages at 1440px (.page-container); the homepage opts out so
   the news fills the whole window on large monitors. */
.page-container:has(.news-home) {
    max-width: none;
}

.news-home {
    /* Fills the whole page area and scales: card height and gaps grow and
       shrink with the window, and big screens get extra columns (below). */
    --news-card-h: clamp(280px, 20vw, 380px);
    --news-cover-h: calc(var(--news-card-h) * 0.48);
    --news-gap: clamp(12px, 1.4vw, 24px);
    width: 100%;
}

/* ── Hero ─────────────────────────────────────────────────────────────── */

.news-hero {
    text-align: center;
    padding: 40px 30px 36px;
    background:
        radial-gradient(700px 260px at 50% 0%, rgba(var(--accent-rgb), 0.14), transparent 70%),
        var(--surface-1);
}

/* main.css caps .page-intro at 720px, which looks lost in a full-width hero;
   let it run about twice as far (it still wraps to the box on smaller screens). */
.news-hero .page-intro {
    max-width: 1440px;
    margin-bottom: 26px;
}

.news-hero-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

.news-hero-actions .btn {
    font-size: 1.05rem;
    padding: 14px 32px;
}

/* ── Section headings ─────────────────────────────────────────────────── */

.news-section {
    margin-top: 40px;
}

.news-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.news-section-head h3 {
    margin: 0;
    color: var(--text-1);
    font-size: 1.15rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.news-section-head::after {
    content: '';
    flex: 1;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--border-accent), transparent);
}

/* ── Shared card bits ─────────────────────────────────────────────────── */

.news-cover {
    position: relative;
    background-color: var(--bg-3);
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

/* Articles with no image get a branded placeholder instead of a blank box */
.news-cover.no-image {
    background-image:
        linear-gradient(135deg, rgba(var(--accent-rgb), 0.22), rgba(var(--accent-2-rgb), 0.12)),
        linear-gradient(180deg, var(--bg-2), var(--bg-1));
}

.news-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.news-play {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.9);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    padding-left: 2px;
    box-shadow: var(--shadow-1);
}

.news-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: rgba(var(--accent-rgb), 0.16);
    border: 1px solid var(--border-accent);
    color: var(--accent);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.news-date,
.news-read {
    font-size: 0.68rem;
    color: var(--text-3);
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.news-card,
.news-feature {
    cursor: pointer;
    outline: none;
}

.news-card:focus-visible,
.news-feature:focus-visible {
    box-shadow: var(--focus-ring);
}

/* ── Top stories: one big, two stacked ────────────────────────────────── */

.news-top {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--news-gap);
}

.news-top.single {
    grid-template-columns: 1fr;
}

.news-top-side {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: var(--news-gap);
    min-width: 0;
}

.news-top-side:empty {
    display: none;
}

.news-top:not(:has(.news-top-side:not(:empty))) {
    grid-template-columns: 1fr;
}

.news-feature {
    position: relative;
    min-height: clamp(380px, 30vw, 600px);
    display: flex;
    align-items: flex-end;
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.news-feature:hover {
    border-color: var(--border-accent-strong);
    box-shadow: var(--shadow-accent);
}

.news-feature .news-cover {
    position: absolute;
    inset: 0;
}

.news-feature:hover .news-cover img {
    transform: scale(1.04);
}

.news-feature::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.88) 100%);
    pointer-events: none;
}

.news-feature-body {
    position: relative;
    z-index: 1;
    padding: 28px;
    max-width: 760px;
}

.news-feature-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.news-feature-meta .news-date,
.news-feature-meta .news-read {
    color: var(--text-2);
}

.news-feature h4 {
    margin: 0 0 10px;
    font-size: clamp(1.3rem, 2.1vw, 1.9rem);
    line-height: 1.2;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    overflow-wrap: anywhere;
}

.news-feature p {
    margin: 0 0 14px;
    color: var(--text-2);
    line-height: 1.6;
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-more {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.news-feature:hover .news-more,
.news-card:hover .news-more {
    text-decoration: underline;
}

/* Side stories: image beside text */
.news-side {
    display: flex;
    min-height: 0;
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.news-side:hover {
    border-color: var(--border-accent-strong);
    transform: translateY(-2px);
}

.news-side:focus-visible {
    box-shadow: var(--focus-ring);
}

.news-side .news-cover {
    flex: 0 0 38%;
}

.news-side:hover .news-cover img {
    transform: scale(1.05);
}

.news-side-body {
    flex: 1;
    min-width: 0;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.news-side h4 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
    color: var(--text-1);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.news-side-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Latest: the scrollable grid ──────────────────────────────────────── */

.news-frame {
    max-height: calc(2 * var(--news-card-h) + var(--news-gap) + 6px);
    overflow-y: auto;
    padding: 3px 8px 3px 3px;
    margin-right: -8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.5) transparent;
}

.news-frame::-webkit-scrollbar {
    width: 8px;
}

.news-frame::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.news-frame::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-rgb), 0.5);
    border-radius: 10px;
}

.news-frame::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--accent-rgb), 0.7);
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--news-gap);
}

.news-card {
    height: var(--news-card-h);
    display: flex;
    flex-direction: column;
    background: var(--bg-1);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.news-card:hover {
    border-color: var(--border-accent-strong);
    transform: translateY(-2px);
}

.news-card:hover .news-cover img {
    transform: scale(1.05);
}

.news-card .news-cover {
    flex: 0 0 var(--news-cover-h);
}

.news-card-body {
    flex: 1;
    min-height: 0;
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.news-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.news-card h4 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
    color: var(--text-1);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.news-card p {
    margin: 0;
    color: var(--text-2);
    font-size: 0.82rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-foot {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border-1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.news-empty,
.news-error {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-3);
    background: var(--surface-1);
    border: 1px dashed var(--border-2);
    border-radius: var(--radius-lg);
}

.news-loading-card {
    height: var(--news-card-h);
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--surface-1), var(--surface-2), var(--surface-1));
    background-size: 200% 100%;
    animation: news-shimmer 1.4s linear infinite;
}

@keyframes news-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ── Article modal ────────────────────────────────────────────────────── */

.news-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.25s ease;
}

.news-modal-card {
    position: relative;
    width: 100%;
    max-width: 780px;
    max-height: 92vh;
    overflow-y: auto;
    background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    animation: slideUp 0.25s ease;
}

.news-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.news-modal-close:hover {
    background: rgba(var(--accent-rgb), 0.85);
    transform: none;
    box-shadow: none;
}

.news-modal-head {
    padding: 28px 28px 8px;
}

.news-modal-head .news-feature-meta {
    margin-bottom: 10px;
}

.news-modal-head h2 {
    margin: 0;
    color: var(--text-1);
    font-size: 1.6rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
    padding-right: 30px;
}

.news-modal-media {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 28px 0;
}

.news-modal-media img,
.news-modal-media video {
    width: 100%;
    max-height: 520px;
    object-fit: contain;
    border-radius: var(--radius-md);
    background: #000;
    display: block;
}

.news-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.news-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.news-modal-text {
    padding: 18px 28px 30px;
    color: var(--text-2);
    line-height: 1.75;
    font-size: 0.98rem;
}

.news-modal-text p {
    margin: 0 0 1em;
    overflow-wrap: anywhere;
}

/* Rendered Markdown (article modal + admin preview) */
.news-prose h3,
.news-prose h4,
.news-prose h5,
.news-prose h6 {
    color: var(--text-1);
    line-height: 1.3;
    margin: 1.5em 0 0.5em;
    overflow-wrap: anywhere;
}

.news-prose h3 {
    font-size: 1.3rem;
    padding-bottom: 0.3em;
    border-bottom: 2px solid var(--border-accent);
}

.news-prose h4 { font-size: 1.12rem; color: var(--accent); }
.news-prose h5 { font-size: 1rem; }
.news-prose h6 { font-size: 0.9rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }

.news-prose > :first-child {
    margin-top: 0;
}

.news-prose strong {
    color: var(--text-1);
}

.news-prose a {
    color: var(--accent);
    text-decoration: underline;
    overflow-wrap: anywhere;
}

.news-prose ul,
.news-prose ol {
    margin: 0 0 1em;
    padding-left: 1.5em;
}

.news-prose li {
    margin-bottom: 0.3em;
    overflow-wrap: anywhere;
}

.news-prose li::marker {
    color: var(--accent);
}

.news-prose blockquote {
    margin: 0 0 1em;
    padding: 0.6em 1em;
    border-left: 3px solid var(--accent);
    background: var(--surface-1);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-2);
}

.news-prose blockquote > :last-child {
    margin-bottom: 0;
}

.news-prose hr {
    border: none;
    height: 2px;
    margin: 1.5em 0;
    background: linear-gradient(90deg, var(--border-accent), transparent);
}

.news-prose code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 0.1em 0.4em;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.news-prose pre {
    margin: 0 0 1em;
    padding: 12px 14px;
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: var(--bg-0);
    border: 1px solid var(--border-1);
}

.news-prose pre code {
    padding: 0;
    background: none;
}

.news-modal-card::-webkit-scrollbar {
    width: 8px;
}

.news-modal-card::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-rgb), 0.5);
    border-radius: 10px;
}

/* ── Large monitors: more columns instead of ever-wider cards ─────────── */

@media (min-width: 1800px) {
    .news-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 2400px) {
    .news-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* ── Tablet ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .news-top {
        grid-template-columns: 1fr;
    }

    .news-top-side {
        grid-template-rows: none;
        grid-template-columns: 1fr 1fr;
    }

    .news-side {
        flex-direction: column;
    }

    .news-side .news-cover {
        flex: 0 0 130px;
    }

    .news-feature {
        min-height: 360px;
    }

    .news-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Two columns: show three rows so about six cards are still visible */
    .news-frame {
        max-height: calc(3 * var(--news-card-h) + 2 * var(--news-gap) + 6px);
    }
}

/* ── Phone ────────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
    .news-home {
        --news-card-h: 112px;
        --news-gap: 12px;
    }

    .news-hero {
        padding: 28px 16px 26px;
    }

    .news-hero-actions .btn {
        width: 100%;
        text-align: center;
    }

    .news-feature {
        min-height: 320px;
    }

    .news-feature-body {
        padding: 18px;
    }

    .news-feature h4 {
        font-size: 1.3rem;
    }

    .news-top-side {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }

    .news-side {
        flex-direction: row;
        min-height: 112px;
    }

    .news-side .news-read {
        display: none;
    }

    .news-side .news-cover {
        flex: 0 0 34%;
    }

    .news-side-body {
        padding: 10px 12px;
        gap: 6px;
    }

    .news-side h4 {
        font-size: 0.88rem;
        -webkit-line-clamp: 2;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    /* Compact horizontal cards: image left, text right, no excerpt */
    .news-card {
        flex-direction: row;
    }

    .news-card .news-cover {
        flex: 0 0 34%;
    }

    .news-card-body {
        padding: 10px 12px;
        gap: 6px;
    }

    .news-card h4 {
        font-size: 0.88rem;
    }

    .news-card p,
    .news-card-foot .news-read {
        display: none;
    }

    .news-frame {
        max-height: calc(5 * var(--news-card-h) + 4 * var(--news-gap) + 6px);
    }

    .news-modal {
        padding: 10px;
    }

    .news-modal-head {
        padding: 20px 16px 6px;
    }

    .news-modal-head h2 {
        font-size: 1.25rem;
    }

    .news-modal-media {
        padding: 12px 16px 0;
    }

    .news-modal-text {
        padding: 14px 16px 24px;
    }
}

/* ══ Admin News editor ═════════════════════════════════════════════════ */

.news-admin-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 26px;
}

.news-admin-form .form-group input[type="text"],
.news-admin-form .form-group textarea {
    width: 100%;
    box-sizing: border-box;
}

.news-admin-form textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.6;
}

.news-md-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.news-md-toolbar button {
    padding: 4px 12px;
    min-width: 36px;
    font-size: 0.82rem;
}

.news-md-toolbar .news-md-spacer {
    flex: 1;
}

.news-md-toolbar button.active {
    box-shadow: var(--focus-ring);
}

.news-md-preview {
    min-height: 220px;
    padding: 16px 18px;
    background: var(--bg-1);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-md);
    color: var(--text-2);
    line-height: 1.75;
}

.news-md-preview p {
    margin: 0 0 1em;
    overflow-wrap: anywhere;
}

.news-admin-hint {
    font-size: 0.78rem;
    color: var(--text-3);
    margin: 0;
}

.news-admin-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.news-admin-row input[type="text"] {
    flex: 1 1 260px;
}

.news-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.news-thumb {
    position: relative;
    width: 110px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-2);
}

.news-thumb img,
.news-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.news-thumb .news-thumb-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.news-thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}

.news-thumb-remove:hover {
    background: var(--danger);
    transform: none;
    box-shadow: none;
}

.news-thumb.marked {
    opacity: 0.4;
    border-color: var(--danger);
}

.news-link-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.news-link-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    word-break: break-all;
}

.news-link-list button {
    margin-left: auto;
    padding: 2px 10px;
}

.news-progress {
    height: 8px;
    border-radius: 4px;
    background: var(--surface-2);
    overflow: hidden;
    margin-top: 12px;
}

.news-progress > div {
    height: 100%;
    width: 0;
    background: var(--gradient-accent);
    transition: width 0.15s linear;
}

.news-admin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.news-admin-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-md);
}

.news-admin-item .news-thumb {
    flex: 0 0 90px;
    width: 90px;
    height: 64px;
}

.news-admin-item-main {
    flex: 1;
    min-width: 0;
}

.news-admin-item-title {
    color: var(--text-1);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.news-admin-item-sub {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 2px;
}

.news-admin-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 560px) {
    .news-admin-item {
        flex-wrap: wrap;
    }

    .news-admin-item-actions {
        width: 100%;
    }
}
