/*
Theme Name: Upbeat
Theme URI: https://upbeatnews.com
Author: UpbeatNews
Description: Clean, fast, editorial theme for UpbeatNews. Classic PHP templates for precise ad-slot control. Hero card block on the home page, highly readable article pages, no webfont dependencies.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: upbeat
Tags: blog, news, custom-menu, featured-images, accessibility-ready
*/

/* -------------------------------------------------------------------------
   Design tokens
   ------------------------------------------------------------------------- */
:root {
    --ink:        #10171d;
    --ink-soft:   #3d4d5a;
    --muted:      #64757f;
    --line:       #e4e9ed;
    --line-soft:  #eff3f5;
    --bg:         #ffffff;
    --surface:    #f7f9fa;
    --accent:     #0a4ea8;
    --accent-ink: #083b7f;
    --accent-bg:  #eaf1fb;

    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;

    --container: 1180px;
    --measure:   706px;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(16, 23, 29, .06), 0 1px 3px rgba(16, 23, 29, .04);
    --shadow-md: 0 4px 16px rgba(16, 23, 29, .07), 0 1px 3px rgba(16, 23, 29, .05);

    --step: clamp(1rem, 0.5vw + 0.9rem, 1.125rem);
}

/* -------------------------------------------------------------------------
   Reset
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--step);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, picture, video, svg { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

h1, h2, h3, h4 {
    font-family: var(--font-sans);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 .5em;
    font-weight: 700;
    color: var(--ink);
}

/* -------------------------------------------------------------------------
   Utilities
   ------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: 20px;
}

.screen-reader-text {
    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: -9999px;
    top: 0;
    z-index: 999;
    padding: 12px 20px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* -------------------------------------------------------------------------
   Header
   ------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 66px;
}

.site-brand {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}
.site-brand:hover { color: var(--accent); }
.site-brand .brand-dot { color: var(--accent); }

.custom-logo-link { display: block; }
.custom-logo { max-height: 44px; width: auto; }

.site-tagline {
    margin: 0;
    font-size: .8rem;
    color: var(--muted);
    border-left: 1px solid var(--line);
    padding-left: 16px;
}

.primary-nav { margin-left: auto; }
.primary-nav ul {
    display: flex;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}
.primary-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
}
.primary-nav a:hover,
.primary-nav .current-menu-item > a,
.primary-nav .current-cat > a {
    background: var(--accent-bg);
    color: var(--accent-ink);
}

.nav-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
}
.nav-toggle:hover { background: var(--surface); }

@media (max-width: 900px) {
    .site-tagline { display: none; }
    .nav-toggle { display: block; }
    .primary-nav {
        display: none;
        width: 100%;
        order: 3;
        padding-bottom: 14px;
        margin-left: 0;
    }
    .primary-nav.is-open { display: block; }
    .primary-nav ul { flex-direction: column; gap: 2px; }
    .header-inner { flex-wrap: wrap; }
}

/* -------------------------------------------------------------------------
   Page scaffolding
   ------------------------------------------------------------------------- */
.site-main { padding-block: 40px 64px; }

.section-head {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin: 0 0 22px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ink);
}
.section-head h2 {
    margin: 0;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: .07em;
}
.section-head .section-note {
    margin: 0 0 0 auto;
    font-size: .85rem;
    color: var(--muted);
}

.eyebrow {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 8px;
}
.eyebrow:hover { color: var(--accent-ink); text-decoration: underline; }

.entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: .82rem;
    color: var(--muted);
}
.entry-meta .dot {
    width: 3px; height: 3px;
    border-radius: 50%;
    background: var(--muted);
    flex: none;
}

/* -------------------------------------------------------------------------
   Hero: three featured cards
   ------------------------------------------------------------------------- */
.hero {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    margin-bottom: 52px;
}

.hero-card {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.hero-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #d4dde4;
}

.hero-card .thumb {
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--surface);
    overflow: hidden;
}
.hero-card .thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}
.hero-card:hover .thumb img { transform: scale(1.03); }

