/*
 * The embeddable calculator (G-6, D-SITE-9 SITE9-1; the one frame /<lang>/embed/custom/, D-SITE-26): draws the fields and the result of
 * /calc/'s page.css in a bare frame - no grid of the page, no header. Every colour and size is a token variable
 * (INV-205); no new colour (SITE7-6).
 */
.nn-embed { max-width: 440px; margin: 0 auto; padding: var(--space16); }
.nn-embed .nn-fields { max-width: none; }
/* The field's hint (CE-F): the parameter's description, a small secondary line under the box that wraps, never past the edge. */
.nn-embed .nn-field-hint { font-size: var(--type-labelSm-size); color: var(--onSurfaceLow); overflow-wrap: anywhere; }
/*
 * The look (CE-I, D-SITE-32 SITE32-11/12): the form's `look` reaches this sheet only as data attributes and custom properties
 * the frame's script sets on the root (`FrameLook` in CustomFrame.kt), each value read against a closed list; without them every rule below draws
 * today's frame, the tokens stand as the defaults (INV-205). The badge and the privacy link are outside the look.
 */
.nn-embed .nn-field-box { border-radius: var(--nn-radius, var(--pillRadius)); }
.nn-embed .nn-label { color: var(--nn-accent, var(--paramChipContent)); }
.nn-embed .nn-input { font-size: var(--nn-font, var(--editorMathFont)); }
/* Columns: a column is never narrower than 150 px, so a narrow site folds to fewer; `auto` lays as many 170 px columns as fit. */
[data-nn-columns] .nn-embed { max-width: 760px; }
[data-nn-columns] .nn-embed .nn-fields { display: grid; column-gap: var(--space14); align-items: start; }
[data-nn-columns] .nn-embed .nn-field { min-width: 0; }
[data-nn-columns="2"] .nn-embed .nn-fields { grid-template-columns: repeat(auto-fit, minmax(max(150px, calc((100% - var(--space14)) / 2)), 1fr)); }
[data-nn-columns="3"] .nn-embed .nn-fields { grid-template-columns: repeat(auto-fit, minmax(max(150px, calc((100% - 2 * var(--space14)) / 3)), 1fr)); }
[data-nn-columns="auto"] .nn-embed .nn-fields { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
/* A field's place (SITE32-13): `row` spans every column the grid has; `2` spans two only where the grid has two
   (2 x 150 px + the 14 px gap, 2 x 170 px + the gap for `auto`), so a narrow site never gets an implicit column. */
[data-nn-columns] .nn-embed .nn-fields { container: nn-fields / inline-size; }
[data-nn-columns] .nn-embed .nn-field[data-nn-span="row"] { grid-column: 1 / -1; }
@container nn-fields (min-width: 314px) { [data-nn-columns="2"] .nn-embed .nn-field[data-nn-span="2"], [data-nn-columns="3"] .nn-embed .nn-field[data-nn-span="2"] { grid-column: span 2; } }
@container nn-fields (min-width: 354px) { [data-nn-columns="auto"] .nn-embed .nn-field[data-nn-span="2"] { grid-column: span 2; } }
/* `left`: the name and the hint left of the box; `inside`: the name inside the box over the value (the script puts it there). */
[data-nn-label="left"] .nn-embed .nn-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); column-gap: var(--space12); row-gap: 0; align-items: center; }
[data-nn-label="left"] .nn-embed .nn-field > .nn-label { grid-column: 1; grid-row: 1; align-self: end; overflow-wrap: anywhere; }
[data-nn-label="left"] .nn-embed .nn-field:not(:has(.nn-field-hint:not([hidden]))) > .nn-label { grid-row: 1 / span 2; align-self: center; }
[data-nn-label="left"] .nn-embed .nn-field > .nn-field-hint { grid-column: 1; grid-row: 2; align-self: start; }
[data-nn-label="left"] .nn-embed .nn-field > .nn-field-box { grid-column: 2; grid-row: 1 / span 2; }
[data-nn-label="inside"] .nn-embed .nn-field-box { flex-wrap: wrap; height: auto; min-height: var(--minTouchTarget); padding-top: var(--space6); padding-bottom: var(--space4); }
[data-nn-label="inside"] .nn-embed .nn-field-box > .nn-label { flex: 0 0 100%; line-height: 1.2; overflow-wrap: anywhere; }
/* `band`: the result in a band of the accent mixed into the ground; `band-top`: the band over the fields. */
[data-nn-result] .nn-embed .nn-embed-head, [data-nn-result] .nn-embed .nn-result-fields { background: color-mix(in srgb, var(--nn-accent, var(--paramChipContent)) 16%, var(--ground)); padding-left: var(--space14); }
[data-nn-result] .nn-embed .nn-embed-head { border-radius: var(--nn-radius, var(--space12)) var(--nn-radius, var(--space12)) 0 0; padding-top: var(--space8); padding-right: calc(var(--space24) + var(--space8) + var(--space14)); }
[data-nn-result] .nn-embed .nn-result-fields { border-radius: 0 0 var(--nn-radius, var(--space12)) var(--nn-radius, var(--space12)); margin-top: -1px; padding: 1px var(--space14) var(--space10); }
[data-nn-result] .nn-embed .nn-formula-button { right: calc(var(--space14) - 7px); }
@media (pointer: coarse) { [data-nn-result] .nn-embed .nn-formula-button { right: calc(var(--space14) - 11px); } }
[data-nn-result="band-top"] .nn-embed { display: flex; flex-direction: column; }
[data-nn-result="band-top"] .nn-embed > .nn-embed-blocked { order: -2; }
[data-nn-result="band-top"] .nn-embed > .nn-embed-head, [data-nn-result="band-top"] .nn-embed > .nn-result-fields { order: -1; }
/* A frame may be narrow or zoomed: the unit goes under the figure, never past the edge. */
.nn-embed .nn-result { display: flex; flex-wrap: wrap; align-items: baseline; }
/* The result's unit pick (CE-D): the fields' chip in the answer's line; its list hangs from it. The row keeps room for a
   wrapped unit, so the chip is centred on the FIGURE's line, never on the row: its box is one line high, the chip overhangs evenly. */
