/* ===========================================================================
   chat — standalone real-time chat styling (self-contained, no imports)
   =========================================================================== */

/* Chat uses a single light theme (Porcelain & Indigo). */
:root {
    --chat-msg-own: #2A3E9C;
    --chat-msg-in-text: #0C1428;
    --chat-accent: #2A3E9C;
    --chat-accent-own: #2A3E9C;
    --chat-text: #0C1428;
    --chat-text-muted: #24304A;
    --chat-border: #D5DCEA;
    --chat-border-strong: #A6B2CD;
    --chat-gold: #B47A12;
    --chat-key-text: #7A4E08;
    --chat-chip-pinned: #D9DFF2;
    --chat-live-text: #0C1428;
    --chat-live: #0E9F6E;
    --chat-error: #D92D20;
    --chat-danger: #ED1380;
    --chat-danger-strong: #C70E69;
    --chat-warn: #C2410C;
    /* Album premium-minimalism tokens — nav bar only, see /album/ album.css */
}

/* ── Live presence line — who is in the room right now ── */
.chat-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 4px 13px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--chat-live-text);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

@keyframes chat-live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

body {
    font-family: 'Roboto', sans-serif;
    color: var(--chat-text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ── App header (detail / create) — same band as the list nav bar ── */
/* row 1 carries the room name alone, row 2 the controls */
.header-row-1 { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.app-header h1 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.02em;
    color: var(--surface);
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

/* ── Content area ── */
.section-label {
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--chat-text-muted);
    text-transform: uppercase;
    margin: 12px 0 8px 4px;
}
.empty-state {
    background: var(--surface);
    border: 2px solid var(--dark-surface);
    padding: 2rem 1.25rem;
    text-align: center;
    font: 400 1.1rem/1.4 'Roboto', sans-serif;
    color: var(--dark-surface);
}

/* ── Chat participants (above messages) ── */
/* the pills sit on Show earlier's white, rounded like it; edge to edge on a phone */
.chat-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 10px;
    padding: 8px;
    background: var(--surface);
    border-radius: 8px;
}
/* one pill per room member: green = in the room now, red = not */
.chat-member {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    border: 2px solid var(--dark-surface);
    border-radius: 999px;
    padding: 3px 14px;
}
.chat-member.is-online { background: var(--accent-activity); color: var(--surface); }
.chat-member.is-away { background: var(--accent-pink); color: var(--dark-surface); }

/* ── Nav bar (list view) — album recipe: charcoal band, gold hairline,
      2px ink borders, square corners, one teal action ── */
.nav-links-group { display: flex; gap: 8px; align-items: center; }
/* current page reads as album's gold eyebrow, not a competing button */
.nav-link {
    color: var(--accent-gold);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
    text-decoration: none;
}
.nav-link.active {
    font-size: 1rem;
    color: var(--accent-gold);
}
/* the + is drawn as two bars, not typed: a glyph rides its font baseline and
   never sits dead centre in the box */
.nav-link-add {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 30px;   /* matches the key chip's height so the row lines up */
    box-sizing: border-box;
    font-size: 0;   /* hides the "+" character, keeps it for screen readers */
    background: var(--accent-gold);
    border: 2px solid var(--dark-surface);
    padding: 0;
}
.nav-link-add::before,
.nav-link-add::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-footer);
}
.nav-link-add::before { width: 16px; height: 3px; }
.nav-link-add::after  { width: 3px;  height: 16px; }
.nav-link-add:hover { background: #e6c65c; }

/* ── People on a room row: invite, remove, and the one free seat ── */

.chat-slab-members {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.4rem;
    font: 700 0.875rem/1.3 'Roboto', sans-serif;
    color: var(--bg-footer);
}
.chat-mname { margin: 0; }
.chat-madd {
    font: 700 0.875rem/1.3 'Roboto', sans-serif;
    color: var(--dark-surface);
    background: var(--accent-pink);
    border: 1px solid var(--dark-surface);
    padding: 1px 9px;
    text-decoration: none;
    cursor: pointer;
}
.chat-madd:hover { background: var(--accent-pink-soft); }

.chat-invite-row { display: flex; align-items: center; gap: 0.4rem; }
.chat-invite-input:focus {
    outline: 3px solid var(--accent-teal-dark);
    outline-offset: 1px;
}
.chat-invite-save {
    flex-shrink: 0;
    font: 700 0.875rem/1 'Roboto', sans-serif;
    color: var(--surface);
    background: var(--accent-teal-dark);
    border: 2px solid var(--dark-surface);
    padding: 4px 12px;
    cursor: pointer;
}
.chat-invite-save:hover { background: #0c8181; }

.chat-seat-chip-row { margin-top: 0.4rem; }

/* ported from album.css .ab-form-error / .ab-seat-offer* — same block, same colours */
.chat-form-error {
    margin: 6px 0 0;
    font: 700 0.875rem/1.3 'Roboto', sans-serif;
    color: var(--danger);
}
.chat-seat-offer {
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: #ffd76a;
    border: 2px solid var(--dark-surface);
    border-radius: 0;
}
.chat-seat-offer-text {
    margin: 0 0 0.4rem;
    font: 700 0.875rem/1.3 'Roboto', sans-serif;
    color: var(--dark-surface);
}
.chat-seat-offer-btn {
    font: 700 0.875rem/1 'Roboto', sans-serif;
    color: var(--surface);
    background: var(--accent-teal-dark);
    border: 2px solid var(--dark-surface);
    padding: 4px 12px;
    cursor: pointer;
}
.chat-seat-offer-btn:hover { background: var(--accent-teal-dark); }

/* ── No access ── */
.chat-noaccess { padding: 32px 12px; text-align: center; }
.chat-noaccess h1 { margin: 0 0 12px; font-size: 1.4rem; color: var(--chat-accent); }
.chat-noaccess p { margin: 0 0 8px; font-size: 0.9rem; color: var(--chat-text-muted); }
.chat-noaccess-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: var(--bg-footer);
    color: var(--surface);
    border: 2px solid var(--accent-gold);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-decoration: none;
}
.chat-noaccess-btn:hover { background: var(--dark-surface); }

/* ── Room slabs (list view) — album recipe: white card, 2px ink border,
      square corners, pink DEL strip fused to the right edge ── */
.room-slab {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 2px solid var(--dark-surface);
    margin-bottom: 0.6rem;
}
.room-slab:hover { background: var(--cream); }
.room-slab-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.room-badge {
    margin-left: auto;
    flex-shrink: 0;
    font: 700 0.875rem/1.4 'Roboto', sans-serif;
    color: var(--bg-footer);
    background: var(--cream);
    border: 1px solid var(--dark-surface);
    padding: 1px 7px;
    white-space: nowrap;
}
.room-actions { align-self: stretch; display: flex; margin: 0; }
.room-delete-btn,
.room-leave-btn {
    height: 100%;
    font: 700 0.875rem/1 'Roboto', sans-serif;
    letter-spacing: 0.08em;
    color: var(--dark-surface);
    background: var(--accent-pink);
    border: none;
    border-left: 2px solid var(--dark-surface);
    padding: 0 14px;
    text-transform: uppercase;
    cursor: pointer;
}
.room-delete-btn:hover { background: var(--accent-pink-dark); }
/* Walking out is not deleting, so it is its own colour — never a weaker pink. */
.room-leave-btn { background: var(--accent-teal-dark); color: var(--surface); }
.room-leave-btn:hover { background: #085757; }

/* ── Message slabs (detail view) ── */
.msg-slab {
    background: #f8edcf;
    color: var(--chat-msg-in-text);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
    padding: 4px 12px 4px 18px;
    font-size: 1.25rem;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
}
.msg-slab::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--chat-accent);
}
.msg-slab.is-own {
    background: var(--chat-msg-own);
    color: var(--surface);
    border-color: transparent;
}
.msg-slab.is-own::before { background: var(--surface); }
.msg-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.msg-tag {
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--surface);
    text-transform: uppercase;
}
.msg-tag-other { color: var(--chat-accent); }
/* The other person's name row: small picture, name, level */
.msg-who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.msg-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--chat-border-strong);
    flex-shrink: 0;
}
.msg-rank {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--chat-key-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.msg-meta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.875rem; }
.msg-delete-form { display: inline; margin: 0; }
.msg-delete-btn {
    background: none;
    border: none;
    color: var(--chat-danger);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 4px;
    text-decoration: underline;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.msg-delete-btn:hover { color: var(--chat-danger-strong); }
/* Delete sits on the blue own-message bubble — keep it bright pink there */
.msg-slab.is-own .msg-delete-btn { color: var(--accent-pink); }
.msg-slab.is-own .msg-delete-btn:hover { color: var(--accent-pink-dark); }
.msg-content { margin-bottom: 6px; }
/* a photo posted from Album, the whole width of its message */
.msg-photo {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    border: 2px solid var(--dark-surface);
}
.msg-content.is-react {
    font-size: 3rem;
    line-height: 1.15;
}

/* ── Composer ── */
.composer { margin: 20px 0; }
.composer form { display: flex; gap: 0; }
.btn-submit {
    background: var(--chat-accent);
    color: var(--surface);
    border: none;
    border-radius: 6px 0 0 6px;
    font-weight: 800;
    font-size: 0.875rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 12px 8px;
    letter-spacing: 2px;
    cursor: pointer;
}
.composer textarea {
    flex: 1;
    background: var(--surface);
    color: var(--chat-text);
    border: 2px solid var(--chat-border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 8px 12px;
    font-size: 1.3rem;
    box-sizing: border-box;
    resize: none;
    overflow: hidden;
    font-family: inherit;
}

/* ── React tray (below composer form, always visible) ── */
.react-bar { margin-top: 8px; }
.react-tray {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.react-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.react-row-pinned:empty { display: none; }
.react-tile {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1.5px solid var(--chat-accent);
    border-radius: 8px;
    background: var(--surface);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.react-tile:hover { background: var(--surface-3); }
.react-tile:active { transform: scale(0.9); }
.react-tile.is-pinned { background: var(--chat-chip-pinned); }

/* ── Frequent-word chips (below composer) ── */
.word-chips { margin: 0 0 20px; }
.word-count-toggle {
    min-width: 36px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1.5px solid var(--chat-accent);
    background: var(--surface);
    color: var(--chat-accent);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.word-count-toggle.is-on { background: var(--chat-accent); color: var(--surface); }
.word-count-toggle:active { transform: scale(0.94); }
.word-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.word-chip {
    background: var(--surface);
    border: 1.5px solid var(--chat-accent);
    border-radius: 999px;
    color: var(--chat-accent);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.word-chip:hover { background: var(--chat-accent); color: var(--surface); }
.word-chip:active { transform: scale(0.96); }
.word-chip.is-pinned { background: var(--chat-chip-pinned); }
@media screen and (max-width: 480px) {
    .word-chips { margin: 0 0 2px; }
    .react-tray { gap: 4px; }
    .react-row { gap: 4px; }
    .react-tile { width: 40px; height: 40px; font-size: 1.5rem; }
}

/* ── Create form ── */
.form-slab {
    background: var(--surface-3);
    border: 2px solid var(--chat-border-strong);
    border-radius: 8px;
    padding: 16px;
    margin-top: 10px;
}
.field-group { margin-bottom: 16px; }
.field-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: var(--chat-text-muted);
}
.field-group input[type="text"],
.field-group input[type="number"] {
    width: 100%;
    background: var(--surface);
    border: 2px solid var(--chat-border-strong);
    border-radius: 4px;
    padding: 10px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
}
.field-error { color: var(--chat-error); font-size: 0.875rem; margin-top: 4px; }
.form-hint { text-align: center; color: var(--chat-text-muted); font-size: 0.875rem; margin-top: 16px; }

/* Chat room and Tavern: a teal floor, so the cream and the blue messages
   both stand out; what sits on the floor itself turns white to stay readable. */
body:has(.chat-stage) { background: #3F9792; }
.chat-stage .form-hint,
.chat-stage .form-hint a,
.chat-stage .chat-form-error { color: var(--surface); }
body:has(.chat-stage) .guide-link { color: #f8edcf; }
.btn-create {
    width: 100%;
    background: var(--chat-accent);
    color: var(--surface);
    border: none;
    padding: 14px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    text-transform: uppercase;
    margin-top: 10px;
}

/* ── Creator actions: trim (wide) + delete room (short), catalog-style ── */
.creator-actions { display: flex; gap: 8px; margin-top: 20px; }
.creator-actions form { margin: 0; }
.creator-actions .trim-form { flex: 1; }
.btn-trim,
.btn-del {
    display: block;
    padding: 8px 14px;
    border-radius: 5px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s, color 0.3s;
}
.btn-trim {
    width: 100%;
    background: var(--blue-btn);
    color: var(--cream-2);
    border: 2px solid var(--cream-2);
}
.btn-trim:hover, .btn-trim:focus { background: var(--salmon); color: var(--ink); }
.btn-del {
    background: var(--accent-pink);
    color: var(--ink);
    border: 2px solid var(--ink);
}
.btn-del:hover, .btn-del:focus { background: var(--accent-pink-soft); color: var(--surface); }

/* ── Mobile: minimum padding at ≤480px ── */
@media screen and (max-width: 480px) {
    .header-row-1 { gap: 6px; }
    .app-header h1 { font-size: 0.95rem; }
    .header-row-2 { gap: 6px; }
    .nav-bar { padding: 8px 2px 10px 12px; border-left: 0; border-right: 0; gap: 4px; }
    .nav-links-group { gap: 6px; }
    .nav-link-add { width: 32px; height: 28px; }
    .nav-link-add::before { width: 14px; }
    .nav-link-add::after { height: 14px; }
    .room-slab { margin-bottom: 0.4rem; }
    .chat-members { border-radius: 0; }
    .room-delete-btn, .room-leave-btn { padding: 0 10px; }
    .room-name {
    letter-spacing: 0.12em;
    font-size: 0.9rem;
    }
    .chat-seat-offer { padding: 0.4rem 0.45rem; }
    .empty-state { padding: 1.5rem 0.5rem; }
    .chat-noaccess { padding: 24px 2px; }
    .msg-slab { border-radius: 0; border-left: 0; border-right: 0; margin-bottom: 2px; padding: 4px 8px 4px 14px; }
    .form-slab { border-radius: 0; border-left: 0; border-right: 0; padding: 16px 8px; }
    .creator-actions { gap: 2px; margin-top: 10px; }
    .btn-trim, .btn-del { padding: 8px 6px; }
}

/* Tavern borrows this file: its header and its own gold title */
.app-header.tavern-header { padding-left: 20px; }
.app-header .tavern-title {
    font-style: italic; font-weight: 900; text-transform: uppercase;
    letter-spacing: 0.2em; color: #F2E6AC; font-size: 1.4rem;
}

/* A room: the push bell and Show earlier */
.push-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 1.8rem;
    flex-shrink: 0;
    line-height: 1;
    margin-left: auto;  /* the key chip used to hold this edge */
    -webkit-tap-highlight-color: transparent;
}
.msg-toggle {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--chat-accent);
    border-radius: 8px;
    color: var(--chat-accent);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.msg-toggle:hover { background: var(--chat-accent); color: #fff; }
@media screen and (max-width: 480px) {
    .msg-toggle { border-radius: 0; border-left: 0; border-right: 0; margin-bottom: 2px; }
}
