/* Editorial Theme - TrainerD Profile Builder */
/* Minimalist base with serif elegance — Libre Caslon headings, bold black section bars, photo right */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Libre+Caslon+Text:ital,wght@0,400;0,700;1,400&family=Lexend:wght@300;400;500;600;700&display=swap');

/* ===================================================================
   A4 PAPER WRAPPER
   =================================================================== */

.a4-paper {
    box-sizing: border-box;
    margin: auto;
    width: 210mm;
    min-height: 297mm;

    /* Theme background layer (bg-first.png) */
    --theme-bg-size:     contain;
    --theme-bg-position: top center;
    --theme-bg-repeat:   no-repeat;

    /* Company header logo layer — set these from the builder */
    --header-logo:          none;
    --header-logo-size:     auto 25mm;
    --header-logo-position: 5mm 5mm;
    --header-logo-repeat:   no-repeat;

    /* Layer order: theme bg first (bottom), header logo on top */
    background-image:    var(--header-logo),    url('./bg-first.png');
    background-size:     var(--header-logo-size),     var(--theme-bg-size);
    background-position: var(--header-logo-position), var(--theme-bg-position);
    background-repeat:   var(--header-logo-repeat),   var(--theme-bg-repeat);

}

.a4-paper .paper-margin {
    padding: 20mm 20mm 20mm 20mm;
}

/* ===================================================================
   THEME VARIABLES
   =================================================================== */

#trainer-profile {
    --primary-color:   #18181b;
    --secondary-color: #52525b;
    --accent-color:    #a1a1aa;
    --text-dark:       #27272a;
    --text-muted:      #71717a;
    --bg-light:        #fafafa;
    --border-color:    #e4e4e7;
    --font-family:     'DM Sans', Arial, sans-serif;
    --font-heading:    'Libre Caslon Text', Georgia, serif;
    --font-section:    'Lexend', Arial, sans-serif;
    --border-radius:   2px;
    --spacing-unit:    1rem;
}

/* ===================================================================
   BASE STYLES
   =================================================================== */

#trainer-profile * {
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

#trainer-profile {
    position: relative;
    font-family: var(--font-family);
    min-height: 297mm;
    color: var(--text-dark);
    font-size: 11pt;
    line-height: 1.6;
}

#trainer-profile section {
    margin-bottom: 9mm;
    break-inside: avoid;
}

/* ===================================================================
   SECTION HEADINGS — Lexend, black bar with white text
   =================================================================== */

#trainer-profile h2 {
    font-family: var(--font-section);
    font-size: 8.5pt;
    font-weight: 600;
    margin-top: 2mm;
    margin-bottom: 4mm;
    margin-left: -20mm;

    page-break-after: avoid;
    text-transform: uppercase;
    letter-spacing: 2pt;
    padding: 2.5mm 5mm;
    padding-left: 20mm;    
    background-color: #000000;
    color: #ffffff;
    border: none;
    display: inline-block;
}

/* ===================================================================
   TRAINER DETAILS SECTION
   =================================================================== */

#trainer-profile section#trainer-details {
    position: relative;
}

#trainer-profile section#trainer-details header {
    position: relative;
    margin-bottom: 7mm;
    min-height: 75mm;
}

/* Profile photo — right side */
#trainer-profile section#trainer-details header img {
    position: absolute;
    right: -10mm;
    top: -10mm;
    width: 80mm;
    height: 100mm;
    object-fit: cover;
    object-position: top center;
    filter: grayscale(100%) contrast(1.1);
    z-index: 10;
}

/* "TRAINER PROFILE" label */
#trainer-profile section#trainer-details header h1::after {
    content: 'TRAINER PROFILE';
    display: block;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 14pt;
    font-weight: 500;
    letter-spacing: 2.5pt;
    margin-top: 7mm;
    margin-right: 10mm;
}

/* Trainer name — Libre Caslon Text, serif elegance */
#trainer-profile section#trainer-details header h1 {
    font-family: var(--font-heading);
    font-size: 40pt;
    font-weight: 400;
    color: var(--primary-color);
    margin-right: 55mm;
    margin-bottom: 1.5mm;
    line-height: 1.15;
    letter-spacing: -0.3pt;
    padding-top: 5mm;
    text-align: right;
    margin-right: 65mm;
    position: relative;
    z-index: 20;
}

/* Specialty pill badges */

#trainer-profile section#trainer-details header ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: flex-end;
    gap: 1.5mm;
    margin-right: 75mm;
}

#public-profile #trainer-profile section#trainer-details header ul {
    margin-right: 80mm;    
}

#trainer-profile section#trainer-details header ul li {
    background-color: transparent;
    color: var(--secondary-color);
    font-size: 11pt;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8pt;
    padding: 0.8mm 0mm;
    margin: 0;
}

#trainer-profile section#trainer-details header ul li + li::before {
    content: '|';
    margin-right: 1.5mm;
    color: #000;
    font-weight: 300;
}

