/* =============================================================================
   履歴書レイアウト 共通スタイル（ResumeSheet 用）
   -----------------------------------------------------------------------------
   構成:
     1) 共有基盤        … #rirekisho-print / .rirekisho-page / 印刷・プレビュー契約
     2) 用紙寸法        … .rk-b5-jis / .rk-a4-jis で width/height/padding のみ切替
     3) レイアウト本体  … .rk-jis 配下（B5/A4 共通。罫線・列幅・行高・書体など）

   B5もA4も同じ .rk-jis のレイアウト規則を共有し、違いは用紙寸法と（テンプレートが
   指定する）各セクションの行数・志望動機の高さだけ。
   ============================================================================= */

/* ===== 1) 共有基盤（全用紙共通） ========================================== */

/* 用紙サイズはテンプレートにより B5/A4 が混在するため size は auto。
   ブラウザ印刷では印刷ダイアログの用紙選択に従う（画像PDFは別途原寸で出力）。 */
@page {
    size: auto;
    /* 用紙寸法(.rk-b5-jis / .rk-a4-jis)が余白まで含んだ実寸なので、ページ側の余白は 0 にする。
       0.5in を入れていると A4(210mm)が有効幅 184.6mm を超えて溢れる。 */
    margin: 0;
}

@media print {
    body * {
        visibility: hidden;
    }

    #rirekisho-print,
    #rirekisho-print * {
        visibility: visible;
    }

    #rirekisho-print {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .preview-scale-outer {
        overflow: visible !important;
        width: auto !important;
        height: auto !important;
    }

    .preview-scale-inner {
        transform: none !important;
    }

    /* 画面プレビュー用の余白は紙に持ち込まない。最後の1枚で空ページを作らない。 */
    .rirekisho-container {
        gap: 0;
    }

    .rirekisho-page:last-child {
        break-after: auto;
    }
}

.rirekisho-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.rirekisho-page {
    /* 1枚が1ページ。これが無いと2枚目の先頭が1ページ目に食い込んで分断される。 */
    break-after: page;
    break-inside: avoid;
    background: white;
    box-sizing: border-box;
    margin: 0 auto;
    font-family: var(--rk-ff, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, "MS PGothic", sans-serif);
    font-size: calc(10.5pt * var(--rk-fs, 1));
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    line-break: strict;
    overflow-wrap: anywhere;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

/* ===== 2) 用紙寸法（用紙タイプごと） ===================================== */

.rk-b5-jis .rirekisho-page {
    width: 182mm;   /* JIS-B5 */
    height: 257mm;
    padding: 10mm;
}

.rk-a4-jis .rirekisho-page {
    width: 210mm;   /* A4 */
    height: 297mm;
    padding: 12mm;
}

/* ===== 3) レイアウト本体（B5/A4 共通 = .rk-jis） ======================== */

.rk-jis table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.rk-jis .cell {
    margin-left: 0.07in;
    margin-right: 0.07in;
}

/* --- 写真 --- */
.rk-jis .profile-wrapper {
    position: relative;
    display: inline-block;
}

.rk-jis .photo-holder {
    position: absolute;
    right: 0.17in;
    top: -0.61in;
    width: 1.05in;
    height: 1.4in;
    /* ズーム(transform: scale)した写真が枠からはみ出して氏名欄などに重なるのを防ぐ */
    overflow: hidden;
}

.rk-jis .photo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rk-jis .photo-placeholder {
    width: 100%;
    height: 100%;
    border: 0.5pt solid black;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(6.5pt * var(--rk-fs, 1));
    text-align: center;
}

/* --- タイトル --- */
.rk-jis .table-title,
.rk-jis .table-title tbody,
.rk-jis .table-title th,
.rk-jis .table-title td {
    border: none;
}

.rk-jis #td-page-title {
    border: none;
    width: 1.97in;
    font-size: calc(22pt * var(--rk-fs, 1));
}

.rk-jis #td-date-created-input {
    border: none;
    width: 2.67in;
    font-size: calc(10pt * var(--rk-fs, 1));
    text-align: right;
    vertical-align: bottom;
}

