/* Auxetic Lace Atlas — placeholder visualizer styles */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.55;
  color: #1c1c1c;
  background: #f5f0e3;  /* same cream as the lace renders */
  margin: 0;
  padding: 0;
}

header {
  max-width: min(2400px, 95vw);
  margin: 0 auto;
  padding: 3rem 1.5rem 1.5rem;
  border-bottom: 1px solid #d9cfb6;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #2a2520;
}

.tagline {
  margin: 0;
  font-size: 1.05rem;
  color: #5a5249;
}

main {
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
  /* Per-page max-widths set below via body classes */
}

.page-home main { max-width: min(2400px, 95vw); }
.page-data main { max-width: min(1800px, 93vw); }
.page-about main { max-width: min(1200px, 90vw); }

/* Fallback when no page class is set */
body:not(.page-home):not(.page-about):not(.page-data) main {
  max-width: min(2400px, 95vw);
}

section {
  margin-bottom: 2.5rem;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
  color: #2a2520;
}

h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  color: #4a423a;
}

.muted { color: #7a7268; font-style: italic; }

dl.stats {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.2rem;
  margin: 0.5rem 0 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 4px;
}

dl.stats dt {
  font-weight: 600;
  color: #4a423a;
}

dl.stats dd {
  margin: 0;
  color: #2a2520;
}

ul {
  padding-left: 1.5rem;
}

table.auxetic-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0 1.5rem;
  font-size: 0.95rem;
}

table.auxetic-table th,
table.auxetic-table td {
  text-align: left;
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid #d9cfb6;
}

table.auxetic-table th {
  background: rgba(255, 255, 255, 0.3);
  font-weight: 600;
  color: #4a423a;
}

/* Use a fixed column-width layout via table-layout: auto, with
   numeric cells right-aligned via inline style or an explicit class.
   Removed the position-3/4 rule because it broke when modal tables
   have 4 columns instead of the home page's 5. */
table.auxetic-table {
  table-layout: auto;
}
table.auxetic-table td.num,
table.auxetic-table th.num {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-align: right;
  white-space: nowrap;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.5);
  padding: 0.05em 0.35em;
  border-radius: 3px;
}

a {
  color: #6a4c93;
  text-decoration: underline;
  text-decoration-color: rgba(106, 76, 147, 0.4);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

#ground-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

#ground-grid figure {
  margin: 0;
  background: #fffaf0;
  border: 1px solid #d9cfb6;
  border-radius: 4px;
  padding: 0.5rem;
}

#ground-grid img {
  width: 100%;
  display: block;
  border-radius: 2px;
}

#ground-grid figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #5a5249;
  text-align: center;
}

.error {
  color: #7a3030;
  background: rgba(220, 180, 180, 0.3);
  padding: 1rem;
  border-radius: 4px;
}

footer {
  max-width: min(2400px, 95vw);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  border-top: 1px solid #d9cfb6;
  font-size: 0.85rem;
  color: #7a7268;
}

footer p {
  margin: 0.4rem 0;
}


/* === Catalog controls === */
.catalog-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 0.5rem 0 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #d9cfb6;
  border-radius: 4px;
}

.catalog-controls input[type="search"] {
  flex: 1 1 280px;
  min-width: 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid #d9cfb6;
  border-radius: 3px;
  font: inherit;
  background: #fffaf0;
}

.catalog-controls select {
  padding: 0.35rem 0.5rem;
  border: 1px solid #d9cfb6;
  border-radius: 3px;
  font: inherit;
  background: #fffaf0;
}

.catalog-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  color: #4a423a;
}

#catalog-count {
  margin-left: auto;
  font-size: 0.88rem;
}

/* === Catalog item (grid figure) === */
.catalog-item {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.catalog-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(80, 60, 30, 0.18);
}
.catalog-item .meta {
  font-size: 0.78rem;
  color: #7a7268;
}

.clickable-row {
  cursor: pointer;
}
.clickable-row:hover td {
  background: rgba(255, 255, 255, 0.6);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 28, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 100;
  overflow-y: auto;
}

.modal-overlay[hidden] { display: none; }

body.modal-open { overflow: hidden; }

