/* ============================================================
   PHILEO PM — Document Page Styles  (doc.css)
   Scoped to .doc-page — matches global.css Design 2b tokens.
   Handles all possible HTML elements in dynamic content.
   ============================================================ */

/* ── Document page wrapper ── */
.doc-page {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ─────────────────────────────────────────
   HEADINGS
───────────────────────────────────────── */

.doc-page h1,
.doc-page h2,
.doc-page h3,
.doc-page h4,
.doc-page h5,
.doc-page h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-primary-dark);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.doc-page > :first-child,
.doc-page h1:first-child,
.doc-page h2:first-child {
  margin-top: 0;
}

.doc-page h1 { font-size: clamp(2rem, 4vw, 2.75rem); letter-spacing: -0.01em; }
.doc-page h2 { font-size: clamp(1.5rem, 3vw, 2rem);  letter-spacing: -0.01em; }
.doc-page h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }
.doc-page h4 { font-size: 1.2rem;  font-weight: 600; }
.doc-page h5 { font-size: 1.05rem; font-weight: 600; }
.doc-page h6 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-accent-blue);
  font-family: var(--font-display);
}


/* ─────────────────────────────────────────
   PARAGRAPH & INLINE TEXT
───────────────────────────────────────── */

.doc-page p {
  margin-top: 0;
  margin-bottom: 1.25rem;
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.7;
}

.doc-page strong,
.doc-page b {
  font-weight: 700;
  color: var(--color-primary-dark);
}

.doc-page em,
.doc-page i { font-style: italic; }

.doc-page u {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.doc-page s,
.doc-page del {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.doc-page mark {
  background: rgba(253, 200, 66, 0.30);
  color: var(--color-primary-dark);
  border-radius: 3px;
  padding: 0 4px;
}

.doc-page small { font-size: 13px; color: var(--color-text-muted); }

.doc-page abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

.doc-page sup,
.doc-page sub { font-size: 0.75em; line-height: 0; position: relative; vertical-align: baseline; }
.doc-page sup { top: -0.5em; }
.doc-page sub { bottom: -0.25em; }

/* ─────────────────────────────────────────
   LINKS
───────────────────────────────────────── */

.doc-page a {
  color: var(--color-accent-blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(21, 101, 192, 0.35);
  transition: color var(--transition-base), text-decoration-color var(--transition-base);
}

.doc-page a:hover {
  color: var(--color-accent-teal);
  text-decoration-color: var(--color-accent-teal);
}

/* ─────────────────────────────────────────
   LISTS  (ul / ol / dl)
───────────────────────────────────────── */

.doc-page ul,
.doc-page ol {
  margin-top: 0;
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
}

.doc-page li > ul,
.doc-page li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

.doc-page li {
  margin-bottom: 0.45rem;
  line-height: 1.7;
  color: var(--color-text);
}

/* Unordered — gradient dot */
.doc-page ul { list-style: none; }

.doc-page ul > li {
  position: relative;
  padding-left: 1.1rem;
}

.doc-page ul > li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent-blue), var(--color-accent-teal));
}

/* Second level — open circle */
.doc-page ul ul > li::before {
  background: transparent;
  border: 2px solid var(--color-accent-blue);
  width: 6px;
  height: 6px;
  top: 0.65em;
}

/* Third level — dash */
.doc-page ul ul ul > li::before {
  content: '';
  width: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-text-muted);
  top: 0.8em;
  border: none;
}

/* Ordered */
.doc-page ol { list-style: none; counter-reset: doc-ol; }

.doc-page ol > li {
  counter-increment: doc-ol;
  position: relative;
  padding-left: 2rem;
}

.doc-page ol > li::before {
  content: counter(doc-ol) ".";
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-accent-blue);
  line-height: 1.7;
  min-width: 1.5rem;
}

.doc-page ol ol { counter-reset: doc-ol-b; }
.doc-page ol ol > li { counter-increment: doc-ol-b; }
.doc-page ol ol > li::before {
  content: counter(doc-ol-b, lower-alpha) ".";
  color: var(--color-text-muted);
  font-weight: 600;
}

