/* in thesis_shared.css */

/* =====================================================
   Thesis Shared Styles — FINAL, CANONICAL VERSION
   ===================================================== */

/* ================================
   Base document rules
   ================================ */
body {
  margin: 0 !important;
  padding: 0 !important;
  hyphens: none !important;
}

/* =====================================================
   SINGLE global page counter
   ===================================================== */
body.thesis-compiled {
  /* counter-reset: page; */
}

/* ================================
   Thesis wrapper
   ================================ */
.thesis-wrapper {
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  line-height: 1.5;
  color: #000;
  background-color: #f3f4f6;
}

.thesis-container {
  margin: 0 !important;
  padding: 0 !important;
  background-color: #f3f4f6;
}

/* =====================================================
   ONE PAGE = ONE thesis-content
   ===================================================== */
.thesis-content {
  width: 8.5in;
  min-height: 11in;

  /* Do NOT force max-height here.
     If content is too long, we need to fix the template pagination,
     not hide the overflow. */
  max-height: none;
  height: auto;
  overflow: visible;

  margin: 1in auto;
  padding: 1in;
  background: #fff;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  box-sizing: border-box;

  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  line-height: 2;
  text-align: justify;
  text-indent: 0.5in;

  position: relative;

  break-after: page;
  page-break-after: always;
}

/* Binding margin
   Keep the page centered in preview/compile.
   Add binding space inside the page instead of moving the page itself. */
.thesis-content.binding-margin {
  padding-left: 1.5in;
  padding-right: 1in;
}

/* =====================================================
   PAGE NUMBER DISPLAY
   ===================================================== */
.thesis-content::after {
  position: absolute;
  bottom: 0.5in;
  font-size: 12pt;
  color: #000;
  content: attr(data-page-label);
}

/* Requirement: bottom right */
.thesis-container.page-number-bottom_right .thesis-content::after {
  right: 1in;
}

/* Requirement: bottom center */
.thesis-container.page-number-bottom_center .thesis-content::after {
  left: 50%;
  transform: translateX(-50%);
}

/* Requirement: bottom left */
.thesis-container.page-number-bottom_left .thesis-content::after {
  left: 1in;
}

/* Requirement: none */
.thesis-container.page-number-none .thesis-content::after {
  content: "";
}

/* =====================================================
   🚨 THE CRITICAL FIX 🚨
   ===================================================== */

/*
  The ONLY reset point allowed in the document
  This MUST be applied to the FIRST Introduction page
*/
/* .thesis-content.arabic-start {
  counter-reset: page 0;
} */

/*
  Defensive rule:
  NO OTHER SECTION may reset the counter
*/
/* .thesis-content:not(.arabic-start) {
  counter-reset: none;
} */

/* =====================================================
   Section breaks (semantic only)
   ===================================================== */
.section-break {
  display: block;
}

/* =====================================================
   Headings
   ===================================================== */
.thesis-content h1,
.thesis-content h2,
.thesis-content h3,
.thesis-content h4,
.thesis-content h5,
.thesis-content h6 {
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
}

/* =====================================================
   Paragraphs
   ===================================================== */
.thesis-content p {
  text-indent: 2em;
  margin: 0.8em 0;
}

.thesis-content p.thesis-paragraph-continuation {
  margin-top: 0;
  text-indent: 0;
}

/* =====================================================
   TOC / Lists
   ===================================================== */
