/* ==========================================================================
   Public page + printable document styles
   --------------------------------------------------------------------------
   Loaded after kogi-green.css (palette tokens) and kogi-site.css (public
   shell). Covers the three states of /check-result:
     1. the entry form
     2. the "result withheld" notice
     3. the printable result sheet

   The result sheet is a document people print, so everything in the sheet is
   defined in absolute units where it matters and the print block at the end
   strips colour-heavy chrome.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page head band
   -------------------------------------------------------------------------- */

.ks-pagehead {
    position: relative;
    overflow: hidden;
    padding: 54px 0 46px;
    background:
        radial-gradient(760px 420px at 10% 0%, rgba(31, 163, 107, .13), transparent 62%),
        linear-gradient(180deg, #F7FBF9 0%, #FFFFFF 100%);
    border-bottom: 1px solid var(--kg-line);
}

.ks-pagehead h1 {
    margin: 18px 0 12px;
    font-size: clamp(28px, 3.6vw, 40px);
    font-weight: 600;
    letter-spacing: -.025em;
    line-height: 1.15;
    color: var(--kg-ink);
}

.ks-pagehead p {
    margin: 0;
    max-width: 620px;
    font-size: 15px;
    font-weight: 300;
    line-height: 1.75;
    color: var(--kg-muted);
}

.ks-crumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 300;
    color: var(--kg-muted);
}

.ks-crumb a { color: var(--kg-600); text-decoration: none; font-weight: 500; }
.ks-crumb a:hover { color: var(--kg-800); }
.ks-crumb svg { width: 12px; height: 12px; opacity: .55; }

/* --------------------------------------------------------------------------
   Two column layout: guidance + form
   -------------------------------------------------------------------------- */

.ks-check {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 44px;
    align-items: start;
    padding: 60px 0 86px;
}

/* --------------------------------------------------------------------------
   Guidance panel
   -------------------------------------------------------------------------- */

.ks-guide {
    padding: 32px 30px;
    border-radius: 18px;
    background: var(--kg-050);
    border: 1px solid var(--kg-100);
}

.ks-guide h2 {
    margin: 16px 0 20px;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--kg-ink);
}

.ks-guide ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 15px; }

.ks-guide li {
    display: flex;
    gap: 12px;
    font-size: 13.5px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--kg-body);
}

.ks-guide li svg {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    padding: 4px;
    border-radius: 50%;
    background: var(--kg-200);
    color: var(--kg-800);
}

.ks-guide a { color: var(--kg-600); font-weight: 500; }

.ks-code {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--kg-200);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--kg-800);
}

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

.ks-formcard {
    padding: 36px 34px 30px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--kg-line);
    box-shadow: 0 30px 70px -36px rgba(6, 53, 29, .35), 0 2px 6px rgba(6, 53, 29, .04);
}

.ks-formcard h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--kg-ink);
}

.ks-formcard-sub {
    margin: 0 0 26px;
    font-size: 13.5px;
    font-weight: 300;
    line-height: 1.65;
    color: var(--kg-muted);
}

/* Fields with floating labels, matching the administrator sign-in page */
.ks-field { position: relative; margin-bottom: 18px; }

.ks-input {
    width: 100%;
    padding: 25px 16px 9px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 400;
    color: var(--kg-ink);
    background: #FBFDFC;
    border: 1.5px solid var(--kg-line);
    border-radius: 12px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.ks-input:hover { border-color: #C6D6CD; }

.ks-input:focus {
    outline: none;
    background: #fff;
    border-color: var(--kg-500);
    box-shadow: 0 0 0 4px rgba(18, 128, 90, .13);
}

.ks-input:-webkit-autofill,
.ks-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 40px #fff inset;
    -webkit-text-fill-color: var(--kg-ink);
}

.ks-label {
    position: absolute;
    left: 17px;
    top: 17px;
    font-size: 14.5px;
    font-weight: 400;
    color: var(--kg-muted);
    pointer-events: none;
    transition: top .16s ease, font-size .16s ease, color .16s ease, letter-spacing .16s ease;
}

.ks-input:focus + .ks-label,
.ks-input:not(:placeholder-shown) + .ks-label,
.ks-label.is-fixed {
    top: 8px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--kg-600);
}

select.ks-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 44px;
    cursor: pointer;
}

.ks-chevron {
    position: absolute;
    top: 50%;
    right: 16px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    color: var(--kg-muted);
    pointer-events: none;
}

