/* ============================================================
   ACERO ALLOYS — Technical Flange Calculator component sheet
   ------------------------------------------------------------
   Ported from the flange-website project's
   css/technical-flange-calculator.css and restyled for this
   site's light theme. Deliberately holds NO hard colours of its
   own: every token below resolves to the theme variables that
   header.php re-declares from the Master Control Panel, so
   changing the brand colours in /admin/ restyles this tool too.
   ============================================================ */

.tfc {
  --tfc-accent:      var(--accent);
  --tfc-accent-2:    var(--accent-2);
  --tfc-accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --tfc-bg:          var(--bg);
  --tfc-surface:     var(--surface);
  --tfc-surface-2:   var(--surface-2);
  --tfc-border:      var(--border);
  --tfc-border-lt:   var(--border);
  --tfc-text:        var(--text);
  --tfc-muted:       var(--muted);
  --tfc-dim:         var(--muted);
  --tfc-ok:          var(--ok);
  --tfc-err:         var(--err);
  --tfc-head:        var(--ff-head);
  --tfc-body:        var(--ff-body);
  --tfc-r:           var(--radius-lg);
  --tfc-ease:        var(--ease);

  color: var(--tfc-text);
  font-family: var(--tfc-body);
  font-size: 15.5px;
  line-height: 1.6;
}

/* ---------- layout ---------- */
.tfc-grid {
  display: grid;
  grid-template-columns: minmax(0, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.tfc-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.tfc-sticky { position: sticky; top: calc(var(--header-h, 72px) + 18px); }

/* ---------- cards ---------- */
.tfc-card {
  background: var(--tfc-surface);
  border: 1px solid var(--tfc-border);
  border-radius: var(--tfc-r);
  padding: 24px;
  min-width: 0;
}
.tfc-card__head {
  display: flex; align-items: center; gap: 11px;
  padding-bottom: 15px; margin-bottom: 18px;
  border-bottom: 1px solid var(--tfc-border);
}
.tfc-card__head h2, .tfc-card__head h3 {
  margin: 0; font-family: var(--tfc-head);
  font-size: 17px; letter-spacing: .8px; text-transform: uppercase;
}
.tfc-card__head .tfc-tag {
  margin-left: auto; font-size: 11px; letter-spacing: .6px;
  text-transform: uppercase; color: var(--tfc-dim);
}
.tfc-card__note { margin: 16px 0 0; font-size: 12.5px; color: var(--tfc-dim); }

/* ---------- form ---------- */
.tfc-fields { display: flex; flex-direction: column; gap: 15px; }
.tfc-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.tfc-field > label {
  font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--tfc-muted); font-weight: 600;
}
.tfc-field .hint { font-size: 11.5px; color: var(--tfc-dim); }
.tfc-control {
  position: relative; display: flex; align-items: center; min-width: 0;
}
.tfc-control select,
.tfc-control input,
.tfc-control textarea {
  width: 100%; min-width: 0;
  appearance: none; -webkit-appearance: none;
  background: var(--tfc-surface-2);
  color: var(--tfc-text);
  border: 1px solid var(--tfc-border-lt);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: inherit; font-size: 14.5px;
  transition: border-color .2s var(--tfc-ease), box-shadow .2s var(--tfc-ease);
}
.tfc-control textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
.tfc-control select { padding-right: 38px; cursor: pointer; }
.tfc-control select:focus,
.tfc-control input:focus,
.tfc-control textarea:focus {
  outline: none;
  border-color: var(--tfc-accent);
  box-shadow: 0 0 0 3px var(--tfc-accent-soft);
}
.tfc-control select:disabled, .tfc-control input:disabled { opacity: .45; cursor: not-allowed; }
.tfc-control::after {
  content: "▾";
  position: absolute; right: 14px; pointer-events: none;
  color: var(--tfc-accent); font-size: 12px; line-height: 1;
}
.tfc-control--plain::after { content: none; }
.tfc-control .unit {
  position: absolute; right: 13px; font-size: 12px; color: var(--tfc-dim);
  pointer-events: none; letter-spacing: .5px;
}
.tfc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.tfc-stepper { display: flex; gap: 8px; }
.tfc-stepper button {
  flex: 0 0 44px; background: var(--tfc-surface-2); color: var(--tfc-muted);
  border: 1px solid var(--tfc-border-lt); border-radius: 8px;
  font-size: 16px; cursor: pointer; transition: all .2s var(--tfc-ease);
}
.tfc-stepper button:hover { border-color: var(--tfc-accent); color: var(--tfc-accent); }
.tfc-stepper input { text-align: center; font-weight: 600; }

/* the server-rendered CAPTCHA block inside a tfc card */
.tfc .field > label {
  font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--tfc-muted); font-weight: 600;
}
.tfc .captcha-box input[type="text"] {
  background: var(--tfc-surface-2); border: 1px solid var(--tfc-border-lt);
  border-radius: 8px; padding: 12px 14px; font-size: 14.5px; font-family: inherit;
}
.tfc .captcha-box input[type="text"]:focus {
  outline: none; border-color: var(--tfc-accent);
  box-shadow: 0 0 0 3px var(--tfc-accent-soft);
}

