/* ============================================================
   Anderman & Company — Materials index (visual spec table)
   New classes only. Everything is namespaced `mc-` so it cannot
   collide with anderman.css / extended.css / additional.css.

   Uses the existing theme tokens (--accent, --dark, --border,
   --r-md, --ease, --shadow-card …) declared in anderman.css.

   Layout switch:
     >= 992px  → one ROW per material, properties across the top,
                 sticky header row, numeric values drawn as bars
     <= 991px  → one CARD per material, same values as label/value
                 rows. No horizontal scrolling at any width.
   ============================================================ */


/* ============================================================
   1. TOOLBAR — search + result count + sort reset
============================================================ */
.mc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.mc-toolbar-group {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.mc-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 260px;
  padding: .55rem .9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.mc-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}
.mc-search svg { color: var(--secondary); flex-shrink: 0; }
.mc-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: .88rem;
  color: var(--dark);
}
.mc-search input::placeholder { color: var(--secondary); }

.mc-count {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.mc-count strong { color: var(--dark); font-weight: 800; }

.mc-reset {
  background: transparent;
  border: none;
  padding: .35rem .2rem;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  color: var(--secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color .2s var(--ease);
}
.mc-reset:hover { color: var(--accent); }
.mc-reset[hidden] { display: none; }


/* ============================================================
   2. THE TABLE  (>= 992px)
============================================================ */
.mc-cards { display: none; }          /* card view is mobile-only */

/* NOTE: no overflow on the wrapper.
   `overflow-x:auto` would force `overflow-y` to `auto` as well, making the
   wrapper the scroll container — the sticky header row would then pin to the
   wrapper instead of the viewport, i.e. not stick at all. Columns are sized
   to always fit the container instead. */
.mc-table-wrap { position: relative; }

.mc-table {
  width: 100%;
  border-collapse: separate;     /* `separate` keeps sticky cell borders painted */
  border-spacing: 0;
  table-layout: fixed;
  font-size: .86rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
/* rounded corners without `overflow:hidden` (which would also kill sticky) */
.mc-table thead th:first-child { border-top-left-radius: var(--r-md); }
.mc-table thead th:last-child  { border-top-right-radius: var(--r-md); }
.mc-table tbody tr:last-child > *:first-child { border-bottom-left-radius: var(--r-md); }
.mc-table tbody tr:last-child > *:last-child  { border-bottom-right-radius: var(--r-md); }

.mc-table th,
.mc-table td {
  padding: .85rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.mc-table tbody tr:last-child > * { border-bottom: none; }

/* --- sticky header row ---
   Offset by the COMPACT header height: by the time the table is on screen
   the site header has already collapsed (.site-header.scrolled). */
.mc-table thead th {
  position: sticky;
  top: var(--header-h-compact, 64px);
  z-index: 3;
  background: var(--light-alt);
  border-bottom: 2px solid var(--border);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--secondary);
  vertical-align: bottom;
  line-height: 1.35;
}
.mc-th-unit {
  display: block;
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: none;
  color: var(--secondary);
  opacity: .8;
  margin-top: .1rem;
}

/* sortable header buttons */
/* block, not flex — so .mc-th-unit stays on its own line underneath the label.
   The sort glyph is positioned out of the text flow. */
.mc-sort {
  display: block;
  position: relative;
  width: 100%;
  padding: 0 1.1rem 0 0;         /* right gutter reserves room for the glyph */
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color .2s var(--ease);
}
.mc-sort:hover { color: var(--accent); }
.mc-sort::after {
  content: '⇅';
  position: absolute;
  top: 0; right: 0;
  font-size: .8rem;
  letter-spacing: 0;
  opacity: .35;
  transition: opacity .2s var(--ease);
}
.mc-sort:hover::after { opacity: .7; }
.mc-table th[aria-sort="ascending"]  .mc-sort { color: var(--accent); }
.mc-table th[aria-sort="descending"] .mc-sort { color: var(--accent); }
.mc-table th[aria-sort="ascending"]  .mc-sort::after { content: '↑'; opacity: 1; }
.mc-table th[aria-sort="descending"] .mc-sort::after { content: '↓'; opacity: 1; }

/* row hover */
.mc-table tbody tr { transition: background .15s var(--ease); }
.mc-table tbody tr:hover > * { background: rgba(var(--accent-rgb), .045); }

/* --- column widths --- */
.mc-col-mat   { width: 24%; }
.mc-col-num   { width: 12%; }
.mc-col-rate  { width: 13%; }
.mc-col-tags  { width: 20%; }
.mc-col-go    { width: 56px; }


/* ============================================================
   3. THE MATERIAL CELL — thumbnail + name + formula
============================================================ */
.mc-mat {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-width: 0;
}
.mc-thumb {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: linear-gradient(140deg, rgba(var(--accent-rgb), .55), rgba(28, 43, 58, .85));
  position: relative;
}
.mc-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* until real imagery is in, the initial keeps the cell from looking broken */
.mc-thumb[data-initial]::after {
  content: attr(data-initial);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: rgba(255, 255, 255, .9);
  letter-spacing: -.02em;
}
.mc-thumb:has(img)::after { content: none; }

.mc-mat-text { min-width: 0; }
.mc-mat-name {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.25;
  letter-spacing: -.005em;
}
a.mc-mat-name:hover { color: var(--accent); }
.mc-mat-formula {
  display: block;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: .74rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: .1rem;
}
.mc-mat-family {
  display: block;
  font-size: .74rem;
  color: var(--secondary);
  margin-top: .15rem;
}


/* ============================================================
   4. VISUAL VALUES — bars, ratings, tags
============================================================ */
/* numeric value drawn as a bar scaled against the highest in the column */
.mc-figure {
  display: block;
  font-size: .92rem;
  font-weight: 700;
  color: var(--dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.mc-unit {
  font-size: .72em;
  font-weight: 600;
  color: var(--secondary);
  margin-left: .15em;
}
.mc-bar {
  display: block;
  height: 5px;
  margin-top: .4rem;
  background: var(--light);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.mc-bar i {
  display: block;
  height: 100%;
  width: var(--v, 0%);
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width .5s var(--ease);
}
/* the top value in a column reads as the standout */
.mc-bar.is-top i { background: var(--dark); }
.mc-figure.is-top { color: var(--dark); }

.mc-na {
  color: var(--secondary);
  font-style: italic;
  font-size: .85em;
}

/* 1–5 rating meter */

/* property / application chips */
.mc-tags { display: flex; flex-wrap: wrap; gap: .28rem; }
.mc-tag {
  display: inline-block;
  padding: .16rem .5rem;
  background: rgba(var(--accent-rgb), .08);
  color: var(--accent);
  border-radius: var(--r-pill);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.55;
  white-space: nowrap;
}
.mc-tag--muted { background: var(--light); color: var(--muted); }

/* go-to-material arrow */
.mc-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--accent);
  transition: all .2s var(--ease);
}
.mc-go:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateX(2px);
}


/* ============================================================
   5. EMPTY STATE
============================================================ */
.mc-empty {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 3.5rem 1.5rem;
  text-align: center;
}
.mc-empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), .1);
  color: var(--accent);
}
.mc-empty h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: .35rem;
}
.mc-empty p {
  font-size: .9rem;
  color: var(--muted);
  max-width: 44ch;
  margin: 0 auto;
}


