/* the society :: layout. */

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

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

body {
    background: var(--ground);
    color: var(--amber);
    font-family: var(--font-chrome);
    font-size: 13px;
    overflow: hidden;
}

button, input, textarea { font: inherit; color: inherit; }

#app {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    gap: var(--gap-sm);
    padding: var(--gap-sm);
    max-width: 1500px;
    margin: 0 auto;
}

#app[hidden] { display: none; }

/* ── masthead ─────────────────────────────────────────────────────────────── */

.masthead {
    display: flex;
    align-items: baseline;
    gap: var(--gap);
    padding: 4px 6px 0;
    flex-wrap: wrap;
}

.wordmark {
    font-family: var(--font-stencil);
    font-weight: 700;
    font-size: clamp(20px, 3.4vw, 30px);
    letter-spacing: 0.42em;
    margin: 0;
    color: var(--amber);
    text-shadow:
        0 0 10px rgba(255, 178, 36, 0.45),
        0 0 32px rgba(255, 178, 36, 0.18);
    white-space: nowrap;
}

.subwordmark {
    font-family: var(--font-chrome);
    font-size: 10px;
    letter-spacing: 0.3em;
    color: var(--amber-dim);
    text-transform: uppercase;
}

.masthead-spacer { flex: 1 1 auto; }

/* ── status strip ─────────────────────────────────────────────────────────── */

.status {
    display: flex;
    align-items: center;
    gap: var(--gap);
    flex-wrap: wrap;
    padding: 7px 12px;
    font-family: var(--font-chrome);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.status .field {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.status .label { color: var(--amber-dim); }
.status .value { color: var(--amber-bright); font-variant-numeric: tabular-nums; }
.status .value.mono { font-family: var(--font-mono); letter-spacing: 0.04em; }

.status .sep {
    width: 1px;
    height: 14px;
    background: var(--panel-edge);
    flex: none;
}

/* ── main deck ────────────────────────────────────────────────────────────── */

.deck {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: var(--gap-sm);
    min-height: 0;
}

.roster-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.roster-list {
    list-style: none;
    margin: 0;
    padding: var(--gap-sm);
    overflow-y: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.operator {
    border: 1px solid var(--panel-edge);
    border-left: 3px solid var(--amber-mid);
    padding: 7px 9px;
    background: rgba(255, 178, 36, 0.03);
}

.operator.self { border-left-color: var(--amber-bright); }
.operator.unverified { border-left-color: var(--alert); }

.operator .callsign {
    font-family: var(--font-chrome);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--amber-bright);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* the callsign truncates and the status tag never wraps: a two-line "ID
   VERIFIED" reads as a rendering fault rather than a status. */
.operator .nm {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.operator .fp {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--amber-dim);
    margin-top: 3px;
    word-break: break-all;
}

.operator .tag {
    font-size: 9px;
    letter-spacing: 0.12em;
    color: var(--good);
    margin-left: auto;
    white-space: nowrap;
    flex: none;
}

.operator.self .tag { color: var(--amber-bright); }

.operator.unverified .tag { color: var(--alert); }

/* ── transmission log ─────────────────────────────────────────────────────── */

.log-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: var(--gap);
    margin: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    gap: 7px;
    overscroll-behavior: contain;
    /* sit the conversation against the compose bar. a short log reading from the
       top of a tall panel looks like the app failed to load something. */
    justify-content: flex-end;
}

.tx { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }

.tx .meta {
    color: var(--amber-dim);
    font-size: 11px;
    white-space: nowrap;
    padding-top: 2px;
}

.tx .who { color: var(--amber); }
.tx .body { color: var(--amber-bright); white-space: pre-wrap; word-break: break-word; }

.tx.self .who { color: var(--amber-bright); font-weight: 600; }

.tx.system .body { color: var(--amber-mid); font-style: italic; }
.tx.alert  .body { color: var(--alert); }

.tx.unverified {
    border-left: 2px solid var(--alert);
    padding-left: 8px;
    margin-left: -10px;
}

/* ── compose ──────────────────────────────────────────────────────────────── */

.compose {
    display: flex;
    gap: var(--gap-sm);
    padding: var(--gap-sm);
    border-top: 1px solid var(--panel-edge);
    align-items: flex-end;
}

.compose textarea {
    flex: 1 1 auto;
    resize: none;
    background: var(--ground-2);
    border: 1px solid var(--panel-edge);
    border-radius: 2px;
    padding: 9px 11px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.45;
    color: var(--amber-bright);
    min-height: 40px;
    max-height: 140px;
    overflow-y: auto;
}

.compose textarea:focus {
    outline: none;
    border-color: var(--amber-mid);
    box-shadow: 0 0 0 1px rgba(255, 178, 36, 0.25), inset 0 0 12px rgba(255, 178, 36, 0.05);
}

.compose textarea::placeholder { color: var(--amber-ghost); }

.typing {
    height: 15px;
    padding: 0 var(--gap-sm) 4px;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--amber-dim);
    text-transform: uppercase;
}

/* ── drop target ──────────────────────────────────────────────────────────── */

body.dropping .log-panel {
    outline: 2px dashed var(--amber);
    outline-offset: -4px;
}

/* ── phone ────────────────────────────────────────────────────────────────── */

/* the roster becomes a slide-over drawer rather than being hidden, so the
   fingerprints stay reachable on a phone — they are the only defence against a
   substituted identity, so they must never be the thing that gets dropped. */
@media (max-width: 720px) {
    .deck { grid-template-columns: minmax(0, 1fr); }

    /* the roster is position:fixed here, but auto-placement still hands it a grid
       row, which left an empty track above the log. stacking both children into
       the same cell removes the phantom row. */
    .deck > * { grid-area: 1 / 1; }

    /* stack the timestamp above the body: a two-column row leaves roughly 180px
       for the message on a phone, which wraps every sentence to ribbons. */
    .tx {
        grid-template-columns: minmax(0, 1fr);
        gap: 1px;
    }

    .tx .meta { white-space: normal; padding-top: 0; }
    .tx.unverified { margin-left: 0; }

    .masthead { gap: var(--gap-sm); }
    .btn { padding: 8px 10px; }

    .roster-panel {
        position: fixed;
        z-index: 30;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(80vw, 300px);
        transform: translateX(-102%);
        transition: transform 160ms ease-out;
    }

    body[data-roster="open"] .roster-panel { transform: translateX(0); }

    .wordmark { letter-spacing: 0.24em; }
    .status { font-size: 10px; gap: var(--gap-sm); }
    .status .sep { display: none; }
    .compose textarea { font-size: 16px; } /* 16px stops iOS zooming the viewport on focus */
    .btn { min-height: 42px; }
}

@media (min-width: 721px) {
    .roster-toggle { display: none; }
}
