/* page-calculator.css — rules that belong to yield-calculator.html and nothing else.
   Shared styling lives in subpage.css, sections.css and parts.css; treat those as read only.
   The lesson layout, key figures and table come from page-academy.css. This file carries:

   1. the input groups: wafer, die and process, each a fieldset of labelled fields
   2. the fields themselves, drawn as underlined rows like the directory search
   3. the results: the gross die count, the model table, the actions and the note

   Colours and rules come from the bridge variables, easing and duration from the motion
   tokens. Radius is 0 throughout, and every control is at least 44px tall. */

/* ── 1. Input groups ───────────────────────────────────────────────────────── */
.sy-calc { margin-top: clamp(32px, 4vw, 52px); max-width: 720px; }
.sy-calc__set {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;                        /* Fieldsets refuse to shrink in a grid otherwise */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px clamp(20px, 3vw, 36px);
}
.sy-calc__set + .sy-calc__set { margin-top: clamp(28px, 3.5vw, 40px); }
.sy-calc__legend {
  grid-column: 1 / -1;
  float: left;                         /* Lets the legend sit inside the grid like any child */
  width: 100%;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--color-line);
  font-family: var(--vy-font-mono);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--vy-text-primary);
}

/* ── 2. Fields ─────────────────────────────────────────────────────────────── */
.sy-calc__field { padding-top: 14px; min-width: 0; }
.sy-calc__field label {
  display: block;
  font-family: var(--vy-font-mono);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--vy-text-secondary);
}
.sy-calc__field label .sy-calc__sym { text-transform: none; }   /* Keeps α and D0 as written */
.sy-calc__control {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-line);
  transition: border-color var(--vy-dur-micro) var(--vy-ease);
}
.sy-calc__control:focus-within { border-bottom-color: var(--vy-text-primary); }
.sy-calc__control input,
.sy-calc__control select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  outline: none;
  color: var(--vy-text-primary);
  font-family: var(--vy-font-body);
  font-size: max(16px, var(--text-sm));   /* Below 16px iOS zooms the page on focus */
  font-variant-numeric: tabular-nums;
}
.sy-calc__control input::placeholder { color: var(--vy-text-secondary); opacity: 0.6; }
.sy-calc__control select { cursor: pointer; }
.sy-calc__control select option { background: var(--vy-bg-primary); color: var(--vy-text-primary); }
.sy-calc__control input[aria-invalid="true"] { color: var(--color-accent); }
.sy-calc__control:has([aria-invalid="true"]) { border-bottom-color: var(--color-accent); }
.sy-calc__unit {
  flex: none;
  font-family: var(--vy-font-mono);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-label);
  color: var(--vy-text-secondary);
}
.sy-calc__hint {
  margin: 8px 0 0;
  font-size: var(--text-2xs);
  line-height: var(--leading-body);
  color: var(--vy-text-secondary);
}
.sy-calc__error {
  margin: 24px 0 0;
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  color: var(--color-accent);
}

/* ── 3. Results ────────────────────────────────────────────────────────────── */
.sy-calc__results { margin-top: clamp(36px, 4.5vw, 56px); }
.sy-calc__facts { margin-top: 0; max-width: none; }
.sy-calc__facts dd { font-variant-numeric: tabular-nums; }
.sy-calc__facts dt var,
.sy-calc__facts dt sub { text-transform: none; }
.sy-calc__gross { align-items: baseline; }
.sy-calc__gross dd {
  font-family: var(--vy-font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: 0;
}
.sy-calc__table { min-width: 480px; }
.sy-calc__table td { font-variant-numeric: tabular-nums; color: var(--vy-text-primary); }

/* Read by screen readers; on screen it repeats the table, so it stays small */
.sy-calc__live {
  margin: 16px 0 0;
  min-height: 1.4em;
  font-size: var(--text-2xs);
  line-height: var(--leading-body);
  color: var(--vy-text-secondary);
}

.sy-calc__actions { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 20px; }
.sy-calc__btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--color-line);
  border-radius: 0;
  cursor: pointer;
  font-family: var(--vy-font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-ui);
  text-transform: uppercase;
  color: var(--vy-text-secondary);
  transition: color var(--vy-dur-micro) var(--vy-ease), border-color var(--vy-dur-micro) var(--vy-ease);
}
.sy-calc__btn:hover { color: var(--vy-text-primary); border-bottom-color: var(--vy-text-primary); }
.sy-calc__btn:focus-visible { outline: 1px solid var(--vy-text-primary); outline-offset: 4px; }
.sy-calc__btn[hidden] { display: none; }

.sy-calc__note {
  margin-top: clamp(40px, 5vw, 64px);
  padding-top: 24px;
  border-top: 1px solid var(--color-line);
  max-width: 62ch;
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  color: var(--vy-text-secondary);
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sy-calc__set { grid-template-columns: minmax(0, 1fr); }
  .sy-calc__table { min-width: 0; }
  .sy-calc__table th,
  .sy-calc__table td { padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .sy-calc__control,
  .sy-calc__btn { transition: none; }
}
