/* ===========================================================================
 * Sound of Joy Voices — supplemental styles
 * ---------------------------------------------------------------------------
 * Tailwind does the heavy lifting (loaded from the CDN in the layouts). This
 * file only holds the few things a utility class cannot express: focus rings
 * for the whole app, print rules and small component tweaks.
 * =========================================================================== */

:root {
    --brand-900: #312e81;
    --brand-800: #3730a3;
    --gold-500:  #f5b301;
}

/* ---------------------------------------------------------------------------
 * The hidden attribute must win.
 * ---------------------------------------------------------------------------
 * The browser's own [hidden] { display: none } lives in the user-agent origin,
 * so ANY author declaration beats it — including a Tailwind utility like
 * .flex or .grid sitting on the same element. Without this rule an element
 * written as <div hidden class="grid …"> is rendered anyway. That is not
 * theoretical: it left the scanner's aiming overlay washing out the camera
 * card before the camera had started, and pinned the "n selected" bar open on
 * the registrations list.
 * ------------------------------------------------------------------------- */
[hidden] { display: none !important; }

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

body { text-rendering: optimizeLegibility; }

/* Consistent, visible focus for keyboard users everywhere. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--brand-800);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Applied by app.js to inputs that failed server-side validation. */
.field-invalid {
    border-color: #e11d48 !important;
    box-shadow: 0 0 0 1px rgba(225, 29, 72, 0.25);
}

/* Truncation helpers (Tailwind's line-clamp plugin is not on the CDN build). */
.line-clamp-1,
.line-clamp-2,
.line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-1 { -webkit-line-clamp: 1; }
.line-clamp-2 { -webkit-line-clamp: 2; }
.line-clamp-3 { -webkit-line-clamp: 3; }

/* SweetAlert restyled to match the ministry palette. */
.swal2-popup { border-radius: 1rem; font-family: Inter, system-ui, sans-serif; }
.swal2-title { font-size: 1.15rem; font-weight: 600; color: #0f172a; }
.swal2-html-container { font-size: .925rem; color: #475569; }
.swal2-styled.swal2-confirm { border-radius: .625rem; font-weight: 600; }
.swal2-styled.swal2-cancel  { border-radius: .625rem; font-weight: 600; }
.swal2-toast { border-radius: .875rem; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); }

/* Tables scroll horizontally on small screens instead of breaking the layout. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Skeleton shimmer used while Ajax content loads. */
@media (prefers-reduced-motion: reduce) {
    .animate-pulse, .animate-spin { animation: none !important; }
    html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------------------
 * Print
 * ---------------------------------------------------------------------------
 * Every dashboard list is printable. On screen the letterhead is hidden and
 * the interface is shown; on paper the reverse. The goal is a sheet that can
 * be handed to a trustee or filed after a programme without anyone being able
 * to tell it came out of a browser.
 * ------------------------------------------------------------------------- */

/* Hidden on screen, revealed on paper. */
.print-only { display: none !important; }

@media print {
    @page {
        size: A4 portrait;
        margin: 14mm 12mm 16mm;
    }

    /* Chrome ignores background colours unless asked; without this the table
       header band and the status pills print as empty white boxes. */
    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        background: #fff !important;
        color: #0f172a;
        font-size: 9.5pt;
        line-height: 1.35;
    }

    /* The dashboard chrome goes away: sidebar, top bar, footer, filter forms,
       pagination, buttons and anything explicitly opted out. */
    #admin-sidebar,
    body > div > div > header,
    footer,
    nav,
    .no-print { display: none !important; }

    main { padding: 0 !important; }

    .print-only { display: block !important; }
    th.print-only, td.print-only { display: table-cell !important; }

    /* Cards lose their screen decoration so the paper is not full of boxes. */
    .rounded-2xl, .rounded-xl, .rounded-lg {
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .bg-white, .bg-slate-50, .bg-slate-100 { background: #fff !important; }

    .print-block,
    .table-scroll {
        border: 0 !important;
        overflow: visible !important;
    }

    /* ---- Letterhead ---- */
    .print-letterhead { margin-bottom: 10pt; }

    .print-letterhead__brand {
        display: flex;
        align-items: center;
        gap: 10pt;
        border-bottom: 1.5pt solid #312e81;
        padding-bottom: 7pt;
    }

    .print-letterhead__brand img { height: 46pt; width: auto; }

    .print-letterhead__ministry {
        font-size: 13pt;
        font-weight: 700;
        color: #312e81;
        letter-spacing: .01em;
    }

    .print-letterhead__alias { font-size: 8pt; font-style: italic; color: #475569; }

    .print-letterhead__address { margin-top: 2pt; font-size: 7.5pt; color: #475569; }

    .print-letterhead__title { margin-top: 9pt; }
    .print-letterhead__title h1 { font-size: 12pt; font-weight: 700; color: #0f172a; }
    .print-letterhead__title p  { font-size: 9pt; color: #475569; }

    .print-letterhead__filters { margin-top: 4pt; font-size: 8pt; color: #475569; }

    .print-letterhead__meta {
        display: flex;
        flex-wrap: wrap;
        gap: 4pt 14pt;
        margin-top: 6pt;
        padding: 4pt 0;
        border-top: .5pt solid #cbd5e1;
        border-bottom: .5pt solid #cbd5e1;
        font-size: 8pt;
        color: #334155;
    }

    .print-letterhead__stamp { margin-left: auto; color: #64748b; }

    /* ---- Tables ---- */
    table { width: 100%; border-collapse: collapse; }

    thead { display: table-header-group; }   /* repeat the header on every page */
    tfoot { display: table-footer-group; }
    tr    { page-break-inside: avoid; }

    th, td {
        border: .5pt solid #cbd5e1;
        padding: 2.5pt 4pt;
        vertical-align: top;
        text-align: left;
        /* break-word, not anywhere: a long reference or email still wraps
           rather than pushing the table past the right margin, but ordinary
           words are never split down the middle. */
        overflow-wrap: break-word;
    }

    td { font-size: 8pt; line-height: 1.25; }

    /* The secondary lines under a name — email, reference, category — are
       useful on paper but should not double the height of every row. */
    td .text-xs,
    td .text-\[11px\],
    td .block { font-size: 6.5pt; line-height: 1.2; }

    th {
        background: #eef2ff !important;
        color: #312e81 !important;
        font-size: 7pt;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .02em;
        white-space: nowrap;     /* a column heading never splits mid-word */
        overflow-wrap: normal;
    }

    /* Sort arrows are meaningless on paper. */
    th a { color: inherit !important; text-decoration: none; }
    th a span { display: none !important; }

    /* Status pills flatten into small tags — and never wrap, so "Confirmed"
       does not come out as "Confirm / ed". */
    .rounded-full {
        display: inline-block;
        border-radius: 2pt !important;
        padding: 1pt 3pt !important;
        font-size: 6.5pt !important;
        white-space: nowrap;
    }

    /* Dates and money read as single units. */
    td > .text-slate-500,
    td .font-mono { white-space: nowrap; }

    /* Signature columns need room to actually sign in. */
    td.print-only { min-width: 90pt; height: 22pt; }

    img { max-width: 100%; }

    /* Links print as their text, not as a page full of URLs. */
    a[href]::after { content: "" !important; }

    /* Keep a heading with the rows it introduces. */
    h1, h2, h3 { page-break-after: avoid; }
}