.modal-card {
  background: #f5f0e3;
  border-radius: 6px;
  max-width: 1100px;
  width: 100%;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 1.5rem 1.75rem 2rem;
  position: relative;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.modal-card h2 {
  margin: 0 0 1rem;
  padding-right: 2rem;  /* leave room for close button */
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.3rem;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: transparent;
  border: 0;
  font-size: 2rem;
  line-height: 1;
  color: #4a423a;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.5); }

.modal-image-viewer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.modal-image-viewer figure {
  margin: 0;
  flex: 1;
  background: #fffaf0;
  border: 1px solid #d9cfb6;
  border-radius: 4px;
  padding: 0.75rem;
}
.modal-image-viewer img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}
.modal-image-viewer figcaption {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #5a5249;
  text-align: center;
}
.image-nav {
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid #d9cfb6;
  background: #fffaf0;
  font-size: 1.6rem;
  line-height: 1;
  color: #4a423a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.12s ease;
}
.image-nav:hover {
  background: #f0e5cc;
  transform: scale(1.05);
}
.image-nav:active { transform: scale(0.97); }
.image-tabs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.image-tab {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid #d9cfb6;
  border-radius: 3px;
  padding: 0.35rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  color: #5a5249;
  cursor: pointer;
}
.image-tab:hover { background: #fffaf0; }
.image-tab.is-active {
  background: #2a2520;
  color: #f5f0e3;
  border-color: #2a2520;
}

.modal-stats { color: #2a2520; }

.default-row td {
  background: rgba(180, 140, 70, 0.18);
  font-weight: 600;
}

@media (max-width: 700px) {
  .modal-image-viewer { flex-direction: column; }
  .image-nav { width: 100%; height: 2.5rem; border-radius: 4px; }
}

/* Crop modal image to left or right half (used by setModalView for
   the pair-diagram / thread-sketch tabs of the combined lace.png).
   Approach: we keep the <img> at full natural width and use a wrapper
   with overflow:hidden to mask one half. The image is then translated
   so the chosen half aligns with the wrapper's left edge, and the
   wrapper's max-width is set so the half scales to fill the figure. */

.modal-image-viewer figure {
  overflow: hidden;        /* clip the doubled image */
}
.modal-image-viewer img.crop-left,
.modal-image-viewer img.crop-right {
  width: 200%;             /* image is twice as wide as the visible figure */
  max-height: none;        /* let height grow proportionally */
  margin-top: -8%;         /* clip the source PNG's title row */
  margin-bottom: -3%;      /* tiny bottom trim too */
}
.modal-image-viewer img.crop-left {
  margin-left: 0;          /* show left half */
}
.modal-image-viewer img.crop-right {
  margin-left: -100%;      /* shift left so right half is visible */
}


/* Sort direction toggle button */
.sort-dir-btn {
  background: #fffaf0;
  border: 1px solid #d9cfb6;
  border-radius: 3px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font: inherit;
  color: #4a423a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  transition: background 0.12s ease;
}
.sort-dir-btn:hover { background: #f0e5cc; }
.sort-dir-arrow { font-size: 1.05rem; line-height: 1; }

/* Atlas scatter plot */
#atlas-scatter-section {
  margin: 1.5rem 0;
}
#atlas-scatter {
  background: #f5f0e3;
  border: 1px solid #d4cebd;
  padding: 0.5rem;
  border-radius: 4px;
}
.scatter-svg {
  display: block;
  max-width: 100%;
  height: auto;
}
.scatter-tooltip {
  position: absolute;
  background: #2a2520;
  color: #f5f0e3;
  padding: 0.5em 0.75em;
  border-radius: 3px;
  font-size: 0.85em;
  line-height: 1.4;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  max-width: 280px;
}

/* Preliminary-work banner */
#preliminary-banner {
  background: #fff3cd;
  border-bottom: 1px solid #d6c47e;
  color: #5a4a16;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  text-align: center;
  margin-bottom: 0.5rem;
}
#preliminary-banner strong {
  font-weight: 700;
}

/* Citation section */
#citation {
  margin: 2rem 0 1rem 0;
  padding: 1rem;
  background: #f5f0e3;
  border: 1px solid #d4cebd;
  border-radius: 4px;
}
#citation h2 {
  margin-top: 0;
}
#citation pre.bibtex {
  background: #2a2520;
  color: #f5f0e3;
  padding: 0.75rem 1rem;
  border-radius: 3px;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre;
}
#citation pre.bibtex code {
  background: transparent;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Footer authorship line */
.author-line {
  font-size: 0.95rem;
  margin: 0.25rem 0 0.75rem 0;
  color: #2a2520;
}
.author-line a {
  color: #6b4a1e;
  text-decoration: underline;
}

