/* FrameHanger — styled with the DATAMetrics Design System.
   Tokens as used by Rock Analytics (site.css): light identity only — the
   system defines no dark mode, so none is shipped. Red is the accent and is
   spent on the answer and on interaction states, nowhere else; structure is
   carried by hairlines on white, not shadows. */

:root {
  color-scheme: light;

  /* -- DATAMetrics tokens ---------------------------------------------- */
  --dm-indigo: #393858;
  --dm-blue-grey: #647A97;
  --dm-blue-grey-shade: #506178;
  --dm-red: #B12029;
  --dm-red-shade: #901A21;
  --dm-warm-white: #E2DDD4;
  --dm-warm-white-40: #F3F1ED;
  --dm-warm-white-tint-2: #EDEAE5;
  --dm-mid-grey: #A5A3A7;
  --dm-ink-soft: #333333;
  --site-neutral: #666666;
  --app-hairline: #E4E4E6;
  --app-stripe: #FBFAF8;
  --font-core: 'Maven Pro', Verdana, sans-serif;
  --radius: 5px;
  --radius-sm: 4px;

  /* -- role mapping ------------------------------------------------------ */
  --bg: #F8F8F8;
  --surface: #FFFFFF;
  --surface-sunken: var(--dm-warm-white-40);
  --line: var(--app-hairline);
  --line-strong: var(--dm-mid-grey);
  --text: var(--dm-ink-soft);
  --text-muted: var(--site-neutral);
  --accent: var(--dm-red);
  --accent-shade: var(--dm-red-shade);
  --warn: var(--dm-red-shade);
  --warn-soft: var(--dm-warm-white-40);
}

/* Every interactive control gets the same visible keyboard focus. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-core);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.shell {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1rem calc(2rem + env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- top bar: the DATAMetrics inverse band ---------- */
/* Full-bleed indigo, content constrained to the shell's column. Not sticky:
   on a one-screen tool the answers band below earns that position instead. */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 calc(50% - 50vw);
  padding: calc(0.625rem + env(safe-area-inset-top)) calc(50vw - 50% + 1rem) 0.625rem;
  min-height: 3.5rem;
  background: var(--dm-indigo);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand h1 .accent {
  color: var(--dm-warm-white);
  font-weight: 500;
}

.brand__mark {
  width: 1.375rem;
  height: 1.375rem;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 3px;
  position: relative;
  flex: none;
}

.brand__mark::after {
  content: '';
  position: absolute;
  inset: 40% -2px auto -2px;
  border-top: 2px dashed var(--dm-warm-white);
}

/* unit switch riding in the band */
.topbar .segments {
  background: rgba(255, 255, 255, 0.14);
  border: 0;
}

.topbar .segment span {
  color: rgba(255, 255, 255, 0.85);
}

.topbar .segment input:checked + span {
  background: #fff;
  color: var(--dm-indigo);
  border-color: transparent;
}

.topbar :focus-visible {
  outline-color: #fff;
}