/* Definition list */
.doc-page dl { margin-bottom: 1.25rem; }

.doc-page dt {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary-dark);
  margin-top: 1rem;
  margin-bottom: 2px;
}

.doc-page dd {
  margin-left: 1.25rem;
  color: var(--color-text-light);
  line-height: 1.7;
}

/* ─────────────────────────────────────────
   BLOCKQUOTE
───────────────────────────────────────── */

.doc-page blockquote {
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--color-bg-cool);
  border-left: 4px solid var(--color-accent-blue);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-text-light);
  line-height: 1.75;
}

.doc-page blockquote > :last-child { margin-bottom: 0; }

.doc-page blockquote cite {
  display: block;
  margin-top: 0.5rem;
  font-size: 12px;
  font-style: normal;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ─────────────────────────────────────────
   CODE  (inline & block)
───────────────────────────────────────── */

.doc-page code {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 0.875em;
  font-weight: 500;
  background: var(--color-bg-light);
  color: var(--color-accent-blue);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.45em;
  border: 1px solid var(--color-border);
}

.doc-page pre {
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--color-bg-dark);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.doc-page pre code {
  background: transparent;
  color: #e2e8f0;
  padding: 0;
  font-size: 14px;
  font-weight: 400;
  border-radius: 0;
  border: none;
  white-space: pre;
}

/* ─────────────────────────────────────────
   HORIZONTAL RULE
───────────────────────────────────────── */

.doc-page hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

/* ─────────────────────────────────────────
   IMAGES & MEDIA
───────────────────────────────────────── */

.doc-page img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
  box-shadow: var(--shadow-card);
}

.doc-page p img {
  display: inline;
  margin: 0;
  border-radius: var(--radius-sm);
  vertical-align: middle;
  box-shadow: none;
}

.doc-page img.doc-img-full {
  width: 100%;
  border-radius: var(--radius-lg);
}

.doc-page figure {
  margin: 1.75rem 0;
  text-align: center;
}

.doc-page figure img {
  margin: 0 auto 0.5rem;
  display: inline-block;
}

.doc-page figcaption {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.doc-page video,
.doc-page iframe {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
}

.doc-page .doc-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin: 1.75rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.doc-page .doc-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
}

/* ─────────────────────────────────────────
   TABLES
───────────────────────────────────────── */

.doc-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75rem 0;
  font-size: 14px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

.doc-page thead {
  background: var(--color-primary-dark);
}

.doc-page thead th {
  padding: 13px 16px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.80);
}

.doc-page tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-base);
}

.doc-page tbody tr:last-child { border-bottom: none; }

.doc-page tbody tr:hover { background: var(--color-bg-cool); }

.doc-page tbody td {
  padding: 12px 16px;
  color: var(--color-text-light);
  vertical-align: top;
  line-height: 1.5;
}

.doc-page tfoot td {
  padding: 12px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--color-primary-dark);
  border-top: 2px solid var(--color-border-strong);
  background: var(--color-bg-light);
}

.doc-page .doc-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin: 1.75rem 0;
}

.doc-page .doc-table-wrap table {
  margin: 0;
  border-radius: 0;
  min-width: 560px;
  box-shadow: none;
}

/* ─────────────────────────────────────────
   DETAILS / SUMMARY
───────────────────────────────────────── */

.doc-page details {
  margin-bottom: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

.doc-page summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--color-primary-dark);
  cursor: pointer;
  list-style: none;
  background: var(--color-bg-cool);
  transition: background var(--transition-base);
  user-select: none;
}

.doc-page summary::-webkit-details-marker { display: none; }

.doc-page summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 400;
  color: var(--color-accent-blue);
  transition: transform var(--transition-base);
  line-height: 1;
}

.doc-page details[open] > summary::after { transform: rotate(45deg); }

