/*
 * Candour: the public pages (compose, about, return, sign-in) and the page chrome of the
 * standalone recipient page (app_standalone.blade.php, which loads app.css as well).
 * Served under a strict CSP (style-src 'self'), so every rule lives here: no inline styles.
 *
 * 0.4.0 visual identity: a sealed letter. Calm, confident, a little old-world. One centred column
 * (44rem), a header band (the seal, the word CANDOUR, the page's one-line purpose), one "sheet"
 * card, a muted footer. Every colour goes through the tokens below: light by default, dark under
 * prefers-color-scheme. Serif headings, system sans body at 17px/1.55, mono for codes. No web
 * fonts, no important flags, no animation beyond a 120ms colour transition.
 *
 * Wax (the accent) is used sparingly: the seal and the primary button. Brass carries fingerprints,
 * receipts, recovery codes, eyebrows and the focus ring.
 *
 * Class hooks the page scripts rely on are kept as they were (do not rename): .sn-state, .sn-card
 * (sn-return.js inserts its status line before the first one inside #sn-state-form), .sn-radio,
 * .sn-counter-over, .sn-checklist-clear, .sn-offscreen, .sn-status-line, .sn-msg, .sn-msg-you,
 * .sn-msg-them, .sn-msg-head, .sn-msg-who, .sn-msg-day, .sn-msg-body, .sn-msg-unreadable, and
 * every id and data-* attribute the Blades carry.
 */

/* ---- Tokens ----------------------------------------------------------------------------- */

:root {
    color-scheme: light dark;

    --sn-paper: #F3F1EB;
    --sn-sheet: #FFFFFF;
    --sn-ink: #1B1F24;
    --sn-ink-muted: #5B636B;
    --sn-rule: #DAD6CE;
    --sn-wax: #8E1B2C;
    --sn-wax-soft: #F2E1E3;
    --sn-brass: #8A6A2E;
    --sn-brass-soft: #F1EADB;
    --sn-ok: #2E6B48;
    --sn-warn: #8A6200;
    --sn-shadow: 0 1px 2px rgba(27, 31, 36, 0.06);

    --sn-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sn-sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --sn-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --sn-paper: #0F1418;
        --sn-sheet: #171D23;
        --sn-ink: #E8E6E1;
        --sn-ink-muted: #A2A8AE;
        --sn-rule: #2A3239;
        --sn-wax: #D45A68;
        --sn-wax-soft: #3A1F25;
        --sn-brass: #C9A45C;
        --sn-brass-soft: #2E2718;
        --sn-ok: #6CBF8A;
        --sn-warn: #D9B24A;
        --sn-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    }
}

/* ---- Base ------------------------------------------------------------------------------- */

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

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

html,
body {
    margin: 0;
    padding: 0;
    background: var(--sn-paper);
    color: var(--sn-ink);
    font-family: var(--sn-sans);
    font-size: 17px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.sn-page {
    max-width: 44rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

@media (min-width: 40rem) {
    .sn-page {
        padding-top: 2.5rem;
    }
}

/* ---- Type ------------------------------------------------------------------------------- */

h1,
h2,
h3 {
    font-family: var(--sn-serif);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.005em;
    color: var(--sn-ink);
    text-wrap: balance;
    overflow-wrap: anywhere;
}

h1 {
    margin: 0 0 0.9rem;
    font-size: 1.85rem;
}

h2 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.3rem;
}

h3 {
    margin: 1.25rem 0 0.4rem;
    font-size: 1.1rem;
}

p {
    margin: 0 0 0.9rem;
}

ul,
ol {
    margin: 0 0 0.9rem;
    padding-left: 1.25rem;
}

li {
    margin: 0.2rem 0;
}

a {
    color: var(--sn-ink);
    text-decoration: underline;
    text-decoration-color: var(--sn-brass);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
    transition: color 120ms ease;
}

a:hover {
    color: var(--sn-brass);
}

code,
.sn-mono {
    font-family: var(--sn-mono);
    font-size: 0.92em;
    letter-spacing: 0.04em;
}

.sn-muted {
    color: var(--sn-ink-muted);
}

.sn-small {
    font-size: 0.9rem;
}

/* The one-sentence introduction under a sheet heading. */
.sn-lede {
    margin: 0 0 1.25rem;
    font-size: 1.02rem;
    color: var(--sn-ink-muted);
}

/* Focus is visible everywhere: a 2px brass ring. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--sn-brass);
    outline-offset: 2px;
}

/* ---- Header band: seal, CANDOUR, purpose ------------------------------------------------ */

.sn-masthead {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin: 0 0 1.5rem;
    padding: 0 0 1.1rem;
    border-bottom: 1px solid var(--sn-rule);
}

.sn-seal {
    display: block;
    flex: none;
    width: 40px;
    height: 40px;
    color: var(--sn-wax);
}

.sn-seal-c,
.sn-seal-ring {
    stroke: var(--sn-paper);
}

.sn-masthead-text {
    flex: 1 1 14rem;
    min-width: 0;
}

.sn-eyebrow {
    margin: 0;
    font-family: var(--sn-sans);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sn-ink);
}