#trainer-profile section#trainer-details > h2 {
    display: none;
}

/* For public profile at /profile/{slug} */
#public-profile #trainer-profile section#trainer-details header > div:nth-child(3) {
    margin-left: -5mm;
    margin-right: -5mm;
    padding-top: 3mm;
    margin-top: 3mm;
    border-top: 0.3mm solid var(--border-color);
    overflow: hidden;
}

#trainer-profile section#trainer-details header .specialty {
    color: var(--text-muted);
    font-size: 10pt;
    font-weight: 400;
}

#trainer-profile section#trainer-details > h2:first-of-type {
    margin-top: 6mm;
}

#trainer-profile section#trainer-details table {
    position: absolute;
    max-width: 65mm;
    top: 100mm;
    left: 115mm;
}

#trainer-profile section#trainer-details table td:nth-child(2){
    width: 50%;
}

#trainer-profile section#trainer-details p {
    width: 100mm;
}

/* ===================================================================
   TABLES
   =================================================================== */

#trainer-profile table {
    box-sizing: border-box;
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    padding: 0;
    margin: 0 0 5mm 0;
}

#trainer-profile table th {
    background-color: var(--bg-light);
    border: none;
    border-bottom: 0.4mm solid var(--primary-color);
    color: var(--text-dark);
    font-weight: 600;
    font-size: 8pt;
    letter-spacing: 0.5pt;
    padding: 2.5mm 4mm;
    line-height: 1.2em;
    text-align: left;
    vertical-align: bottom;
    text-transform: uppercase;
}

#trainer-profile table td {
    background: #fff;
    border: none;
    border-bottom: 0.3mm solid var(--border-color);
    font-size: 10pt;
    padding: 2.2mm 4mm;
    vertical-align: top;
    color: var(--text-dark);
}

#trainer-profile table tr:nth-of-type(even) td {
    background-color: var(--bg-light);
}

/* ===================================================================
   KEY-VALUE TABLES (Current Position)
   =================================================================== */

#trainer-profile section#current-position table td:first-child {
    font-weight: 500;
    color: var(--text-muted);
    width: 30%;
    font-size: 9.5pt;
}

/* ===================================================================
   TRAINER DETAILS TABLE — stacked label/value layout
   =================================================================== */

#trainer-profile section#trainer-details table {
    border-collapse: collapse;
    border-spacing: 0;
    margin: 0 0 5mm 0;
}

#trainer-profile section#trainer-details table,
#trainer-profile section#trainer-details table tbody,
#trainer-profile section#trainer-details table tr {
    display: block;
    width: 100%;
}

#trainer-profile section#trainer-details table tr {
    margin-bottom: 4mm;
    padding-bottom: 4mm;
    border-bottom: 0.3mm solid var(--border-color);
}

#trainer-profile section#trainer-details table tr:last-child {
    border-bottom: none;
}

#trainer-profile section#trainer-details table td {
    display: block;
    border: none;
    padding: 0;
    background: none;
    width: 100% !important;
}

/* Label — first td: small uppercase muted text */
#trainer-profile section#trainer-details table td:first-child {
    font-family: var(--font-section);
    font-size: 7pt;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1pt;
    margin-bottom: 1mm;
}

/* Value — second td: normal body text */
#trainer-profile section#trainer-details table td:nth-child(2) {
    font-size: 10.5pt;
    font-weight: 400;
    color: #fff;
    width: 100% !important;
}

/* ===================================================================
   PUBLICATIONS
   =================================================================== */

.a4-paper #trainer-profile section#publications table td.cover-cell {
    background-color: white !important;
    padding: 0;
    text-align: center;
}

#trainer-profile section#publications table td.cover-cell img {
    max-width: 50mm;
    max-height: 75mm;
    object-fit: cover;
    border: 0.2mm solid var(--border-color);
    margin-top: 3mm;
    margin-right: 5mm;
    border-radius: 2px;
}

#trainer-profile section#publications table td.label-cell {
    font-weight: 500;
    padding: 2.5mm 4mm;
    font-size: 9.5pt;
    line-height: 1.2em;
    text-align: left;
    width: 20%;
    color: var(--text-muted);
    border-bottom: 0.3mm solid var(--border-color);
}

#trainer-profile section#publications table td.data-cell {
    font-size: 10pt;
    padding: 2.2mm 4mm;
    vertical-align: top;
    font-weight: 400;
    border-bottom: 0.3mm solid var(--border-color);
}

/* ===================================================================
   COLUMN WIDTHS
   =================================================================== */

#trainer-profile section#academic table td:nth-child(3),
#trainer-profile section#professional table td:nth-child(3),
#trainer-profile section#academic table th:nth-child(3),
#trainer-profile section#professional table th:nth-child(3) {
    width: 25mm;
}

