/* Readability, mobile navigation and content-system refinements */

:root {
  --orange-deep: #b84725;
  --paper-muted: #575249;
}

body {
  font-size: 16px;
}

p {
  line-height: 1.75;
}

.micro {
  font-size: 0.72rem;
  line-height: 1.5;
  letter-spacing: 0.1em;
  color: var(--paper-muted);
}

.hero .micro,
.level--dark .micro,
.live .micro {
  color: rgba(244, 239, 230, 0.72);
}

.fine {
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--paper-muted);
}

.level--dark .fine,
.hero .fine {
  color: rgba(244, 239, 230, 0.7);
}

.brand__text small {
  font-size: 0.66rem;
}

.topnav a {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.progress-chip {
  font-size: 0.7rem;
}

.lang-switch a {
  font-size: 0.66rem;
  padding: 5px 6px;
}

.btn {
  font-size: 0.72rem;
}

.hero__meta span {
  font-size: 0.7rem;
}

.map-card__status {
  font-size: 0.68rem;
}

.map-num {
  font-size: 0.8rem;
}

.map-list small {
  font-size: 0.7rem;
  line-height: 1.5;
  color: rgba(244, 239, 230, 0.68);
}

.map-card__note {
  font-size: 0.87rem;
  line-height: 1.65;
  color: rgba(244, 239, 230, 0.68);
}

.levelbar__inner {
  min-height: 56px;
  height: auto;
  padding: 8px 0;
}

.levelbar__label {
  font-size: 0.7rem;
  color: rgba(244, 239, 230, 0.62);
}

.levelbar a {
  font-size: 0.72rem;
  color: rgba(244, 239, 230, 0.74);
}

.levelbar a.is-active {
  color: var(--orange);
}

.level-tag {
  font-size: 0.72rem;
  padding: 0.4rem 0.75rem;
}

.block-num {
  font-size: 0.72rem;
}

.module-lead,
.module-text {
  max-width: 820px;
  font-size: 1.06rem;
  line-height: 1.8;
}

.section-head > p:last-child {
  max-width: 760px;
  font-size: 1.08rem;
  line-height: 1.8;
}

.level-head__copy > p:last-child {
  font-size: 1.05rem;
  line-height: 1.75;
}

.check-list {
  max-width: 980px;
}

.check-list li {
  padding-top: 16px;
  padding-bottom: 16px;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--paper-muted);
}

.level--dark .check-list li {
  color: rgba(244, 239, 230, 0.78);
}

.step-list li > span {
  font-size: 0.72rem;
}

.step-list h4 {
  font-size: 1.32rem;
}

.step-list p {
  font-size: 0.96rem;
  line-height: 1.7;
}

.level--dark .step-list p {
  color: rgba(244, 239, 230, 0.72);
}

.cap-card {
  padding: 24px;
}

.cap-card h4 {
  font-size: 1.32rem;
}

.cap-card p {
  font-size: 0.95rem;
  line-height: 1.65;
}

.level--dark .cap-card p {
  color: rgba(244, 239, 230, 0.72);
}

.cap-card__tag {
  font-size: 0.68rem;
  color: var(--orange-deep);
}

.level--dark .cap-card__tag {
  color: var(--orange);
}

.cap-card .cap-card__learn {
  font-size: 0.9rem;
}

.cap-card .cap-card__learn strong {
  font-size: 0.64rem;
}

.cap-card small {
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--paper-muted);
}

.level--dark .cap-card small {
  color: rgba(244, 239, 230, 0.56);
}

.stack-layer h3 {
  font-size: 1.45rem;
}

.stack-layer p {
  font-size: 0.92rem;
  line-height: 1.65;
  color: rgba(244, 239, 230, 0.72);
}

.stack-layer small {
  font-size: 0.72rem;
  line-height: 1.6;
  color: rgba(244, 239, 230, 0.56);
}

.changes-grid .check-list li {
  color: rgba(244, 239, 230, 0.8);
}

.source-card {
  padding: 22px;
}

.source-card strong {
  font-size: 1.32rem;
}

.source-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--paper-muted);
}

.source-card span {
  font-size: 0.68rem;
  color: var(--orange-deep);
}