.sn-purpose {
    margin: 0.15rem 0 0;
    font-size: 0.95rem;
    color: var(--sn-ink-muted);
}

/* Standalone app only: the signed-in address and Sign out on the right of the band. */
.sn-masthead-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem 0.9rem;
    margin-left: auto;
}

.sn-masthead-email {
    font-size: 0.9rem;
    color: var(--sn-ink-muted);
    overflow-wrap: anywhere;
}

/* ---- The sheet -------------------------------------------------------------------------- */

.sn-card {
    margin: 0 0 1.25rem;
    padding: 2rem;
    background: var(--sn-sheet);
    border: 1px solid var(--sn-rule);
    border-radius: 6px;
    box-shadow: var(--sn-shadow);
}

.sn-card > :last-child {
    margin-bottom: 0;
}

.sn-state h1 {
    margin-top: 0;
}

/* The seal on a success sheet, the tick on the sign-in sent sheet. */
.sn-mark {
    display: flex;
    margin: 0 0 1rem;
}

.sn-tick {
    display: block;
    width: 40px;
    height: 40px;
    color: var(--sn-ok);
}

/* ---- Notices ---------------------------------------------------------------------------- */

.sn-banner {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--sn-ink);
    background: var(--sn-sheet);
    border: 1px solid var(--sn-rule);
    border-left: 3px solid var(--sn-brass);
    border-radius: 6px;
}

.sn-banner p {
    margin: 0 0 0.4rem;
}

.sn-banner p:last-child {
    margin-bottom: 0;
}

.sn-banner-error,
.sn-banner-warn {
    color: var(--sn-warn);
    border-left-color: var(--sn-warn);
}

.sn-banner-error .sn-small {
    color: var(--sn-ink-muted);
}

.sn-error {
    margin: 0 0 1rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    color: var(--sn-warn);
    background: var(--sn-paper);
    border: 1px solid var(--sn-rule);
    border-left: 3px solid var(--sn-warn);
    border-radius: 6px;
}

.sn-status-line {
    margin: 0 0 1rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    color: var(--sn-ok);
    background: var(--sn-paper);
    border: 1px solid var(--sn-rule);
    border-left: 3px solid var(--sn-ok);
    border-radius: 6px;
}

/* ---- Compose: intro and fingerprint chip ------------------------------------------------ */

/* The recipient's intro, set like a short quotation. */
.sn-intro {
    margin: 0 0 1.25rem;
    padding: 0.15rem 0 0.15rem 1rem;
    border-left: 2px solid var(--sn-rule);
    font-family: var(--sn-serif);
    font-size: 1.08rem;
    line-height: 1.5;
    white-space: pre-line;
    overflow-wrap: anywhere;
    color: var(--sn-ink);
}

.sn-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.2rem 0.6rem;
    margin: 0 0 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    color: var(--sn-brass);
    background: var(--sn-brass-soft);
    border-radius: 6px;
}

.sn-chip-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sn-chip code {
    font-size: 0.9rem;
    color: var(--sn-brass);
    overflow-wrap: anywhere;
}

.sn-chip-help {
    margin: 0 0 1.25rem;
}

/* ---- Fields ----------------------------------------------------------------------------- */

.sn-form {
    margin: 0;
}

.sn-field {
    margin: 0 0 1.25rem;
}

.sn-label {
    display: block;
    margin: 0 0 0.3rem;
    font-weight: 600;
}

.sn-hint {
    margin: 0 0 0.55rem;
    font-size: 0.9rem;
    color: var(--sn-ink-muted);
}

.sn-input,
.sn-textarea {
    display: block;
    width: 100%;
    margin: 0;
    padding: 12px;
    font: inherit;
    line-height: 1.5;
    color: var(--sn-ink);
    background: var(--sn-paper);
    border: 1px solid var(--sn-rule);
    border-radius: 6px;
    transition: border-color 120ms ease, background-color 120ms ease;
}

.sn-textarea {
    min-height: 12rem;
    resize: vertical;
}

.sn-textarea-short {
    min-height: 6rem;
}

