/* Escea fireplace article: the frame builder, the lighting-window stepper and the
   rounding demo. Uses style.css and article.css tokens only. Controls start hidden
   and are shown by escea-fireplace.js, so the page reads the same without it. */

.prose .k {
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
}
.prose .k code { text-transform: none; letter-spacing: 0; }

/* Plain comparison tables */
.ef-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; }
.ef-table caption {
  text-align: left; padding: 14px 16px 4px; font-family: var(--mono); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}
.ef-table th, .ef-table td { text-align: left; padding: 10px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.ef-table thead th { font-weight: 500; font-size: 13px; color: var(--muted); border-top: 0; }
.ef-table tbody th { font-weight: 600; }
.prose .ef-table code { font-size: 0.84em; }
.prose .ef-table th code, .prose .frame-table td code { overflow-wrap: normal; white-space: nowrap; }
.prose > section > .table-scroll { margin: 28px 0 32px; }

/* Shared form bits */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span {
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
  display: flex; justify-content: space-between; gap: 10px;
}
.field output { color: var(--text); font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; font-size: 13px; }
.field select, .field input[type="text"] {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 15px var(--font); width: 100%;
  transition: border-color var(--dur-quick);
}
.field input[type="text"] { font-family: var(--mono); font-size: 14px; letter-spacing: 0.04em; }
.field select:hover, .field input[type="text"]:hover { border-color: var(--faint); }
.field select:focus-visible, .field input[type="text"]:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-color: var(--text); }
.field input[type="range"] { width: 100%; accent-color: var(--text); min-height: 28px; margin: 0; }
.check {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 12px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 15px; cursor: pointer; background: var(--bg);
  transition: border-color var(--dur-quick), background-color var(--dur-quick), color var(--dur-quick);
}
.check:hover { border-color: var(--faint); }
.check:has(input:checked) { background: var(--text); color: var(--bg); border-color: var(--text); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--bg); }
.check:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; }

