/* Indicatrix — project datasheet stylesheet.
 * Spectral gemstone path tracer and faceting-design CAD, in Rust.
 * MIT License. Source: https://github.com/suitable-name/indicatrix
 *
 * No web fonts, no CDNs, no JS frameworks. System serif/monospace stacks only.
 */

:root {
  --paper: #f5f2ec;
  --paper-2: #ebe7df;
  --ink: #191919;
  --ink-2: #4a4740;
  --rule: #c7c1b4;
  --accent: #6b1f2a;
  --figure-frame: #111111;

  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --content-width: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161514;
    --paper-2: #1f1d1b;
    --ink: #e8e3da;
    --ink-2: #a9a39a;
    --rule: #3a3733;
    --accent: #d18a93;
  }
}

:root[data-theme="dark"] {
  --paper: #161514;
  --paper-2: #1f1d1b;
  --ink: #e8e3da;
  --ink-2: #a9a39a;
  --rule: #3a3733;
  --accent: #d18a93;
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font-serif);
  font-weight: 400;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* -----------------------------------------------------------------------
 * Headings and text
 * --------------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
}

h1 {
  font-size: 2.4rem;
  margin: 0 0 0.5rem 0;
}

h2 {
  font-size: 1.5rem;
  margin: 2.75rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

h3 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem 0;
  color: var(--ink);
}

/* Numbered section heading: "2  Optics" — number in accent monospace. */
.sec-num {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.6em;
}

p {
  margin: 0 0 1.1rem 0;
}

.subtitle {
  font-size: 1.15rem;
  color: var(--ink-2);
  margin: 0 0 1.5rem 0;
}

.lede {
  font-size: 1.05rem;
  color: var(--ink-2);
}

small, .small {
  font-size: 0.85rem;
  color: var(--ink-2);
}

ul, ol {
  padding-left: 1.4rem;
}

li {
  margin-bottom: 0.5rem;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* -----------------------------------------------------------------------
 * Masthead
 * --------------------------------------------------------------------- */

.masthead {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--rule);
}

.masthead .container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-serif);
  font-variant: small-caps;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  margin-right: 0.75rem;
}

.brand img {
  width: 24px;
  height: 24px;
}

.masthead nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.9rem;
  font-size: 0.95rem;
}

.masthead nav a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.15rem 0;
}

.masthead nav a:hover,
.masthead nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
}

.masthead .gh-link {
  margin-left: auto;
  font-size: 0.95rem;
  color: var(--ink-2);
  text-decoration: none;
}

.masthead .gh-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* -----------------------------------------------------------------------
 * Page header block
 * --------------------------------------------------------------------- */

.page-head {
  padding: 2.5rem 0 1.5rem 0;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

/* -----------------------------------------------------------------------
 * Sections
 * --------------------------------------------------------------------- */

main {
  padding-bottom: 3rem;
}

section {
  margin: 2.5rem 0;
}

/* -----------------------------------------------------------------------
 * Abstract (two-column, index page)
 * --------------------------------------------------------------------- */

.abstract-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2.5rem;
  align-items: start;
  margin: 1.5rem 0;
}

.abstract-grid .fig {
  margin: 0;
}

/* -----------------------------------------------------------------------
 * Figures
 * --------------------------------------------------------------------- */

.fig {
  margin: 1.75rem 0;
}

.fig a {
  display: block;
  background: var(--figure-frame);
  padding: 16px;
  line-height: 0;
}

.fig img {
  width: 100%;
  height: auto;
}

figcaption {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-top: 0.6rem;
  line-height: 1.5;
}

.fig-note {
  font-size: 0.92rem;
  color: var(--ink-2);
  margin-top: 0.4rem;
}

.fig-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
}

/* A responsive strip for a multi-panel figure (e.g. one cut in five materials):
   as many columns as fit, wrapping instead of forcing a ragged fixed grid. Lives
   INSIDE a single <figure>, so the panels share one caption and one number. */
.fig-grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2px;
}

.fig-grid-auto img {
  display: block;
  width: 100%;
  height: auto;
}

.fig-grid .fig {
  margin: 0;
}

/* Schematic figures (inline SVG): drawn on paper with a hairline frame, not on
 * the dark plate the renders and screenshots use. */
.diagram-fig svg {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  background: var(--paper);
}