.rk-jis .td-title-blank {
    width: 1.53in;
}

.rk-jis #td-title-blank,
.rk-jis #td-profile-blank-1,
.rk-jis #td-profile-blank-2 {
    border: none;
}

/* --- プロフィール表 --- */
.rk-jis .table-profile {
    margin-bottom: 4mm;
}

/* 列幅は colgroup で確定させる（行ごとに colspan が変わっても崩れないように）。
   写真なしテンプレートでは氏名・ふりがな行が col2+col3 をまたいで広がる。 */
.rk-jis .col-profile-1 {
    width: 0.69in;
}

.rk-jis .col-profile-2 {
    width: 3.95in;
}

.rk-jis .col-profile-3 {
    width: 1.53in;
}

.rk-jis .td-profile-col-1 {
    width: 0.69in;
}

.rk-jis .td-profile-col-2 {
    width: 3.95in;
}

.rk-jis .td-profile-col-3 {
    width: 1.53in;
}

.rk-jis .td-profile-row-1 {
    height: 0.17in;
}

.rk-jis .td-profile-row-2 {
    height: 0.73in;
}

.rk-jis .td-profile-row-3 {
    height: 0.51in;
}

.rk-jis .td-profile-row-4,
.rk-jis .td-profile-row-6 {
    height: 0.16in;
}

.rk-jis .td-profile-row-5,
.rk-jis .td-profile-row-7 {
    height: 0.58in;
    font-size: calc(10pt * var(--rk-fs, 1));
    vertical-align: top;
}

/* ふりがな（ラベル・入力とも 8pt）。住所入力の実DOM id は address-furigana-{1,2}-input。 */
.rk-jis #name-furigana,
.rk-jis #address-1-furigana,
.rk-jis #address-furigana-1-input,
.rk-jis #address-2-furigana,
.rk-jis #address-furigana-2-input {
    font-size: calc(8pt * var(--rk-fs, 1));
}

.rk-jis #name-furigana-input {
    font-size: calc(8pt * var(--rk-fs, 1));
    text-align: left;
}

.rk-jis #name-kanji {
    font-size: calc(14pt * var(--rk-fs, 1));
}

.rk-jis #name-kanji-input {
    font-size: calc(16pt * var(--rk-fs, 1));
    text-align: left;
}

.rk-jis #date-of-birth-input {
    font-size: calc(10.5pt * var(--rk-fs, 1));
    text-align: center;
}

.rk-jis #td-gender {
    vertical-align: top;
}

.rk-jis #gender {
    font-size: calc(10pt * var(--rk-fs, 1));
}

.rk-jis #gender-input {
    font-size: calc(10.5pt * var(--rk-fs, 1));
    text-align: center;
}

.rk-jis #phone-1,
.rk-jis #phone-2 {
    font-size: calc(10pt * var(--rk-fs, 1));
}

.rk-jis #e-mail-1-input,
.rk-jis #e-mail-2-input {
    font-size: calc(9pt * var(--rk-fs, 1));
}

/* プロフィール表の罫線（ふりがな行は破線で仕切る） */
.rk-jis #td-name-furigana {
    border-top: 1px solid black;
    border-left: 1px solid black;
    border-bottom: 1px dashed black;
}

.rk-jis #td-name-furigana-input {
    border-top: 1px solid black;
    border-right: 1px solid black;
    border-bottom: 1px dashed black;
}

.rk-jis #td-name-kanji {
    border-left: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-name-kanji-input {
    border-right: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-date-of-birth-blank {
    border-left: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-date-of-birth {
    border-right: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-gender {
    border-top: 1px solid black;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-address-1-furigana,
.rk-jis #td-address-2-furigana {
    border-left: 1px solid black;
    border-bottom: 1px dashed black;
}

.rk-jis #td-address-furigana-1-input,
.rk-jis #td-address-furigana-2-input {
    border-right: 1px solid black;
    border-bottom: 1px dashed black;
}

.rk-jis #td-phone-1,
.rk-jis #td-phone-2 {
    border-right: 1px solid black;
    border-bottom: 1px dashed black;
}

.rk-jis #td-address-1,
.rk-jis #td-address-2 {
    border-left: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-postal-code-1,
.rk-jis #td-postal-code-2 {
    border-right: 1px solid black;
    border-bottom: 1px solid black;
}

