/* ==========================================================================
   sv-portal.css — student portal (sign-in + signed-in landing).
   Phase 2 of the Y2 student portal.

   Namespaced sv- like the Strategy Vault, and loaded alongside css/sv.css,
   which owns the --sv-* tokens and the shared breadcrumb strip. Nothing here
   redefines a token; if a colour needs changing it changes in sv.css and both
   surfaces follow.

   Contrast, measured against the AA 4.5:1 floor for body text:
     ink   #14264C on paper  #FBFAF6   14.25:1
     ink   #14264C on pencil #F5B91E    8.39:1   (primary button)
     soft  #3D4E75 on paper  #FBFAF6    7.90:1   (help text)
     red   #B3413A on paper  #FBFAF6    5.38:1   (errors)
     green #2E7D4F on paper  #FBFAF6    4.83:1   (confirmations)
     mist  #D9DEEA on ink    #14264C   11.04:1   (header)
   Re-measure before changing any hex.
   ========================================================================== */

/* ---------- shell ---------- */

.sv-portal {
    font-family: var(--sv-font-body);
    background: var(--sv-paper);
    color: var(--sv-ink);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sv-portal-head {
    background: var(--sv-ink);
    color: var(--sv-paper);
    padding: 14px 20px;
}

.sv-portal-head-inner {
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sv-portal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sv-paper);
    text-decoration: none;
    font-family: var(--sv-font-display);
    font-weight: 650;
    font-size: 1.02rem;
}

.sv-portal-brand img {
    width: 34px;
    height: 34px;
    display: block;
}

.sv-portal-brand:hover,
.sv-portal-brand:focus-visible {
    color: var(--sv-pencil);
}

.sv-portal-headlink {
    color: var(--sv-mist);
    font-size: 0.88rem;
    text-decoration: none;
}

.sv-portal-headlink:hover,
.sv-portal-headlink:focus-visible {
    color: var(--sv-pencil);
    text-decoration: underline;
}

.sv-portal-main {
    flex: 1;
    padding: 40px 20px 64px;
}

.sv-portal-wrap {
    max-width: 980px;
    margin: 0 auto;
}

.sv-portal-narrow {
    max-width: 520px;
    margin: 0 auto;
}

.sv-portal h1 {
    font-family: var(--sv-font-display);
    font-weight: 650;
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.18;
    margin: 0 0 8px;
}

.sv-portal h2 {
    font-family: var(--sv-font-display);
    font-weight: 650;
    font-size: 1.16rem;
    margin: 0 0 10px;
}

.sv-portal-lede {
    color: var(--sv-ink-soft);
    margin: 0 0 26px;
}

/* ---------- card ---------- */

.sv-portal-card {
    background: var(--sv-white);
    border: 1px solid var(--sv-line);
    border-radius: var(--sv-radius);
    box-shadow: var(--sv-shadow);
    padding: 26px 24px;
}

.sv-portal-card + .sv-portal-card {
    margin-top: 20px;
}

/* ---------- form ---------- */

.sv-field {
    margin-bottom: 16px;
}

.sv-label {
    display: block;
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 6px;
}

.sv-hint {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--sv-ink-soft);
    margin-top: 2px;
}

.sv-input {
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1rem;
    color: var(--sv-ink);
    background: var(--sv-white);
    border: 1.5px solid var(--sv-mist);
    border-radius: 10px;
    padding: 11px 13px;
}

.sv-input::placeholder {
    color: #6B7691;      /* 4.62:1 on white — placeholders still need to be readable */
}

.sv-input:focus-visible {
    outline: 3px solid var(--sv-pencil);
    outline-offset: 1px;
    border-color: var(--sv-ink);
}

.sv-input[aria-invalid="true"] {
    border-color: var(--sv-red);
}

/* ---------- buttons ---------- */

.sv-btn {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 12px 20px;
    border: 1.5px solid transparent;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.sv-btn:focus-visible {
    outline: 3px solid var(--sv-ink);
    outline-offset: 2px;
}

.sv-btn[disabled] {
    opacity: 0.6;
    cursor: default;
}

.sv-btn-primary {
    background: var(--sv-pencil);
    color: var(--sv-ink);
}

.sv-btn-primary:hover:not([disabled]) {
    background: #E2A916;
}

.sv-btn-ghost {
    background: var(--sv-white);
    color: var(--sv-ink);
    border-color: var(--sv-mist);
}

.sv-btn-ghost:hover:not([disabled]) {
    border-color: var(--sv-ink);
}

.sv-btn-quiet {
    width: auto;
    background: transparent;
    color: var(--sv-ink);
    border-color: var(--sv-mist);
    font-size: 0.9rem;
    padding: 8px 14px;
}

.sv-btn-quiet:hover:not([disabled]) {
    border-color: var(--sv-ink);
}

/* ---------- divider ---------- */

.sv-or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 26px 0 20px;
    color: var(--sv-ink-soft);
    font-size: 0.85rem;
}

/* Explanatory line above the magic-link button. Sits closer to its button than
   to the divider above, so the grouping reads correctly. */
.sv-alt-hint {
    margin: 0 0 14px;
    font-size: 0.88rem;
    color: var(--sv-ink-soft);
}

.sv-or::before,
.sv-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--sv-line);
}