.doc-page details[open] > summary {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.doc-page details > *:not(summary) { padding: 0.75rem 1.25rem; }
.doc-page details > :last-child { padding-bottom: 1.25rem; }

/* ─────────────────────────────────────────
   FORMS
───────────────────────────────────────── */

.doc-page input[type="text"],
.doc-page input[type="email"],
.doc-page input[type="number"],
.doc-page input[type="search"],
.doc-page input[type="url"],
.doc-page input[type="password"],
.doc-page textarea,
.doc-page select {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.doc-page input:focus,
.doc-page textarea:focus,
.doc-page select:focus {
  border-color: var(--color-accent-blue);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.doc-page textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.doc-page label {
  display: block;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary-dark);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.doc-page fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.doc-page legend {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-accent-blue);
  padding: 0 8px;
}

/* ─────────────────────────────────────────
   CALLOUT BLOCKS
   (.doc-note, .doc-tip, .doc-warn, .doc-danger)
───────────────────────────────────────── */

.doc-page .doc-note,
.doc-page .doc-tip,
.doc-page .doc-warn,
.doc-page .doc-danger {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1.25rem 0;
  font-size: 14.5px;
  line-height: 1.7;
}

.doc-page .doc-note {
  background: rgba(21, 101, 192, 0.07);
  border-left: 4px solid var(--color-accent-blue);
  color: var(--color-text-light);
}

.doc-page .doc-tip {
  background: rgba(47, 138, 58, 0.07);
  border-left: 4px solid var(--color-accent-green);
  color: var(--color-text-light);
}

.doc-page .doc-warn {
  background: rgba(253, 200, 66, 0.12);
  border-left: 4px solid var(--color-accent-gold-dark);
  color: var(--color-text-light);
}

.doc-page .doc-danger {
  background: rgba(176, 17, 36, 0.07);
  border-left: 4px solid var(--color-accent-red);
  color: var(--color-text-light);
}

/* ─────────────────────────────────────────
   BADGES  (.doc-badge)
───────────────────────────────────────── */

.doc-page .doc-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(21, 101, 192, 0.10);
  color: var(--color-accent-blue);
  vertical-align: middle;
}

/* ─────────────────────────────────────────
   KEYBOARD  (<kbd>)
───────────────────────────────────────── */

.doc-page kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-primary-dark);
  color: #fff;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.04em;
}

/* ─────────────────────────────────────────
   SPACING GUARDS
───────────────────────────────────────── */

.doc-page * + h2,
.doc-page * + h3,
.doc-page * + h4 { margin-top: 2.5rem; }

.doc-page h1 + h2,
.doc-page h2 + h3,
.doc-page h3 + h4,
.doc-page h4 + p,
.doc-page h4 + ul,
.doc-page h4 + ol { margin-top: 0.5rem; }

.doc-page > *:first-child { margin-top: 0 !important; }
.doc-page > *:last-child  { margin-bottom: 0; }

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */

@media (max-width: 1200px) {
  .doc-page { max-width: 720px; }
}

@media (max-width: 768px) {
  .doc-page { padding: 50px 20px; }

  .doc-page h1 { font-size: clamp(1.6rem, 6vw, 2rem); }
  .doc-page h2 { font-size: clamp(1.3rem, 5vw, 1.6rem); }
  .doc-page h3 { font-size: clamp(1.1rem, 4vw, 1.3rem); }

  .doc-page pre { padding: 1rem; border-radius: var(--radius-sm); font-size: 13px; }
  .doc-page blockquote { padding: 1rem 1.25rem; }

  .doc-page thead th,
  .doc-page tbody td,
  .doc-page tfoot td { padding: 10px 12px; }
}

@media (max-width: 575px) {
  .doc-page { padding: 40px 16px; }

  .doc-page ul,
  .doc-page ol { padding-left: 1.25rem; }

  .doc-page img { border-radius: var(--radius-sm); }
  .doc-page figure { margin: 1.25rem 0; }

  .doc-page table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ─────────────────────────────────────────
   REDUCED MOTION
───────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .doc-page *,
  .doc-page *::before,
  .doc-page *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}