/* EP-133 K.O. II Manual — Intellijel Multigrain–inspired stylesheet */
/* Uses CSS Paged Media (rendered by Paged.js polyfill in Chrome) */

/* ================================================================
   Page Setup
   ================================================================ */

@page {
  size: letter;
  margin: 25mm 20mm 30mm 20mm;

  @bottom-center {
    content: counter(page);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    color: #999;
  }

  @top-left {
    content: "Particules Manual";
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 8pt;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
}

@page :first {
  @bottom-center { content: none; }
  @top-left { content: none; }
}

/* ================================================================
   Base Typography
   ================================================================ */

html {
  font-size: 10.5pt;
  line-height: 1.45;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #1a1a1a;
  max-width: 7in;
  margin: 2em auto;
  padding: 0 1em;
  /* Ensure content is always visible even if Paged.js fails */
  visibility: visible !important;
  /* Flexbox ordering: cover + TOC side by side, then content */
  display: flex;
  flex-wrap: wrap;
}

/* All body children default to full width; cover and TOC override */
body > * {
  flex: 0 0 100%;
}

/* ================================================================
   Cover Page
   ================================================================ */

.cover {
  break-after: page;
  text-align: left;
  padding-top: 2em;
  order: -2;
  flex: 0 0 50%;
}

.cover h1 {
  font-size: 36pt;
  font-weight: 800;
  letter-spacing: -0.02em;
  border: none;
  padding: 0;
  margin: 0 0 0.2em;
  color: #1a1a1a;
}

.cover h1::after {
  display: none;
}

.cover .subtitle {
  font-size: 14pt;
  font-weight: 300;
  color: #666;
  margin-bottom: 2em;
}

.cover .version {
  display: inline-block;
  background: #5b4ea7;
  color: white;
  font-size: 9pt;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cover img {
  max-width: 100%;
  margin: 1em 0;
  display: block;
}

/* ================================================================
   Headings
   ================================================================ */

h1 {
  font-size: 22pt;
  font-weight: 800;
  color: #1a1a1a;
  margin-top: 0;
  margin-bottom: 0.2em;
  padding-bottom: 0;
  break-before: page;
  letter-spacing: -0.01em;
}

/* Don't page-break on the first h1 (cover) or TOC */
h1:first-of-type {
  break-before: auto;
}

h2 {
  font-size: 15pt;
  font-weight: 700;
  color: #1a1a1a;
  margin-top: 0.8em;
  margin-bottom: 0.15em;
}

h3 {
  font-size: 12pt;
  font-weight: 700;
  color: #333;
  margin-top: 0.7em;
  margin-bottom: 0.15em;
}

h4 {
  font-size: 10.5pt;
  font-weight: 700;
  color: #5b4ea7;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.6em;
  margin-bottom: 0.15em;
  padding-left: 10px;
  border-left: 4px solid #5b4ea7;
}

/* ================================================================
   Control Name Formatting
   ================================================================ */

/* Bold text in body = control names. Styled via strong tag. */
strong {
  font-weight: 700;
  color: #1a1a1a;
}

/* ================================================================
   Callout Boxes (tip / note / warning)
   ================================================================ */

.tip, .note, .warning {
  margin: 0.5em 0;
  padding: 0.7em 1em 0.7em 1.2em;
  border-radius: 3px;
  font-size: 9.5pt;
  line-height: 1.4;
  break-inside: avoid;
}

.tip {
  border-left: 4px solid #5b4ea7;
  background: #f0effe;
}

.tip::before {
  content: "PRO TIP";
  display: block;
  font-weight: 700;
  font-size: 8pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5b4ea7;
  margin-bottom: 0.3em;
}

.note {
  border-left: 4px solid #e6a817;
  background: #fef9ec;
}

.note::before {
  content: "NOTE";
  display: block;
  font-weight: 700;
  font-size: 8pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c9910e;
  margin-bottom: 0.3em;
}

.warning {
  border-left: 4px solid #d43f3f;
  background: #fdf0f0;
}

.warning::before {
  content: "WARNING";
  display: block;
  font-weight: 700;
  font-size: 8pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #d43f3f;
  margin-bottom: 0.3em;
}

/* Remove extra p margin inside callouts */
.tip p, .note p, .warning p {
  margin: 0;
}

/* Patch idea callout */
.patch {
  border-left: 4px solid #c9860a;
  background: #fffbf0;
  padding: 0.6em 1em;
  margin: 1.2em 0;
}
.patch p:first-child strong:first-child {
  color: #c9860a;
}

/* Deep dive sidebar */
.sidebar {
  border-left: 4px solid #aaa;
  background: #f7f7f7;
  padding: 0.6em 1em;
  margin: 1.2em 0;
  font-size: 0.92em;
}
.sidebar p:first-child strong:first-child {
  color: #555;
}

/* Diff callout */
.diff {
  border-left: 4px solid #c94040;
  background: #fff8f8;
  padding: 0.4em 0.8em;
  margin: 0.8em 0;
  font-size: 0.92em;
  font-style: italic;
}

/* ================================================================
   Tables
   ================================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 9.5pt;
  break-inside: auto;
}

thead th {
  background: #2a2a2a;
  color: white;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody td {
  padding: 6px 10px;
  border-bottom: 0.5px solid #e8e8e8;
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: #f9f9f9;
}

/* ================================================================
   Lists
   ================================================================ */

ul, ol {
  margin: 0.2em 0;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.25em;
}

/* Numbered step lists */
ol li {
  margin-bottom: 0.25em;
}

/* ================================================================
   Horizontal Rules
   ================================================================ */

hr {
  border: none;
  border-top: 2px solid #999;
  margin: 2em 0;
}

/* ================================================================
   Links
   ================================================================ */

a {
  color: #5b4ea7;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Internal cross-reference links */
a[href^="#"]:not(nav#TOC a) {
  text-decoration: underline;
}

/* ================================================================
   Images & Figures
   ================================================================ */

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
}

.icon-map p {
  margin: 0;
  font-size: 0;
}

.icon-map img {
  margin: 0 auto;
}

figure {
  margin: 1em 0;
  break-inside: avoid;
}

figcaption {
  font-size: 8.5pt;
  color: #888;
  text-align: center;
  margin-top: 0.4em;
}

/* ================================================================
   Code (for system codes etc.)
   ================================================================ */

code {
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-size: 9pt;
  background: #f4f4f4;
  padding: 1px 5px;
  border-radius: 3px;
}

pre {
  background: #f4f4f4;
  padding: 0.8em 1em;
  border-radius: 4px;
  font-size: 9pt;
  overflow-x: auto;
  break-inside: avoid;
}

pre code {
  background: none;
  padding: 0;
}

/* ================================================================
   Two-Column Layout
   ================================================================ */

.two-col {
  display: flex;
  gap: 1.5em;
  align-items: flex-start;
  margin: 1em 0;
  break-inside: avoid;
}

.two-col .col-left {
  flex: 0 0 45%;
}

.two-col .col-right {
  flex: 1;
}

.two-col img {
  width: 100%;
  margin: 0;
}

/* ================================================================
   Version Badges
   ================================================================ */

.version-badge {
  display: inline-block;
  background: #5b4ea7;
  color: white;
  font-size: 7.5pt;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 8px;
  vertical-align: middle;
  margin-left: 0.3em;
}

/* ================================================================
   Section Number
   ================================================================ */

.section-num {
  color: #ff6600;
  font-weight: 800;
}

/* ================================================================
   Keyboard / Button Badge
   ================================================================ */

kbd {
  display: inline-block;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 8.5pt;
  font-weight: 700;
  background: #2a2a2a;
  color: white;
  padding: 1px 7px;
  border-radius: 3px;
  margin: 0 1px;
  white-space: nowrap;
}

/* ================================================================
   SVG Diagram Styles
   ================================================================ */

.diagram-container {
  margin: 1.5em 0;
  text-align: center;
  break-inside: avoid;
}

.diagram-container svg {
  max-width: 100%;
  height: auto;
}

.diagram-caption {
  font-size: 8.5pt;
  color: #888;
  text-align: center;
  margin-top: 0.5em;
  font-style: italic;
}

/* ================================================================
   Table of Contents
   ================================================================ */

nav#TOC {
  order: -1;
  flex: 0 0 50%;
  text-align: right;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

nav#TOC::before {
  content: "Contents";
  display: block;
  font-size: 18pt;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 0.6em;
}

nav#TOC ul {
  list-style: none;
  padding-left: 0;
}