#trainer-profile section#previous-companies table td:nth-child(3),
#trainer-profile section#previous-companies table td:nth-child(4),
#trainer-profile section#previous-companies table th:nth-child(3),
#trainer-profile section#previous-companies table th:nth-child(4) {
    width: 18mm;
}

#trainer-profile section#training-programmes table td:nth-child(3),
#trainer-profile section#training-programmes table td:nth-child(4),
#trainer-profile section#training-programmes table th:nth-child(3),
#trainer-profile section#training-programmes table th:nth-child(4) {
    width: 18mm;
}

#trainer-profile section#training-programmes table td:nth-child(1),
#trainer-profile section#training-programmes table th:nth-child(1),
#trainer-profile section#previous-companies table td:nth-child(1),
#trainer-profile section#previous-companies table th:nth-child(1) {
    width: 10mm;
}

#trainer-profile section#previous-companies table tr:nth-of-type(even) td,
#trainer-profile section#training-programmes table tr:nth-of-type(even) td {
    background-color: var(--bg-light);
}

/* ===================================================================
   CERTIFICATES
   =================================================================== */

.certificates-container {
    text-align: center;
}

.certificate-block {
    display: inline-block;
    vertical-align: bottom;
    text-align: left;
    margin: 0 1.5mm 5mm 1.5mm;
    page-break-inside: avoid;
    line-height: normal;
}

.certificate-block.orientation-portrait {
    width: 45%;
    max-width: 90mm;
}

.certificate-block.orientation-landscape {
    width: 70%;
    max-width: 140mm;
}

.certificate-block .certificate-image {
    margin-bottom: 2mm;
}

.certificate-block .certificate-img {
    width: 100%;
    height: auto;
    display: block;
    border: 0.3mm solid var(--border-color);
    border-radius: 2px;
}

.certificate-block .certificate-title {
    font-size: 9.5pt;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
}

/* ===================================================================
   ACKNOWLEDGEMENT LETTERS
   =================================================================== */

.acknowledgement-letters-container {
    text-align: center;
}

.acknowledgement-letter-block {
    display: inline-block;
    vertical-align: bottom;
    text-align: left;
    margin: 0 1.5mm 8mm 1.5mm;
    page-break-inside: avoid;
    line-height: normal;
}

.acknowledgement-letter-block.orientation-portrait {
    width: 45%;
    max-width: 90mm;
}

.acknowledgement-letter-block.orientation-landscape {
    width: 80%;
    max-width: 175mm;
}

.acknowledgement-letter-block .acknowledgement-letter-image {
    margin-bottom: 2mm;
}

.acknowledgement-letter-block .acknowledgement-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
}

.acknowledgement-letter-block .letter-title {
    font-size: 9.5pt;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
}

/* ===================================================================
   GALLERY
   =================================================================== */

#trainer-profile .gallery-container {
    margin: 5mm 0 15mm 0;
}

/* ===================================================================
   PARAGRAPH SPACING
   =================================================================== */

#trainer-profile p {
    margin-bottom: 3mm;
    text-align: justify;
    color: var(--text-dark);
    font-family: var(--font-family);
}

/* ===================================================================
   PRINT OPTIMIZATIONS
   =================================================================== */

@media print {

    @page {
        size: A4;
        padding: 20mm 0 20mm 0;
        margin: 0;
        background: none;
        background-color: #fff;

        /* Company header logo layer — injected by PDF job via --header-logo */
        --header-logo:          none;

        background-repeat:   no-repeat,   repeat-y;
        background-size:     auto 25mm,     100% auto;
        background-position: 5mm 5mm, 0mm 0;
        background-image:    var(--header-logo),          url('./blank-white.png');

    }

    @page :first {
        padding-top: 0mm;
        margin-top: 0mm;


        background-repeat:   no-repeat,   no-repeat;
        background-size:     auto 25mm,     100% auto;
        background-position: 5mm 5mm, 0mm 0;
        background-image:    var(--header-logo), url('./bg-first.png');

        background-color: rgba(0,0,0,0);
    }

    #trainer-profile section#trainer-details header {
        margin-top: -12mm;
    }

    .a4-paper {
        margin: 0;
        padding: 0;
        background: none;
    }

    .paper-margin {
        margin: 0;
        padding: 0 20mm 0 20mm;
    }

    #trainer-profile {
        margin: 0;
        page-break-inside: avoid;
    }

    #trainer-profile section {
        page-break-inside: avoid;
        margin-top: 8mm;
        margin-bottom: 8mm;
    }

    #trainer-profile .gallery-container {
        width: 180mm;
        padding: 0;
        margin: auto;
        margin-left: 0;
    }

    #trainer-profile .gallery-container .gallery-img {
        margin-bottom: 1mm;
    }

    #trainer-profile .gallery-container .orientation-portrait {
        width: 24%;
    }

    #trainer-profile .gallery-container .orientation-landscape {
        width: 48.3%;
    }
}