.rk-jis #td-e-mail-1,
.rk-jis #td-e-mail-2 {
    border-right: 1px solid black;
    border-bottom: 1px solid black;
}

/* --- 学歴・職歴表（1・2ページ目共通） --- */
.rk-jis .col-history-year {
    width: 0.68in;
}

.rk-jis .col-history-month {
    width: 0.47in;
}

.rk-jis .table-history-2 {
    margin-bottom: 4mm;
}

.rk-jis .table-history-1 th,
.rk-jis .table-history-2 th {
    font-weight: normal;
    font-size: calc(9pt * var(--rk-fs, 1));
    height: 0.28in;
    border: 1px solid black;
    border-bottom: 3px double black;
}

.rk-jis .table-history-1 td,
.rk-jis .table-history-2 td {
    border: 1px solid black;
}

.rk-jis .td-history-year,
.rk-jis .td-history-month {
    height: 0.32in;
    text-align: center;
    font-size: calc(10.5pt * var(--rk-fs, 1));
}

.rk-jis .td-history-desc {
    height: 0.32in;
    text-align: left;
    font-size: calc(10.5pt * var(--rk-fs, 1));
}

.rk-jis #history-title {
    text-align: center;
}

/* --- 資格・免許表 --- */
.rk-jis .col-licence-year {
    width: 0.68in;
}

.rk-jis .col-licence-month {
    width: 0.47in;
}

.rk-jis .table-licence {
    margin-bottom: 4mm;
}

.rk-jis .table-licence th {
    font-weight: normal;
    font-size: calc(9pt * var(--rk-fs, 1));
    height: 0.28in;
    border: 1px solid black;
    border-bottom: 3px double black;
}

.rk-jis .table-licence td {
    border: 1px solid black;
}

.rk-jis .td-licence-year,
.rk-jis .td-licence-month {
    height: 0.32in;
    text-align: center;
    font-size: calc(10.5pt * var(--rk-fs, 1));
}

.rk-jis .td-licence-name {
    height: 0.32in;
    text-align: left;
    font-size: calc(10.5pt * var(--rk-fs, 1));
}

/* --- 志望動機・自己PR --- */
.rk-jis .table-objective {
    margin-bottom: 4mm;
}

.rk-jis .table-objective th {
    font-weight: normal;
    font-size: calc(9pt * var(--rk-fs, 1));
    height: 0.28in;
    text-align: left;
    border: 1px solid black;
    border-bottom: 3px double black;
}

.rk-jis .table-objective td {
    border: 1px solid black;
}

/* 高さはテンプレートごとに ResumeSheet がインラインで指定（ここは既定値） */
.rk-jis .td-objective {
    font-size: calc(10.5pt * var(--rk-fs, 1));
    vertical-align: top;
    line-height: 1.7;
}

/* 志望動機の本文欄。テンプレート指定の高さで固定し、超過テキストはクリップする。
   （td の height は最小高さ扱いのため、長文だと枠が伸びて本人希望欄を押し出し、
   　サーバーPDF（overflow:hidden の固定用紙）では下部が切れてしまう。）
   本文側で高さを固定＆クリップすることで、プレビューとPDFの見た目を一致させる。 */
.rk-jis .objective-body {
    box-sizing: border-box;
    overflow: hidden;
}

/* --- 本人希望記入欄 --- */
.rk-jis .table-request th {
    font-weight: normal;
    font-size: calc(9pt * var(--rk-fs, 1));
    height: 0.28in;
    text-align: left;
    border: 1px solid black;
    border-bottom: 3px double black;
}

.rk-jis .table-request td {
    border: 1px solid black;
}

.rk-jis .td-request {
    height: 0.3in;
    line-height: 1.7;
}