.topbar .segment input:focus-visible + span {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* ---------- the two answers ---------- */

.answers {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0.5rem;
  margin: 0 -1rem;
  padding: 0.5rem 1rem 0.625rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.answer {
  display: grid;
  gap: 0.125rem;
  align-content: start;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 0.625rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.answer:active {
  transform: scale(0.985);
}

/* The answer is the app's one call to action, so it takes the red. */
.answer--primary {
  border: 2px solid var(--accent);
  padding: calc(0.625rem - 1px) calc(0.75rem - 1px);
}

.answer__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.answer--primary .answer__label {
  color: var(--accent);
}

.answer__value {
  font-size: clamp(1.5rem, 8.5vw, 2.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--dm-indigo);
}

.answer--primary .answer__value {
  color: var(--accent);
}

.answer__value small {
  font-size: 0.45em;
  font-weight: 600;
  letter-spacing: 0;
  margin-left: 0.2em;
  color: var(--text-muted);
}

.answer__alt {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.answer[data-empty='true'] .answer__value {
  color: var(--dm-mid-grey);
}

/* ---------- notes ---------- */

.notes:not(:empty) {
  display: grid;
  gap: 0.375rem;
  margin: 0.875rem 0 0;
}

.note {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8125rem;
  padding: 0.5rem 0.6875rem;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--line);
}

.note--info {
  background: var(--surface);
  color: var(--text-muted);
}

.note::before {
  content: '!';
  font-weight: 700;
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.6875rem;
  margin-top: 0.0625rem;
}

.note--info::before {
  content: 'i';
}

/* ---------- form ---------- */

form {
  display: grid;
  gap: 0.875rem;
  margin: 0.875rem 0 0;
}

.card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.875rem;
  display: grid;
  gap: 1rem;
}

.card__title {
  padding: 0 0.375rem;
  margin-left: -0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.card__aside {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--dm-mid-grey);
}

.card__aside::before {
  content: '· ';
}

.field {
  display: grid;
  gap: 0.375rem;
}

.field__label {
  font-size: 0.875rem;
  font-weight: 600;
  display: grid;
  gap: 0.0625rem;
  color: var(--dm-indigo);
}

.field__aside {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.control {
  display: flex;
  align-items: center;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding-right: 0.75rem;
}

.control:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.control input {
  flex: 1;
  min-width: 0;
  /* 17px keeps iOS Safari from zooming the page on focus. */
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: inherit;
  background: none;
  border: 0;
  outline: none;
  padding: 0.6875rem 0.75rem;
  min-height: 2.75rem;
  appearance: none;
}

.control__unit {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  flex: none;
}

.control[data-invalid='true'] {
  border-color: var(--warn);
}

.field__error {
  margin: 0;
  font-size: 0.75rem;
  color: var(--warn);
  font-weight: 500;
}

/* ---------- segmented controls ---------- */

.segmented {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.segments {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.1875rem;
  padding: 0.1875rem;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.segment {
  position: relative;
  display: block;
  min-width: 0;
}

.segment input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  /* The visible focus ring goes on the label beside it, not on this. */
  outline: none;
}

.segment span {
  display: grid;
  place-items: center;
  min-height: 2.25rem;
  padding: 0.25rem 0.375rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-sm) - 1px);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  transition: background 120ms ease, color 120ms ease;
}

.segment input:checked + span {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--dm-indigo);
}

.segment input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.segmented--compact .segments {
  gap: 0.125rem;
  padding: 0.125rem;
}

.segmented--compact .segment span {
  min-height: 1.875rem;
  padding-inline: 0.625rem;
  font-size: 0.75rem;
}

/* ---------- diagram ---------- */
/* Viz rule from the system: series lead blue-grey/indigo; red is reserved.
   Here the one red element is the nail — it is the answer, not a series. */

.diagram {
  margin: 0.875rem 0 0;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.diagram figcaption {
  margin-top: 0.5rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
}

.d-line {
  stroke: var(--dm-mid-grey);
  fill: none;
}

.d-floor {
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
}

.d-frame {
  fill: rgb(57 56 88 / 6%);
  stroke: var(--dm-indigo);
  stroke-width: 1.5;
}

.d-ref {
  stroke: var(--dm-blue-grey);
  stroke-width: 1;
  stroke-dasharray: 5 4;
  fill: none;
}

.d-wire {
  stroke: var(--dm-blue-grey-shade);
  stroke-width: 1.25;
  fill: none;
}

.d-accent {
  stroke: var(--accent);
  stroke-width: 1.5;
  fill: none;
}

.d-accent-fill {
  fill: var(--accent);
}

.d-text {
  fill: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  font-family: inherit;
}

.d-text--accent {
  fill: var(--accent);
  font-size: 10px;
}

/* Eye-height convention presets under the reference line field. */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.preset {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--dm-indigo);
  /* Longhands on purpose: `inherit` inside the `font` shorthand is invalid
     CSS and drops the whole declaration (the PR #2 iPhone-zoom bug). */
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.3125rem 0.5rem;
  cursor: pointer;
  transition: border-color 120ms ease;
}

.preset small {
  font-weight: 400;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.preset:hover,
.preset:focus-visible {
  border-color: var(--dm-blue-grey);
}

/* Algebra letter linking an input field to its mark on the diagram. */
.dim {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px solid var(--dm-blue-grey);
  border-radius: 4px;
  color: var(--dm-indigo);
  font-size: 0.72em;
  font-style: normal;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: 1px;
}

/* ---------- panels ---------- */

.panel {
  margin: 0.875rem 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel summary {
  padding: 0.8125rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--dm-indigo);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
}

.panel summary::-webkit-details-marker {
  display: none;
}

.panel summary::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--dm-mid-grey);
  border-bottom: 2px solid var(--dm-mid-grey);
  transform: rotate(45deg);
  transition: transform 150ms ease;
  flex: none;
}

.panel[open] summary::after {
  transform: rotate(-135deg);
}

.derived {
  margin: 0;
  padding: 0 0.875rem 0.875rem;
  display: grid;
  gap: 0;
}

.derived > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}

.derived dt {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.derived dd {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.derived .is-key dd {
  color: var(--accent);
}

.prose {
  padding: 0 0.875rem 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.prose p {
  margin: 0 0 0.75rem;
}

.prose strong {
  color: var(--dm-indigo);
}

/* ---------- actions ---------- */

.actions {
  display: flex;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
}

/* Solid red: the sanctioned accent use for the primary action. */
.btn {
  flex: 1;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.btn:hover,
.btn:active {
  background: var(--accent-shade);
  border-color: var(--accent-shade);
}

.btn--quiet {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
}

.btn--quiet:hover,
.btn--quiet:active {
  background: none;
  border-color: var(--accent);
  color: var(--accent);
}

.install {
  margin: 1rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
}

.footer {
  margin-top: 1.5rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
}

.footer p {
  margin: 0;
}

/* the one place the parent company puts its name on the page */
.signoff {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.625rem !important;
  padding-top: 0.625rem;
  border-top: 1px solid var(--line);
}

.signoff .dm-mark {
  height: 0.875rem;
  width: auto;
  fill: var(--dm-red);
  flex: none;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--dm-indigo);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.875rem;
  border-radius: 999px;
  z-index: 20;
  box-shadow: 0 6px 20px rgb(40 40 41 / 25%);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
