/* Film Color: its own styles, on the family tokens (site.css) and the bench
   layer (bench.css). Light and dark come from the tokens.

   The swatch, the thickness map and the coating swatches are computed
   colours, the same in either theme. The few labels laid over them sit on
   their own dark scrim, because the colour underneath can be anything. */

.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
@media (max-width: 54rem) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Mode ---------- */

.mode-toggle-row {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}
.mode-toggle {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
}
.mode-toggle-btn {
  padding: 0.55rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font: 600 0.88rem/1.2 var(--font);
  cursor: pointer;
}
.mode-toggle-btn.active {
  background: var(--accent-fill);
  color: var(--ink-on-accent);
}

/* ---------- Calculator ---------- */

.calc-panel {
  border: 1px solid var(--glass-line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.calc-panel-header {
  padding: 1.1rem 1.5rem 1rem;
  border-bottom: 1px solid var(--glass-line);
}
.calc-panel-header h2 {
  margin-bottom: 0.2rem;
  color: var(--ink);
  font: 800 1.1rem/1.2 var(--font-display);
}
.calc-panel-header p {
  color: var(--ink-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.calc-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}
.calc-divider {
  height: 1px;
  margin: 2px -1.5rem;
  background: var(--glass-line);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field .bench-flabel {
  display: flex;
}
.field input:not([type="range"]) {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: 400 0.95rem/1.3 var(--font-mono);
  -moz-appearance: textfield;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field input::-webkit-inner-spin-button,
.field input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-hint {
  color: var(--ink-muted);
  font-size: 0.8rem;
  line-height: 1.55;
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.field-unit {
  color: var(--ink-muted);
  font: 400 0.8rem/1.3 var(--font-mono);
  white-space: nowrap;
}
.flabel-aside {
  margin-left: auto;
  color: var(--ink-muted);
  font: 400 0.75rem/1.3 var(--font);
}
.flabel-value {
  margin-left: auto;
  color: var(--accent-ink);
  font: 600 0.82rem/1.3 var(--font-mono);
}

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.seg-btn {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-muted);
  font: 600 0.82rem/1.2 var(--font);
  white-space: nowrap;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--accent-fill);
  color: var(--ink-on-accent);
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem;
  align-items: center;
  gap: 0.6rem;
}
input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-fill);
  box-shadow: 0 0 0 3px var(--accent-soft);
  -webkit-appearance: none;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-fill);
  cursor: pointer;
}

.preset-chips,
.mat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.preset-chip,
.mat-chip {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-muted);
  font: 500 0.8rem/1.2 var(--font);
  white-space: nowrap;
  cursor: pointer;
}
.mat-chip {
  font-weight: 600;
}
.preset-chip:hover,
.mat-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.preset-chip.active,
.mat-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.custom-n-field {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.25s ease, opacity 0.2s;
}
.custom-n-field.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.custom-n-inner {
  overflow: hidden;
  padding: 2px 0;
}

/* ---------- Swatch and map ---------- */

