/**
 * File: assets/css/public-page.css
 * Version: 1.1.1
 * Description: Dedicated mobile-first public page and public chat styles for Chatting.im.
 */

:root {
    --bg: #f7f3ea;
    --bg-deep: #eee6d5;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-solid: #ffffff;
    --surface-soft: #fbf8f1;
    --text: #171411;
    --muted: #756f65;
    --line: rgba(31, 24, 17, 0.12);
    --line-strong: rgba(31, 24, 17, 0.18);
    --primary: #174f3f;
    --primary-2: #226a55;
    --primary-soft: #dfeee8;
    --gold: #d9a441;
    --peach: #f3c7a4;
    --danger: #a33a2e;
    --shadow: 0 24px 80px rgba(52, 39, 21, 0.12);
    --shadow-soft: 0 16px 40px rgba(52, 39, 21, 0.08);
    --radius-xl: 34px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --max: 1160px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background:
        radial-gradient(circle at 15% 8%, rgba(243, 199, 164, 0.55), transparent 28rem),
        radial-gradient(circle at 90% 15%, rgba(223, 238, 232, 0.95), transparent 26rem),
        linear-gradient(135deg, var(--bg), var(--bg-deep));
    overflow-x: hidden;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(rgba(23, 20, 17, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 20, 17, 0.035) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 80%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

textarea {
    resize: vertical;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(var(--max), calc(100% - 32px));
    margin: 0 auto;
    padding: 7px 0;
    background: transparent;
    backdrop-filter: none;
}

.site-header.slim {
    width: min(var(--max), calc(100% - 32px));
}

.brand {
    display: inline-flex;
    align-items: center;
    flex: none;
    gap: 10px;
    font-weight: 850;
    letter-spacing: -0.04em;
}

.brand-mark {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    color: #fff;
    font-size: 21px;
    font-weight: 900;
    line-height: 1;
    background:
        radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.28), transparent 26%),
        linear-gradient(135deg, var(--primary), var(--primary-2));
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(23, 79, 63, 0.24);
}

label {
    display: grid;
    gap: 7px;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 16px;
    outline: none;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

input {
    height: 48px;
    padding: 0 14px;
}

textarea {
    padding: 13px 14px;
    line-height: 1.45;
}

input:focus,
textarea:focus {
    background: #fff;
    border-color: rgba(23, 79, 63, 0.35);
    box-shadow: 0 0 0 4px rgba(23, 79, 63, 0.1);
}

.message-form {
    display: grid;
    gap: 14px;
}

.form-result {
    display: grid;
    gap: 4px;
    max-height: 132px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.35;
    background: var(--primary-soft);
    border: 1px solid rgba(23, 79, 63, 0.12);
    border-radius: 16px;
    overflow-wrap: anywhere;
    word-break: break-word;
    scrollbar-width: thin;
}

.form-result[hidden] {
    display: none;
}

.form-result strong {
    display: block;
    font-size: 13px;
    line-height: 1.25;
}

.form-result a {
    display: block;
    color: var(--primary);
    font-weight: 900;
    text-decoration: none;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.form-result-text {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.form-result.error {
    color: var(--danger);
    background: #fff0ec;
    border-color: rgba(163, 58, 46, 0.16);
}

.public-shell,
.center-shell {
    display: grid;
    width: min(980px, calc(100% - 32px));
    min-height: calc(100svh - 48px);
    margin: 0 auto;
    padding: 8px 0 14px;
    place-items: center;
}

.public-card {
    position: relative;
    display: grid;
    gap: 14px;
    width: 100%;
    max-height: calc(100svh - 64px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px;
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 34px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    scrollbar-width: thin;
}

.public-orb {
    position: absolute;
    top: -90px;
    right: -80px;
    width: 220px;
    height: 220px;
    pointer-events: none;
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.65), transparent 24%),
        linear-gradient(135deg, rgba(217, 164, 65, 0.34), rgba(23, 79, 63, 0.18));
    border-radius: 999px;
    filter: blur(2px);
}

.public-identity {
    position: relative;
    z-index: 1;
    text-align: center;
}

.public-avatar {
    display: grid;
    width: 58px;
    height: 58px;
    margin: 2px auto 12px;
    place-items: center;
    color: #fff;
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    border-radius: 24px;
    box-shadow: 0 18px 42px rgba(23, 79, 63, 0.22);
}

.public-identity h1 {
    margin-bottom: 6px;
    font-size: clamp(30px, 7vw, 46px);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.public-identity p {
    max-width: 540px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
}

.public-chat {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 10px;
    min-height: 0;
    padding: 10px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 26px;
}

.messages {
    display: grid;
    align-content: start;
    gap: 4px;
    min-height: 180px;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 20px;
}

.public-message-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    padding: 7px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 18px;
}

.public-message-composer:focus-within {
    background: #fff;
    border-color: rgba(23, 79, 63, 0.35);
    box-shadow: 0 0 0 4px rgba(23, 79, 63, 0.1);
}

.public-message-composer textarea {
    min-height: 42px;
    max-height: 132px;
    padding: 9px 6px;
    resize: none;
    overflow-y: auto;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.public-message-composer textarea:focus {
    background: transparent;
    border: 0;
    box-shadow: none;
}

.public-send-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    min-height: 42px;
    padding: 0 12px;
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    border: 0;
    border-radius: 14px;
    background:
        radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.24), transparent 26%),
        linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 10px 22px rgba(23, 79, 63, 0.2);
}

