/* ============================================================
   The Daily Spark — bright, blue-toned theme
   ============================================================ */
:root {
    --blue-900: #0b2a6b;
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --blue-300: #93c5fd;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;
    --cyan:     #06b6d4;
    --sky:      #0ea5e9;
    --amber:    #f59e0b;
    --green:    #16a34a;
    --red:      #dc2626;
    --ink:      #0f172a;
    --muted:    #64748b;
    --line:     #e2e8f0;
    --white:    #ffffff;
    --radius:   14px;
    --shadow:   0 6px 24px rgba(37, 99, 235, .12);
    --grad:     linear-gradient(120deg, var(--blue-600), var(--cyan));
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--blue-50);
    line-height: 1.6;
}
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: .85rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; cursor: pointer;
    padding: .5rem .9rem; border-radius: 10px;
    border: 1px solid var(--blue-300); background: var(--white);
    color: var(--blue-700); font-weight: 600; font-size: .9rem;
    transition: transform .05s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; border: none; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-warn { color: var(--red); border-color: #fecaca; }

/* ---------- Pills ---------- */
.pill {
    display: inline-block; padding: .12rem .55rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    background: var(--blue-100); color: var(--blue-700);
}
.pill-queued      { background: #e0e7ff; color: #4338ca; }
.pill-gathering,
.pill-writing,
.pill-illustrating{ background: #cffafe; color: #0e7490; }
.pill-ready       { background: #dcfce7; color: #166534; }
.pill-published   { background: var(--grad); color: #fff; }
.pill-failed      { background: #fee2e2; color: #991b1b; }
.pill-category    { background: var(--blue-100); color: var(--blue-700); }
.pill-oneoff      { background: #fef3c7; color: #92400e; }

/* ============================================================
   ADMIN
   ============================================================ */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .8rem 1.5rem; background: var(--grad); color: #fff;
    box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 1.2rem; }
.brand span { opacity: .8; font-weight: 500; }
.topbar nav a { color: #fff; margin-left: 1.1rem; font-weight: 600; opacity: .92; }
.topbar nav a:hover { opacity: 1; text-decoration: none; }
.topbar nav a.muted { opacity: .7; }

.wrap { max-width: 1040px; margin: 2rem auto; padding: 0 1.25rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
.head-actions { display: flex; align-items: center; gap: .6rem; }
.head-actions form { margin: 0; }

.card {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow);
    margin-bottom: 1.2rem;
}
.card.success { border-color: #bbf7d0; }
.card.error-card { border-color: #fecaca; }
.card.error-card pre { white-space: pre-wrap; color: var(--red); }
.empty { padding: 2.5rem; text-align: center; color: var(--muted);
    background: var(--white); border-radius: var(--radius); border: 1px dashed var(--blue-300); }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--white);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--blue-50); color: var(--blue-900); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: none; }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: .25rem; }
.err-msg { color: var(--red); font-size: .75rem; margin-top: .25rem; }

/* Forms */
.form label { display: block; margin-bottom: 1rem; font-weight: 600; color: var(--blue-900); }
.form input[type=text], .form input[type=password], .form select, .form textarea {
    display: block; width: 100%; margin-top: .35rem; padding: .6rem .7rem;
    border: 1px solid var(--blue-300); border-radius: 10px; font: inherit; background: #fbfdff;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-100);
}
.check { font-weight: 600; }
.inline-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 180px; margin-top: 0; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1.2rem; }
.tab { padding: .5rem .9rem; border: 1px solid var(--blue-300); border-radius: 10px;
    cursor: pointer; font-weight: 600; background: #fbfdff; }
.tab input { margin-right: .4rem; }

.actions { display: flex; gap: .6rem; margin-top: 1rem; }

/* Review screen */
.review-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.2rem; }

/* Tabbed body editor (Visual / HTML / Preview) */
.editor-block { margin: 1rem 0; }
.editor-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.field-label { font-weight: 600; color: var(--blue-900); }
.editor-tabs { display: inline-flex; background: var(--blue-50); border: 1px solid var(--blue-300); border-radius: 10px; padding: 3px; }
.etab { border: none; background: transparent; padding: .35rem .8rem; border-radius: 8px; font: inherit; font-weight: 600; font-size: .85rem; color: var(--blue-700); cursor: pointer; }
.etab:hover { background: var(--blue-100); }
.etab.active { background: var(--grad); color: #fff; }
.editor-pane[hidden] { display: none; }

/* Visual editor (Quill) */
#editor { background: #fff; border-radius: 0 0 10px 10px; }
.ql-toolbar.ql-snow { border-color: var(--blue-300); border-radius: 10px 10px 0 0; background: var(--blue-50); }
.ql-container.ql-snow { border-color: var(--blue-300); border-radius: 0 0 10px 10px; min-height: 480px; font-family: inherit; font-size: 1.04rem; }
.ql-editor { min-height: 480px; }

/* Raw HTML box */
.code-box { width: 100%; min-height: 520px; resize: vertical; padding: 1rem; line-height: 1.5;
    border: 1px solid var(--blue-300); border-radius: 10px; background: #0f172a; color: #e2e8f0; }
.code-box:focus { outline: none; box-shadow: 0 0 0 3px var(--blue-100); }

/* Live preview box */
.preview-box { min-height: 480px; padding: 1.4rem 1.6rem; background: #fff;
    border: 1px solid var(--blue-300); border-radius: 10px; overflow: auto; }
.preview-box:empty::before { content: "Nothing to preview yet."; color: var(--muted); }
.review-side .card h3 { margin-top: 0; color: var(--blue-900); }
.preview-img { width: 100%; border-radius: 10px; }
.src-list { padding-left: 1.1rem; margin: 0; }
.src-list li { margin-bottom: .4rem; }
.success-banner { background: #dcfce7; color: #166534; padding: .7rem 1rem; border-radius: 10px; font-weight: 600; }
@media (max-width: 820px) { .review-grid { grid-template-columns: 1fr; } }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--grad); }
.login-card { background: #fff; padding: 2.2rem; border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0,0,0,.25); width: 320px; }
.login-card h1 { margin: 0 0 1.2rem; text-align: center; color: var(--blue-700); }
.login-card h1 span { color: var(--muted); font-weight: 500; }
.login-card input { width: 100%; padding: .7rem; margin-bottom: 1rem; border: 1px solid var(--blue-300); border-radius: 10px; font: inherit; }
.login-card button { width: 100%; padding: .7rem; border: none; border-radius: 10px; background: var(--grad); color: #fff; font-weight: 700; cursor: pointer; }
.error { color: var(--red); font-weight: 600; }

/* ============================================================
   PUBLIC SITE
   ============================================================ */
.site-head { background: var(--grad); color: #fff; padding: 2.5rem 1.5rem; text-align: center; box-shadow: var(--shadow); }
.site-head.slim { padding: 1.2rem; text-align: left; }
.masthead h1 { margin: 0; font-size: 2.4rem; letter-spacing: -.02em; }
.masthead p { margin: .3rem 0 0; opacity: .9; }
.masthead .back { color: #fff; font-weight: 800; font-size: 1.3rem; }

.feed { max-width: 1080px; margin: 2rem auto; padding: 0 1.25rem;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.4rem; }
.card-article { background: #fff; border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .12s ease, box-shadow .12s ease; }
.card-article:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(37,99,235,.2); }
.card-article a { color: inherit; }
.card-article a:hover { text-decoration: none; }
.card-article .thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.card-body { padding: 1.1rem; }
.card-body h2 { margin: .4rem 0 .5rem; font-size: 1.25rem; color: var(--blue-900); }
.card-body p { margin: 0 0 .6rem; color: #334155; }
.card-body time { color: var(--muted); font-size: .8rem; }
.card-article.lead { grid-column: 1 / -1; }
/* The grid lives on the <a>, so image + text sit side-by-side (not stacked). */
.card-article.lead a { display: grid; grid-template-columns: 1.25fr 1fr; align-items: stretch; min-height: 330px; }
.card-article.lead .thumb { height: 100%; }
.card-article.lead .thumb img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; }
.card-article.lead .card-body { display: flex; flex-direction: column; justify-content: center; padding: 1.7rem 2.1rem; }
.card-article.lead h2 { font-size: 1.7rem; margin-top: .35rem; }
.card-article.lead p { font-size: 1.06rem; }
@media (max-width: 720px) {
    .card-article.lead a { grid-template-columns: 1fr; min-height: 0; }
    .card-article.lead .thumb img { aspect-ratio: 16/9; height: auto; }
}

.tag { display: inline-block; background: var(--blue-100); color: var(--blue-700);
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: .15rem .6rem; border-radius: 999px; }

/* Article page */
.article-page { max-width: 740px; margin: 2rem auto; padding: 0 1.25rem; }
.article-page h1 { font-size: 2.2rem; color: var(--blue-900); margin: .6rem 0; }
.article-page .standfirst { font-size: 1.2rem; color: #334155; font-weight: 500; }
.article-page time { color: var(--muted); font-size: .85rem; }
.hero { margin: 1.5rem 0; }
.hero img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.article-body { font-size: 1.08rem; color: #1e293b; }
.article-body h2 { color: var(--blue-800, #1e40af); margin-top: 1.8rem; }
.article-body blockquote { border-left: 4px solid var(--cyan); margin: 1.2rem 0; padding: .3rem 1rem; background: var(--blue-50); border-radius: 0 10px 10px 0; }
.sources { margin-top: 2.5rem; padding-top: 1.2rem; border-top: 2px solid var(--line); }
.sources h3 { color: var(--blue-900); }
.back { font-weight: 600; }
.site-foot { text-align: center; padding: 2rem; color: var(--muted); font-size: .85rem; }
