/* Portal-specific styles — layered on top of Pico CSS */

/* ---- Base typography — cap Pico's fluid scale for desktop ---- */
:root {
    --pico-font-size: clamp(16px, 1vw + 14px, 17px);
}

/* ---- Skip navigation (accessibility — WCAG 2.4.1) ---- */
/* Duplicated from main.css because portal uses a separate base template */
.visually-hidden-focusable {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
.visually-hidden-focusable:focus {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    padding: 0.75rem 1.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
    background: #0d7377;
    color: #fff;
    z-index: 10001;
    font-size: 1rem;
    font-weight: bold;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

/* ---- Language toggle bar ---- */
.portal-lang-nav {
    background: #f5f5f5;
    padding: 0.25rem 0;
    text-align: right;
}
.portal-lang-nav .container {
    display: flex;
    justify-content: flex-end;
    padding-right: 10rem;
}
.portal-lang-nav .lang-link {
    background: none;
    border: 2px solid #0d7377;
    color: #0d7377;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 44px;
    min-width: 44px;
}
.portal-lang-nav .lang-link:hover,
.portal-lang-nav .lang-link:focus {
    background: #0d7377;
    color: #fff;
}

/* Quick-exit button — always visible, high contrast */
#quick-exit {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 9999;
    background: var(--pico-del-color, #c62828);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
}

#quick-exit:hover,
#quick-exit:focus {
    background: #b71c1c;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Session timeout warning — uses native <dialog> */
.portal-timeout-dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    max-width: 400px;
}
.portal-timeout-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

/* Legacy warning overlay (kept for backwards compatibility) */
#session-timeout-warning {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

#session-timeout-warning[hidden] {
    display: none;
}

#session-timeout-warning .warning-content {
    background: var(--kn-card-bg, #fff);
    padding: 2rem;
    border-radius: 8px;
    max-width: 400px;
    text-align: center;
}

/* Portal navigation — simpler than staff nav */
.portal-nav {
    padding: 0.5rem 1rem;
    padding-right: 10rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 1px solid var(--pico-muted-border-color, #ddd);
}

.portal-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.portal-nav .language-toggle {
    font-size: 0.85rem;
}

/* Portal logout button — inline, no margin bloat */
.portal-logout-btn {
    background: none;
    border: 1px solid var(--pico-muted-border-color, #ddd);
    color: var(--pico-muted-color, #666);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin: 0;
}
.portal-logout-btn:hover {
    border-color: var(--pico-del-color, #c62828);
    color: var(--pico-del-color, #c62828);
}
.portal-logout-btn:focus-visible {
    outline: 2px solid #0d7377;
    outline-offset: 2px;
}

/* Larger touch targets (WCAG 2.5.8 — 44×44 minimum) */
.portal-nav a,
a.portal-card {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
}

/* Dashboard nav cards — responsive grid */
.portal-nav-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* Dashboard cards */
a.portal-card {
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--pico-muted-border-color, #ddd);
    border-radius: 8px;
    padding: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}
a.portal-card:hover,
a.portal-card:focus-visible {
    border-color: #0d7377;
    box-shadow: 0 2px 8px rgba(13, 115, 119, 0.12);
}
a.portal-card article {
    padding: 1.5rem;
    margin: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.portal-card svg {
    display: block;
    margin-bottom: 0.5rem;
    color: #0d7377;
}
.portal-card h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

/* Progress descriptor badges */
.descriptor-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Warm/neutral palette — avoids alarming red/green judgement colours */
.descriptor-harder { background: #f5f0eb; color: #5d4e37; }
.descriptor-holding { background: #eef0f2; color: #4a5568; }
.descriptor-shifting { background: #edf5f0; color: #3b6b4f; }
.descriptor-good { background: #ebf4f5; color: #2c6b6f; }

/* Milestone celebrations */
.milestone-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--pico-muted-border-color, #ddd);
}

.milestone-check {
    color: #2e7d32;
    font-size: 1.5rem;
}

/* Journal "only you" notice */
.privacy-notice {
    background: #f3e5f5;
    border-left: 4px solid #7b1fa2;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
}

/* Crisis resources highlight */
.crisis-notice {
    background: #fff3e0;
    border-left: 4px solid #e65100;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0 4px 4px 0;
}

/* New since last visit banner */
.portal-new-banner {
    background: #e3f2fd;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.portal-banner-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--pico-muted-color, #555);
    padding: 0;
}
.portal-banner-dismiss:focus-visible {
    outline: 2px solid #0d7377;
    outline-offset: 2px;
}
.portal-new-detail {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
    font-size: 0.9rem;
    color: var(--pico-muted-color, #555);
}

/* Portal footer contact block */
.portal-footer-contact {
    font-size: 0.95rem;
    color: var(--pico-muted-color, #666);
    margin-top: 0.5rem;
    white-space: pre-line;
}

/* Staff notes — encouragement from worker */
.portal-staff-notes {
    margin-bottom: 1.5rem;
}
.portal-staff-note {
    background: #f0f7f7;
    border-left: 4px solid #0d7377;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 0 4px 4px 0;
}
.portal-staff-note time {
    display: block;
    font-size: 0.85rem;
    color: var(--pico-muted-color, #666);
    margin-top: 0.25rem;
}

/* Goal name — which goal this metric is tracking */
.portal-metric-goal {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pico-primary, #0d7377);
    margin-bottom: 0.25rem;
}

/* Metric description — plain-language explanation for participants */
.portal-metric-description {
    font-size: 0.95rem;
    color: var(--pico-muted-color, #555);
    margin-bottom: 1rem;
    font-style: italic;
}

/* Sent message history */
.portal-sent-message {
    border-bottom: 1px solid var(--pico-muted-border-color, #ddd);
    padding: 0.75rem 0;
}
.portal-sent-message time {
    display: block;
    font-size: 0.85rem;
    color: var(--pico-muted-color, #666);
    margin-bottom: 0.25rem;
}
.portal-msg-read {
    color: #2c6b6f;
}

/* Safety notice on login page */
.portal-safety-notice {
    background: #f5f0eb;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
}

/* Crisis resources — collapsible */
.portal-crisis-resources summary {
    cursor: pointer;
    font-weight: 600;
    color: #e65100;
}

/* Correction request soft step */
.soft-step {
    text-align: center;
    padding: 2rem 1rem;
}

.soft-step .options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Portal dashboard header */
.portal-dashboard-header {
    margin-bottom: 1.5rem;
}

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
    /* Nav stacks vertically on small screens */
    .portal-nav {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.5rem;
    }
    .portal-nav ul {
        width: 100%;
        justify-content: center;
    }

    /* Cards go single column */
    .portal-nav-cards {
        grid-template-columns: 1fr;
    }

    /* Quick-exit button — smaller on mobile but still accessible */
    #quick-exit {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        top: 0.25rem;
        right: 0.25rem;
    }

    /* New-since banner stacks */
    .portal-new-banner {
        flex-direction: column;
    }
}