/* ============================================================
   6. PLACEHOLDER-DATA NOTICE (remove once real datasheet
      values are in place)
============================================================ */
.mc-datanote {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .9rem 1.1rem;
  margin-bottom: 1.5rem;
  background: #fff8ec;
  border: 1px solid #f0d49a;
  border-left: 3px solid #e8a33d;
  border-radius: var(--r-sm);
  font-size: .84rem;
  line-height: 1.55;
  color: #6b4d18;
}
.mc-datanote svg { flex-shrink: 0; color: #e8a33d; margin-top: .15rem; }
.mc-datanote strong { font-weight: 800; }


/* ============================================================
   7. Tighter table in the 992–1099px band
============================================================ */
@media (min-width: 992px) and (max-width: 1099px) {
  .mc-table { font-size: .82rem; }
  .mc-table th, .mc-table td { padding: .75rem .65rem; }
  .mc-thumb { width: 44px; height: 44px; }
  .mc-mat { gap: .6rem; }
  .mc-mat-name { font-size: .88rem; }
  .mc-light-label { font-size: .7rem; }   /* narrow desktop: keep the word, shrink it */
  .mc-col-go { width: 48px; }
  .mc-go { width: 30px; height: 30px; }
}


/* ============================================================
   8. CARD VIEW  (<= 991px)
   The table is replaced outright — no sideways scrolling on
   phones, no squashed columns.
============================================================ */
@media (max-width: 991px) {

  .mc-table-wrap { display: none; }
  .mc-cards { display: grid; gap: 1.1rem; }

  .mc-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  }
  .mc-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-card-hover);
  }

  /* card head — thumbnail, name, formula */
  .mc-card-head {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1.1rem;
    background: var(--dark);
    color: #fff;
  }
  .mc-card-head .mc-thumb { width: 46px; height: 46px; }
  .mc-card-head-text { min-width: 0; flex: 1; }
  .mc-card-head-text h3 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
  }
  .mc-card-head-text .mc-mat-formula { color: #7fd6f7; }
  .mc-card-head-text .mc-mat-family { color: rgba(255, 255, 255, .6); }
  .mc-card-head .mc-go {
    flex-shrink: 0;
    border-color: rgba(255, 255, 255, .25);
    color: #fff;
  }
  .mc-card-head .mc-go:hover { background: var(--accent); border-color: var(--accent); }

  /* one property row */
  .mc-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem 1.1rem;
    border-bottom: 1px solid var(--border);
  }
  .mc-card-row:last-child { border-bottom: none; }
  .mc-card-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    flex: 0 0 auto;
  }
  .mc-card-value {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
  }
  .mc-card-value .mc-figure { display: inline-block; }
  .mc-card-value   /* the bar spans the row under the figure */
  .mc-card-value .mc-bar { margin-top: .35rem; }

  /* full-width row for tag clouds */
  .mc-card-row--stack {
    flex-direction: column;
    align-items: stretch;
    gap: .45rem;
  }
  .mc-card-row--stack .mc-card-value { text-align: left; }

  .mc-toolbar { gap: .75rem; }
  .mc-search { min-width: 0; flex: 1 1 200px; }
}

