/* ==========================================================================
   Client portal — layered on top of the main site's styles.css so the portal
   reads as the same product: same tokens, same citation device, same rules.
   ========================================================================== */

/* ===== App header (replaces the marketing nav once signed in) ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}

.app-header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 70px;
}

.app-badge {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--steel);
    border: 1px solid var(--rule-strong);
    padding: 4px 9px;
    white-space: nowrap;
}

.app-header .wordmark {
    margin-right: 0;
}

/* The wordmark points at the portal dashboard, so the way out needs its own link. */
.app-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel);
    white-space: nowrap;
    transition: color 0.16s var(--ease);
}

.app-back:hover {
    color: var(--red);
}

.app-spacer {
    margin-left: auto;
}

.app-user {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

.app-user-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.25;
}

.app-user-org {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    color: var(--steel-2);
}

.app-signout {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    border: 1px solid var(--rule-strong);
    padding: 9px 14px;
    white-space: nowrap;
    transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease),
        color 0.16s var(--ease);
}

.app-signout:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

/* ===== Login ===== */
.login-page {
    min-height: calc(100vh - 70px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
    align-items: stretch;
}

.login-aside {
    background: var(--ink);
    color: #a9b4c0;
    padding: 72px 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-aside h1 {
    color: #fff;
    font-size: clamp(2rem, 3.4vw, 3rem);
    margin: 18px 0 24px;
}

.login-aside p {
    max-width: 44ch;
    font-size: 1.0625rem;
}

.login-aside .checklist {
    margin-top: 36px;
    max-width: 42ch;
}

.login-aside .checklist li {
    border-bottom-color: rgba(255, 255, 255, 0.12);
    font-size: 0.9375rem;
}

.login-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 72px 64px;
    background: var(--paper-2);
}

.login-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    padding: 40px 36px;
}

.login-card h2 {
    font-size: 1.75rem;
    margin: 12px 0 6px;
}

.login-card .login-intro {
    color: var(--steel);
    font-size: 0.9375rem;
    margin-bottom: 30px;
}

.login-card .field + .field {
    margin-top: 18px;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    margin-top: 28px;
}

.login-card .btn[aria-busy="true"] {
    opacity: 0.65;
    pointer-events: none;
}

/* Form-level error, distinct from the per-field messages */
.form-alert {
    margin-top: 22px;
    padding: 13px 16px;
    border-left: 3px solid var(--red);
    background: var(--red-tint);
    font-size: 0.9375rem;
    color: var(--ink-2);
}

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

/* Same block used to carry good news — a saved password, not a rejection. */
.form-alert--notice {
    border-left-color: var(--clear);
    background: var(--clear-tint);
}

.login-help {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--rule);
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--steel-2);
}

.login-help a {
    color: var(--ink);
    border-bottom: 1px solid var(--red-line);
}

.login-help a:hover {
    color: var(--red);
    border-bottom-color: var(--red);
}

/* ===== Dashboard ===== */
.dash-head {
    padding: 44px 0 36px;
    background: var(--paper-2);
    border-bottom: 1px solid var(--rule);
}

.dash-head h1 {
    font-size: clamp(1.875rem, 3.4vw, 2.75rem);
}

.dash-head .lede {
    margin-top: 14px;
    max-width: 58ch;
}

.dash-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    margin-top: 34px;
}

.dash-stat {
    background: var(--paper);
    padding: 20px 24px;
}

.dash-stat dt {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--steel);
}

.dash-stat dd {
    font-family: var(--font-display);
    font-weight: 800;
    font-stretch: 82%;
    font-size: 2rem;
    line-height: 1;
    margin-top: 8px;
    color: var(--ink);
}

.dash-stat--action dd {
    color: var(--red);
}

.dash-stat--complete dd {
    color: var(--clear);
}

/* ===== Document list ===== */
.doc-list {
    border: 1px solid var(--rule);
    border-bottom: 0;
}

.doc-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px 128px;
    gap: 8px 28px;
    align-items: center;
    padding: 22px 26px;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    transition: background-color 0.16s var(--ease);
}

a.doc-row:hover,
button.doc-row:hover {
    background: var(--paper-2);
}

/* A completed row is a <button> (it opens the submitted file rather than
   navigating to the form page). Strip the UA button chrome so it renders
   identically to the <a> rows either side of it. */
button.doc-row {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--rule);
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

/* These are spans in the markup, so they need explicit block display for the
   vertical rhythm to apply. */
.doc-main {
    display: block;
}

.doc-main .cite {
    margin-bottom: 7px;
}

.doc-title {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-stretch: 86%;
    font-size: 1.1875rem;
    line-height: 1.2;
    color: var(--ink);
    margin-bottom: 6px;
}

.doc-summary {
    display: block;
    font-size: 0.9375rem;
    color: var(--steel);
    max-width: 68ch;
}

.doc-status {
    display: block;
}

.doc-meta {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--steel-2);
    line-height: 1.5;
}

.doc-status .doc-meta {
    margin-top: 8px;
}

.doc-action {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--red);
    white-space: nowrap;
}

a.doc-row:hover .doc-action svg {
    transform: translateX(4px);
}

.doc-action svg {
    transition: transform 0.16s var(--ease);
}

/* Status pill — red / neutral / green mirrors the threshold semantics used
   on the marketing site. */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 6px 11px;
    border: 1px solid currentColor;
    white-space: nowrap;
}

.pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.pill--action {
    color: var(--red);
    background: var(--red-tint);
}