.frontier-card h3 {
  font-size: 1.45rem;
}

.frontier-card p {
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--paper-muted);
}

.frontier-card > span {
  font-size: 0.7rem;
  color: var(--orange-deep);
}

.frontier-card small {
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--orange-deep);
}

.sources-note,
.atlas-note {
  font-size: 0.88rem;
  line-height: 1.7;
}

.faq-list summary {
  font-size: 1rem;
  line-height: 1.5;
}

.faq-list details p {
  font-size: 0.98rem;
  line-height: 1.75;
}

.faq-list summary::after {
  font-size: 1.1rem;
}

.data-table th {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.data-table td {
  font-size: 0.9rem;
  line-height: 1.6;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-block__top,
.skill-file__top {
  font-size: 0.7rem;
}

.code-block pre,
.skill-file pre {
  font-size: 0.8rem;
  line-height: 1.7;
}

.copy-code,
.copy-prompt,
.tag {
  font-size: 0.68rem;
}

.prompt-card__top {
  font-size: 0.7rem;
}

.prompt-card p {
  font-size: 0.98rem;
  line-height: 1.7;
}

.prompt-note {
  font-size: 0.9rem !important;
  line-height: 1.65;
}

.level-finish strong {
  font-size: 1rem;
}

.complete-btn {
  font-size: 0.7rem;
}

.repo-card h3 {
  font-size: 1.32rem;
}

.repo-card p {
  font-size: 0.9rem;
  line-height: 1.6;
}

.repo-card__category,
.repo-card__stars,
.repo-card__example,
.repo-card__release,
.repo-card__link {
  font-size: 0.68rem;
  line-height: 1.55;
}

.repo-card__link,
.research-card a,
.preprint-panel__head a,
.trending-panel__head a {
  color: var(--orange-deep);
}

.live .fine,
.live .micro {
  color: var(--paper-muted);
}

.research-card__meta {
  font-size: 0.68rem;
}

.research-card p {
  font-size: 0.86rem;
}

.preprint-item span,
.preprint-item a,
.trending-item {
  font-size: 0.78rem;
}

.live-dot {
  font-size: 0.7rem;
}

.footer__brand span:not(.brand__mark) {
  font-size: 0.72rem;
  color: rgba(244, 239, 230, 0.58);
}

.footer p {
  font-size: 0.8rem;
  line-height: 1.65;
  color: rgba(244, 239, 230, 0.62);
}

.footer a,
.footer__links a {
  font-size: 0.72rem;
  color: rgba(244, 239, 230, 0.7);
}

.skip-link {
  font-size: 0.72rem;
}

/* New: role-based routes */
.level--paths {
  background: radial-gradient(circle at 92% 0%, rgba(255, 107, 69, 0.08), transparent 30%), var(--paper);
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.path-card {
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-3);
}

.path-card:hover {
  border-color: rgba(255, 107, 69, 0.45);
}

.path-card__tag {
  margin-bottom: 24px;
  color: var(--orange-deep);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.path-card h3 {
  margin-bottom: 10px;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 450;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.path-card p {
  color: var(--paper-muted);
  font-size: 0.94rem;
  line-height: 1.65;
}

.path-card__links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 22px;
}

.path-card__links a {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.5;
  text-decoration: underline;
  text-decoration-color: rgba(0, 86, 158, 0.22);
  text-underline-offset: 3px;
}

.path-card__links a:hover {
  color: var(--orange-deep);
}

/* New: level contents */
.level-toc {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 26px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.level-toc > .micro {
  flex: 0 0 120px;
  padding-top: 3px;
}

.level-toc ol {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 20px;
  list-style: none;
  margin: 0;
}

.level-toc a {
  display: inline-flex;
  gap: 7px;
  color: var(--paper-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.level-toc a span {
  color: var(--orange-deep);
  font-family: var(--mono);
  font-size: 0.68rem;
  padding-top: 2px;
}

.level--dark .level-toc a {
  color: rgba(244, 239, 230, 0.72);
}

.level--dark .level-toc a span {
  color: var(--orange);
}

.level-toc a:hover {
  color: var(--orange-deep);
}

.level--dark .level-toc a:hover {
  color: var(--orange);
}

/* New: next-step navigation */
.level-next {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.level-next__back {
  color: var(--paper-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.level--dark .level-next__back {
  color: rgba(244, 239, 230, 0.64);
}

.level-next__go {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  text-align: right;
}

.level-next__go span {
  color: var(--orange-deep);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.level-next__go strong {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 450;
  line-height: 1.2;
}

.level--dark .level-next__go strong {
  color: var(--paper);
}

.level--dark .level-next__go span {
  color: var(--orange);
}

.level-next__back:hover,
.level-next__go:hover strong {
  color: var(--orange);
}

@media (max-width: 1180px) {
  .topnav {
    display: none;
  }

  .topbar__actions {
    margin-left: auto;
  }
}

@media (max-width: 1100px) {
  .path-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .levelbar {
    position: static;
  }

  .levelbar__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
    padding: 14px 0;
    overflow: visible;
  }

  .levelbar__label {
    grid-column: 1 / -1;
    margin-bottom: 2px;
  }

  .levelbar a {
    padding: 3px 0;
    font-size: 0.75rem;
  }

  .level-toc {
    display: block;
  }

  .level-toc > .micro {
    display: block;
    margin-bottom: 10px;
  }

  .level-toc ol {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .level-toc a {
    font-size: 0.86rem;
  }

  .level-next {
    flex-direction: column;
    align-items: flex-start;
  }

  .level-next__go {
    align-items: flex-start;
    text-align: left;
  }

  html[dir="rtl"] .level-next__go {
    align-items: flex-start;
    text-align: right;
  }

  .path-grid {
    grid-template-columns: 1fr;
  }

  .path-card {
    min-height: 0;
  }
}

@media (max-width: 360px) {
  .brand__text {
    display: none;
  }

  .lang-switch a {
    padding: 5px;
    font-size: 0.64rem;
  }
}

/* Minimum readable sizes for labels, navigation and card metadata */
.micro,
.fine,
.hero__meta span,
.map-list small,
.levelbar a,
.levelbar__label,
.level-tag,
.block-num,
.cap-card__tag,
.cap-card small,
.stack-layer small,
.source-card span,
.frontier-card small,
.path-card__tag,
.path-card__links a,
.level-toc a span,
.level-next__back,
.level-next__go span,
.code-block__top,
.skill-file__top,
.copy-code,
.copy-prompt,
.tag,
.prompt-card__top,
.repo-card__category,
.repo-card__stars,
.repo-card__example,
.repo-card__release,
.repo-card__link,
.research-card__meta,
.preprint-item span,
.live-dot,
.footer__brand span:not(.brand__mark),
.footer a,
.footer__links a,
.complete-btn,
.btn,
.lang-switch a,
.brand__text small,
.progress-chip,
.map-card__status,
.map-num {
  font-size: 0.75rem;
  line-height: 1.5;
}

.fine {
  font-size: 0.82rem;
}

.topnav a {
  font-size: 0.75rem;
}

.level-toc a {
  font-size: 0.88rem;
}

.level-toc a span {
  font-size: 0.72rem;
}

.path-card__links a {
  font-size: 0.76rem;
}

.path-card__tag,
.cap-card__tag,
.source-card span {
  font-size: 0.72rem;
}

.source-card p,
.repo-card p {
  font-size: 0.94rem;
}

.research-card p {
  font-size: 0.92rem;
}

.repo-card__category,
.repo-card__stars,
.repo-card__example,
.repo-card__release,
.repo-card__link,
.research-card__meta,
.preprint-item span,
.live-dot,
.level-next__go span {
  font-size: 0.72rem;
}

.level--paper .block-num,
.level--paper .step-list li > span,
.level--paper .level-toc a span {
  color: var(--orange-deep);
}

.level--dark .block-num,
.level--dark .step-list li > span {
  color: var(--orange);
}

@media (max-width: 1180px) and (min-width: 641px) {
  .topnav {
    display: none;
  }

  .topbar__actions {
    margin-left: auto;
  }
}

/* Final minimum for remaining micro-labels */
.path-card__tag,
.cap-card__tag,
.source-card span,
.repo-card__category,
.repo-card__stars,
.repo-card__example,
.repo-card__release,
.repo-card__link,
.live-dot,
.level-toc a span,
.stack-layer__num,
.block-num,
.step-list li > span,
.level-next__back,
.level-next__go span {
  font-size: 0.75rem;
}

.cap-card .cap-card__learn strong {
  font-size: 0.72rem;
}

.trending-panel__head a,
.preprint-panel__head a {
  font-size: 0.75rem;
}

.data-table th,
.frontier-card > span,
.trending-item span,
.cap-card .cap-card__learn strong {
  font-size: 0.75rem;
}

.research-card__meta,
.research-card a,
.preprint-panel__head a {
  font-size: 0.75rem;
}

.preprint-item span {
  font-size: 0.75rem;
}

/* Contrast corrections for light editorial sections */
.level--beginner {
  --level-accent: #8a4a00;
}

.level--advanced {
  --level-accent: #a33f20;
}

.level--expert {
  --level-accent: #1f6b52;
}

.level-head__index {
  opacity: 0.82;
}

.topbar .brand__text small {
  color: rgba(244, 239, 230, 0.62);
}

.lang-switch a {
  color: rgba(244, 239, 230, 0.68);
}

.level--paper .prompt-card {
  background: var(--paper-2);
  border-color: var(--line);
}

.level--paper .prompt-card--weak {
  opacity: 1;
}

.level--paper .prompt-card--strong {
  background: rgba(255, 107, 69, 0.09);
  border-color: rgba(163, 63, 32, 0.45);
}

.level--paper .prompt-card p {
  color: var(--ink);
}

.level--paper .prompt-card__top {
  color: var(--paper-muted);
}

.level--paper .prompt-card--strong .prompt-card__top {
  color: #7d351c;
}

.level--paper .copy-prompt {
  border-color: rgba(125, 53, 28, 0.45);
  color: #7d351c;
}

.level--paper .tag {
  color: var(--paper-muted);
  border-color: var(--line);
}

.level--paper .data-table th {
  color: #7d351c;
}

.level--dark .prompt-card p {
  color: var(--paper);
}

.level--dark .prompt-card__top {
  color: rgba(244, 239, 230, 0.72);
}

.level--dark .prompt-card--strong .prompt-card__top {
  color: var(--orange);
}

.level--dark .atlas-note {
  color: rgba(244, 239, 230, 0.7) !important;
}

.live {
  --level-accent: #7d351c;
  --muted: var(--paper-muted);
  --link: var(--blue);
  color: var(--ink);
}

.live .repo-card__category,
.live .research-card__meta,
.live .preprint-panel__head a,
.live .trending-panel__head a {
  color: #7d351c;
}

.live .repo-card__example,
.live .repo-card__stars,
.live .repo-card__release,
.live .research-card p,
.live .preprint-item span {
  color: var(--paper-muted);
}

.live .research-card a {
  color: #7d351c;
}

.live .repo-card__link {
  color: #7d351c;
}

.live .preprint-item a {
  color: var(--ink);
}

.fine {
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.65;
  letter-spacing: 0;
  text-transform: none;
  color: var(--paper-muted);
}

.level--dark .fine,
.hero .fine {
  color: rgba(244, 239, 230, 0.72);
}

.prompt-note {
  margin-top: 10px;
  color: var(--paper-muted) !important;
}

.prompt-note + .fine {
  margin-top: 8px;
}

/* Mobile navigation: allow long labels to wrap instead of breaking the viewport */
@media (max-width: 640px) {
  .levelbar__inner {
    align-items: start;
  }

  .levelbar__inner > * {
    min-width: 0;
  }

  .levelbar a {
    white-space: normal;
    line-height: 1.35;
  }

  /* Tables become readable stacked cards on small screens */
  .table-wrap {
    overflow: visible;
  }

  .data-table {
    display: block;
    min-width: 0;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: block;
  }

  .data-table tr {
    display: block;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
  }

  .data-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--paper-muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.5;
    text-transform: uppercase;
  }

  .level--dark .data-table tr {
    background: rgba(244, 239, 230, 0.045);
  }

  .level--dark .data-table td::before {
    color: rgba(244, 239, 230, 0.7);
  }
}