/* two cards side by side on tablets, one on phones */
@media (min-width: 640px) and (max-width: 991px) {
  .mc-cards { grid-template-columns: repeat(2, 1fr); align-items: start; }
}

@media (max-width: 480px) {
  .mc-card-row { padding: .6rem .9rem; }
  .mc-card-label { font-size: .76rem; }
  .mc-toolbar { flex-direction: column; align-items: stretch; }
  .mc-toolbar-group { justify-content: space-between; }
}


/* ============================================================
   9. Short-viewport safety — the sticky header uses the compact
      height once the site header collapses / drawer nav kicks in.
============================================================ */
@media (max-height: 670px) {
  .mc-table thead th { top: var(--header-h-compact, 64px); }
}

@media (prefers-reduced-motion: reduce) {
  .mc-bar i, .mc-go, .mc-card, .mc-table tbody tr { transition: none; }
}


/* ============================================================
   10. Print — always the table, never the cards
============================================================ */
@media print {
  .mc-toolbar, .mc-datanote, .mc-col-go, .mc-go { display: none !important; }
  .mc-table-wrap { display: block !important; }
  .mc-table { box-shadow: none; border-color: #999; }
  .mc-cards { display: none !important; }
  .mc-table thead th { position: static; }
  .mc-bar { display: none; }
}


/* ============================================================
   TRAFFIC-LIGHT RATINGS + KEY (Anderman comparison spreadsheet)
   good = green, moderate = amber, poor = red
============================================================ */
.mc-light {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
}
.mc-light i {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #cbd5e1;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  flex-shrink: 0;
}
.mc-light--good i     { background: #22a559; }
.mc-light--moderate i { background: #f2a623; }
.mc-light--poor i     { background: #d9342b; }

.mc-key {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  font-size: .8rem;
  color: var(--muted);
}
.mc-key-lights {
  list-style: none;
  margin: 0 0 .75rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
}
.mc-key-note { margin: .25rem 0; line-height: 1.5; }
.mc-key-note strong { color: var(--dark); }
