/* JOW members area (PortalTheme): only what the portal adds on top of theme.css. */
@layer components {
    /* The footer sits at the bottom of the window, also on short pages. */
    .portal-body {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
    }

    .portal-body > main {
        flex: 1;
    }

    .portal-section {
        padding-top: clamp(2rem, 5vw, 3.5rem);
    }

    .portal-content {
        min-width: 0;
    }

    .portal-head {
        display: flex;
        flex-wrap: wrap;
        align-items: end;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .portal-head h1 {
        font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
        margin: 0;
    }

    .portal-back {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 0.5rem;
        color: var(--muted);
        font-size: var(--fs-small);
        text-decoration: none;
    }

    .portal-back svg {
        width: 1rem;
        height: 1rem;
    }

    /* Header: name and a way back to the website */
    .portal-topnav {
        display: flex;
        align-items: center;
        gap: 1.25rem;
        margin-left: auto;
        font-size: var(--fs-small);
    }

    .portal-topnav a {
        color: inherit;
    }

    .portal-topnav__name {
        opacity: 0.8;
    }

    @media (max-width: 599px) {
        .portal-topnav__name {
            display: none;
        }
    }

    /* Side nav: badge and the logout button */
    .side-nav__badge {
        margin-left: auto;
        min-width: 1.4rem;
        padding: 0.05rem 0.4rem;
        border-radius: 999px;
        background: var(--terra-btn);
        color: #fff;
        font-size: 0.75rem;
        font-weight: 700;
        text-align: center;
    }

    .side-nav__button {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        width: 100%;
        padding: 0.7rem 0.95rem;
        border: 0;
        border-radius: 1.2rem 1.2rem 1.2rem var(--sharp);
        background: none;
        color: var(--text);
        font: inherit;
        font-weight: 500;
        white-space: nowrap;
        cursor: pointer;
    }

    .side-nav__button:hover {
        background: var(--surface);
    }

    .side-nav__button svg {
        width: 1.15rem;
        height: 1.15rem;
        flex: none;
    }

    /* Alerts */
    .alert {
        margin-bottom: 1.25rem;
        padding: 1rem 1.2rem;
        border-radius: 16px 16px 16px var(--sharp);
        background: color-mix(in srgb, var(--accent) 14%, var(--surface));
        color: var(--text);
        font-weight: 500;
    }

    .alert--error {
        background: color-mix(in srgb, var(--terra-btn) 16%, var(--surface));
    }

    .alert--info {
        background: var(--surface);
        box-shadow: inset 0 0 0 1.5px var(--line-strong);
    }

    .alert ul {
        margin: 0;
        padding-left: 1.1rem;
    }

    /* Tables */
    .table-wrap {
        overflow-x: auto;
        margin-inline: calc(clamp(1.4rem, 3vw, 2rem) * -1);
        padding-inline: clamp(1.4rem, 3vw, 2rem);
    }

    .table {
        width: 100%;
        border-collapse: collapse;
        font-size: var(--fs-small);
    }

    .table th,
    .table td {
        padding: 0.75rem 0.6rem;
        border-bottom: 1px solid var(--line);
        text-align: left;
        vertical-align: top;
    }

    .table th {
        color: var(--muted);
        font-weight: 600;
        white-space: nowrap;
    }

    .table tfoot td {
        border-bottom: 0;
    }

    .table .num {
        text-align: right;
        white-space: nowrap;
    }

    /* Invoice notes keep their line breaks. */
    .pre-line {
        white-space: pre-line;
    }

    /* Invoice status */
    .pill--paid {
        background: color-mix(in srgb, var(--accent) 22%, var(--surface));
        color: var(--text);
    }

    .pill--open {
        background: var(--surface-2);
        color: var(--text);
    }

    .pill--late {
        background: var(--terra-btn);
        color: #fff;
    }

    /* Pager */
    .pager {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        margin-top: 1.25rem;
    }

    /* Notifications */
    .rows .is-read {
        opacity: 0.6;
    }

    .rows__date {
        color: var(--muted);
        font-size: var(--fs-small);
        font-weight: 600;
    }

    /* A small dot with a 24px hit area (WCAG 2.5.8). */
    .dot-button {
        width: 1.5rem;
        height: 1.5rem;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: radial-gradient(circle, var(--accent) 0 0.375rem, transparent 0.4rem);
        cursor: pointer;
    }

    /* Read-only field (the e-mail address under review) */
    .field input[readonly] {
        background: var(--surface);
        color: var(--muted);
        cursor: not-allowed;
    }

    /* Logo preview: on white, like the members page, also in dark mode */
    .portal-logo-preview {
        max-width: 14rem;
        max-height: 5rem;
        padding: 0.6rem;
        border-radius: 12px 12px 12px var(--sharp);
        background: #fff;
        box-shadow: inset 0 0 0 1px var(--line);
        object-fit: contain;
    }

    /* Danger zone (account deletion) */
    .panel--danger {
        box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--terra-btn) 55%, transparent);
    }

    /* Footer */
    .portal-footer {
        padding-block: 1.25rem;
        background: var(--navy-block);
        color: var(--sand);
        font-size: var(--fs-small);
    }

    .portal-footer a {
        color: inherit;
    }

    .portal-footer .wrap {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.75rem;
    }

    /* Folded form part (the other invoice address) */
    .fold {
        display: grid;
        gap: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--line);
    }

    .fold > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        color: var(--heading);
        font-size: 1.125rem;
        font-weight: 700;
        cursor: pointer;
        list-style: none;
    }

    .fold > summary::-webkit-details-marker {
        display: none;
    }

    .fold > summary::after {
        content: "";
        flex: none;
        width: 1.75rem;
        height: 1.75rem;
        border-radius: 1rem 1rem 1rem 3px;
        background:
            linear-gradient(var(--sand), var(--sand)) center / 0.7rem 2px no-repeat,
            linear-gradient(var(--sand), var(--sand)) center / 2px 0.7rem no-repeat,
            var(--navy-block);
        transition: transform 0.25s ease;
    }

    .fold[open] > summary::after {
        transform: rotate(45deg);
    }

    .fold[open] > summary {
        margin-bottom: 0.25rem;
    }

    /* Guest pages (log in, password, invitation): one screen */
    .portal-section--guest {
        padding-block: clamp(1.5rem, 5vh, 3rem);
    }

    .portal-auth__heading {
        margin-bottom: 1.25rem;
        text-align: center;
    }

    .form--tight {
        gap: 1rem;
    }

    .portal-auth__row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        align-items: center;
        justify-content: space-between;
    }

    .portal-auth__foot {
        margin-top: 1.25rem;
        padding-top: 1rem;
        border-top: 1px solid var(--line);
        font-size: var(--fs-small);
        text-align: center;
    }
}

/* Same layer as theme.css .dialog and .login, so these sizes win. */
@layer sections {
    /* Applying and confirming: two fields per row and a list of answers, so
       room for a whole e-mail address next to the phone number. */
    .login--wide {
        width: min(100%, 46rem);
    }

    .dialog--confirm {
        width: min(100% - 2rem, 28rem);
        color: var(--text);
    }

    .dialog__actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
}