/* ---------- current-selection summary ---------- */
.tfc-sum {
  display: flex; align-items: center; gap: 15px; min-width: 0;
  background: var(--tfc-surface);
  border: 1px solid var(--tfc-border);
  border-left: 3px solid var(--tfc-accent);
  border-radius: var(--tfc-r);
  padding: 16px 20px;
}
.tfc-sum > div { min-width: 0; flex: 1 1 auto; }
.tfc-sum strong {
  display: block; font-family: var(--tfc-head); font-size: 19px;
  letter-spacing: .5px; text-transform: uppercase; line-height: 1.2;
  color: var(--tfc-text);
}
.tfc-sum span { display: block; font-size: 13px; color: var(--tfc-muted); margin-top: 3px; }
.tfc-sum em {
  flex: 0 0 auto; font-style: normal; font-size: 11px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--tfc-accent);
  background: var(--tfc-accent-soft); border-radius: 6px; padding: 6px 10px;
  white-space: nowrap;
}

/* ---------- readouts ---------- */
.tfc-rows { display: flex; flex-direction: column; }
.tfc-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 11px 0;
  border-bottom: 1px dashed var(--tfc-border);
}
.tfc-row:last-child { border-bottom: 0; padding-bottom: 0; }
.tfc-row .k { color: var(--tfc-muted); font-size: 13.5px; }
.tfc-row .k small { display: block; color: var(--tfc-dim); font-size: 11px; letter-spacing: .3px; }
.tfc-row .v {
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 15px; white-space: nowrap;
}
.tfc-row .v small { display: block; font-weight: 400; font-size: 11.5px; color: var(--tfc-dim); }
.tfc-row .v.is-spec { color: var(--tfc-accent); font-size: 13.5px; font-weight: 600; }

.tfc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.tfc-tile {
  background: var(--tfc-surface-2); border: 1px solid var(--tfc-border);
  border-radius: 8px; padding: 14px 15px;
}
.tfc-tile .k {
  display: block; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--tfc-dim); margin-bottom: 6px;
}
.tfc-tile .v {
  display: block; font-family: var(--tfc-head); font-size: 25px; line-height: 1.1;
  letter-spacing: .4px; font-variant-numeric: tabular-nums;
}
.tfc-tile .s { display: block; font-size: 11.5px; color: var(--tfc-muted); margin-top: 5px; }
.tfc-tile--hl .v { color: var(--tfc-accent); }
.tfc-tile--spec .v { font-size: 15px; color: var(--tfc-accent); padding-top: 7px; }

/* ---------- notices ---------- */
.tfc-notice {
  display: none; gap: 14px; align-items: flex-start;
  border: 1px solid var(--tfc-accent);
  border-left-width: 4px;
  background: var(--tfc-accent-soft);
  border-radius: 8px; padding: 15px 17px;
}
.tfc-notice.is-on { display: flex; }
.tfc-notice h4 {
  margin: 0 0 4px; font-family: var(--tfc-head); font-size: 14px;
  letter-spacing: .7px; text-transform: uppercase; color: var(--tfc-text);
}
.tfc-notice p { margin: 0 0 12px; font-size: 13px; color: var(--tfc-muted); }
.tfc-notice .tfc-btn { margin: 0; }