.sn-input:focus-visible,
.sn-textarea:focus-visible {
    border-color: var(--sn-brass);
    outline: 2px solid var(--sn-brass);
    outline-offset: 1px;
}

.sn-input[readonly],
.sn-textarea[readonly] {
    color: var(--sn-ink-muted);
}

.sn-input-mono {
    font-family: var(--sn-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sn-counter {
    margin: 0.3rem 0 0;
    text-align: right;
    font-size: 0.82rem;
    color: var(--sn-ink-muted);
    font-variant-numeric: tabular-nums;
}

.sn-counter-over {
    color: var(--sn-warn);
    font-weight: 600;
}

/* The optional context field: visually secondary to the note. */
.sn-field-secondary {
    padding: 0.9rem 1rem 0.75rem;
    background: var(--sn-paper);
    border-radius: 6px;
}

.sn-field-secondary .sn-label {
    font-size: 0.95rem;
}

.sn-field-secondary .sn-textarea {
    background: var(--sn-sheet);
}

/* ---- Checklist (identification warnings) ------------------------------------------------ */

.sn-checklist {
    margin: 0 0 1.25rem;
    padding: 0.85rem 1rem 0.6rem;
    font-size: 0.93rem;
    color: var(--sn-warn);
    background: var(--sn-paper);
    border: 1px solid var(--sn-rule);
    border-left: 3px solid var(--sn-warn);
    border-radius: 6px;
}

.sn-checklist-title {
    margin: 0 0 0.35rem;
    font-weight: 600;
}

.sn-checklist ul {
    margin: 0 0 0.5rem;
}

.sn-checklist-note {
    margin: 0 0 0.25rem;
    font-size: 0.85rem;
    color: var(--sn-ink-muted);
}

.sn-checklist-clear {
    color: var(--sn-ink-muted);
    border-left-color: var(--sn-ok);
}

.sn-checklist-clear .sn-checklist-title {
    color: var(--sn-ink);
}

/* ---- The "Let {name} reply to you" option ----------------------------------------------- */

.sn-reply-opt {
    padding: 0.85rem 1rem 0.6rem;
    border: 1px solid var(--sn-rule);
    border-radius: 6px;
}

.sn-check-label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 0 0 0.35rem;
    font-weight: 600;
    cursor: pointer;
}

.sn-check {
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    margin: 0.25rem 0 0;
    accent-color: var(--sn-brass);
}

.sn-reply-opt .sn-hint {
    margin: 0 0 0.25rem 1.7rem;
}

/* ---- Release choice: a compact radio list ----------------------------------------------- */

.sn-release {
    margin: 0 0 1.25rem;
    padding: 0;
    border: 0;
    min-width: 0;
}

.sn-release legend {
    margin: 0 0 0.3rem;
    padding: 0;
    font-weight: 600;
}

.sn-release .sn-hint {
    margin-bottom: 0.4rem;
}

.sn-radio {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.25rem 0;
    font-size: 0.97rem;
    cursor: pointer;
}

.sn-radio input {
    flex: none;
    margin: 0.35rem 0 0;
    accent-color: var(--sn-brass);
}

/* ---- Honeypot: kept off screen, never display:none -------------------------------------- */

.sn-hp-wrap {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.sn-hp {
    width: 1px;
    height: 1px;
    border: 0;
    padding: 0;
    margin: 0;
}

/* ---- Privacy statement: a bordered notice, always visible ------------------------------- */

.sn-statement {
    margin: 1.5rem 0 1.25rem;
    padding: 1rem 1.15rem;
    font-size: 0.9rem;
    color: var(--sn-ink);
    background: var(--sn-paper);
    border: 1px solid var(--sn-rule);
    border-radius: 6px;
}

.sn-statement h2,
.sn-statement h3 {
    margin: 0 0 0.7rem;
    font-family: var(--sn-sans);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sn-brass);
    text-wrap: initial;
}

.sn-statement p {
    margin: 0 0 0.65rem;
    overflow-wrap: anywhere;
}

.sn-statement p:last-child {
    margin-bottom: 0;
}

/* ---- Buttons ---------------------------------------------------------------------------- */

.sn-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 10px 18px;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--sn-paper);
    background: var(--sn-wax);
    border: 1px solid var(--sn-wax);
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.sn-button:hover {
    filter: brightness(0.94);
}

.sn-button:disabled {
    opacity: 0.55;
    cursor: default;
    filter: none;
}

.sn-button-secondary {
    color: var(--sn-ink);
    background: var(--sn-sheet);
    border-color: var(--sn-rule);
}

.sn-button-secondary:hover {
    filter: none;
    border-color: var(--sn-ink-muted);
}

.sn-button-inline {
    padding: 6px 12px;
    font-size: 0.92rem;
}