.ks-error {
    display: block;
    margin: 7px 2px 0;
    font-size: 12px;
    color: var(--kg-danger);
}

.ks-error:empty { display: none; }

.ks-input.input-validation-error {
    border-color: #E2A19C;
    background: #FFFBFB;
}

.ks-input.input-validation-error:focus {
    border-color: var(--kg-danger);
    box-shadow: 0 0 0 4px rgba(166, 35, 28, .12);
}

.ks-hint {
    display: block;
    margin: 7px 2px 0;
    font-size: 11.5px;
    font-weight: 300;
    color: var(--kg-muted);
}

.ks-submit {
    width: 100%;
    margin-top: 8px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--kg-700) 0%, var(--kg-500) 100%);
    box-shadow: 0 12px 26px -12px rgba(11, 93, 51, .75);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}

.ks-submit svg { width: 17px; height: 17px; transition: transform .18s ease; }
.ks-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 32px -14px rgba(11, 93, 51, .8); }
.ks-submit:hover:not(:disabled) svg { transform: translateX(3px); }
.ks-submit:disabled { opacity: .7; cursor: progress; }

.ks-formcard-foot {
    margin: 24px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--kg-line);
    text-align: center;
    font-size: 12.5px;
    font-weight: 300;
    color: var(--kg-muted);
}

.ks-formcard-foot a { color: var(--kg-600); font-weight: 500; text-decoration: none; }
.ks-formcard-foot a:hover { color: var(--kg-800); }

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.ks-alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 22px;
    padding: 13px 40px 13px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.55;
}

.ks-alert svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }

.ks-alert--danger {
    background: var(--kg-danger-bg);
    border: 1px solid #F3C7C3;
    border-left: 3px solid var(--kg-danger);
    color: var(--kg-danger);
}

.ks-alert-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: .65;
}

.ks-alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }

/* --------------------------------------------------------------------------
   "Result withheld" state
   -------------------------------------------------------------------------- */

.ks-state {
    max-width: 580px;
    margin: 0 auto;
    padding: 72px 0 92px;
    text-align: center;
}

.ks-state-card {
    padding: 44px 38px 36px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--kg-line);
    box-shadow: 0 30px 70px -36px rgba(6, 53, 29, .35);
}

.ks-state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 22px;
    border-radius: 50%;
    background: var(--kg-warning-bg);
    color: var(--kg-warning);
}

.ks-state-badge svg { width: 30px; height: 30px; }

.ks-state h1 {
    margin: 0 0 12px;
    font-size: 24px;
    font-weight: 600;
    color: var(--kg-ink);
}

.ks-state p {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.75;
    color: var(--kg-muted);
}

.ks-state-phone {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 6px;
    padding: 11px 18px;
    border-radius: 12px;
    background: var(--kg-050);
    border: 1px solid var(--kg-100);
    font-size: 15px;
    font-weight: 600;
    color: var(--kg-800);
    text-decoration: none;
}

.ks-state-phone svg { width: 16px; height: 16px; color: var(--kg-500); }
.ks-state-phone:hover { background: var(--kg-100); color: var(--kg-900); }

.ks-state-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 26px;
}

/* --------------------------------------------------------------------------
   Result sheet
   -------------------------------------------------------------------------- */

.ks-result-wrap { padding: 40px 0 80px; background: var(--kg-page); min-height: 100vh; }

/* Screen-only action bar above the sheet */
.ks-actionbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    max-width: 940px;
    margin: 0 auto 24px;
}

.ks-actionbar-title { margin-right: auto; }

.ks-actionbar-title h1 {
    margin: 0 0 4px;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--kg-ink);
}

.ks-actionbar-title p {
    margin: 0;
    font-size: 13px;
    font-weight: 300;
    color: var(--kg-muted);
}

.ks-sheet {
    max-width: 940px;
    margin: 0 auto;
    padding: 44px 48px 40px;
    background: #fff;
    border: 1px solid var(--kg-line);
    border-radius: 14px;
    box-shadow: 0 30px 70px -40px rgba(6, 53, 29, .4), 0 2px 6px rgba(6, 53, 29, .04);
    color: #17211b;
}

/* Sheet header: crests + titles */
.ks-sheet-head {
    display: grid;
    grid-template-columns: 84px 1fr 84px;
    gap: 20px;
    align-items: center;
    text-align: center;
}

.ks-sheet-head img { width: 78px; height: 78px; object-fit: contain; }
.ks-sheet-head img.ks-crest-right { margin-left: auto; }

