/* =====================================================================
   Newsworthy - printable documents
   ---------------------------------------------------------------------
   Deliberately NOT the application's dark theme. These pages exist to be
   printed, filed and attached to emails, and a dark newsroom UI on paper
   is a waste of toner and an unreadable photocopy. Black on white, one
   serif stack, and a layout that behaves at A4 and Letter alike.
   ===================================================================== */

:root {
    --ink:        #15181c;
    --ink-soft:   #4a525c;
    --ink-faint:  #767f8a;
    --rule:       #c9cfd6;
    --rule-soft:  #e3e7eb;
    --accent:     #b0342a;
    --paper:      #ffffff;

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono:  ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

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

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

body {
    margin: 0;
    padding: 2rem 1rem 4rem;
    background: #eef1f4;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 15px;
    line-height: 1.55;
}

/* The sheet. 21cm is A4's width; Letter is wider, so this fits both. */
.sheet {
    max-width: 21cm;
    margin: 0 auto;
    padding: 2.5cm 2.2cm;
    background: var(--paper);
    box-shadow: 0 2px 16px rgba(0, 0, 0, .14);
}

/* ---------------------------------------------------------- Letterhead */

.doc-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--ink);
    margin-bottom: 1.5rem;
}

.doc-mark {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-family: var(--sans);
    font-weight: 700; font-size: 24px;
    display: grid; place-items: center;
}

.doc-issuer { flex: 1; min-width: 0; }
.doc-issuer b {
    display: block;
    font-family: var(--sans);
    font-size: 15px; font-weight: 700; letter-spacing: -.01em;
}
.doc-issuer span {
    display: block;
    font-family: var(--sans);
    font-size: 11px; color: var(--ink-soft); line-height: 1.5;
}

.doc-ref { text-align: right; font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.doc-ref b { display: block; font-size: 13px; color: var(--ink); }

/* ------------------------------------------------------------- Titles */

.doc-title { margin: 0 0 .25rem; font-size: 1.6rem; line-height: 1.15; letter-spacing: -.01em; }
.doc-subtitle {
    margin: 0 0 1.75rem;
    font-family: var(--sans);
    font-size: 12px; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .08em;
}

h2.doc-section {
    margin: 1.9rem 0 .7rem;
    padding-bottom: .3rem;
    border-bottom: 1px solid var(--rule);
    font-family: var(--sans);
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--ink-soft);
}
h2.doc-section:first-of-type { margin-top: 0; }

h3.doc-clause { margin: 1.1rem 0 .3rem; font-size: 1rem; }

/* -------------------------------------------------------- The parties */

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: .5rem; }

.party { border: 1px solid var(--rule); padding: .8rem .9rem; }
.party .role {
    font-family: var(--sans);
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
    color: var(--accent); margin-bottom: .3rem;
}
.party .name { font-weight: 700; font-size: 1.02rem; }
.party .line { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }

/* ---------------------------------------------------------- Key/value */

.doc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.doc-table th, .doc-table td {
    text-align: left; vertical-align: top;
    padding: .42rem .6rem .42rem 0;
    border-bottom: 1px solid var(--rule-soft);
}
.doc-table th {
    width: 34%;
    font-family: var(--sans);
    font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .05em;
    white-space: nowrap;
}
.doc-table tr:last-child th, .doc-table tr:last-child td { border-bottom: 0; }
.doc-table .mono { font-family: var(--mono); font-size: 12px; }

/* Wide data tables - the download log, a payout's sales. */
.doc-grid { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 11.5px; }
.doc-grid th, .doc-grid td { padding: .35rem .5rem; border-bottom: 1px solid var(--rule-soft); text-align: left; }
.doc-grid thead th {
    border-bottom: 1px solid var(--rule);
    font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
}
.doc-grid .num { text-align: right; font-family: var(--mono); white-space: nowrap; }

/* ------------------------------------------------------- The headline */

.doc-amount {
    display: flex; align-items: baseline; gap: .6rem;
    margin: .3rem 0 1.1rem;
    padding: .8rem 1rem;
    background: #f6f7f9;
    border-left: 3px solid var(--accent);
}
.doc-amount b { font-size: 1.5rem; font-family: var(--sans); letter-spacing: -.02em; }
.doc-amount span { font-family: var(--sans); font-size: 11.5px; color: var(--ink-soft); }

