/*
 * Masbro brand styles.
 *
 * Palette taken from the RGB logo SVGs, which are authoritative for
 * screen. Note the CMYK variants carry a different forest green
 * (#004a51) — that is the print ink, not a colour-space conversion of
 * this one, so do not "correct" one to the other.
 *
 * Two typefaces, matching what masbro.gi itself serves: LeifSN for
 * display, FixelText for everything else.
 *
 * Only WOFF2 is referenced, and only the weights actually used. The
 * Baat AS EULA forbids OTF on websites (§4.2) and forbids modifying the
 * font (§7.1/7.2), so payload comes down by shipping fewer files rather
 * than by subsetting.
 */

@font-face {
    font-family: 'FixelText';
    src: url('fonts/FixelText-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'FixelText';
    src: url('fonts/FixelText-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'FixelText';
    src: url('fonts/FixelText-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LeifSN';
    src: url('fonts/LeifSN-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'LeifSN';
    src: url('fonts/LeifSN-Italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

:root {
    --forest: #072b2b;
    --eggshell: #f6f3eb;

    /* Derived, not invented: tints of the two brand colours. */
    --forest-80: rgba(7, 43, 43, 0.8);
    --forest-55: rgba(7, 43, 43, 0.55);
    --forest-12: rgba(7, 43, 43, 0.12);
    --forest-06: rgba(7, 43, 43, 0.06);

    --body: 'FixelText', ui-sans-serif, system-ui, sans-serif;
    --display: 'LeifSN', Georgia, serif;

    /* A pill for the composer, a softer radius for bubbles. */
    --radius: 14px;
    --pill: 999px;
    --max-width: 44rem;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
    background: var(--eggshell);
    color: var(--forest);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.page {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* #chat participates in the page's column so only the log scrolls. */
#chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

/* ── header ─────────────────────────────────────────────────────────── */

.header {
    text-align: center;
    /* Generous, deliberately: the mark is the first thing seen and was
       sitting too close to the top edge. */
    padding: 3rem 0 1.25rem;
}

.brandmark {
    height: 30px;
    width: auto;
    display: block;
    margin: 0 auto;
}

/*
 * The notice is a small pill rather than a banner. It is situational
 * ("responses may be slow"), so it should read as a label on the
 * assistant rather than as an alert competing with the conversation.
 */
.notice {
    display: inline-block;
    margin: 0.9rem 0 0;
    padding: 0.2rem 0.7rem;
    border-radius: var(--pill);
    border: 1px solid var(--forest-12);
    background: transparent;
    color: var(--forest-80);
    font-size: 0.8125rem;
}

/* ── conversation ───────────────────────────────────────────────────── */

.log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    padding: 0.5rem 0 1.25rem;
}

/*
 * Pushes the conversation to the BOTTOM of the log area, so a new
 * conversation starts with the greeting sitting just above the input
 * rather than stranded at the top of an empty screen. As turns
 * accumulate they fill upward and then scroll.
 *
 * margin-top:auto on the first child rather than justify-content:flex-end
 * — the latter makes overflowing content unreachable when scrolling up.
 */
.log > :first-child { margin-top: auto; }

.turn { display: flex; gap: 0.7rem; }

/*
 * Agent turns are plain text with a small mark, not bubbles. Only the
 * user's words are boxed. It reads as the assistant talking and you
 * replying, rather than two parties trading equal-weight blocks.
 */
.turn--agent .bubble {
    padding: 0;
    background: none;
    border: 0;
}

.mark {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 0.28rem;
    color: var(--forest-55);
}

.turn--user {
    justify-content: flex-end;
    padding-left: 2.5rem;
}

.turn--user .bubble {
    background: var(--forest-06);
    border: 1px solid var(--forest-12);
    border-radius: var(--radius);
    padding: 0.7rem 0.95rem;
}

.bubble {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Failure markers (Pa-42) — set apart from anything actually said. */
.turn--system .bubble {
    font-family: var(--display);
    font-style: italic;
    color: var(--forest-55);
    border: 1px dashed var(--forest-12);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    width: 100%;
}

.thinking {
    display: flex;
    gap: 0.7rem;
    color: var(--forest-55);
    font-family: var(--display);
    font-style: italic;
}

/* ── composer ───────────────────────────────────────────────────────── */

.composer { padding-bottom: 1.1rem; }

.composer-pill {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid var(--forest-12);
    border-radius: var(--pill);
    padding: 0.4rem 0.4rem 0.4rem 1.1rem;
}

.composer-pill:focus-within {
    border-color: var(--forest-55);
}

textarea {
    flex: 1;
    resize: none;
    border: 0;
    outline: none;
    background: transparent;
    font: inherit;
    color: inherit;
    padding: 0.55rem 0;
    max-height: 8rem;
    line-height: 1.5;
}

textarea::placeholder { color: var(--forest-55); }

#send {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--forest);
    color: var(--eggshell);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: opacity 0.15s;
}

#send:disabled { opacity: 0.35; cursor: not-allowed; }
#send:focus-visible, textarea:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

.send-icon { width: 18px; height: 18px; }

/*
 * Under the composer, as asked. Quiet — it is a standing condition, not
 * something to read before every message.
 */
.disclaimer {
    margin: 0.7rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--forest-55);
}

/* ── gates ──────────────────────────────────────────────────────────── */

.gate {
    margin: auto;
    text-align: center;
    padding: 2rem 0;
    max-width: 28rem;
}

.gate-logo { height: 34px; width: auto; margin: 0 auto 1.5rem; display: block; }

.gate h1 {
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.5rem;
    margin: 0 0 0.5rem;
}

.gate a { color: var(--forest); }

.hidden { display: none !important; }

@media (max-width: 30rem) {
    .header { padding-top: 2rem; }
    .turn--user { padding-left: 1rem; }
}