.ks-sheet-head h2 {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.25;
    color: var(--kg-900);
    text-transform: uppercase;
}

.ks-sheet-head h3 {
    margin: 0 0 3px;
    font-size: 14px;
    font-weight: 600;
    color: #17211b;
}

.ks-sheet-head .ks-sheet-sub {
    margin: 0;
    font-size: 12.5px;
    font-weight: 400;
    color: #4a5b52;
}

.ks-sheet-rule {
    height: 3px;
    margin: 18px 0 4px;
    border-radius: 2px;
    background: var(--kg-700);
}

.ks-sheet-rule--thin {
    height: 1px;
    margin: 0 0 26px;
    background: var(--kg-500);
    border-radius: 0;
}

/* Candidate details */
.ks-sheet-body {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 28px;
    align-items: start;
}

.ks-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 26px; }

.ks-meta-item { min-width: 0; }

.ks-meta-label {
    display: block;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #7a8a81;
}

.ks-meta-value {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    color: #17211b;
    word-break: break-word;
}

.ks-photo {
    width: 160px;
    height: 175px;
    object-fit: cover;
    border-radius: 8px;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--kg-200);
    background: var(--kg-050);
}

.ks-photo-missing {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 175px;
    border-radius: 8px;
    border: 1px dashed var(--kg-200);
    background: var(--kg-050);
    color: var(--kg-muted);
    font-size: 11px;
    text-align: center;
    padding: 10px;
}

/* Subjects */
.ks-doctable-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 30px 0 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--kg-800);
}

.ks-doctable-head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--kg-100);
}

.ks-doctable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.ks-doctable thead th {
    padding: 9px 14px;
    background: var(--kg-050);
    color: var(--kg-800);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid var(--kg-100);
}

.ks-doctable thead th:last-child,
.ks-doctable tbody td:last-child { text-align: center; width: 110px; }

.ks-doctable tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid #EDF1EE;
    font-weight: 500;
    color: #17211b;
}

.ks-doctable tbody tr:nth-child(even) td { background: #FBFDFC; }

.ks-grade {
    display: inline-block;
    min-width: 34px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--kg-050);
    border: 1px solid var(--kg-100);
    font-size: 12px;
    font-weight: 700;
    color: var(--kg-800);
    text-align: center;
}

/* Sheet footer: declaration + QR */
.ks-sheet-foot {
    display: grid;
    grid-template-columns: 1fr 150px;
    gap: 28px;
    align-items: center;
    margin-top: 34px;
    padding-top: 24px;
    border-top: 1px solid var(--kg-100);
}

.ks-declaration {
    margin: 0;
    font-size: 12px;
    font-weight: 400;
    font-style: italic;
    line-height: 1.7;
    color: #3f5148;
}

.ks-declaration strong { font-weight: 700; font-style: normal; color: var(--kg-800); }

.ks-qr { text-align: center; }
.ks-qr img { width: 120px; height: 120px; margin: 0 auto; }

.ks-qr-cap {
    display: block;
    margin-top: 8px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #7a8a81;
}

/* --------------------------------------------------------------------------
   Roster variant - the candidate list on /student-list.
   Four columns rather than two, and the last column is a registration number
   rather than a grade, so the centred narrow last column is undone here.
   -------------------------------------------------------------------------- */

.ks-doctable--roster thead th:last-child,
.ks-doctable--roster tbody td:last-child { text-align: left; width: auto; }

.ks-doctable--roster .ks-col-sn { width: 54px; text-align: center; }
.ks-doctable--roster .ks-col-gender { width: 100px; }

.ks-doctable--roster .ks-col-reg {
    width: 220px;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    letter-spacing: -.01em;
}

.ks-doctable--roster tbody td { font-weight: 500; }
.ks-doctable--roster tbody td.ks-col-sn { font-weight: 400; color: #7a8a81; }

/* Candidate count, shown beside the document title */
.ks-sheet-count {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--kg-050);
    border: 1px solid var(--kg-100);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--kg-800);
}

.ks-sheet-count svg { width: 13px; height: 13px; color: var(--kg-500); }

.ks-doctable-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 26px 0 12px;
}

.ks-doctable-head-row .ks-doctable-head { margin: 0; flex: 1; }

