/*
 * KTP Resource Center Branding
 *
 * Login-page branding and layout overrides.
 * Migrated from ktp_course_portal.
 *
 * ResourceSpace core is not modified.
 */

/* ============================================================
   CP14L-B2 BEGIN
   KTP Resource Center — Login page visual override

   Scope:
   - Login page only
   - Hide ResourceSpace global login header
   - Remove login slideshow visually
   - Centre login content
   - Use KTP Resource Center logo
   - Hide ResourceSpace powered-by footer

   ResourceSpace core is not modified.
   ============================================================ */

header.LoginHeader {
    display: none !important;
}

#UICenter.NoSearch.LoginPage.slideshow-enabled {
    display: flex;
    flex-direction: column;
    align-items: center;

    width: 100%;
    height: auto;
    min-height: 100vh;

    padding: 32px 16px;
    box-sizing: border-box;

    overflow-x: hidden;
    overflow-y: auto;

    background-color: var(--colour-surface-100, #ececec);
}

#UICenter.NoSearch.LoginPage.slideshow-enabled > #CentralSpaceLogin {
    flex: 0 0 auto;

    width: 434px;
    max-width: 100%;

    margin: auto;
    padding: 0;

    box-sizing: border-box;
    overflow: visible;
}

#UICenter.NoSearch.LoginPage #login-slideshow,
#UICenter.NoSearch.LoginPage .login-slide {
    display: none !important;
}

#UICenter.NoSearch.LoginPage #LoginHeader {
    width: 340px;
    max-width: 100%;
    aspect-ratio: 897 / 205;

    margin: 0 auto 24px;

    background-image:
        url("../gfx/ktp-resource-center-logo.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

#UICenter.NoSearch.LoginPage #LoginHeader .LoginHeaderImg {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;
    opacity: 0;
}

#UICenter.NoSearch.LoginPage #loginform {
    width: 100%;
}

#UICenter.NoSearch.LoginPage #login_box {
    width: 100%;
    box-sizing: border-box;
}

#UICenter.NoSearch.LoginPage #login-footer {
    display: none !important;
}

@media (max-width: 498px) {
    #UICenter.NoSearch.LoginPage.slideshow-enabled {
        padding: 24px 16px;
    }

    #UICenter.NoSearch.LoginPage.slideshow-enabled > #CentralSpaceLogin {
        width: 100%;
        max-width: 434px;
        padding: 0;
    }

    #UICenter.NoSearch.LoginPage #LoginHeader {
        width: 320px;
        max-width: 100%;
        margin-bottom: 20px;
    }
}

/* CP14L-B2 END */

/* ============================================================
   CP14L-C1 BEGIN
   Hide "first time using..." text while retaining account apply.
   Login page only.
   ============================================================ */

#UICenter.NoSearch.LoginPage .login-link:has(#account_apply) {
    font-size: 0;
}

#UICenter.NoSearch.LoginPage #account_apply {
    font-size: 14px;
}

/* CP14L-C1 END */

/* ============================================================
   CP14L-C2 BEGIN
   Login / Forgot password / Apply for account on one row.
   Login page only.
   ============================================================ */

#UICenter.NoSearch.LoginPage #login_box {
    display: grid;
    grid-template-columns: max-content 1fr max-content;
    align-items: center;
    column-gap: 16px;
}

/*
 * Normal login fields continue to occupy the full card width.
 */
#UICenter.NoSearch.LoginPage #login_box > .login-welcome-text,
#UICenter.NoSearch.LoginPage #login_box > .field-input {
    grid-column: 1 / -1;
}

/*
 * Break the ResourceSpace login-links wrapper out of layout so
 * its two children participate directly in the login_box grid.
 */
#UICenter.NoSearch.LoginPage #login_box > .login-links {
    display: contents;
}

/* Login button: left */
#UICenter.NoSearch.LoginPage #login_box > .button {
    grid-column: 1;
    margin: 0;
    padding: 0;
    align-self: center;
}

#UICenter.NoSearch.LoginPage #login_box > .button input[name="Submit"] {
    width: auto !important;
    min-width: 88px;
    margin: 0;
}

/* Forgot password: centre */
#UICenter.NoSearch.LoginPage
#login_box > .login-links > .login-link:has(#account_pw_reset) {
    grid-column: 2;
    margin: 0;
    justify-self: center;
    align-self: center;
    white-space: nowrap;
}

/* Apply for account: right */
#UICenter.NoSearch.LoginPage
#login_box > .login-links > .login-link:has(#account_apply) {
    grid-column: 3;
    margin: 0;
    justify-self: end;
    align-self: center;
    white-space: nowrap;
}

/*
 * CP14L-C1 set the parent font-size to zero to suppress the
 * "first time using..." text. Keep the actual link readable.
 */
#UICenter.NoSearch.LoginPage #account_pw_reset,
#UICenter.NoSearch.LoginPage #account_apply {
    font-size: 14px;
}

@media (max-width: 498px) {
    #UICenter.NoSearch.LoginPage #login_box {
        column-gap: 8px;
    }

    #UICenter.NoSearch.LoginPage
    #login_box > .button input[name="Submit"] {
        min-width: 76px;
    }

    #UICenter.NoSearch.LoginPage #account_pw_reset,
    #UICenter.NoSearch.LoginPage #account_apply {
        font-size: 13px;
    }
}

/* CP14L-C2 END */

/* ==========================================================
   CP14-A Search Results card surface polish
   Visual-only: no geometry / positioning / overflow changes
   ========================================================== */

.resource-card {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
}

