/* Constrain top-level regions to the viewport and allow flex children to
   shrink below their content size, so wide content wraps instead of widening
   the document. */
html,
body {
    width: 100%;
    max-width: 100%;
}

/* ------------------------------------------------------------- Landing hero */

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 3rem;
    align-items: center;
    padding: 4.5rem 0 3.5rem;
}

.home-hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 1.1rem;
}

.home-hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.3rem, 4.5vw, 3.2rem);
    line-height: 1.03;
    letter-spacing: -0.03em;
    color: var(--slate);
    margin: 0 0 1rem;
}

.home-hero-lead {
    font-size: 1.1rem;
    color: var(--muted);
    max-width: 44ch;
    margin: 0 0 1.75rem;
}

.home-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Terminal "stack manifest" — the page's signature element. */
.stack-term {
    background: var(--slate);
    border: 1px solid #2c3b43;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 0;
}

.stack-term-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid #2c3b43;
}

.stack-term-bar span.dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    display: inline-block;
}
.stack-term-bar .dot-r { background: #e05a4d; }
.stack-term-bar .dot-y { background: var(--amber); }
.stack-term-bar .dot-g { background: #57b894; }

.stack-term-title {
    margin-left: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #8a9ba0;
}

.stack-term-body {
    padding: 1.1rem 1.15rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.5;
    color: #cdd8da;
    overflow-x: auto;
}

.stack-term-cmd { color: #8fb7c0; }
.stack-term-cmd b { color: var(--amber); font-weight: 600; }

.stack-term-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}
.stack-term-list li {
    display: flex;
    gap: 0.9rem;
    padding: 0.2rem 0;
}
.stack-term-ok { color: #57b894; }
.stack-term-pkg { color: #fff; font-weight: 600; min-width: 5.5rem; }
.stack-term-desc { color: #93a4a8; overflow-wrap: anywhere; }

.stack-term-foot { margin-top: 0.75rem; color: #8a9ba0; }

.stack-term-cursor {
    display: inline-block;
    width: 0.5rem;
    height: 0.95rem;
    background: var(--amber);
    vertical-align: -0.12rem;
    margin-left: 0.25rem;
    animation: fjp-blink 1.05s step-end infinite;
}

@keyframes fjp-blink { 50% { opacity: 0; } }

/* Staggered reveal on load. */
.stack-term-cmd,
.stack-term-list li,
.stack-term-foot {
    animation: fjp-line-in 0.4s ease both;
}
.stack-term-list li:nth-child(1) { animation-delay: 0.12s; }
.stack-term-list li:nth-child(2) { animation-delay: 0.22s; }
.stack-term-list li:nth-child(3) { animation-delay: 0.32s; }
.stack-term-list li:nth-child(4) { animation-delay: 0.42s; }
.stack-term-foot { animation-delay: 0.55s; }

@keyframes fjp-line-in {
    from { opacity: 0; transform: translateX(-0.4rem); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 767.98px) {
    .home-hero {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2.5rem 0;
    }
    .home-hero-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .stack-term-cursor,
    .stack-term-cmd,
    .stack-term-list li,
    .stack-term-foot {
        animation: none;
    }
}

body,
body > header,
body > main,
body > footer,
main {
    min-width: 0;
    max-width: 100%;
}

.invalid-feedback {
    display: none;
    color: red;
}

input:invalid:not(:placeholder-shown) + .invalid-feedback {
    display: block;
}

/* Organization page header. */
.organization-page-header {
    min-width: 0;
    max-width: 100%;
}

.organization-page-header-title {
    flex: 1 1 20rem;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.organization-page-header-actions {
    flex: 0 0 auto;
}

@media (max-width: 767.98px) {
    .organization-page-header-actions {
        width: 100%;
    }
}

/* Dashboard organization selector. */
.dashboard-org-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    min-width: 0;
    max-width: 100%;
}

.dashboard-org-selector-label {
    white-space: nowrap;
}

.dashboard-org-selector-name {
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.dashboard-org-selector-control .dropdown-toggle {
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-resources-card-title {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.dashboard-resource-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem 1rem;
    min-width: 0;
}

.dashboard-resource-item-title {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.dashboard-resource-item-date {
    flex-shrink: 0;
    white-space: nowrap;
}

.dashboard-resource-item-description {
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 767.98px) {
    /* Multi-org picker: stack label above full-width dropdown. */
    .dashboard-org-selector:has(.dashboard-org-selector-control) {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-org-selector-control {
        width: 100%;
    }

    .dashboard-org-selector-control .dropdown-toggle {
        max-width: 100%;
        width: 100%;
    }

    .dashboard-resource-item-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Profile page. */
.profile-email-list-item-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    min-width: 0;
}

.profile-email-leading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    min-width: 0;
}

.profile-email-address {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-email-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.profile-organizations-card-title {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-organizations-create-btn {
    flex-shrink: 0;
}

.profile-organization-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem 1rem;
    min-width: 0;
}

.profile-organization-item-name {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-organization-item-date {
    flex-shrink: 0;
    white-space: nowrap;
}

.profile-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.profile-form-actions .profile-form-cancel-btn {
    margin-left: 0;
}

@media (max-width: 767.98px) {
    .profile-email-list-item-body {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-email-leading {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-email-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .profile-email-action-form {
        width: 100%;
    }

    .profile-email-action-form .btn {
        width: 100%;
    }

    .profile-organizations-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-organizations-create-btn {
        width: 100%;
        align-self: stretch;
    }

    .profile-organization-item-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-form-actions .btn {
        width: 100%;
    }

    .profile-add-email-form .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-add-email-form .input-group > .form-control,
    .profile-add-email-form .input-group > .btn {
        width: 100%;
        border-radius: var(--radius-sm);
    }

    .profile-add-email-form .input-group > .form-control {
        border-bottom-right-radius: var(--radius-sm);
        border-bottom-left-radius: var(--radius-sm);
    }

    .profile-add-email-form .input-group > .btn {
        margin-top: 0.5rem;
    }
}

/* Site navbar: long brand text must not crowd the mobile toggler. */
.site-navbar-brand {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 991.98px) {
    .site-navbar-brand {
        flex: 1 1 auto;
        max-width: calc(100% - 3.5rem);
        font-size: 1rem;
        line-height: 1.25;
    }
}

/* Site footer: align horizontal padding with navbar; spread copyright and contact. */
.site-footer-inner {
    padding-inline: 1.25rem;
}

.site-footer-row {
    display: grid;
    gap: 1.25rem;
    text-align: center;
}

.site-footer-copyright,
.site-footer-links,
.site-footer-contact {
    min-width: 0;
}

.site-footer-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.15;
    letter-spacing: -0.015em;
    color: var(--muted);
    margin: 0 0 0.5rem;
}

.site-footer-body,
.site-footer-body a {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--muted);
}

.site-footer-body a:hover {
    color: var(--primary);
}

@media (min-width: 992px) {
    .site-footer-row {
        grid-template-columns: 1fr auto 1fr;
        align-items: end;
        gap: 2rem;
    }

    .site-footer-copyright {
        justify-self: start;
        text-align: start;
    }

    .site-footer-links {
        justify-self: center;
        text-align: center;
    }

    .site-footer-contact {
        justify-self: end;
        text-align: end;
    }
}

/* Pending invitations in organization members card. */
.invitation-list-item-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.invitation-list-leading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.35rem;
    min-width: 0;
}

.invitation-list-email {
    word-break: break-word;
}

.invitation-actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Desktop: bleed list to card edges so actions align with Invite Member. */
.card-body .invitation-list.list-group-flush {
    margin-left: calc(-1 * var(--card-spacer-x));
    margin-right: calc(-1 * var(--card-spacer-x));
}

.card-body .invitation-list .invitation-list-item {
    padding-left: var(--card-spacer-x);
    padding-right: var(--card-spacer-x);
}

.invitation-resend-form .btn-invitation-resend,
.invitation-cancel-form .btn {
    min-width: 6.75rem;
}

@media (max-width: 767.98px) {
    .card-body .invitation-list.list-group-flush {
        margin-left: 0;
        margin-right: 0;
    }

    .card-body .invitation-list .invitation-list-item {
        padding-left: 0;
        padding-right: 0;
    }

    .invitation-list-item + .invitation-list-item {
        margin-top: 0.25rem;
        padding-top: 0.75rem;
    }

    .invitation-list-item-body {
        flex-direction: column;
        align-items: stretch;
    }

    .invitation-list-leading {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .invitation-actions-cell {
        width: 100%;
    }

    .invitation-resend-form,
    .invitation-cancel-form {
        flex: 1 1 0;
    }

    .invitation-resend-form .btn-invitation-resend,
    .invitation-cancel-form .btn {
        min-width: 0;
        width: 100%;
    }
}