/* Empty state when a school has no candidates on record */
.ks-doc-empty {
    padding: 34px 24px;
    text-align: center;
    border: 1px dashed var(--kg-200);
    border-radius: 12px;
    background: var(--kg-050);
    color: var(--kg-muted);
    font-size: 13.5px;
    font-weight: 300;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
    .ks-check { grid-template-columns: 1fr; gap: 28px; padding: 40px 0 64px; }
    .ks-guide { order: 2; }
    .ks-formcard { order: 1; }
    .ks-sheet { padding: 30px 24px 28px; }
    .ks-sheet-body { grid-template-columns: 1fr; }
    .ks-photo, .ks-photo-missing { margin: 0 auto; }
    .ks-sheet-foot { grid-template-columns: 1fr; text-align: center; }
    .ks-sheet-head { grid-template-columns: 54px 1fr 54px; gap: 12px; }
    .ks-sheet-head img { width: 52px; height: 52px; }
    .ks-sheet-head h2 { font-size: 15px; }
}

@media (max-width: 560px) {
    .ks-meta { grid-template-columns: 1fr; }
    .ks-formcard { padding: 28px 22px 24px; }
    .ks-guide { padding: 26px 22px; }
    .ks-result-wrap { padding: 24px 0 56px; }
}

/* --------------------------------------------------------------------------
   Print - the result sheet is the document; everything else is chrome
   -------------------------------------------------------------------------- */

@page {
    size: auto;
    margin: 0.4in;
}

@media print {
    .ks-header,
    .ks-footer,
    .ks-notice,
    .ks-actionbar,
    .no-print { display: none !important; }

    html, body { background: #fff !important; }

    .ks-result-wrap { padding: 0 !important; background: #fff !important; min-height: 0 !important; }

    .ks-sheet {
        max-width: none;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .ks-sheet-rule { background: #000 !important; }
    .ks-sheet-rule--thin { background: #000 !important; }
    .ks-sheet-head h2 { color: #000 !important; }
    .ks-doctable-head { color: #000 !important; }

    .ks-doctable thead th {
        background: #fff !important;
        color: #000 !important;
        border-bottom: 1.5px solid #000 !important;
    }

    .ks-doctable tbody tr:nth-child(even) td { background: #fff !important; }

    .ks-grade {
        background: #fff !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }

    .ks-meta-label { color: #333 !important; }
    .ks-declaration strong { color: #000 !important; }

    /* A4 at 96dpi is roughly 794px wide, so the max-width:900px rules above
       match while printing. Restore the full-width document layout, otherwise
       the photograph stacks under the details and the sheet runs to a second
       page. */
    .ks-sheet-head { grid-template-columns: 84px 1fr 84px !important; gap: 20px !important; }
    .ks-sheet-head img { width: 74px !important; height: 74px !important; }
    .ks-sheet-head h2 { font-size: 17px !important; }
    .ks-sheet-body { grid-template-columns: 1fr 150px !important; gap: 24px !important; }
    .ks-meta { grid-template-columns: 1fr 1fr !important; gap: 11px 24px !important; }
    .ks-sheet-foot { grid-template-columns: 1fr 140px !important; text-align: left !important; }
    .ks-photo, .ks-photo-missing { width: 150px !important; height: 164px !important; margin: 0 !important; }

    .ks-photo-missing {
        border: 1px solid #999 !important;
        background: #fff !important;
        color: #555 !important;
    }

    /* Tighten the sheet so a normal subject list lands on one page.
       Sized against US Letter (about 979px of printable height at 96dpi with
       the 0.4in margin) rather than A4 (about 1045px), because `size: auto`
       above follows whatever paper the printer has loaded - fitting the
       smaller of the two fits both. */
    .ks-sheet-rule { margin: 12px 0 3px !important; }
    .ks-sheet-rule--thin { margin: 0 0 16px !important; }
    .ks-doctable-head { margin: 16px 0 8px !important; }
    .ks-doctable thead th { padding: 6px 12px !important; }
    .ks-doctable tbody td { padding: 4px 12px !important; }
    .ks-sheet-foot { margin-top: 18px !important; padding-top: 14px !important; }
    .ks-qr img { width: 100px !important; height: 100px !important; }
    .ks-declaration { font-size: 11px !important; line-height: 1.6 !important; }

    /* Keep rows and the header block intact, but let a long subject list flow
       onto a second page rather than jumping there whole. */
    .ks-sheet-head, .ks-sheet-body, .ks-sheet-foot { page-break-inside: avoid; }
    .ks-doctable tr { page-break-inside: avoid; }
    .ks-doctable thead { display: table-header-group; }
}
