/*
 * kink.town theme for ejabberd's mod_invites pages (Nightcap: brass on ink)
 * --------------------------------------------------------------------------
 * Replaces Bootstrap 5, which ejabberd normally ships separately. The
 * templates keep their Bootstrap class names, so this file implements only
 * the classes they (and static/invite.js) actually use. Upstream template
 * updates should keep working; if a new template uses a class not covered
 * here it will simply render unstyled.
 *
 * invite.css still loads after this file. It reads Bootstrap's colour
 * variables (--bs-info-rgb etc.), which are defined below in the Nightcap
 * palette.
 */

/* ---------- Fonts ---------- */

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/Roboto-Regular-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url(fonts/Roboto-Medium-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url(fonts/CormorantGaramond-Medium.woff) format('woff');
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 500;
    font-display: swap;
    src: url(fonts/CormorantGaramond-MediumItalic.woff) format('woff');
}

/* ---------- Tokens ---------- */

:root {
    --ink: #0D0F14;
    --smoke: #181B23;
    --smoke-2: #1E222C;
    --well: #08090C;
    --ivory: 244, 238, 227;
    --brass: #CDA766;
    --brass-rgb: 205, 167, 102;
    --champagne: #DCC28E;
    --on-brass: #15120C;
    --sage: #8CB89A;
    --sage-rgb: 140, 184, 154;
    --straw-rgb: 220, 206, 134;
    --rose: #E5918C;
    --rose-rgb: 229, 145, 140;
    --hairline: rgba(205, 167, 102, 0.22);
    --rule: rgba(244, 238, 227, 0.08);
    --text: rgba(var(--ivory), 0.87);
    --text-2: rgba(var(--ivory), 0.64);
    --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
    --radius: 12px;

    /* Bootstrap variables used by invite.css */
    --bs-info-rgb: var(--brass-rgb);
    --bs-warning-rgb: var(--straw-rgb);
    --bs-danger-rgb: var(--rose-rgb);
    --bs-gray-100: var(--smoke-2);
    --bs-gray-300: rgba(244, 238, 227, 0.2);

    color-scheme: dark;
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 70% 55% at 85% 100%, rgba(205, 167, 102, 0.12), transparent 70%),
        radial-gradient(ellipse 60% 50% at 10% 0%, rgba(151, 169, 222, 0.06), transparent 70%),
        var(--ink);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.6;
}

::selection { background: rgba(205, 167, 102, 0.35); color: rgb(var(--ivory)); }

[hidden] { display: none !important; }

p { margin: 0 0 1rem; }
strong, b { font-weight: 500; color: rgb(var(--ivory)); }
small, .small { font-size: 0.875rem; }
img, svg { vertical-align: middle; }
code { font-family: ui-monospace, monospace; font-size: 0.9em; color: var(--champagne); }

a { color: var(--champagne); text-decoration-color: rgba(220, 194, 142, 0.4); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

h1, h2, h3, h4, h5, h6, .h3, .h4, .h5, .h6 {
    margin: 0 0 0.75rem;
    font-family: var(--serif);
    font-weight: 500;
    line-height: 1.15;
    color: rgb(var(--ivory));
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3, .h3 { font-size: 1.6rem; }
h4, .h4 { font-size: 1.45rem; }
h5, .h5 { font-size: 1.35rem; }
h6, .h6 { font-size: 1.15rem; }

/* ---------- Page frame ---------- */

/* The one card that holds each page (base_min.html: #form > .card) */
#form {
    width: min(100% - 2rem, 46rem);
    margin: 3rem auto;
    padding: 0;
}
/* Pages that keep the wide default layout (invite, client and roster pages) */
#form.col-lg-10 { width: min(100% - 2rem, 64rem); }

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--smoke);
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px var(--hairline);
}
#form > .card { box-shadow: inset 0 0 0 1px var(--hairline), 0 24px 60px rgba(0, 0, 0, 0.45); }