.hero-card .card-body {
    padding: 18px 20px 22px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.hero-card h3 {
    font-size: 1.13rem;
    line-height: 1.3;
    margin: 0 0 10px;
}
.hero-card h3 a { color: var(--ink); text-decoration: none; }
.hero-card h3 a:hover { color: var(--accent); }
.hero-card .excerpt {
    margin: 0 0 16px;
    font-size: .93rem;
    color: var(--ink-soft);
    line-height: 1.6;
}
.hero-card .entry-meta { margin-top: auto; }

@media (max-width: 980px) {
    .hero { grid-template-columns: repeat(2, 1fr); }
    .hero-card:first-child { grid-column: 1 / -1; }
    .hero-card:first-child .thumb { aspect-ratio: 21 / 9; }
    .hero-card:first-child h3 { font-size: 1.45rem; }
}
@media (max-width: 640px) {
    .hero { grid-template-columns: 1fr; gap: 18px; margin-bottom: 40px; }
    .hero-card:first-child { grid-column: auto; }
    .hero-card:first-child .thumb { aspect-ratio: 16 / 9; }
    .hero-card:first-child h3 { font-size: 1.2rem; }
}

/* -------------------------------------------------------------------------
   Post list rows
   ------------------------------------------------------------------------- */
.post-list { display: flex; flex-direction: column; }

.post-row {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 26px;
    padding: 26px 0;
    border-bottom: 1px solid var(--line-soft);
    align-items: start;
}
.post-row:first-child { padding-top: 6px; }

.post-row .thumb {
    display: block;
    aspect-ratio: 16 / 10;
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
}
.post-row .thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}
.post-row:hover .thumb img { transform: scale(1.03); }

.post-row h2 {
    font-size: 1.3rem;
    line-height: 1.28;
    margin: 6px 0 10px;
}
.post-row h2 a { color: var(--ink); text-decoration: none; }
.post-row h2 a:hover { color: var(--accent); }

.post-row .excerpt {
    margin: 0 0 12px;
    color: var(--ink-soft);
    font-size: .97rem;
}

.thumb.is-placeholder {
    display: grid;
    place-items: center;
    color: #9fb0bb;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-decoration: none;
}

@media (max-width: 760px) {
    .post-row { grid-template-columns: 1fr; gap: 14px; }
    .post-row h2 { font-size: 1.16rem; }
}

/* -------------------------------------------------------------------------
   Single post
   ------------------------------------------------------------------------- */
.article-head {
    max-width: var(--measure);
    margin: 0 auto 28px;
}
.article-head h1 {
    font-size: clamp(1.9rem, 1rem + 2.6vw, 2.7rem);
    line-height: 1.14;
    margin: 0 0 16px;
}
.article-standfirst {
    font-family: var(--font-serif);
    font-size: 1.19rem;
    line-height: 1.6;
    color: var(--ink-soft);
    margin: 0 0 18px;
}