.tfc-info {
  border: 1px solid var(--tfc-border); border-left: 3px solid var(--tfc-border-lt);
  border-radius: 8px; padding: 14px 16px; font-size: 12.5px; color: var(--tfc-dim);
  background: var(--tfc-bg);
}
.tfc-info b { color: var(--tfc-muted); font-weight: 600; }

/* ---------- buttons ---------- */
.tfc-actions { display: flex; flex-wrap: wrap; gap: 11px; }
.tfc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--tfc-accent); color: #fff;
  border: 1px solid var(--tfc-accent); border-radius: 8px;
  padding: 13px 20px; font-family: var(--tfc-body);
  font-size: 13px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase;
  cursor: pointer; text-decoration: none;
  transition: transform .2s var(--tfc-ease), background .2s var(--tfc-ease), box-shadow .2s var(--tfc-ease);
}
.tfc-btn:hover { transform: translateY(-2px); background: var(--tfc-accent-2); border-color: var(--tfc-accent-2); color: #fff; box-shadow: var(--shadow); }
.tfc-btn:active { transform: translateY(0); }
.tfc-btn:disabled { opacity: .55; cursor: progress; transform: none; box-shadow: none; }
.tfc-btn--ghost { background: transparent; color: var(--tfc-text); border-color: var(--tfc-border-lt); }
.tfc-btn--ghost:hover { background: var(--tfc-accent); border-color: var(--tfc-accent); color: #fff; }

/* ---------- methodology ---------- */
.tfc-method { font-size: 12.5px; color: var(--tfc-dim); }
.tfc-method p { margin: 0 0 9px; color: inherit; font-size: inherit; }
.tfc-method ul { margin: 0; padding-left: 18px; list-style: disc; }
.tfc-method li { margin-bottom: 6px; }
.tfc-method code {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  background: var(--tfc-bg); border: 1px solid var(--tfc-border);
  border-radius: 4px; padding: 1px 5px; font-size: 12px; color: var(--tfc-muted);
}

.tfc-field .req { color: var(--tfc-accent); font-weight: 600; }

/* ---------- two-step guide ---------- */
.tfc-steps {
  display: flex; flex-wrap: wrap; gap: 10px;
  list-style: none; margin: 0 0 26px; padding: 0;
}
.tfc-steps li {
  display: flex; align-items: center; gap: 11px; flex: 1 1 220px; min-width: 0;
  background: var(--tfc-surface); border: 1px solid var(--tfc-border);
  border-radius: 10px; padding: 12px 14px;
  transition: border-color .25s var(--tfc-ease), background .25s var(--tfc-ease);
}
.tfc-steps b {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--tfc-head); font-size: 13px; font-weight: 600;
  color: var(--tfc-muted); border: 1px solid var(--tfc-border-lt);
  transition: all .25s var(--tfc-ease);
}
.tfc-steps span { font-size: 12.5px; line-height: 1.4; color: var(--tfc-dim); }
.tfc-steps span strong { color: inherit; }
.tfc-steps li.is-now { border-color: var(--tfc-accent); }
.tfc-steps li.is-now b { background: var(--tfc-accent); border-color: var(--tfc-accent); color: #fff; }
.tfc-steps li.is-now span { color: var(--tfc-text); }
.tfc-steps li.is-done b { color: var(--tfc-ok); border-color: var(--tfc-ok); }

.tfc-card { scroll-margin-top: 96px; }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .tfc-grid { grid-template-columns: minmax(0, 1fr); }
  .tfc-sticky { position: static; }
}
@media (max-width: 560px) {
  .tfc { font-size: 15px; }
  .tfc-card { padding: 18px 16px; }
  .tfc-two { grid-template-columns: minmax(0, 1fr); }
  .tfc-card__head { flex-wrap: wrap; gap: 9px; }
  .tfc-card__head .tfc-tag { margin-left: 0; width: 100%; }
  .tfc-row { flex-direction: column; gap: 3px; align-items: flex-start; }
  .tfc-row .v { text-align: left; }
  .tfc-actions .tfc-btn { flex: 1 1 100%; }
  .tfc-sum { flex-wrap: wrap; gap: 11px; padding: 14px 16px; }
  .tfc-sum em { margin-left: auto; }
  .tfc-tiles { grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); }
  .tfc-tile .v { font-size: 21px; }
}