.card-header {
    margin: 0;
    padding: 1.75rem 2rem 1.25rem;
    font-size: clamp(1.9rem, 5vw, 2.6rem);
    font-style: italic;
    line-height: 1.05;
    border-bottom: 1px solid var(--rule);
}
.card-header::before {
    content: "";
    display: inline-block;
    width: 0.4em; height: 0.4em;
    margin-right: 0.5em;
    vertical-align: 0.12em;
    border-radius: 50%;
    background: var(--brass);
    box-shadow: 0 0 14px rgba(205, 167, 102, 0.55);
}
.card-body { flex: 1 1 auto; padding: 1.75rem 2rem 2rem; }
.card-title { margin-bottom: 0.75rem; }
.card-text { color: var(--text-2); }

/* ---------- Grid (the subset the templates use) ---------- */

.container, .container-sm-fluid { width: 100%; margin-inline: auto; }
.row { display: flex; flex-wrap: wrap; margin-inline: -0.75rem; }
.row > * { flex-shrink: 0; width: 100%; max-width: 100%; padding-inline: 0.75rem; }
.row.no-gutters { margin-inline: 0; }
.row.no-gutters > * { padding-inline: 0; }
.col { flex: 1 0 0%; }
.col-12 { flex: 0 0 auto; width: 100%; }

@media (min-width: 576px) {
    .col-sm-8  { flex: 0 0 auto; width: 66.6667%; }
    .col-sm-12 { flex: 0 0 auto; width: 100%; }
}
@media (min-width: 768px) {
    .col-md-4  { flex: 0 0 auto; width: 33.3333%; }
    .col-md-8  { flex: 0 0 auto; width: 66.6667%; }
    .col-md-9  { flex: 0 0 auto; width: 75%; }
    .col-md-10 { flex: 0 0 auto; width: 83.3333%; }
}
@media (min-width: 992px) {
    .col-lg-5  { flex: 0 0 auto; width: 41.6667%; }
    .col-lg-10 { flex: 0 0 auto; width: 83.3333%; }
}
@media (min-width: 1200px) {
    .col-xl-4 { flex: 0 0 auto; width: 33.3333%; }
    .col-xl-8 { flex: 0 0 auto; width: 66.6667%; }
}
/* #form is sized above; its column classes must not resize it */
#form[class*="col-"] { flex: none; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: 999px;
    font: 500 0.9375rem/1.2 var(--sans);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    color: rgb(var(--ivory));
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--hairline);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.btn:hover { background: rgba(205, 167, 102, 0.1); box-shadow: inset 0 0 0 1px rgba(205, 167, 102, 0.5); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary, .btn-success {
    background: var(--brass);
    color: var(--on-brass);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.btn-primary:hover, .btn-success:hover { background: var(--champagne); color: var(--on-brass); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }

.btn-secondary, .btn-info, .btn-outline-secondary {
    background: var(--smoke-2);
    color: rgb(var(--ivory));
}

.btn-sm { min-height: 2.25rem; padding: 0 0.9rem; font-size: 0.875rem; }
.btn-lg { min-height: 3.25rem; padding: 0 1.75rem; font-size: 1.0625rem; }

.btn-close {
    width: 2.25rem; height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
}
.btn-close::before { content: "×"; font-size: 1.6rem; line-height: 1; }
.btn-close:hover { background: rgba(205, 167, 102, 0.1); color: rgb(var(--ivory)); }

/* ---------- Forms ---------- */

.form-label, .col-form-label { display: inline-block; margin-bottom: 0.375rem; color: rgb(var(--ivory)); }
.col-form-label { padding-top: 0.6rem; margin-bottom: 0; }
.form-text { display: block; margin-top: 0.375rem; font-size: 0.875rem; color: var(--text-2); }

.form-control {
    display: block;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--well);
    box-shadow: inset 0 0 0 1px rgba(244, 238, 227, 0.12);
    color: rgb(var(--ivory));
    font: 400 1rem/1.4 var(--sans);
}
.form-control:focus { outline: none; box-shadow: inset 0 0 0 1px var(--brass), 0 0 0 3px rgba(205, 167, 102, 0.2); }
.form-control[readonly], .form-control:disabled { color: var(--text-2); }

.form-control-plaintext {
    display: block;
    width: 100%;
    padding: 0.55rem 0;
    border: 0;
    background: transparent;
    color: var(--champagne);
    font: 500 1rem/1.4 var(--sans);
}

.input-group { position: relative; display: flex; flex-wrap: wrap; align-items: stretch; width: 100%; }
.input-group > .form-control { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group-append { display: flex; }
.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 0.9rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--smoke-2);
    box-shadow: inset 0 0 0 1px rgba(244, 238, 227, 0.12);
    color: var(--text-2);
    white-space: nowrap;
}
.input-group-append .btn { min-height: 100%; border-radius: 0 var(--radius) var(--radius) 0; }
.rounded-start-0 { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }

/* Validation: shown after a failed submit (.was-validated) or from the server (.is-invalid) */
.invalid-feedback { display: none; width: 100%; margin-top: 0.375rem; font-size: 0.875rem; color: var(--rose); }
.is-invalid ~ .invalid-feedback,
.was-validated :invalid ~ .invalid-feedback { display: block; }
.form-control.is-invalid,
.was-validated .form-control:invalid { box-shadow: inset 0 0 0 1px var(--rose); }
.was-validated .form-control:valid { box-shadow: inset 0 0 0 1px rgba(140, 184, 154, 0.6); }

.form-check { display: block; padding-left: 1.75rem; }
.form-check-input { float: left; margin: 0.3rem 0 0 -1.75rem; width: 1.1rem; height: 1.1rem; accent-color: var(--brass); }
.form-check-label { color: rgb(var(--ivory)); }

.account-details {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    background: var(--well);
    box-shadow: inset 0 0 0 1px var(--hairline);
}
.account-details > .input-group + .input-group { margin-top: 0.5rem; }

/* ---------- Alerts, callouts, badges ---------- */

.alert {
    position: relative;
    margin-bottom: 1rem;
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius);
    background: rgba(var(--alert-rgb, var(--brass-rgb)), 0.08);
    box-shadow: inset 0 0 0 1px rgba(var(--alert-rgb, var(--brass-rgb)), 0.35);
    color: var(--text);
}
.alert > :last-child { margin-bottom: 0; }
.alert-info    { --alert-rgb: var(--brass-rgb); }
.alert-success { --alert-rgb: var(--sage-rgb); }
.alert-warning { --alert-rgb: var(--straw-rgb); }
.alert-danger  { --alert-rgb: var(--rose-rgb); }
/* Step headings ("Step 1: …") are styled as alerts upstream */
h2.alert, .h3.alert, .h5.alert { padding: 0.6rem 1rem; font-size: 1.35rem; }

.bd-callout { border-radius: 0 var(--radius) var(--radius) 0; }

.badge {
    display: inline-block;
    padding: 0.3em 0.7em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.text-bg-info      { background: rgba(var(--brass-rgb), 0.16); color: var(--champagne) !important; }
.text-bg-success   { background: rgba(var(--sage-rgb), 0.18);  color: var(--sage) !important; }
.text-bg-secondary { background: rgba(244, 238, 227, 0.08);    color: var(--text-2) !important; }
.text-bg-light     { background: var(--smoke-2);               color: rgb(var(--ivory)) !important; }

/* ---------- App list (apps.html, client.html) ---------- */

.client-card {
    margin: 0 1rem 1rem 0;
    padding: 0.75rem;
    background: var(--smoke-2);
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(244, 238, 227, 0.06);
    transition: box-shadow 0.2s ease;
}
.client-card:hover, .client-card.supported-platform { box-shadow: inset 0 0 0 1px var(--hairline); }
.client-card img { max-height: 6rem; object-fit: contain; }
.client-card .card-body { padding: 0.5rem 0.75rem; }
.client-card .card-title { margin-bottom: 0.25rem; }
.invite-download-button { max-width: 160px; }

/* ---------- Invite-link page (index.html) ---------- */

/* The QR code needs a light background to scan */
#qr-invite-page { padding: 12px; border-radius: var(--radius); background: #fff !important; }
#qr-invite-page img, #qr-invite-page canvas { display: block; max-width: 100%; height: auto; }
.tab-pane { display: block; }

/* "Scan with mobile device" tip box (base.html) */
#qr-button-container { border-radius: 16px; background: var(--smoke-2); box-shadow: inset 0 0 0 1px var(--hairline); color: var(--text-2); font-size: 0.9375rem; }

/* ---------- Pagination ("Previous" link) ---------- */

.pagination { display: flex; padding: 0; margin: 0; list-style: none; }
.page-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.5rem;
    padding: 0 1rem;
    border-radius: 999px;
    color: var(--text-2);
    text-decoration: none;
    box-shadow: inset 0 0 0 1px var(--rule);
}
.page-link:hover { color: rgb(var(--ivory)); box-shadow: inset 0 0 0 1px var(--hairline); }