.resource-card:hover,
.resource-card:focus-within {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

/* ==========================================================
   CP14L-R1 Restore login vertical scrolling
   Keep vertical centering when content fits; create a real
   viewport scroll container when login content is taller.
   ========================================================== */

#UICenter.NoSearch.LoginPage.slideshow-enabled {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow-y: auto;
}

/* CP14L-R1 END */

/* ==========================================================
   SHARE-R5B-A BEGIN
   KTP global Share UI suppression.

   Normal Resource / Collection sharing is disabled through
   $allow_share=false. These rules suppress the remaining
   External Upload Share / External Share management surfaces.
   ========================================================== */

/*
 * Team / management menu entries pointing to External Shares.
 */
li:has(> a[href*="pages/manage_external_shares.php"]),
li:has(> a[href*="pages/team/team_external_shares.php"]) {
    display: none !important;
}

/*
 * Collection Management "View Shared Collections" section.
 */
.BasicsBox:has(a[href*="pages/view_shares.php"]) {
    display: none !important;
}

/*
 * Defence-in-depth: suppress any remaining direct Share UI links.
 */
a[href*="pages/share_upload.php"],
a[href*="pages/manage_external_shares.php"],
a[href*="pages/view_shares.php"],
a[href*="pages/team/team_external_shares.php"] {
    display: none !important;
}

/* SHARE-R5B-A END */

/* ==========================================================
   CONTRIB-R2B-A BEGIN
   KTP global Contributions workflow UI suppression.

   General-user contribution permission "d" is disabled
   separately for Group 2.

   Administrator resource upload remains available through the
   normal administrative Upload workflow.
   ========================================================== */

/*
 * User menu / navigation entries for Contributions.
 */
li:has(> a#contribute_link),
li:has(> a[href*="/pages/contribute.php"]),
li:has(> a[href*="pages/contribute.php"]) {
    display: none !important;
}

/*
 * Defence-in-depth for Contributions links outside list menus.
 */
a#contribute_link,
a[href*="/pages/contribute.php"],
a[href*="pages/contribute.php"] {
    display: none !important;
}

/*
 * Team / administrative shortcuts for contribution searches.
 * Preserve the underlying created_by provenance data.
 */
a[href*="search=!contributions"],
a[href*="search=%21contributions"] {
    display: none !important;
}

/* CONTRIB-R2B-A END */

/* ==========================================================
   CONTRIB-R2B-A-R1 BEGIN
   Remove complete menu rows for Contributions searches.
   Prevent empty <li> rows after hiding the underlying links.
   ========================================================== */

li:has(a[href*="search=!contributions"]),
li:has(a[href*="search=%21contributions"]) {
    display: none !important;
}

/* CONTRIB-R2B-A-R1 END */

/* ==========================================================
   CP15-A-R2 BEGIN
   Resource View / Resource Tools presentation hardening.

   Scope:
   - visual only
   - keep ResourceSpace core / permissions / viewer behavior unchanged
   - preserve locale-dependent button labels on one line
   ========================================================== */

.RecordPanel #DownloadsTab #ResourceDownloadOptions td.DownloadFileName {
    width: auto;
    min-width: 0;
}

.RecordPanel #DownloadsTab #ResourceDownloadOptions td.DownloadButton {
    width: 1%;
    vertical-align: middle;
    white-space: nowrap;
}

.RecordPanel #DownloadsTab #ResourceDownloadOptions td.DownloadButton > a {
    display: inline-block;
    width: auto;
    min-width: 72px;
    box-sizing: border-box;
    white-space: nowrap;
    line-height: 1.35rem;
    padding: 0.35rem 0.8rem;
}

.RecordPanel #DownloadsTab .RecordTools:not(:has(#ResourceToolsContainer > li)) {
    display: none;
}

@media (max-width: 768px) {
    .RecordPanel #DownloadsTab #ResourceDownloadOptions td.DownloadButton > a {
        min-width: 64px;
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }
}

/* CP15-A-R2 END */

/* ==========================================================
   R1F-R2-V4 BEGIN
   Resource Details one-field-per-row layout correction.

   ResourceSpace fixed-list values are rendered as block markup
   inside a <p>. Browsers repair that invalid nesting by moving
   the value wrapper outside the <p>, so position both normal
   <p> values and repaired direct <div> values explicitly.

   Scope:
   - Resource Details (#Metadata) only
   - system properties and normal itemNarrow metadata
   - fixed-list pills stay in the value column
   - no ResourceSpace core changes
   ========================================================== */

.RecordPanel #Metadata .itemNarrow {
    float: none;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    column-gap: 20px;
    align-items: start;
    box-sizing: border-box;
}

.RecordPanel #Metadata .itemNarrow > h3 {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.RecordPanel #Metadata .itemNarrow > p,
.RecordPanel #Metadata .itemNarrow > div {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0;
}

.RecordPanel #Metadata .itemNarrow > p:empty {
    display: none;
}

.RecordPanel #Metadata .itemNarrow > p {
    overflow-wrap: anywhere;
}

.RecordPanel #Metadata .itemNarrow > div .fixedlistnodepill {
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 620px) {
    .RecordPanel #Metadata .itemNarrow {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 4px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .RecordPanel #Metadata .itemNarrow > h3 {
        grid-column: 1;
        grid-row: 1;
    }

    .RecordPanel #Metadata .itemNarrow > p,
    .RecordPanel #Metadata .itemNarrow > div {
        grid-column: 1;
        grid-row: 2;
    }
}

/* R1F-R2-V4 END */