.sn-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0.5rem 0 0;
}

/* ---- The receipt, shown once on the success sheet --------------------------------------- */

.sn-receipt {
    margin: 1.5rem 0 0;
    padding: 1.25rem 1.25rem 1rem;
    background: var(--sn-brass-soft);
    border: 1px solid var(--sn-brass);
    border-radius: 6px;
}

.sn-receipt h2 {
    margin: 0 0 0.75rem;
    font-family: var(--sn-sans);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sn-brass);
}

.sn-code-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.9rem;
}

.sn-code {
    flex: 1 1 16rem;
    display: block;
    min-width: 0;
    padding: 0.9rem 1rem;
    font-family: var(--sn-mono);
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    line-height: 1.3;
    overflow-wrap: anywhere;
    color: var(--sn-brass);
    background: var(--sn-sheet);
    border: 1px dashed var(--sn-brass);
    border-radius: 6px;
    user-select: all;
}

.sn-code-row .sn-button-inline {
    flex: none;
}

.sn-warn-text {
    margin: 0;
    font-size: 0.93rem;
    color: var(--sn-ink);
    overflow-wrap: anywhere;
}

/* Copy fallback target: off screen, never display:none */
.sn-offscreen {
    position: absolute;
    top: 0;
    left: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* ---- Return page: the conversation as a vertical timeline ------------------------------- */

.sn-conversation {
    margin: 0 0 1.25rem;
}

.sn-timeline {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0 0.25rem 1.5rem;
    border-left: 1px solid var(--sn-rule);
}

.sn-timeline > .sn-msg {
    position: relative;
}

.sn-timeline > .sn-msg::before {
    content: "";
    position: absolute;
    top: 1.1rem;
    left: calc(-1.5rem - 5px);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--sn-rule);
    border: 1px solid var(--sn-paper);
}

.sn-timeline > .sn-msg-them::before {
    background: var(--sn-ink-muted);
}

.sn-msg {
    margin: 0 0 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--sn-sheet);
    border: 1px solid var(--sn-rule);
    border-radius: 6px;
    box-shadow: var(--sn-shadow);
}

.sn-msg:last-child {
    margin-bottom: 0;
}

/* The sender's own follow-ups are tinted; the recipient's replies sit on a sheet. */
.sn-msg-you {
    background: var(--sn-wax-soft);
    border-color: var(--sn-wax-soft);
    box-shadow: none;
}

.sn-msg-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    color: var(--sn-ink-muted);
}

.sn-msg-who {
    font-weight: 600;
}

.sn-msg-body {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.sn-msg-unreadable {
    font-style: italic;
    color: var(--sn-ink-muted);
}

.sn-conversation-empty {
    margin: 0;
    padding: 0.9rem 1.1rem;
    color: var(--sn-ink-muted);
    background: var(--sn-sheet);
    border: 1px dashed var(--sn-rule);
    border-radius: 6px;
}

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

.sn-foot {
    margin: 1.75rem 0 0;
    font-size: 0.85rem;
    color: var(--sn-ink-muted);
    overflow-wrap: anywhere;
}

.sn-foot p {
    margin: 0 0 0.35rem;
}

.sn-foot a {
    color: inherit;
}

.sn-foot-mono,
.sn-hash {
    font-family: var(--sn-mono);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

/* ---- About page ------------------------------------------------------------------------- */

.sn-about .sn-card > h1,
.sn-about .sn-card > h2:first-child {
    margin-top: 0;
}

.sn-about .sn-statement {
    margin-top: 0.5rem;
}

/* ---- Responsive ------------------------------------------------------------------------- */

@media (max-width: 600px) {
    .sn-page {
        padding: 1rem 0.85rem 2.5rem;
    }

    .sn-card {
        padding: 1.25rem;
    }

    .sn-button:not(.sn-button-inline) {
        width: 100%;
    }

    .sn-code {
        font-size: 1.2rem;
        letter-spacing: 0.05em;
    }

    .sn-timeline {
        padding-left: 1.1rem;
    }

    .sn-timeline > .sn-msg::before {
        left: calc(-1.1rem - 5px);
    }

    .sn-masthead-user {
        margin-left: 0;
    }
}

/* ---- Reduced motion and print ----------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    a,
    .sn-button,
    .sn-input,
    .sn-textarea {
        transition: none;
    }
}

@media print {
    .sn-button,
    .sn-button-row,
    .sn-checklist {
        display: none;
    }
}

/* ---- Hidden: the attribute beats every display rule above (kept last on purpose) -------- */

[hidden],
.sn-page [hidden] {
    display: none;
}