/* ---------- Modal (QR dialog; behaviour in kinktown.js) ---------- */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1050;
    padding: 1rem;
    overflow-y: auto;
    background: rgba(8, 9, 12, 0.8);
    backdrop-filter: blur(2px);
}
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-dialog { width: min(100%, 26rem); }
.modal-content {
    background: var(--smoke);
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px var(--hairline), 0 24px 60px rgba(0, 0, 0, 0.5);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.5rem 0.75rem; }
.modal-title { margin: 0; }
.modal-body { padding: 0.5rem 1.5rem 1rem; }
.modal-footer { display: flex; justify-content: flex-end; padding: 0 1.5rem 1.5rem; }
body.modal-open { overflow: hidden; }

/* ---------- Utilities ---------- */

.d-none  { display: none !important; }
.d-block { display: block !important; }
.d-flex  { display: flex !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.float-end { float: right !important; }
.clear-both { clear: both; }
.h-100 { height: 100% !important; }
.w-100 { width: 100% !important; }
.w-25  { width: 25% !important; }
.img-fluid { max-width: 100%; height: auto; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-nowrap { white-space: nowrap !important; }
.fw-bold { font-weight: 500 !important; }

.text-muted { color: var(--text-2) !important; }
.text-warning { color: var(--brass) !important; }
.text-warning-emphasis { color: var(--champagne) !important; }
.text-alert { color: var(--champagne) !important; }
.bg-light { background: var(--smoke-2) !important; }

.shadow { box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.rounded, .rounded-2 { border-radius: var(--radius) !important; }
.rounded-top { border-top-left-radius: var(--radius) !important; border-top-right-radius: var(--radius) !important; }
.border { border: 1px solid var(--rule) !important; }
.border-info { border-color: var(--hairline) !important; }
.border-secondary-light { border-color: var(--rule) !important; }

.m-0 { margin: 0 !important; }
.mx-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.my-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
.my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-3 { margin-right: 1rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-5 { margin-left: 3rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pb-0 { padding-bottom: 0 !important; }

@media (min-width: 768px) {
    .d-md-block { display: block !important; }
    .text-md-start { text-align: left !important; }
    .mt-md-0 { margin-top: 0 !important; }
    .mt-md-auto { margin-top: auto !important; }
    .ms-md-1 { margin-left: 0.25rem !important; }
    .ms-md-5 { margin-left: 3rem !important; }
    .ps-md-1 { padding-left: 0.25rem !important; }
    .p-md-0 { padding: 0 !important; }
}

/* ---------- Small screens ---------- */

@media (max-width: 575.98px) {
    #form, #form.col-lg-10 { width: 100%; margin: 0; }
    #form > .card { min-height: 100vh; border-radius: 0; box-shadow: none; }
    .card-header { padding: 1.25rem 1.25rem 1rem; }
    .card-body { padding: 1.25rem; }
    .ms-5 { margin-left: 0 !important; }
    .client-card { margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