/* ============================================================
   PRINT — A4 engineering datasheet
   The datasheet replaces the whole page: every direct child of
   <body> except the print sheet is hidden, then only #printSheet
   shows. This is independent of the site chrome class names.
   ============================================================ */
.tfc-print { display: none; }

@page { size: A4 portrait; margin: 13mm 14mm 15mm; }

@media print {
  body > :not(.tfc-print) { display: none !important; }

  html, body { background: #fff !important; overflow: visible !important; }

  .tfc-print { display: block !important; color: #000; font-family: var(--ff-body, 'Inter', Arial, sans-serif); font-size: 10.5pt; line-height: 1.45; }
  .tfc-print * { color: #000 !important; box-shadow: none !important; }

  .pf-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2.2pt solid #000; padding-bottom: 9px; }
  .pf-brand { font-family: var(--ff-head, 'Oswald', Arial, sans-serif); font-size: 19pt; letter-spacing: .6px; text-transform: uppercase; line-height: 1.05; }
  .pf-brand span { display: block; font-family: var(--ff-body, Arial, sans-serif); font-size: 8.6pt; letter-spacing: 2.1px; text-transform: uppercase; margin-top: 3px; }
  .pf-contact { text-align: right; font-size: 8.6pt; line-height: 1.6; }
  .pf-title { font-family: var(--ff-head, 'Oswald', Arial, sans-serif); font-size: 13pt; text-transform: uppercase; letter-spacing: 1.6px; margin: 13px 0 3px; }
  .pf-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 8.4pt; border-bottom: .6pt solid #000; padding-bottom: 7px; margin-bottom: 11px; }

  .pf-box { border: .8pt solid #000; padding: 0; margin-bottom: 12px; page-break-inside: avoid; }
  .pf-box h4 { font-family: var(--ff-head, 'Oswald', Arial, sans-serif); font-size: 9.4pt; text-transform: uppercase; letter-spacing: 1.2px; margin: 0; padding: 5px 9px; background: #ececec !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; border-bottom: .8pt solid #000; }
  .pf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-cell { padding: 5px 9px; border-bottom: .4pt solid #b9b9b9; font-size: 9.4pt; display: flex; justify-content: space-between; gap: 10px; }
  .pf-cell:nth-child(odd) { border-right: .4pt solid #b9b9b9; }
  .pf-cell b { font-weight: 600; text-align: right; }
  .pf-cell span { color: #333 !important; }

  table.pf-table { width: 100%; border-collapse: collapse; font-size: 9.2pt; margin-bottom: 12px; page-break-inside: avoid; }
  table.pf-table caption { text-align: left; font-family: var(--ff-head, 'Oswald', Arial, sans-serif); font-size: 9.4pt; text-transform: uppercase; letter-spacing: 1.2px; padding: 5px 9px; background: #ececec !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; border: .8pt solid #000; border-bottom: 0; }
  table.pf-table th, table.pf-table td { border: .5pt solid #6f6f6f; padding: 5px 9px; text-align: left; }
  table.pf-table th { background: #f5f5f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 8.4pt; text-transform: uppercase; letter-spacing: .7px; }
  table.pf-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
  table.pf-table tr.total td { font-weight: 700; background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .pf-qa { border: .8pt solid #000; padding: 9px 11px; font-size: 8.8pt; page-break-inside: avoid; }
  .pf-qa b { font-family: var(--ff-head, 'Oswald', Arial, sans-serif); text-transform: uppercase; letter-spacing: 1px; }
  .pf-foot { margin-top: 12px; padding-top: 7px; border-top: .6pt solid #000; font-size: 7.8pt; display: flex; justify-content: space-between; gap: 10px; }

  .pf-sign { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; margin-top: 26px; page-break-inside: avoid; }
  .pf-sign div { border-top: .6pt solid #000; padding-top: 5px; font-size: 8.4pt; }
}