.pill--progress {
    color: var(--steel);
    background: var(--paper-2);
}

.pill--complete {
    color: var(--clear);
    background: var(--clear-tint);
}

/* ===== Form workspace ===== */
.work-head {
    padding: 28px 0;
    border-bottom: 1px solid var(--rule);
    background: var(--paper-2);
}

.work-head-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    flex-wrap: wrap;
}

.work-head h1 {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    margin-top: 8px;
}

.work-head .doc-summary {
    margin-top: 12px;
}

.work-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Phase 2 mounts <pdf-viewer> in here; Phase 1 shows the placeholder. */
.editor-mount {
    min-height: 60vh;
    border: 1px solid var(--rule-strong);
    background: var(--paper);
}

/* ===== Editor loading state ===== */
.editor-loading {
    min-height: 60vh;
    display: grid;
    place-items: center;
    padding: 60px 32px;
}

.editor-loading-inner {
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.editor-loading h2 {
    font-size: 1.25rem;
    margin: 12px 0 22px;
}

.loading-track {
    position: relative;
    height: 6px;
    background: var(--paper-3);
    overflow: hidden;
}

.loading-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: var(--red);
    transition: width 0.35s var(--ease);
}

/* Before any bytes are measurable, sweep so the panel never looks frozen. */
.loading-track[data-indeterminate="true"] .loading-bar {
    width: 32%;
    animation: loading-sweep 1.1s var(--ease) infinite;
}

@keyframes loading-sweep {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(420%); }
}

.loading-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    color: var(--steel-2);
}

.loading-hint {
    margin-top: 26px;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--steel-2);
}

@media (prefers-reduced-motion: reduce) {
    .loading-track[data-indeterminate="true"] .loading-bar {
        animation: none;
        width: 15%;
    }
}

.editor-placeholder {
    min-height: 60vh;
    display: grid;
    place-items: center;
    padding: 60px 32px;
    text-align: center;
    background:
        repeating-linear-gradient(
            45deg,
            var(--paper-2) 0 12px,
            var(--paper) 12px 24px
        );
}

.editor-placeholder-inner {
    max-width: 52ch;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    padding: 40px 38px;
}

.editor-placeholder h2 {
    font-size: 1.375rem;
    margin: 14px 0 14px;
}

.editor-placeholder p {
    color: var(--steel);
    font-size: 0.9375rem;
}

.editor-placeholder p + p {
    margin-top: 14px;
}

.editor-placeholder code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    padding: 1px 5px;
    color: var(--ink);
}

.editor-placeholder .btn-row {
    margin-top: 28px;
    justify-content: center;
}

/* ===== Portal footer ===== */
.portal-footer {
    border-top: 1px solid var(--rule);
    padding: 26px 0;
    margin-top: 64px;
    font-size: 0.8125rem;
    color: var(--steel-2);
}

.portal-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.portal-footer a:hover {
    color: var(--red);
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
    .login-page {
        grid-template-columns: minmax(0, 1fr);
    }

    .login-aside {
        padding: 52px 32px;
    }

    .login-main {
        padding: 52px 32px;
    }

    .doc-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .doc-meta {
        grid-column: 1 / -1;
    }

    .doc-action {
        grid-column: 2;
        grid-row: 1;
        align-self: start;
    }
}

@media (max-width: 700px) {
    .app-header-inner {
        height: auto;
        padding-top: 14px;
        padding-bottom: 14px;
        gap: 14px;
        flex-wrap: wrap;
    }

    /* Wraps to: wordmark + badge, then user + sign out. */
    .app-spacer {
        display: none;
    }

    .app-user {
        text-align: left;
        margin-left: auto;
    }

    .dash-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .doc-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .doc-action,
    .doc-status {
        justify-self: start;
        grid-column: 1;
        grid-row: auto;
    }

    .login-aside,
    .login-main {
        padding: 40px 22px;
    }

    .login-card {
        padding: 30px 24px;
    }

    .work-head-inner {
        align-items: flex-start;
    }
}

/* ===== Filed documents + upload =====
   Added when the portal moved off the hardcoded catalog: these render real
   files out of the DMS rather than a fixed list. */

.files-head {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    margin-bottom: 6px;
}

.lede--tight {
    margin-top: 0;
    margin-bottom: 20px;
    max-width: 58ch;
}

.doc-empty {
    padding: 22px 20px;
    background: var(--paper-2);
    border: 1px dashed var(--rule-strong);
    color: var(--steel);
    font-size: 0.9375rem;
}

.file-list {
    border-top: 1px solid var(--rule);
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--rule);
}

.file-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: var(--ink);
    /* Imported file names run long and must not push the button off-screen. */
    overflow-wrap: anywhere;
}

.file-meta {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    color: var(--steel-2);
}

.btn--small {
    padding: 7px 14px;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.upload-form {
    margin-top: 28px;
    padding: 22px 20px;
    background: var(--paper-2);
    border: 1px solid var(--rule);
}

.upload-label {
    display: block;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--steel);
    margin-bottom: 14px;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.upload-row input[type="file"] {
    font-size: 0.875rem;
    min-width: 0;
    flex: 1 1 240px;
}

.upload-status:not(:empty) {
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--steel);
}

/* Submission feedback. Fixed rather than inline because the editor can be
   scrolled well past the top of the page when Save is pressed. */
.submit-banner {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 200;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    padding: 12px 20px;
    border-bottom: 2px solid var(--red);
    max-width: calc(100vw - 32px);
    text-align: center;
}

@media (max-width: 640px) {
    .file-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