/* -----------------------------------------------------------------------
 * Tables
 * --------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* A wide table (the comparison matrix) scrolls in its own box rather than making
   the whole page scroll sideways. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 54rem;
}

/* The comparison matrix: row labels are prose, the cells are single glyphs, so the
   labels get the serif face and left alignment while everything else centres. */
.matrix th[scope="row"] {
  font-family: var(--font-serif);
  font-weight: 400;
  text-align: left;
  white-space: normal;
}

.matrix td {
  text-align: center;
  /* Qualifiers wrap inside a bounded column instead of stretching it, so every
     product column stays roughly the same width and a tick sits under its name. */
  white-space: normal;
  min-width: 6.5rem;
  max-width: 9rem;
}

/* The product names sit CENTRED over their columns of glyphs (the page-wide `th`
   rule is left-aligned, which put each name at the left edge of a column whose
   ticks are centred). The empty corner cell keeps the row-label column's alignment. */
.matrix thead th[scope="col"] {
  text-align: center;
  vertical-align: bottom;
}

.matrix thead th[scope="col"]:first-child {
  text-align: left;
}

.matrix tr.group th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: left;
  padding-top: 1.1rem;
}

/* A qualifier beside a tick ("beta", "MIT"): present but deliberately quiet, so the
   column still reads as a column of glyphs at a glance. */
.qual {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

caption {
  text-align: left;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--ink-2);
  margin-bottom: 0.5rem;
  caption-side: top;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

th {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 1px solid var(--ink-2);
}

tbody tr:nth-child(even) {
  background: var(--paper-2);
}

/* Definition lists, used instead of a table where a table would be silly. */
dl.deflist {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
  font-size: 0.95rem;
}

dl.deflist dt {
  font-family: var(--font-mono);
  color: var(--ink-2);
  font-size: 0.85rem;
  padding-top: 0.1rem;
}

dl.deflist dd {
  margin: 0;
}

/* -----------------------------------------------------------------------
 * Status notice
 * --------------------------------------------------------------------- */

.status {
  border-left: 3px solid var(--accent);
  background: var(--paper-2);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.status .status-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.4rem;
}

.status p {
  margin: 0;
}

/* -----------------------------------------------------------------------
 * Call-to-action link (web app page, index)
 * --------------------------------------------------------------------- */

.cta {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--paper);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0.6rem 1.1rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.cta:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* -----------------------------------------------------------------------
 * Code blocks
 * --------------------------------------------------------------------- */

.code-block {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  margin: 1.25rem 0;
  overflow: hidden;
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-2);
}

.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--ink);
  border-color: var(--ink-2);
}

pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

code {
  font-family: var(--font-mono);
}

:not(pre) > code {
  font-size: 0.9em;
  background: var(--paper-2);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

.cmt { color: var(--ink-2); }

/* -----------------------------------------------------------------------
 * Chart / canvas container (materials dispersion chart)
 * --------------------------------------------------------------------- */

.chart-box {
  border: 1px solid var(--rule);
  padding: 1rem;
  margin: 1.5rem 0;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.chart-controls button {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  padding: 0.3rem 0.65rem;
  border-radius: 2px;
  cursor: pointer;
}

.chart-controls button:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

.chart-controls button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

#dispersionCanvas {
  width: 100%;
  height: 260px;
  display: block;
}

.chart-readout {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-top: 0.75rem;
}

.noscript-note {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-2);
}

/* -----------------------------------------------------------------------
 * Footer
 * --------------------------------------------------------------------- */

footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 0 2.5rem 0;
  font-size: 0.9rem;
  color: var(--ink-2);
}

footer a {
  color: var(--ink-2);
}

footer a:hover {
  color: var(--accent);
}

/* -----------------------------------------------------------------------
 * Responsive
 * --------------------------------------------------------------------- */

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .container {
    padding: 0 1rem;
  }

  h1 {
    font-size: 1.9rem;
  }

  .abstract-grid {
    grid-template-columns: 1fr;
  }

  .fig-grid {
    grid-template-columns: 1fr;
  }

  .fig a {
    padding: 10px;
  }

  dl.deflist {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.78rem;
  }

  /* Long file paths and identifiers in table cells wrap instead of widening the page. */
  .matrix td, .matrix th { overflow-wrap: normal; }
  td, th, td code, :not(pre) > code {
    overflow-wrap: anywhere;
  }
}

/* -----------------------------------------------------------------------
 * Print
 * --------------------------------------------------------------------- */

@media print {
  .masthead, footer, .copy-btn {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .fig a {
    background: #222;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}