.list-title {
  font-size: 18pt;
  font-weight: bold;
  text-align: center;
  margin-bottom: 1em;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-entry {
  display: flex;
  align-items: baseline;
  margin-bottom: 0.5em;
}

.leader-dots {
  flex: 1;
  margin: 0 1em;
  border-bottom: 1pt dotted black;
}

/* =====================================================
   Tables & figures
   ===================================================== */
.thesis-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.thesis-content th,
.thesis-content td {
  border: 1px solid #000;
  padding: 0.5em;
}

/* =====================================================
   Appendix of Images
   ===================================================== */

/*
  Appendix of Images uses its own compact page layout.

  These rules are intentionally scoped to .appendix-images-page
  so normal figures, Writing images, charts, tables, appendices,
  and other thesis pages keep their existing behavior.
*/
.thesis-content.appendix-images-page {
  text-indent: 0;
}

/*
  Four image records are prepared per .thesis-content page
  by appendix_images.html.erb.

  Each record displays:
  LEFT  = Figure data
  RIGHT = Image
*/
.appendix-images-page .image-appendix-list {
  display: flex;
  flex-direction: column;
  gap: 0.22in;
  width: 100%;
}

/*
  Critical compile rule:
  force each appendix entry into a horizontal row.
*/
.appendix-images-page .image-appendix-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;

  width: 100%;
  min-height: 1.65in;

  gap: 0.3in;
  padding: 0.12in 0 0.18in;

  border-bottom: 1px solid #e5e7eb;

  box-sizing: border-box;

  page-break-inside: avoid;
  break-inside: avoid;
}

/*
  Left side: figure number, title, caption, and reference.
*/
.appendix-images-page .image-appendix-details {
  display: block;

  flex: 1 1 58%;
  width: 58%;
  min-width: 0;

  margin: 0;
  padding: 0;

  text-align: left;
  text-indent: 0;
}

/*
  Override the normal thesis paragraph indentation only
  inside Appendix of Images metadata.
*/
.appendix-images-page .image-appendix-details p {
  margin: 0 0 0.15em;
  padding: 0;

  text-align: left;
  text-indent: 0 !important;

  line-height: 1.3;
}

/*
  Right side: compact image.
*/
.appendix-images-page .image-appendix-visual {
  display: flex !important;

  flex: 0 0 36%;
  width: 36%;

  align-items: center;
  justify-content: center;

  margin: 0;
  padding: 0;

  text-align: center;
  text-indent: 0;
}

/*
  Keep appendix images deliberately smaller than ordinary
  manuscript figures so approximately 3–4 fit on one page.
*/
.appendix-images-page .image-appendix-image {
  display: block !important;

  width: auto !important;
  height: auto !important;

  max-width: 2.25in !important;
  max-height: 1.55in !important;

  margin: 0 auto !important;
  padding: 0;

  object-fit: contain;
}

/* Figure / Fig. label */
.appendix-images-page .image-appendix-label {
  margin-bottom: 0.12em !important;
  font-weight: bold;
}

/* Optional stored title */
.appendix-images-page .image-appendix-title {
  margin-bottom: 0.18em !important;
  font-weight: normal;
}

/* Caption and reference */
.appendix-images-page .image-appendix-caption,
.appendix-images-page .image-appendix-reference {
  margin-bottom: 0.12em !important;

  line-height: 1.3;

  overflow-wrap: anywhere;
  word-break: normal;
}

.appendix-images-page .image-appendix-field-label {
  font-weight: normal;
}

.appendix-images-page .image-appendix-missing {
  color: #6b7280;
  font-style: italic;
  text-indent: 0;
}

/* =====================================================
   Print
   ===================================================== */
@media print {
  .thesis-wrapper,
  .thesis-container {
    background: white;
  }

  .thesis-content {
  width: 8.5in;
  min-height: 11in;
  max-height: none;
  height: auto;
  overflow: visible;

  box-shadow: none;
  margin: 0;
  padding: 1in;
}
  .no-print {
      display: none !important;
    }


  @page {
    size: 8.5in 11in;
    margin: 0;
  }

    /*
    Preserve the Appendix of Images horizontal layout
    during PDF/print generation.
  */
  .appendix-images-page .image-appendix-row {
    display: flex !important;
    flex-direction: row !important;

    page-break-inside: avoid;
    break-inside: avoid;
  }

  .appendix-images-page .image-appendix-image {
    width: auto !important;
    height: auto !important;

    max-width: 2.25in !important;
    max-height: 1.55in !important;

    object-fit: contain;
  }
}

/* Keep pasted text readable inside the Writing editor */
#editor-container .ql-editor {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Ensure pasted paragraphs use the editor's configured line spacing */
#editor-container .ql-editor p,
#editor-container .ql-editor li,
#editor-container .ql-editor blockquote {
  line-height: inherit;
  max-width: 100%;
}