/* policies.css — diff views, active-tab marker, summary prose tweaks.
 * Loaded after tailwind.js so utility-class specificity is fine.
 */

/* ── Nav: active-tab marker ───────────────────────────────────────── */

.nav-link {
    color: #3a3a3f;           /* ink-700 */
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: color 0.1s, border-color 0.1s;
}
.nav-link:hover {
    color: #c94907;           /* accent-600 */
}
.nav-link-active {
    color: #0f0f12;           /* ink-900 */
    font-weight: 600;
    border-bottom-color: #c94907;
}
.nav-link-active:hover {
    color: #9a3a07;           /* accent-700 */
}

/* ── Diff view toggle (segmented control) ─────────────────────────── */

.diff-view-toggle {
    display: inline-flex;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 12px;
    font-size: 13px;
}
.diff-view-toggle button {
    padding: 5px 12px;
    background: white;
    color: #3a3a3f;
    border: none;
    border-right: 1px solid #cbd5e1;
    cursor: pointer;
    font-family: inherit;
}
.diff-view-toggle button:last-child { border-right: none; }
.diff-view-toggle button:hover { background: #f8fafc; }
.diff-view-toggle button[aria-selected="true"] {
    background: #c94907;
    color: white;
    font-weight: 600;
}

/* Large-diff banner */
.diff-large-banner {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3a07;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ── Diff: inline (default, word-level prose) ─────────────────────── */

.diff-inline {
    font-size: 14.5px;
    line-height: 1.6;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 16px 18px;
    color: #0f0f12;
}
.diff-inline-hunk {
    /* Tighten spacing between hunks; the <br> tags inside preserve
       paragraph shape so we don't need extra block margins. */
}
.diff-inline ins {
    background: #d1fae5;
    color: #065f46;
    text-decoration: underline;
    text-decoration-color: #10b981;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    padding: 0 1px;
    border-radius: 2px;
}
.diff-inline del {
    background: #fee2e2;
    color: #7f1d1d;
    text-decoration: line-through;
    text-decoration-color: #ef4444;
    padding: 0 1px;
    border-radius: 2px;
}
.diff-hunk-sep {
    border: none;
    border-top: 1px dashed #e2e8f0;
    margin: 14px 0;
}

/* ── Diff: line-by-line (tidied unified diff) ─────────────────────── */

.diff-line {
    font-family: ui-monospace, SFMono-Regular, "Menlo", "Consolas", monospace;
    font-size: 13px;
    line-height: 1.25;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    overflow-x: auto;
    padding: 6px 0;
}
.diff-line-hunk + .diff-line-hunk { border-top: 1px solid #e5e7eb; margin-top: 6px; padding-top: 6px; }
.diff-line-hunk-header {
    color: #475569;
    background: #f1f5f9;
    font-weight: 600;
    padding: 2px 12px;
    font-size: 12px;
}
.diff-line-rows { padding: 4px 0; }
.diff-line-rows > div {
    white-space: pre;
    padding: 0 12px 0 14px;
    border-left: 3px solid transparent;
}
.diff-line-add { background: #ecfdf5; border-left-color: #10b981 !important; color: #065f46; }
.diff-line-del { background: #fef2f2; border-left-color: #ef4444 !important; color: #7f1d1d; }
.diff-line-ctx { color: #525258; }
.diff-line-gap {
    color: #94a3b8;
    text-align: center;
    background: #f8fafc;
    padding: 2px 0;
    font-size: 11px;
    user-select: none;
}

/* ── Diff: side-by-side (paragraph-aligned two columns) ───────────── */

.diff-side {
    font-size: 13.5px;
    line-height: 1.5;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.diff-side-headers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.diff-side-headers > span {
    padding: 6px 14px;
    border-right: 1px solid #e2e8f0;
}
.diff-side-headers > span:last-child { border-right: none; }
.diff-side-hunk + .diff-side-hunk { border-top: 1px dashed #e2e8f0; margin-top: 8px; padding-top: 8px; }
.diff-side-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px dotted #f1f5f9;
}
.diff-side-cell {
    padding: 6px 14px;
    border-right: 1px solid #f1f5f9;
    overflow-wrap: anywhere;
}
.diff-side-cell:last-child { border-right: none; }
.diff-side-cell ins { background: #d1fae5; color: #065f46; padding: 0 2px; border-radius: 2px; }
.diff-side-cell del { background: #fee2e2; color: #7f1d1d; padding: 0 2px; border-radius: 2px; text-decoration: line-through; }
.diff-side-empty { background: repeating-linear-gradient(135deg, #f8fafc, #f8fafc 6px, #f1f5f9 6px, #f1f5f9 7px); min-height: 28px; }
.diff-side-changed { background: #fffbf0; }

/* Stack columns below 768px for narrow viewports (brief Section 2). */
@media (max-width: 767px) {
    .diff-side-headers { display: none; }
    .diff-side-row {
        display: block;
        border-bottom: 1px dashed #e2e8f0;
        padding: 6px 0;
    }
    .diff-side-cell {
        display: block;
        border-right: none;
        border-bottom: 1px dotted #f1f5f9;
    }
    .diff-side-cell:last-child { border-bottom: none; }
    .diff-side-cell::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #94a3b8;
        margin-bottom: 2px;
    }
    .diff-side-old::before { content: "Old"; }
    .diff-side-new::before { content: "New"; }
}

/* ── Summary body (rendered markdown) — unchanged from v1 ─────────── */

.prose-summary h1,
.prose-summary h2,
.prose-summary h3,
.prose-summary h4 {
    font-family: "Oswald", system-ui, -apple-system, sans-serif;
    font-weight: 600;
    color: #0f0f12;
    margin-top: 1.6em;
    margin-bottom: 0.4em;
    line-height: 1.25;
}
.prose-summary h2 { font-size: 1.25rem; }
.prose-summary h3 { font-size: 1.10rem; }
.prose-summary h4 { font-size: 1.00rem; }
.prose-summary p  { margin: 0.5em 0 0.7em; line-height: 1.55; }
.prose-summary ul,
.prose-summary ol { padding-left: 1.5rem; margin: 0.4em 0 0.8em; }
.prose-summary li { margin: 0.15em 0; line-height: 1.5; }
.prose-summary a  { color: #c94907; text-decoration: underline; text-underline-offset: 2px; }
.prose-summary a:hover { color: #9a3a07; }
.prose-summary code {
    background: #f1f5f9;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* ── Expanders ────────────────────────────────────────────────────── */

.expander[aria-expanded="true"]::after { content: " ▾"; }
.expander[aria-expanded="false"]::after { content: " ▸"; }

@media (max-width: 480px) {
    .feed-entry { padding-top: 1rem; padding-bottom: 1rem; }
}

/* ── /monitored rows + also-monitored section (iteration 6) ───────── */

.monitored-row { font-size: 0.95rem; }

.monitored-status-200,
.monitored-status-301,
.monitored-status-302 {
    background: #ecfdf5;       /* emerald-50 */
    color: #047857;            /* emerald-700 */
    font-size: 11px;
    font-weight: 600;
}
.monitored-status-404,
.monitored-status-410 {
    background: #fef2f2;       /* red-50 */
    color: #b91c1c;            /* red-700 */
    font-size: 11px;
    font-weight: 600;
}
.monitored-status-unknown {
    background: #f1f5f9;       /* slate-100 */
    color: #475569;            /* slate-600 */
    font-size: 11px;
    font-weight: 600;
}

.monitored-failing-badge {
    background: #fef3c7;       /* amber-100 */
    color: #92400e;            /* amber-800 */
    font-weight: 500;
}

.also-monitored-section { scroll-margin-top: 4rem; }

.sort-control { background: white; }

@media (max-width: 480px) {
    .monitored-row { padding: 0.75rem 0; }
}

/* ── Floating "Give feedback" button (iteration 4) ────────────────── */

.feedback-floating-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #c94907;         /* accent-600 */
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(201, 73, 7, 0.30),
                0 2px 4px rgba(0, 0, 0, 0.10);
    transition: background 0.15s, transform 0.15s;
}
.feedback-floating-btn::before {
    content: "💬";
    font-size: 14px;
    line-height: 1;
}
.feedback-floating-btn:hover {
    background: #9a3a07;         /* accent-700 */
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}
.feedback-floating-btn:focus-visible {
    outline: 2px solid #c94907;
    outline-offset: 3px;
}
@media (max-width: 480px) {
    .feedback-floating-btn {
        bottom: 1rem;
        right: 1rem;
        padding: 8px 13px;
        font-size: 13px;
    }
}

/* ── Feedback modal (native <dialog>) ─────────────────────────────── */

/* Scoped to [open] so the modal is hidden until .showModal() sets the
   open attribute. Without this restriction, author CSS competes with the
   UA `dialog:not([open]) { display: none }` rule and the modal appears on
   page load. */
.feedback-modal[open] {
    border: none;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    max-width: 560px;
    width: 92%;
    /* Native <dialog> sets its own positioning; this max-height
       keeps long forms scrollable inside the modal. */
    max-height: calc(100vh - 4rem);
    overflow: hidden;          /* outer; body scrolls internally */
    display: flex;
    flex-direction: column;
    color: #0f0f12;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.feedback-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
}
.feedback-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
}
.feedback-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #65656a;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 3px;
}
.feedback-modal-close:hover { color: #c94907; }
.feedback-modal-body {
    padding: 16px 18px 20px;
    overflow-y: auto;
}
/* On narrow viewports, fill the screen (centred) */
@media (max-width: 600px) {
    .feedback-modal {
        max-width: none;
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
}
/* Body scroll lock when modal is open. JS adds this class. */
body.feedback-modal-open {
    overflow: hidden;
}

/* ── AI summary chip ──────────────────────────────────────────────
   Small, muted label that marks the narrative summary as AI-generated.
   Sits at the top of the narrative block on both the feed entry and
   the permalink page. Grey/neutral by design — must read as secondary
   to the category badge and not crowd the layout at 375px.
   Tooltip / aria-label carries the longer message:
     "AI-generated summary of the gov.uk change. Verify against the
      diff and the original."
*/
.ai-summary-chip {
    display: inline-block;
    vertical-align: 0.075em;          /* aligns visually with following text x-height */
    margin-right: 0.5em;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #65656a;                    /* ink.500 */
    background-color: #f1f5f9;         /* slate-100, lighter than the category badges */
    border: 1px solid #e2e8f0;         /* slate-200 — quiet outline */
    border-radius: 3px;
    cursor: help;
    user-select: none;
    white-space: nowrap;
}

/* One-time global notice at the top of the feed.
   Visible but understated. Does not appear on the permalink. */
.ai-summary-notice {
    font-size: 12px;
    color: #65656a;                    /* ink.500 */
    margin-top: 6px;
}