/* ---------- messages ----------
   Both live in an aria-live region that is always present in the DOM, so a
   screen reader announces the text when it appears. Toggling the whole
   container's existence would not announce reliably. */

.sv-msg {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 0.94rem;
    border: 1.5px solid;
}

.sv-msg[hidden] {
    display: none;
}

.sv-msg-error {
    color: var(--sv-red);
    border-color: var(--sv-red);
    background: #FDF4F3;
}

.sv-msg-ok {
    color: var(--sv-green);
    border-color: var(--sv-green);
    background: #F1F8F3;
}

.sv-msg-info {
    color: var(--sv-ink);
    border-color: var(--sv-mist);
    background: #F4F6FB;
}

/* ---------- footnote ---------- */

.sv-footnote {
    margin: 20px 0 0;
    font-size: 0.88rem;
    color: var(--sv-ink-soft);
}

.sv-footnote a {
    color: var(--sv-ink);
}

.sv-footnote a:focus-visible {
    outline: 3px solid var(--sv-pencil);
    outline-offset: 2px;
}

/* ---------- signed-in landing ---------- */

.sv-greet {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.sv-resource-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.sv-resource {
    border: 1px solid var(--sv-line);
    border-radius: var(--sv-radius);
    background: var(--sv-white);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.sv-resource-title {
    font-weight: 600;
    margin: 0;
}

.sv-resource-meta {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--sv-ink-soft);
    margin-top: 2px;
}

.sv-resource-link {
    color: var(--sv-ink);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sv-resource-link:focus-visible {
    outline: 3px solid var(--sv-pencil);
    outline-offset: 2px;
}

.sv-portal-empty {
    color: var(--sv-ink-soft);
    margin: 0;
}

/* ---------- admin tables (Phase 3) ----------
   Prefixed sv-admin- / sv-cell- / sv-pill- so nothing here can reach the
   student-facing pages, and nothing in sv.css reaches these. */

.sv-greet-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Wide tables scroll inside their own box rather than pushing the page
   sideways. tabindex makes the scroll container reachable by keyboard, which
   is required once a region scrolls. */
.sv-table-scroll {
    overflow-x: auto;
    margin-top: 4px;
}

.sv-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    text-align: left;
}

.sv-admin-table th,
.sv-admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--sv-line);
    vertical-align: top;
    white-space: nowrap;
}

.sv-admin-table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sv-ink-soft);
    border-bottom: 2px solid var(--sv-mist);
}

/* Row headers hold the long values — a student's name, a resource title — so
   they are the one column allowed to wrap. The min-width stops that wrapping
   becoming one-word-per-line once the table is scrolling horizontally and the
   browser starts hunting for a narrower layout. */
.sv-admin-table tbody th {
    font-weight: 600;
    white-space: normal;
    min-width: 15rem;
}

.sv-admin-table tbody tr:last-child th,
.sv-admin-table tbody tr:last-child td {
    border-bottom: none;
}

.sv-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Secondary line inside a name cell — the email under a student, the section
   under a resource. */
.sv-cell-sub {
    display: block;
    font-weight: 400;
    font-size: 0.82rem;
    color: var(--sv-ink-soft);
    margin-top: 2px;
}

/* Status words. Colour is a reinforcement, never the only signal — the cell
   also reads "Active"/"Inactive" and "Published"/"Draft" in text. */
.sv-pill-ok {
    color: var(--sv-green);
    font-weight: 600;
}

.sv-pill-off {
    color: var(--sv-ink-soft);
    font-weight: 600;
}

/* "Public path" — a file still served openly, i.e. work outstanding. Uses the
   error red (5.38:1 on paper) because it is a real finding, not decoration.
   The word carries the meaning on its own for anyone who cannot see colour. */
.sv-pill-warn {
    color: var(--sv-red);
    font-weight: 600;
}

.sv-btn-tiny {
    font-size: 0.82rem;
    padding: 5px 12px;
}

.sv-detail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.sv-detail-head h2 {
    margin-bottom: 0;
}

#detailTitle:focus-visible {
    outline: 3px solid var(--sv-pencil);
    outline-offset: 4px;
}

/* Visually hidden, still announced. Used for table captions and for column
   headers whose visible content is a button. */
.sv-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- skeleton while the session and profile resolve ---------- */

.sv-loading {
    color: var(--sv-ink-soft);
}

@media (max-width: 560px) {
    .sv-portal-main {
        padding: 28px 16px 48px;
    }

    .sv-portal-card {
        padding: 22px 18px;
    }
}

/* Respect a reduced-motion preference: nothing here animates, but the hover
   colour shifts are removed for anyone who has asked for less movement. */
@media (prefers-reduced-motion: reduce) {
    .sv-btn,
    .sv-input {
        transition: none;
    }
}

/* A resource whose file could not be signed. Since Phase 4b there is no public
   copy to fall back to, so the row says so rather than offering a link that
   404s. Uses the error red (5.38:1 on paper); the wording carries the meaning
   on its own. */
.sv-resource-unavailable {
    color: var(--sv-red);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Diagnostic output, shown only with ?debug=1 on the portal. Monospace and
   wrapped because the content is error codes and ids that must be readable
   and copyable, not prose. */
.sv-debug {
    margin: 0 0 18px;
    padding: 12px 14px;
    background: #14264C;
    color: #FBFAF6;          /* 14.25:1 */
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

.sv-debug[hidden] {
    display: none;
}