/* 1. Frame builder */
.frame, .fsm, .rounding {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px;
}
.frame-tools { display: grid; gap: 18px; margin-bottom: 22px; }
.seg-control {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); justify-self: start;
}
.seg-control button {
  font: inherit; font-size: 14.5px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color var(--dur-quick) var(--spring), color var(--dur-quick);
}
.seg-control button:hover { color: var(--text); }
.seg-control button[aria-checked="true"] { background: var(--text); color: var(--bg); }
.frame-inputs { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.frame-inputs[hidden], .frame-tools[hidden], .fsm-panel[hidden], .round-controls[hidden], .round-results[hidden], .round-line[hidden] { display: none; }
.frame-inputs .field { flex: 1 1 200px; }
.frame-inputs .field-wide { flex-basis: 100%; }
.frame-samples { display: flex; flex-wrap: wrap; gap: 8px; }
.frame-samples .button { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.field-temp[hidden] { display: none; }

.frame-bytes { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.byte {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 0; padding: 6px 0 0;
}
.byte .i { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.byte .v {
  display: grid; place-items: center; width: 100%; height: 46px; border-radius: 10px;
  font-family: var(--mono); font-size: 14.5px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  transition: background-color var(--dur-quick), color var(--dur-quick), border-color var(--dur-quick);
}
.byte .r {
  font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  white-space: nowrap; min-height: 1.4em;
}
.b-start .v, .b-end .v { border-style: dashed; border-color: var(--faint); }
.b-id .v { background: var(--text); color: var(--bg); border-color: var(--text); }
.b-size .v { background: color-mix(in srgb, var(--text) 16%, var(--bg)); }
.b-crc .v {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--text) 18%, var(--bg)) 0 2px, var(--bg) 2px 7px);
  border-color: var(--text);
}
.byte.zero .v { color: var(--faint); font-weight: 400; }
.byte.summed::after {
  content: ""; position: absolute; left: 3px; right: 3px; bottom: -6px; height: 2px; border-radius: 2px;
  background: var(--text); opacity: 0.55;
}
.byte.bad .v { border: 2px solid var(--text); text-decoration: line-through; }
.frame-hexline { margin: 18px 0 6px !important; overflow-x: auto; }
.frame-hexline code { font-size: 13px !important; white-space: nowrap; }
.frame-readout { margin: 0 0 20px; min-height: 5.2em; }
.frame-readout p { margin: 0 0 6px !important; font-size: 15.5px; line-height: 1.55; color: var(--muted); }
.frame-readout p .k { display: inline-block; min-width: 7.5em; }
.frame-readout strong { color: var(--text); }
.frame-readout .err { color: var(--text); font-weight: 600; }
.frame .table-scroll { background: var(--bg); }
.frame-table td:nth-child(2) { white-space: nowrap; }
@media (max-width: 680px) { .frame-table { min-width: 600px; } }
@media (prefers-reduced-motion: no-preference) {
  .motion .byte.flip .v { animation: byte-flip var(--dur-move) var(--spring) backwards; animation-delay: var(--bd, 0ms); }
  .motion .byte.summed::after { animation: sum-in var(--dur-move) var(--spring) backwards; animation-delay: var(--bd, 0ms); transform-origin: 0 50%; }
}
@keyframes byte-flip {
  0% { transform: translateY(-10px) scale(0.86); opacity: 0.2; }
  100% { transform: none; opacity: 1; }
}
@keyframes sum-in { from { transform: scaleX(0); } }
@media (max-width: 680px) {
  .frame-bytes { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 10px; }
  .byte .r:empty::before { content: "Data"; opacity: 0.55; }
}
@media (max-width: 560px) {
  .frame, .fsm, .rounding { margin: 0 -12px; padding: 18px 14px; border-radius: 18px; }
  .seg-control { justify-self: stretch; }
  .seg-control button { flex: 1; padding: 0 10px; font-size: 13.5px; }
  .ef-table th, .ef-table td { padding: 9px 10px; font-size: 14px; }
}

/* 2. Lighting window stepper */
.fsm-states { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; margin-bottom: 20px; }
.fsm-state {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--bg);
  transition: background-color var(--dur-move) var(--spring), color var(--dur-move) var(--spring), border-color var(--dur-quick), transform var(--dur-move) var(--spring);
}
.fsm-state strong { font-size: 16px; }
.fsm-state span { font-size: 13px; color: var(--muted); line-height: 1.35; transition: color var(--dur-move) var(--spring); }
.fsm-state:not(:last-child)::after {
  content: "\2192"; position: absolute; right: -18px; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: 14px;
}
.fsm-state:last-child::after {
  content: "\21BA"; position: absolute; right: 10px; top: 8px; color: var(--faint); font-size: 13px;
}
.fsm-state.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.fsm-state.active span { color: color-mix(in srgb, var(--bg) 72%, var(--text)); }
.fsm-state.active:last-child::after { color: var(--bg); }
@media (prefers-reduced-motion: no-preference) {
  .motion .fsm-state.active { transform: translateY(-3px); }
}
.fsm-status { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: baseline; margin-bottom: 12px; }
.fsm-now { margin: 0 !important; display: flex; gap: 8px; align-items: baseline; }
.fsm-now strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.fsm-clock { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; flex: 1 1 220px; }
.fsm-clock strong { font-size: 19px; font-variant-numeric: tabular-nums; min-width: 3ch; }
.fsm-bar {
  flex: 1 1 100%; height: 8px; border-radius: 999px; overflow: hidden; outline: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.fsm-bar span { display: block; height: 100%; width: 100%; background: var(--text); transform: scaleX(0); transform-origin: 0 50%; }
.fsm-held { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; min-height: 32px; }
.fsm-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.fsm-chips .chip { font-size: 12.5px; padding: 3px 11px; border-style: dashed; color: var(--text); }
.fsm-none { color: var(--faint); font-size: 14.5px; }
@media (prefers-reduced-motion: no-preference) {
  .motion .fsm-chips .chip { animation: hero-in var(--dur-move) var(--spring) backwards; }
}
.fsm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fsm-actions .button { min-height: 40px; padding: 0 15px; font-size: 14px; }
.fsm-actions .button.flash { outline: 2px solid var(--text); outline-offset: 2px; }
.fsm-old { font-size: 14px; margin-bottom: 18px; }
.fsm-logwrap > .k { display: flex; justify-content: space-between; align-items: center; margin: 0 0 8px !important; }
.fsm-clear {
  font: inherit; font-size: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.1em;
  min-height: 32px; transition: border-color var(--dur-quick), color var(--dur-quick);
}
.fsm-clear:hover { border-color: var(--faint); color: var(--text); }
.fsm-log {
  list-style: none; padding: 0 !important; margin: 0 !important; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); height: 248px; overflow-y: auto; font-size: 14.5px;
}
.fsm-log li {
  margin: 0 !important; padding: 9px 14px !important; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 4.2em 1fr; gap: 10px; line-height: 1.45;
}
.fsm-log li:first-child { border-top: 0; }
.fsm-log .t { font-family: var(--mono); font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.fsm-log .wire { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.fsm-log .no { font-weight: 600; }
.fsm-log li.note { color: var(--muted); }
.fsm-log li.empty { display: block; color: var(--faint); }
@media (prefers-reduced-motion: no-preference) {
  .motion .fsm-log li.new { animation: log-in var(--dur-move) var(--spring) backwards; }
}
@keyframes log-in { from { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 680px) {
  .fsm-states { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; }
  .fsm-state:nth-child(2)::after { content: "\2193"; right: auto; left: 50%; top: auto; bottom: -15px; transform: translateX(-50%); }
  .fsm-state:nth-child(3)::after { content: "\2190"; right: auto; left: -18px; }
  .fsm-states .fsm-state:nth-child(3) { order: 4; }
  .fsm-states .fsm-state:nth-child(4) { order: 3; }
  .fsm-state:last-child::after { content: "\2191"; right: auto; left: 50%; top: -15px; transform: translateX(-50%); }
}
@media (max-width: 560px) {
  .fsm-actions .button { flex: 1 1 calc(50% - 4px); padding: 0 10px; }
  .fsm-log li { grid-template-columns: 3.6em 1fr; padding: 8px 10px !important; font-size: 14px; }
}

/* 3. Rounding */
.round-controls { margin-bottom: 18px; }
.round-results { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.round-card {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--bg);
}
.round-card strong { font-size: clamp(32px, 6vw, 44px); line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.round-note { color: var(--muted); font-size: 14px; }
.round-card.is-fixed { border-color: var(--text); }
.rounding.differs .round-card:not(.is-fixed) strong { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.round-line { margin: 0 6px 22px; }
.round-track { position: relative; height: 44px; border-bottom: 1px solid var(--faint); }
.round-pin {
  position: absolute; bottom: -6px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  left: calc((var(--x, 22) - 18) / 8 * 100%);
  transition: left var(--dur-move) var(--spring);
}
.round-pin i {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-family: var(--mono); font-size: 10.5px; font-style: normal; color: var(--muted);
}
.p-in { background: var(--bg); border: 2px solid var(--text); width: 14px; height: 14px; margin-left: -7px; bottom: -7px; z-index: 2; }
.p-bank { background: var(--faint); }
.p-up { background: var(--text); }
.p-bank i { bottom: 34px; }
.round-ticks { position: relative; height: 22px; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.round-ticks span { position: absolute; top: 8px; transform: translateX(-50%); }
.round-ticks span:nth-child(1) { left: 0; }
.round-ticks span:nth-child(2) { left: 12.5%; }
.round-ticks span:nth-child(3) { left: 25%; }
.round-ticks span:nth-child(4) { left: 37.5%; }
.round-ticks span:nth-child(5) { left: 50%; }
.round-ticks span:nth-child(6) { left: 62.5%; }
.round-ticks span:nth-child(7) { left: 75%; }
.round-ticks span:nth-child(8) { left: 87.5%; }
.round-ticks span:nth-child(9) { left: 100%; }
.rounding .table-scroll { background: var(--bg); }
.round-table th, .round-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.round-table thead td { font-weight: 500; color: var(--muted); }
.round-table td.diff { font-weight: 700; }
.round-table tbody tr:first-child td.diff { text-decoration: underline dashed; text-underline-offset: 4px; color: var(--muted); }
.round-table td.current { background: color-mix(in srgb, var(--text) 9%, transparent); }
.round-table td { transition: background-color var(--dur-quick); }
@media (max-width: 560px) {
  .round-results { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .round-pin, .fsm-state, .seg-control button { transition: none; }
}
