* {
    box-sizing: border-box;
}

:root {

    --text: #18181b;
    --muted: #71717a;
    --line: #e4e4e7;
    --soft: #f7f7f8;
    --white: #ffffff;

    --mastodon: #6364ff;
    --bluesky: #1185fe;

    --success: #087a35;
    --error: #b42318;
}

[hidden] {
    display: none !important;
}

body {

    margin: 0;

    background: var(--white);

    color: var(--text);

    font-family: Arial, Helvetica, sans-serif;

    line-height: 1.55;
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

.discussion {

    width: min(100% - 32px, 760px);

    margin: 70px auto;
}

/* ==========================================================
   EN-TÊTE
   ========================================================== */

.discussion-header {

    padding-bottom: 24px;

    border-bottom:
        1px solid var(--line);
}

.discussion-header-top {

    display: flex;

    align-items: center;

    justify-content:
        space-between;

    gap: 20px;
}

.discussion-title {

    margin: 0;

    font-size:
        clamp(
            1.65rem,
            4vw,
            2.1rem
        );

    line-height: 1.15;

    letter-spacing: -.025em;
}

.comment-count {

    color: var(--muted);

    font-size: .9rem;

    font-weight: 700;

    white-space: nowrap;
}

.discussion-intro {

    max-width: 640px;

    margin:
        10px 0 0;

    color: var(--muted);

    font-size: .95rem;
}

/* ==========================================================
   RÉSEAUX
   ========================================================== */

.network {

    margin-top: 38px;
}

.network-heading {

    display: flex;

    align-items: center;

    gap: 9px;

    margin-bottom: 14px;

    color: var(--muted);

    font-size: .76rem;

    font-weight: 750;

    text-transform: uppercase;

    letter-spacing: .08em;
}

.network-dot {

    width: 8px;

    height: 8px;

    border-radius: 50%;
}

.network-dot.mastodon {
    background: var(--mastodon);
}

.network-dot.bluesky {
    background: var(--bluesky);
}

/* ==========================================================
   MESSAGES
   ========================================================== */

.post {

    position: relative;

    margin: 0;

    padding:
        20px 0
        20px 60px;

    border-bottom:
        1px solid var(--line);
}

.post:last-child {
    border-bottom: 0;
}

.post-header {

    display: flex;

    align-items: center;

    min-height: 42px;
}

.avatar {

    position: absolute;

    top: 20px;

    left: 0;

    width: 44px;

    height: 44px;

    border-radius: 50%;

    object-fit: cover;

    background: var(--soft);
}

.identity {
    min-width: 0;
}

.author {

    font-size: .95rem;

    font-weight: 700;

    line-height: 1.3;
}

.handle {

    overflow: hidden;

    margin-top: 1px;

    color: var(--muted);

    font-size: .82rem;

    text-overflow: ellipsis;

    white-space: nowrap;
}

.post-content {

    margin-top: 12px;

    font-size: .96rem;

    overflow-wrap: anywhere;
}

.post-content p {

    margin:
        0 0 .75em;
}

.post-content p:last-child {
    margin-bottom: 0;
}

.post-meta {

    display: flex;

    align-items: center;

    gap: 12px;

    margin-top: 13px;

    color: var(--muted);

    font-size: .78rem;
}

.post-meta a {
    text-decoration: none;
}

.root-post {

    margin-bottom: 12px;

    padding:
        18px 18px
        18px 76px;

    border:
        1px solid var(--line);

    border-radius: 10px;

    background: var(--soft);
}

.root-post .avatar {

    left: 18px;

    top: 18px;
}

.reply-post {
    margin-left: 28px;
}

.reply-level-1 {
    margin-left: 16px;
}

.reply-level-2 {
    margin-left: 32px;
}

.reply-level-3 {
    margin-left: 48px;
}

.empty {

    padding:
        12px 0;

    color: var(--muted);

    font-size: .9rem;
}

/* ==========================================================
   ZONE DE COMMENTAIRE
   ========================================================== */

.join-discussion {

    margin-top: 55px;

    padding-top: 32px;

    border-top:
        1px solid var(--line);
}

.join-discussion h2 {

    margin:
        0 0 8px;

    font-size: 1.35rem;
}

.join-intro {

    max-width: 620px;

    margin:
        0 0 25px;

    color: var(--muted);

    font-size: .92rem;
}

/* ==========================================================
   SÉLECTEUR MASTODON / ATPROTO
   ========================================================== */

.protocol-selector {

    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;

    margin-bottom: 22px;
}

.protocol-button {

    min-height: 48px;

    padding:
        10px 15px;

    border:
        1px solid var(--line);

    border-radius: 9px;

    background: var(--white);

    color: var(--text);

    font-weight: 700;

    cursor: pointer;
}

.protocol-button:hover {
    background: var(--soft);
}

.protocol-button.active.mastodon {

    border-color:
        var(--mastodon);

    box-shadow:
        inset 0 0 0 1px
        var(--mastodon);
}

.protocol-button.active.atproto {

    border-color:
        var(--bluesky);

    box-shadow:
        inset 0 0 0 1px
        var(--bluesky);
}

/* ==========================================================
   PANNEAUX
   ========================================================== */

.protocol-panel {

    padding: 22px;

    border:
        1px solid var(--line);

    border-radius: 11px;
}

.protocol-title {

    margin:
        0 0 5px;

    font-size: 1rem;
}

.protocol-description {

    margin:
        0 0 20px;

    color: var(--muted);

    font-size: .86rem;
}

/* ==========================================================
   FORMULAIRES
   ========================================================== */

.form-label {

    display: block;

    margin-bottom: 7px;

    font-size: .85rem;

    font-weight: 650;
}

.form-input {

    display: block;

    width: 100%;

    min-height: 44px;

    padding:
        9px 12px;

    margin-bottom: 12px;

    border:
        1px solid var(--line);

    border-radius: 7px;

    background: #fff;

    color: var(--text);
}

.form-input:focus,
.reply-textarea:focus {

    outline:
        2px solid
        rgba(17,133,254,.18);

    border-color:
        var(--bluesky);
}

.action-button {

    min-height: 44px;

    padding:
        10px 16px;

    border: 0;

    border-radius: 7px;

    background: var(--text);

    color: #fff;

    font-weight: 650;

    cursor: pointer;
}

.action-button:hover:not(:disabled) {
    opacity: .88;
}

.action-button:disabled {

    opacity: .55;

    cursor: wait;
}

/* ==========================================================
   COMPTE CONNECTÉ
   ========================================================== */

.connected-account {

    display: flex;

    align-items: center;

    gap: 13px;

    margin-bottom: 22px;

    padding:
        13px 15px;

    border:
        1px solid var(--line);

    border-radius: 9px;

    background: var(--soft);
}

.connected-avatar {

    width: 46px;

    height: 46px;

    flex:
        0 0 46px;

    border-radius: 50%;

    object-fit: cover;

    background: #e4e4e7;
}

.connected-identity {

    min-width: 0;

    flex: 1;
}

.connected-name {

    overflow: hidden;

    font-size: .93rem;

    font-weight: 700;

    text-overflow: ellipsis;

    white-space: nowrap;
}

.connected-handle {

    overflow: hidden;

    margin-top: 1px;

    color: var(--muted);

    font-size: .82rem;

    text-overflow: ellipsis;

    white-space: nowrap;
}

.logout-button {

    flex:
        0 0 auto;

    padding: 5px 0;

    border: 0;

    background: transparent;

    color: var(--muted);

    font-size: .8rem;

    text-decoration: underline;

    text-underline-offset: 3px;

    cursor: pointer;
}

.logout-button:hover {
    color: var(--text);
}

/* ==========================================================
   ÉDITEUR
   ========================================================== */

.reply-textarea {

    display: block;

    width: 100%;

    min-height: 135px;

    padding:
        12px 14px;

    border:
        1px solid var(--line);

    border-radius: 8px;

    background: #fff;

    color: var(--text);

    line-height: 1.5;

    resize: vertical;
}

.compose-footer {

    display: flex;

    align-items: center;

    justify-content:
        space-between;

    gap: 20px;

    margin-top: 9px;
}

.character-counter {

    color: var(--muted);

    font-size: .8rem;
}

.status-message {

    min-height: 22px;

    margin-top: 14px;

    color: var(--muted);

    font-size: .88rem;
}

.status-message.success {
    color: var(--success);
}

.status-message.error {
    color: var(--error);
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */

@media (max-width: 600px) {

    .discussion {

        width:
            min(
                100% - 24px,
                760px
            );

        margin:
            36px auto;
    }

    .discussion-header-top {

        align-items:
            flex-start;

        flex-direction:
            column;

        gap: 5px;
    }

    .post {
        padding-left: 52px;
    }

    .avatar {

        width: 38px;

        height: 38px;
    }

    .root-post {

        padding:
            16px 14px
            16px 62px;
    }

    .root-post .avatar {

        left: 14px;

        top: 16px;
    }

    .reply-post {
        margin-left: 12px;
    }

    .reply-level-1 {
        margin-left: 8px;
    }

    .reply-level-2 {
        margin-left: 12px;
    }

    .reply-level-3 {
        margin-left: 16px;
    }

    .protocol-selector {

        grid-template-columns:
            1fr;
    }

    .protocol-panel {
        padding: 18px;
    }

    .connected-account {

        align-items:
            center;
    }

    .logout-button {
        white-space: nowrap;
    }

    .compose-footer {

        align-items:
            stretch;

        flex-direction:
            column;
    }

    .character-counter {
        text-align: right;
    }

    .action-button {
        width: 100%;
    }
}

.connected-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}