/* Catalog pagination */
.catalog-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin: 0.75rem 0;
}
.catalog-pagination:empty {
  display: none;
}
.page-btn {
  background: #fffaf0;
  border: 1px solid #d4cebd;
  color: #2a2520;
  padding: 0.35em 0.7em;
  font-size: 0.9rem;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  min-width: 2.2em;
}
.page-btn:hover:not(:disabled) {
  background: #ebe2c8;
  border-color: #b8af96;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-btn.page-current {
  background: #6b4a1e;
  color: #fffaf0;
  border-color: #6b4a1e;
  font-weight: 600;
}
.page-ellipsis {
  padding: 0 0.4em;
  color: #888;
}
#catalog-page-size {
  background: #fffaf0;
  border: 1px solid #d4cebd;
  padding: 0.25em 0.5em;
  border-radius: 3px;
  font-size: 0.9rem;
  font-family: inherit;
  margin-right: 0.5rem;
}

/* Data access + data dictionary sections */
#data-access, #data-dictionary {
  margin: 2rem 0 1rem 0;
  padding: 1rem;
  background: #f5f0e3;
  border: 1px solid #d4cebd;
  border-radius: 4px;
}
#data-access h2, #data-dictionary h2 { margin-top: 0; }
#data-access pre.code-block {
  background: #2a2520;
  color: #f5f0e3;
  padding: 0.75rem 1rem;
  border-radius: 3px;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre;
}
#data-access pre.code-block code {
  background: transparent;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#data-dictionary table.data-dict {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
#data-dictionary table.data-dict th,
#data-dictionary table.data-dict td {
  border: 1px solid #d4cebd;
  padding: 0.4em 0.6em;
  text-align: left;
  vertical-align: top;
}
#data-dictionary table.data-dict th {
  background: #ebe2c8;
  font-weight: 600;
}
#data-dictionary table.data-dict code {
  background: #fffaf0;
  padding: 0 0.2em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
#data-dictionary h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
}

/* Tagline under the H1 */
.tagline {
  margin: -0.4rem 0 1rem 0;
  font-size: 1.05rem;
  color: #5a4a16;
  font-style: italic;
}

/* Page navigation strip */
.page-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1.25rem 0;
  padding: 0.5rem 0;
  border-top: 1px solid #d4cebd;
  border-bottom: 1px solid #d4cebd;
  background: #f5f0e3;
}
.nav-item {
  padding: 0.4em 1.2em;
  font-size: 1rem;
  color: #2a2520;
  text-decoration: none;
  border-radius: 3px;
}
.nav-item:hover {
  background: #ebe2c8;
}
.nav-current {
  background: #6b4a1e;
  color: #fffaf0;
  font-weight: 600;
}


/* topology-equivalents section in modal */
.topology-equivalents { margin: 1rem 0 1.5rem; }
.topology-equivalents h3 { margin: 0 0 0.4rem; }
.topology-equivalents .unique-note {
  color: #6b6557; font-style: italic; font-size: 0.95em; margin: 0;
}
.topology-equivalents .muted {
  color: #6b6557; font-size: 0.9em; margin: 0 0 0.4rem;
}
.topology-equivalents .equiv-list {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.topology-equivalents .equiv-pill {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  background: rgba(133, 79, 11, 0.08);
  border: 1px solid rgba(133, 79, 11, 0.25);
  border-radius: 999px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: #4d2e08;
  cursor: pointer;
}
.topology-equivalents .equiv-pill:hover {
  background: rgba(133, 79, 11, 0.18);
}


/* manufacturability pills in modal stats */
.stats .mfg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.mfg-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  border: 1px solid transparent;
  white-space: nowrap;
}
.mfg-pill.mfg-yes {
  background: rgba(45, 100, 30, 0.10);
  border-color: rgba(45, 100, 30, 0.25);
  color: #2d641e;
}
.mfg-pill.mfg-no {
  background: rgba(160, 50, 30, 0.10);
  border-color: rgba(160, 50, 30, 0.25);
  color: #a0321e;
}
.mfg-pill.mfg-unknown {
  background: rgba(120, 110, 95, 0.10);
  border-color: rgba(120, 110, 95, 0.25);
  color: #6b6557;
  font-style: italic;
}

/* Scatter carousel header: arrows + title in a row */
.scatter-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.scatter-titlebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.scatter-titlebar h2 {
  margin: 0;
  text-align: center;
}
#atlas-scatter-indicator {
  font-size: 0.8rem;
}
.scatter-arrow {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid #cfc4ad;
  border-radius: 50%;
  background: #fffaf0;
  color: #2a2520;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}
.scatter-arrow:hover {
  background: #f0e7d2;
}
.scatter-arrow:active {
  background: #e6d9b8;
}