.public-send-button:disabled {
    opacity: 0.65;
    box-shadow: none;
}

.message {
    display: grid;
    gap: 4px;
    width: fit-content;
    max-width: min(82%, 100%);
    min-width: 0;
    padding: 8px 10px 7px;
    font-size: 13px;
    line-height: 1.32;
    border-radius: 16px;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    box-shadow: 0 8px 20px rgba(52, 39, 21, 0.055);
}

.message.visitor {
    justify-self: start;
    color: var(--text);
    background: #fff;
    border: 1px solid rgba(31, 24, 17, 0.1);
    border-bottom-left-radius: 7px;
}

.message.owner {
    justify-self: end;
    color: #fff;
    background:
        radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.18), transparent 26%),
        linear-gradient(135deg, var(--primary), var(--primary-2));
    border: 1px solid rgba(23, 79, 63, 0.1);
    border-bottom-right-radius: 7px;
}

.message.visitor .message-time {
    text-align: left;
}

.message.owner .message-time {
    text-align: right;
}

.message * {
    max-width: 100%;
    margin: 0;
    padding: 0;
    line-height: inherit;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-time {
    display: block;
    opacity: 0.72;
    font-size: 10px;
    line-height: 1.1;
}

.message::before,
.message::after {
    display: none;
    content: none;
}

.empty-state {
    display: grid;
    min-height: 120px;
    place-items: center;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}

.message-pending {
    opacity: 0.72;
}

.message-failed {
    color: #fff;
    background: linear-gradient(135deg, #8f2f29, #b54338) !important;
    border-color: rgba(143, 47, 41, 0.2) !important;
}

@media (min-width: 720px) {

    .public-card {
        grid-template-columns: 0.9fr 1.1fr;
        align-items: center;
        padding: 24px;
    }

    .public-identity {
        text-align: left;
    }

    .public-avatar {
        margin-left: 0;
    }
}

@media (min-width: 960px) {
.public-chat .messages {
        height: clamp(240px, 46svh, 520px);
        min-height: 0;
        max-height: none;
    }

    .messages {
        max-height: 520px;
    }
}

@media (max-width: 520px) {

    .site-header {
        width: min(var(--max), calc(100% - 24px));
    }

    .public-shell,
    .center-shell {
        width: calc(100% - 24px);
    }

    .public-shell {
        min-height: calc(100svh - 48px);
        padding: 4px 0 10px;
        place-items: start center;
    }

    .public-card {
        gap: 10px;
        max-height: calc(100svh - 56px);
        padding: 14px;
        border-radius: 26px;
    }

    .public-avatar {
        width: 48px;
        height: 48px;
        margin-bottom: 8px;
        font-size: 26px;
        border-radius: 18px;
    }

    .public-identity h1 {
        margin-bottom: 4px;
        font-size: clamp(26px, 9vw, 36px);
    }

    .public-identity p {
        font-size: 13px;
        line-height: 1.3;
    }

    .public-chat {
        gap: 8px;
        padding: 8px;
        border-radius: 22px;
    }

    .public-chat .messages {
        min-height: 150px;
        max-height: 250px;
    }

    .message-form {
        gap: 9px;
    }

    .message-form textarea {
        min-height: 74px;
        max-height: 120px;
    }

    .public-message-composer textarea {
        min-height: 42px;
        max-height: 112px;
    }

    .form-result {
        max-height: 118px;
        padding: 9px 10px;
        font-size: 11px;
        border-radius: 14px;
    }

    .form-result strong {
        font-size: 12px;
    }

    .form-result-text {
        font-size: 11px;
    }
}

@media (max-height: 680px) {

    .public-card {
        align-items: start;
    }

    .public-avatar {
        width: 44px;
        height: 44px;
        margin-bottom: 7px;
        font-size: 24px;
        border-radius: 17px;
    }

    .public-identity h1 {
        font-size: clamp(24px, 7vw, 34px);
    }

    .public-identity p {
        font-size: 12px;
    }

    .public-chat .messages {
        min-height: 130px;
        max-height: 220px;
    }

    input {
        height: 44px;
    }

    textarea {
        padding: 11px 12px;
    }
}

@media (prefers-reduced-motion: no-preference) {

    .public-orb {
        animation: ciPulse 7s ease-in-out infinite;
    }

    @keyframes ciPulse {
        0%,
        100% {
            transform: scale(1);
            opacity: 0.88;
        }

        50% {
            transform: scale(1.06);
            opacity: 1;
        }
    }
}
