/* Horizon reading profile. Load after horizon-v2.css; opt in on <html> only. */
:root[data-hz-reading="comfortable"] {
  --reading-canvas: var(--background-subtle);
  --reading-surface: color-mix(in srgb, var(--surface) 65%, var(--card));
  --reading-text: color-mix(in srgb, var(--foreground) 90%, var(--card));
  --reading-secondary: color-mix(in srgb, var(--muted-foreground) 85%, var(--foreground));
  --reading-divider: color-mix(in srgb, var(--border) 70%, var(--reading-surface));
  --reading-scrim: color-mix(in srgb, var(--foreground) 24%, transparent);
  --reading-font-size: var(--fs-body);
  --reading-meta-font-size: var(--fs-sm);
  --reading-line-height: var(--lh-body);
}

:root[data-hz-reading="comfortable"]:is([data-theme="dark"], [data-theme="hc-dark"]) {
  --reading-scrim: color-mix(in srgb, var(--background) 65%, transparent);
}

/* Contrast themes retain their unmodified foreground, surface and boundary. */
:root[data-hz-reading="comfortable"]:is([data-theme="hc-light"], [data-theme="hc-dark"]) {
  --reading-canvas: var(--background);
  --reading-surface: var(--card);
  --reading-text: var(--foreground);
  --reading-secondary: var(--muted-foreground);
  --reading-divider: var(--border);
}

:root[data-hz-reading="comfortable"] body {
  background: var(--reading-canvas);
  color: var(--reading-text);
  font-size: var(--reading-font-size);
  line-height: var(--reading-line-height);
}

:root[data-hz-reading="comfortable"] :is(.card, .datatable-shell, .hz-dialog, .hz-sheet, .hz-reading-surface) {
  background: var(--reading-surface);
  color: var(--reading-text);
  border-color: var(--reading-divider);
  box-shadow: none;
}

:root[data-hz-reading="comfortable"] :is(.card-header, .card-footer, .hz-dialog-header, .hz-dialog-footer),
:root[data-hz-reading="comfortable"] .datatable-shell > :is(.datatable-toolbar, .datatable-pagination, .pattern-toolbar, .pattern-pagination) {
  background: var(--reading-surface);
  border-color: var(--reading-divider);
}

/* Explicit semantic text wins when a status also carries a neutral utility. */
:root[data-hz-reading="comfortable"] :is(.text-muted, .card-description, .table-identity-secondary, .hz-reading-meta):not(.text-primary, .text-success, .text-destructive, .text-warning) {
  color: var(--reading-secondary);
}

/* Light primary text needs extra contrast on the quieter neutral surfaces.
   Filled controls and high-contrast/other themes retain their semantic colors. */
:root[data-hz-reading="comfortable"]:is(:not([data-theme]), [data-theme="light"]) .text-primary {
  color: color-mix(in srgb, var(--primary) 90%, var(--foreground));
}

:root[data-hz-reading="comfortable"] :is(.card-description, .table-identity-secondary, .hz-reading-meta) {
  font-size: var(--reading-meta-font-size);
  line-height: var(--lh-sm);
}

:root[data-hz-reading="comfortable"] :is(.hz-dialog-body, .hz-sheet-body, .hz-reading-copy),
:root[data-hz-reading="comfortable"] table.table {
  font-size: var(--reading-font-size);
  line-height: var(--reading-line-height);
}

:root[data-hz-reading="comfortable"] .table th {
  background: var(--reading-surface);
  color: var(--reading-secondary);
  font-size: var(--reading-meta-font-size);
  font-weight: 500;
  line-height: var(--lh-sm);
}

:root[data-hz-reading="comfortable"] .table :is(th, td) {
  box-shadow: inset 0 -1px 0 var(--reading-divider);
}

:root[data-hz-reading="comfortable"] .table tr:last-child td {
  box-shadow: none;
}

/* Numbers are opt-in. Code, UUIDs, logs and raw editors keep their mono font. */
:root[data-hz-reading="comfortable"] .hz-reading-number {
  font-variant-numeric: tabular-nums;
}

:root[data-hz-reading="comfortable"] .card-hover,
:root[data-hz-reading="comfortable"] .card-hover:hover {
  transform: none;
  box-shadow: none;
}

:root[data-hz-reading="comfortable"] .card-hover:hover {
  border-color: var(--border-strong);
}

:root[data-hz-reading="comfortable"] :is(.hz-overlay, .hz-sheet-overlay) {
  background: var(--reading-scrim);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* State, opacity and positioning stay owned by Horizon and its controllers. */
:root[data-hz-reading="comfortable"] .hz-overlay .hz-dialog,
:root[data-hz-reading="comfortable"] .hz-sheet-overlay .hz-sheet {
  transform: none;
  transition-property: opacity;
}

@media (prefers-reduced-motion: reduce) {
  :root[data-hz-reading="comfortable"] .hz-overlay .hz-dialog,
  :root[data-hz-reading="comfortable"] .hz-sheet-overlay .hz-sheet,
  :root[data-hz-reading="comfortable"] :is(.hz-overlay, .hz-dialog, .hz-sheet-overlay, .hz-sheet, .card-hover) {
    transition: none;
  }
}