nav#TOC > ul > li {
  margin-bottom: 0.4em;
  font-weight: 400;
}

nav#TOC a {
  color: #1a1a1a;
  text-decoration: none;
}

nav#TOC a:hover {
  color: #5b4ea7;
}

/* ================================================================
   Print Adjustments
   ================================================================ */

@media print {
  body {
    font-size: 10.5pt;
  }

  a {
    color: #1a1a1a;
    text-decoration: none;
  }
}

/* ================================================================
   Utility Classes
   ================================================================ */

.page-break {
  break-before: page;
}

.no-break {
  break-inside: avoid;
}

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

.text-small {
  font-size: 9pt;
  color: #666;
}

.text-muted {
  color: #999;
}

/* ================================================================
   Mobile
   ================================================================ */

@media screen and (max-width: 600px) {
  body {
    padding: 0 0.75em;
    margin: 1em auto;
  }

  /* Stack cover and TOC vertically */
  .cover {
    flex: 0 0 100%;
    padding-top: 1em;
  }

  nav#TOC {
    flex: 0 0 100%;
    text-align: left;
    margin-top: 1em;
  }

  .cover h1 {
    font-size: 24pt;
  }

  h1 {
    font-size: 18pt;
  }

  h2 {
    font-size: 13pt;
  }

  /* Scrollable tables */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  thead, tbody, tr, th, td {
    white-space: nowrap;
  }

  /* Two-column layouts stack */
  .two-col {
    flex-direction: column;
  }

  .two-col .col-left {
    flex: 0 0 100%;
  }
}