/* ------------------------------------------------------------- Clauses */

.doc-terms { margin: 0; padding-left: 1.2rem; }
.doc-terms li { margin-bottom: .55rem; }
.doc-terms li strong { font-weight: 700; }

.doc-note {
    margin: 1.1rem 0;
    padding: .7rem .9rem;
    border: 1px solid var(--rule);
    background: #fbfbfc;
    font-size: 12.5px; line-height: 1.55;
}
.doc-note strong { font-weight: 700; }

.doc-warn {
    border-color: #d8b26a;
    background: #fdf8ee;
}

/* --------------------------------------------------- Execution block */

/* These agreements are concluded by clicking, not by signing, so the
   block records the evidence of assent rather than pretending there is
   a signature. Saying so is more honest than an empty ruled line - and
   more useful if the document is ever relied on. */
.execution { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
.execution .block { border-top: 1px solid var(--ink); padding-top: .5rem; }
.execution .who { font-weight: 700; font-size: 13.5px; }
.execution .how { font-family: var(--sans); font-size: 11px; color: var(--ink-soft); line-height: 1.5; }
.execution .stamp { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }

/* ------------------------------------------------------------- Footer */

.doc-foot {
    margin-top: 2.2rem;
    padding-top: .8rem;
    border-top: 1px solid var(--rule);
    font-family: var(--sans);
    font-size: 10.5px; color: var(--ink-faint); line-height: 1.6;
}
.doc-foot b { color: var(--ink-soft); }

.doc-status {
    display: inline-block;
    font-family: var(--sans);
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    padding: .16rem .45rem; border: 1px solid; border-radius: 3px;
    vertical-align: middle;
}
.status-live    { color: #1f7a4d; border-color: #1f7a4d; background: #eef8f2; }
.status-ended   { color: var(--ink-faint); border-color: var(--rule); background: #f6f7f9; }
.status-pending { color: #8a6416; border-color: #c9a441; background: #fdf8ee; }
.status-void    { color: var(--accent); border-color: var(--accent); background: #fdf1f0; }

/* ----------------------------------------------------- Screen actions */

.doc-actions {
    max-width: 21cm;
    margin: 0 auto 1rem;
    display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
    font-family: var(--sans); font-size: 13px;
}
.doc-actions .spacer { margin-left: auto; }

.doc-btn {
    font-family: var(--sans);
    font-size: 13px; font-weight: 600;
    padding: .45rem .9rem;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: #fff; color: var(--ink);
    cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; gap: .35rem;
}
.doc-btn:hover { border-color: var(--ink-soft); }
.doc-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.doc-btn-primary:hover { background: #8e2a22; border-color: #8e2a22; color: #fff; }

/* ============================================================== PRINT */

@page {
    size: A4;
    /* The sheet supplies its own margin so the letterhead can sit where
       it does on screen; this is the printer's unprintable-edge safety. */
    margin: 14mm;
}

@media print {
    body { background: #fff; padding: 0; font-size: 11.5pt; }

    .sheet { max-width: none; margin: 0; padding: 0; box-shadow: none; }

    /* The toolbar is for the screen. Nobody needs a "Print" button on
       the paper they are already holding. */
    .doc-actions, .no-print { display: none !important; }

    a { color: inherit; text-decoration: none; }

    /* A URL is only worth spelling out when it is not already readable
       in the text, so the qualified links say so and the rest do not. */
    a.print-url::after {
        content: " (" attr(href) ")";
        font-family: var(--mono); font-size: 9pt; color: var(--ink-faint);
        word-break: break-all;
    }

    h2.doc-section, h3.doc-clause { break-after: avoid-page; }
    .party, .doc-note, .doc-amount, .execution .block { break-inside: avoid; }
    .doc-grid tr { break-inside: avoid; }
    thead { display: table-header-group; }

    .doc-foot { break-inside: avoid; }
}

@media (max-width: 640px) {
    body { padding: .75rem .5rem 2rem; }
    .sheet { padding: 1.2rem 1rem; }
    .parties, .execution { grid-template-columns: 1fr; }
    .doc-head { flex-wrap: wrap; }
    .doc-ref { text-align: left; width: 100%; }
}