.fc-view {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}
.fc-view-btn {
  padding: 0.2rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font: 600 0.72rem/1.2 var(--font);
  cursor: pointer;
}
.fc-view-btn.active {
  background: var(--accent-fill);
  color: var(--ink-on-accent);
}
.swatch-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--glass-line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
#swatch-canvas {
  display: block;
  width: 100%;
  height: 180px;
}
.swatch-meta {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Its colour follows the swatch's lightness; script sets it. */
.swatch-hex {
  padding: 3px 9px;
  border-radius: 6px;
  background: rgb(0 0 0 / 45%);
  font: 600 0.75rem/1.3 var(--font-mono);
}

.spectrum-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--glass-line);
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: crosshair;
}
#spectrum-canvas {
  display: block;
  width: 100%;
  height: 100px;
}
.spectrum-y-labels {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 0;
  pointer-events: none;
}
.spectrum-y-label {
  padding: 2px 6px;
  border-radius: 0 4px 4px 0;
  background: rgb(4 10 20 / 72%);
  color: #ffffff;
  font: 500 0.62rem/1.3 var(--font-mono);
  white-space: nowrap;
}
.spectrum-axes {
  display: flex;
  justify-content: space-between;
  padding-top: 3px;
  color: var(--ink-muted);
  font: 400 0.7rem/1.3 var(--font-mono);
}
.map-computing {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-strong);
  color: var(--ink-muted);
  font: 500 0.75rem/1.3 var(--font-mono);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.metric-box {
  padding: 0.65rem 0.75rem;
  border-radius: var(--r-sm);
  background: var(--surface-sunk);
  text-align: center;
}
.metric-label {
  margin-bottom: 0.2rem;
  color: var(--ink-muted);
  font: 500 0.7rem/1.3 var(--font-mono);
}
.metric-val {
  color: var(--accent-ink);
  font: 500 1.1rem/1.1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.metric-unit {
  margin-left: 1px;
  color: var(--ink-muted);
  font-size: 0.7rem;
}

/* ---------- Sidebar ---------- */

.calc-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  position: sticky;
  top: 6rem;
}
@media (max-width: 54rem) {
  .calc-sidebar {
    position: static;
  }
}
.sidebar-card {
  padding: 1.25rem;
  border: 1px solid var(--glass-line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.sidebar-card .bench-kicker {
  margin-bottom: 0.85rem;
}
.formula-block {
  padding: 0.75rem 0.9rem;
  border-radius: var(--r-sm);
  background: var(--surface-sunk);
  color: var(--ink);
  font: 400 0.75rem/1.9 var(--font-mono);
  white-space: pre;
  overflow-x: auto;
}
.formula-desc {
  margin-top: 0.6rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  line-height: 1.6;
}
.formula-desc strong {
  color: var(--ink);
}
.mat-name {
  margin-bottom: 2px;
  color: var(--ink);
  font: 800 1.2rem/1.2 var(--font-display);
}
.mat-formula {
  margin-bottom: 0.85rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}
.mat-info-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--glass-line);
  font-size: 0.8rem;
}
.mat-info-row:last-child {
  border-bottom: none;
}
.mat-info-row span:first-child {
  color: var(--ink-muted);
}
.mat-info-row span:last-child {
  color: var(--ink);
  font: 600 0.8rem/1.4 var(--font-mono);
}
.order-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 0.6rem;
}
.order-cell {
  display: grid;
  gap: 3px;
  color: var(--ink-muted);
  font: 400 0.68rem/1.2 var(--font-mono);
}
.order-cell i {
  display: block;
  height: 22px;
  border: 1px solid var(--glass-line);
  border-radius: 4px;
}

/* ---------- PVD coatings ---------- */

.pvd-substrate-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.pvd-substrate-label {
  color: var(--ink-muted);
  font: 500 0.75rem/1.3 var(--font-mono);
}
.pvd-note {
  margin-left: auto;
  color: var(--ink-muted);
  font-size: 0.8rem;
}
@media (max-width: 38rem) {
  .pvd-note {
    display: none;
  }
}
/* A physical backdrop (steel or dark glass) to judge coating colour
   against, so it stays dark in either theme; script sets it. */
.pvd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.9rem;
  padding: 0.9rem;
  border-radius: var(--r-md);
}
@media (max-width: 40rem) {
  .pvd-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.pvd-card {
  border: 1px solid var(--glass-line);
  border-radius: var(--r-sm);
  background: var(--surface);
  overflow: hidden;
  transition: transform 0.15s var(--ease);
}
.pvd-card:hover {
  transform: translateY(-2px);
}
.pvd-swatch {
  position: relative;
  display: block;
  width: 100%;
  height: 76px;
  overflow: hidden;
}
.pvd-swatch-inner {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(135deg, rgb(255 255 255 / 12%) 0%, transparent 60%);
}
.pvd-body {
  padding: 0.75rem 0.9rem;
}
.pvd-name {
  margin-bottom: 1px;
  color: var(--ink);
  font: 800 1rem/1.2 var(--font-display);
}
.pvd-full {
  margin-bottom: 0.5rem;
  color: var(--ink-muted);
  font-size: 0.75rem;
}
.pvd-props {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.pvd-prop {
  color: var(--ink-muted);
  font: 400 0.72rem/1.3 var(--font-mono);
}
.pvd-prop strong {
  color: var(--ink);
  font-weight: 600;
}
.pvd-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.pvd-tag {
  padding: 2px 7px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font-size: 0.68rem;
  font-weight: 500;
}

/* ---------- Physics notes ---------- */

.edu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
}
@media (max-width: 45rem) {
  .edu-grid {
    grid-template-columns: 1fr;
  }
}
.edu-card {
  padding: 1.35rem;
  border-radius: var(--r-md);
}
.edu-card h3 {
  margin-bottom: 0.6rem;
  color: var(--ink);
  font: 800 1rem/1.25 var(--font-display);
}
.edu-card p {
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.65;
}
.edu-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 0.85rem;
}
.edu-tag {
  padding: 3px 9px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: 500 0.72rem/1.3 var(--font-mono);
}