.featured-media {
    margin: 0 auto 36px;
    max-width: 980px;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
}
.featured-media img { width: 100%; }
.featured-media figcaption {
    padding: 10px 16px;
    font-size: .82rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.entry-content {
    max-width: var(--measure);
    margin-inline: auto;
    font-family: var(--font-serif);
    font-size: 1.14rem;
    line-height: 1.78;
    color: #1b2630;
}
.entry-content > * + * { margin-top: 1.25em; }
.entry-content p { margin: 0; }

.entry-content h2 {
    font-family: var(--font-sans);
    font-size: 1.48rem;
    line-height: 1.25;
    margin-top: 2.1em;
    margin-bottom: .6em;
}
.entry-content h3 {
    font-family: var(--font-sans);
    font-size: 1.17rem;
    margin-top: 1.7em;
    margin-bottom: .5em;
}

.entry-content ul, .entry-content ol { padding-left: 1.4em; margin-top: 1.1em; }
.entry-content li + li { margin-top: .5em; }

.entry-content a { font-weight: 500; }

.entry-content blockquote {
    margin: 1.8em 0;
    padding: 4px 0 4px 22px;
    border-left: 3px solid var(--accent);
    color: var(--ink-soft);
    font-style: italic;
}

.entry-content strong { font-weight: 650; color: var(--ink); }
.entry-content img { border-radius: var(--r-md); margin-block: 1.6em; }

.entry-footer {
    max-width: var(--measure);
    margin: 48px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}
.tag-list {
    display: flex; flex-wrap: wrap; gap: 8px;
    list-style: none; padding: 0; margin: 0;
}
.tag-list a {
    display: inline-block;
    padding: 5px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .82rem;
    color: var(--ink-soft);
    text-decoration: none;
}
.tag-list a:hover { background: var(--accent-bg); border-color: #cddcf2; color: var(--accent-ink); }

.related {
    margin-top: 64px;
    padding-top: 8px;
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}
@media (max-width: 900px) { .related-grid { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------------
   Ad slots
   ------------------------------------------------------------------------- */
.ad-slot {
    margin: 36px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}
.ad-slot--header { margin: 18px auto 0; }
.ad-slot--in-article,
.ad-slot--article-end { max-width: var(--measure); }
.ad-slot--in-feed { margin-block: 14px; }

.ad-slot__label {
    display: block;
    font-size: .63rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #9aa9b3;
    margin-bottom: 6px;
}

.ad-debug .ad-slot {
    outline: 2px dashed #c0392b;
    outline-offset: 4px;
    min-height: 110px;
    background: repeating-linear-gradient(45deg, #fff, #fff 10px, #fdf1f0 10px, #fdf1f0 20px);
}
.ad-debug .ad-slot::after {
    content: "slot: " attr(data-slot-id);
    font-size: .72rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #c0392b;
    font-weight: 700;
}

/* -------------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------------- */
.pagination { margin-top: 44px; }
.pagination .nav-links {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.pagination .page-numbers {
    display: inline-block;
    min-width: 42px;
    padding: 9px 12px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: .92rem;
}
.pagination .page-numbers:hover { background: var(--surface); }
.pagination .page-numbers.current {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}
.pagination .screen-reader-text { position: absolute !important; }

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */
.site-footer {
    margin-top: 72px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-block: 44px 32px;
    font-size: .92rem;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: 36px;
    margin-bottom: 32px;
}
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr; gap: 26px; } }

.site-footer h3 {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    margin-bottom: 12px;
}
.site-footer p { color: var(--ink-soft); margin: 0 0 10px; max-width: 46ch; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li + li { margin-top: 8px; }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

.footer-bottom {
    padding-top: 22px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    color: var(--muted);
    font-size: .85rem;
}
.footer-bottom .sep { margin-left: auto; }
@media (max-width: 800px) { .footer-bottom .sep { margin-left: 0; } }

/* -------------------------------------------------------------------------
   Search / archive / 404 / page
   ------------------------------------------------------------------------- */
.page-hero {
    padding: 8px 0 30px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 30px;
}
.page-hero h1 { font-size: clamp(1.6rem, 1rem + 2vw, 2.3rem); margin: 0 0 8px; }
.page-hero p { margin: 0; color: var(--muted); }

.search-form { display: flex; gap: 8px; max-width: 460px; }
.search-form input[type="search"] {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font: inherit;
    font-size: .95rem;
    min-width: 0;
}
.search-form input[type="search"]:focus { border-color: var(--accent); }
.search-form button {
    padding: 11px 18px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--ink);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.search-form button:hover { background: var(--accent-ink); }

.notice {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink-soft);
}

.page-content {
    max-width: var(--measure);
    margin-inline: auto;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.75;
}
.page-content > * + * { margin-top: 1.2em; }

/* -------------------------------------------------------------------------
   Print
   ------------------------------------------------------------------------- */
@media print {
    .site-header, .site-footer, .ad-slot, .related, .pagination, .skip-link { display: none !important; }
    .entry-content { max-width: none; font-size: 11pt; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}