.nn-embed .nn-result-pick { position: relative; display: inline-flex; align-self: flex-start; align-items: center; height: 1lh; }
.nn-embed .nn-result-pick[hidden] { display: none; }
/* A unit list near the frame's bottom opens upward (D-SITE-28): the frame's height never moves for it. */
.nn-embed .nn-unit-list.nn-up { top: auto; bottom: calc(100% + var(--space4)); }
/* The badge (SITE26-3): the image's own box (width and height attributes), never wider than the frame, no underline. */
.nn-embed-badge { display: block; width: max-content; max-width: 100%; line-height: 0; text-decoration: none; }
.nn-embed-badge img { display: block; max-width: 100%; height: auto; }
.nn-embed-badge[hidden] { display: none; }
/* The blocked site's line (SITE26-10): the calculator's empty rows keep no room above it, the privacy link stands under it. */
.nn-embed-blocked { margin: 0; font-size: 14px; color: var(--ink); }
.nn-embed-blocked:not([hidden]) ~ .nn-embed-fields, .nn-embed-blocked:not([hidden]) ~ .nn-embed-head, .nn-embed-blocked:not([hidden]) ~ .nn-result-fields { display: none; }
/* The foot (SITE32-12): the badge and the privacy link on one line, wrapping to two only where they do not fit. */
.nn-embed-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space4) var(--space12); }
.nn-embed-legal { margin: 0; font-size: 14px; }
/* The formula, shown (SITE26-8): the button hangs in the result name's row and never makes it taller; its glyph's ink ends on the fields' edge. */
.nn-embed-head { position: relative; padding-right: calc(var(--space24) + var(--space8)); }
.nn-formula-button { position: absolute; top: 50%; right: -7px; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--onSurfaceLow); cursor: pointer; transform: translateY(-50%); }
.nn-formula-button[hidden] { display: none; }
.nn-formula-button[aria-expanded="true"] { background: var(--surfaceLow); color: var(--ink); }
.nn-formula-button:focus-visible, .nn-formula:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
@media (pointer: coarse) { .nn-formula-button { right: -11px; width: 44px; height: 44px; } }
/* The panel lies exactly over the fields: absolute, so the frame's height stays; a long formula scrolls inside it. */
.nn-embed-fields { position: relative; }
.nn-formula { position: absolute; inset: 0; box-sizing: border-box; overflow: auto; overscroll-behavior: contain; padding: var(--space6) var(--space12); background: var(--surfaceHigh); border: var(--border-card) solid var(--outline); border-radius: var(--keyRadius); font-size: 15px; line-height: 1.6; }
.nn-formula[hidden] { display: none; }
/* The formula drawn as the app draws it (SITE26-11): only the top row wraps, what stands inside a term stays whole and the panel scrolls. */
.nn-formula-line, .nn-formula-numbers { display: flex; flex-wrap: wrap; align-items: center; row-gap: 2px; line-height: 1.3; }
.nn-formula-numbers { margin-top: var(--space6); color: var(--onSurfaceLow); font-variant-numeric: tabular-nums; }
.nn-formula-name { min-width: 0; overflow-wrap: anywhere; }
.nn-math-word { white-space: pre; }
.nn-math-op { padding: 0 .25em; white-space: pre; }
.nn-formula-numbers > .nn-math-op:first-child { padding-left: 0; }
.nn-math-row { display: inline-flex; align-items: center; white-space: nowrap; }
.nn-formula .nn-chip { display: inline-flex; padding: 0 6px; font-size: .93em; line-height: 1.45; white-space: nowrap; }
.nn-formula .nn-frac { font-size: .86em; }
.nn-formula .nn-num { border-bottom-color: currentColor; padding: 0 .12em .1em; }
.nn-formula .nn-den { padding: .1em .12em 0; }
.nn-formula .nn-sup { display: inline-flex; align-items: center; font-size: .68em; margin-left: .1em; }
.nn-formula .nn-root { align-items: stretch; }
.nn-radical { display: flex; align-items: flex-end; font-size: 1.1em; line-height: 1.1; }
.nn-formula .nn-radicand { border-top-color: currentColor; padding: .08em .12em 0; }
/* The stems stand as tall as the content (R-1); the feet are wider than the app's: at this size the app's 0.16 em reads as a modulus. The mark's own glyph stays in the text, out of sight. */
.nn-marks { position: relative; display: inline-flex; align-items: center; padding: 0 max(6px, .4em); }
.nn-mark { position: absolute; top: .03em; bottom: .03em; width: max(4px, .26em); overflow: hidden; text-indent: -9em; white-space: nowrap; border: 0 solid currentColor; }
.nn-mark-open { left: .02em; border-left-width: max(1.5px, .07em); }
.nn-mark-close { right: .02em; border-right-width: max(1.5px, .07em); }
.nn-marks-ceil > .nn-mark, .nn-marks-round > .nn-mark-close { border-top-width: max(1.5px, .07em); }
.nn-marks-floor > .nn-mark, .nn-marks-round > .nn-mark-open { border-bottom-width: max(1.5px, .07em); }
.nn-marks-bracket > .nn-mark-open { border-radius: 60% 0 0 60% / 50% 0 0 50%; }
.nn-marks-bracket > .nn-mark-close { border-radius: 0 60% 60% 0 / 0 50% 50% 0; }
.nn-embed-legal a { color: var(--onSurfaceLow); text-underline-offset: 3px; }
