/* AeroGyan — aerospace calculators (aerocalc.js). Every class starts with ac-.
   Only app theme variables are used, so light and dark themes both work. */

.ac-root {
  container-type: inline-size;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}
.ac-root *,
.ac-root *::before,
.ac-root *::after { box-sizing: border-box; }

/* ── Tabs ── */
.ac-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}
.ac-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.ac-tab i { font-size: 12px; opacity: .8; }
.ac-tab:hover { border-color: var(--brand-500); color: var(--text-primary); }
.ac-tab.ac-tab-on,
.ac-tab[aria-selected="true"] {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}
.ac-tab.ac-tab-on i { opacity: 1; }

/* ── Heading ── */
.ac-head { margin: 0 0 12px; }
.ac-title {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.ac-intro {
  margin: 0;
  max-width: 70ch;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* ── Layout: stacked on phones, two columns when there is room ── */
.ac-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@container (min-width: 760px) {
  .ac-grid { grid-template-columns: minmax(240px, 310px) minmax(0, 1fr); }
  .ac-in { position: sticky; top: 76px; }
}
.ac-card {
  min-width: 0;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

/* ── Inputs ── */
.ac-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 0 12px;
  min-width: 0;
}
.ac-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.ac-label-unit { font-weight: 500; color: var(--text-tertiary); }
.ac-input,
.ac-select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  font: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ac-input { font-variant-numeric: tabular-nums; }
.ac-select { padding-right: 6px; cursor: pointer; }
.ac-input::placeholder { color: var(--text-tertiary); }
.ac-input:focus,
.ac-select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent);
}
.ac-inrow { display: flex; gap: 6px; min-width: 0; }
.ac-inrow .ac-input { flex: 1 1 auto; }
.ac-inrow .ac-select { flex: 0 0 auto; width: auto; min-width: 70px; }
.ac-hint { font-size: 12px; color: var(--text-tertiary); }

/* ── Buttons row ── */
.ac-btnrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}
.ac-btnrow .btn { display: inline-flex; align-items: center; gap: 6px; }
.ac-btnrow .btn:disabled { opacity: .5; cursor: not-allowed; }
.ac-in .ac-btnrow { margin-top: 2px; }

/* ── Message ── */
.ac-msg { display: none; }
.ac-msg-info,
.ac-msg-err {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 10px;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
}
.ac-msg i { margin-top: 3px; flex: 0 0 auto; }
.ac-msg-info {
  background: color-mix(in srgb, var(--brand-500) 9%, transparent);
  border-left: 3px solid var(--brand-500);
}
.ac-msg-info i { color: var(--brand-500); }
.ac-msg-err {
  background: color-mix(in srgb, var(--rose-500, #e5484d) 11%, transparent);
  border-left: 3px solid var(--rose-500, #e5484d);
}
.ac-msg-err i { color: var(--rose-500, #e5484d); }

/* ── Results table ── */
.ac-tablewrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.ac-tablewrap[hidden] { display: none; }
.ac-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.ac-table th,
.ac-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}
.ac-table thead th {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.ac-table tbody th {
  font-weight: 500;
  color: var(--text-primary);
  min-width: 9em;
}
.ac-table .ac-num { text-align: right; }
.ac-table .ac-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  white-space: nowrap;
  color: var(--text-primary);
}
.ac-table .ac-val.ac-text {
  font-family: inherit;
  white-space: normal;
  text-align: right;
  color: var(--text-secondary);
}
.ac-table .ac-unit {
  color: var(--text-tertiary);
  white-space: nowrap;
  font-size: 12.5px;
}
.ac-table tbody tr:hover > * { background: var(--bg-surface-2); }
.ac-table tbody tr:last-child > * { border-bottom: 0; }
.ac-table .ac-sec td,
.ac-table tbody tr.ac-sec:hover > * {
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* ── Airfoil plot ── */
.ac-plot {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.ac-canvas { display: block; width: 100%; height: 160px; }
.ac-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.ac-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.ac-key { display: inline-block; width: 20px; height: 0; border-top: 2px solid var(--text-primary); }
.ac-key-camber { border-top: 2px dashed var(--brand-500); }
.ac-key-chord { border-top: 1px solid var(--text-tertiary); }
.ac-dlrow { margin-bottom: 12px; }

/* ── How it's calculated ── */
.ac-how {
  margin: 14px 0 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.ac-how summary {
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.ac-how summary i { color: var(--brand-500); margin-right: 2px; }
.ac-how[open] summary { border-bottom: 1px solid var(--border-subtle); }
.ac-formula {
  margin: 0;
  padding: 10px 12px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: none;
  border: 0;
}

/* ── Phones ── */
@media (max-width: 600px) {
  .ac-input, .ac-select { font-size: 16px; height: 40px; } /* no iOS zoom */
  .ac-tab { padding: 6px 11px; font-size: 12.5px; }
}
@container (max-width: 480px) {
  .ac-card { padding: 12px; }
  .ac-table th, .ac-table td { padding: 6px 8px; }
  .ac-table tbody th { min-width: 7.5em; }
}
