/* ============================================================
   RF Lab — Yagi calculator
   Page-only styles, built on the site's tokens (style.css).
   ============================================================ */

.yagi-page [hidden] { display: none !important; }
.yagi-section { padding-top: .25rem; }

.yagi {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: clamp(1rem, 2.4vw, 1.6rem);
  align-items: start;
}

/* ---- Controls ---- */
.yagi__controls {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: grid;
  align-items: start;
  gap: .7rem;
  padding: 0 .3rem .3rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.yf {
  margin: 0;
  padding: .85rem .95rem .95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: .6rem;
  min-width: 0;
}
.yf legend {
  float: left;
  width: 100%;
  padding: 0;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--signal);
}
.yf__row { display: flex; gap: .6rem; flex-wrap: wrap; }
.yf__field { display: grid; gap: .28rem; min-width: 0; }
.yf__field--grow { flex: 1 1 7.5rem; }
.yf__label { font-size: .8rem; color: var(--muted); }
.yf__input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--bg-2);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.yf__input:focus-within { border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 20%, transparent); }
.yf__input input,
.yf__input select {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: .93rem;
  padding: .52rem .6rem;
  min-width: 0;
  outline: none;
}
.yf__input input { flex: 1; width: 100%; }
.yf__input input::placeholder { color: var(--muted-2); }
.yf__input select { border-left: 1px solid var(--line); cursor: pointer; }
.yf__input .yf__select--wide { flex: 1; border-left: 0; font-family: var(--font-sans); font-size: .9rem; }
.yf__input select option { background: var(--panel); color: var(--text); }
.yf__unit {
  display: flex;
  align-items: center;
  padding: 0 .6rem;
  border-left: 1px solid var(--line);
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: .78rem;
}
.yf__hint { margin: 0; font-family: var(--font-mono); font-size: .74rem; color: var(--muted-2); }
.yf__hint b, .yde__hint b { color: var(--text); font-weight: 700; }
/* "Use 4 mm": puts a recommended size into its input. */
.yf__use { margin-left: .35rem; padding: .05rem .55rem; border: 1px solid var(--signal); border-radius: 999px; background: none; color: var(--signal); font: inherit; font-size: .72rem; line-height: 1.5; white-space: nowrap; cursor: pointer; }
.yf__use:hover, .yf__use:focus-visible { background: var(--signal); color: #04130d; }
.yf__check { display: flex; align-items: center; gap: .5rem; font-size: .84rem; color: var(--muted); cursor: pointer; }
.yf__check input { width: 1rem; height: 1rem; accent-color: var(--signal); }

.yf__chips { display: flex; flex-wrap: wrap; gap: .32rem; }
.yf__chips button {
  font-family: var(--font-mono);
  font-size: .7rem;
  padding: .28rem .48rem;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .02);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.yf__chips button:hover { border-color: var(--signal); color: var(--text); }
.yf__chips button[aria-pressed="true"] { border-color: var(--signal); background: var(--signal); color: #04130d; font-weight: 700; }

.yf--more { display: block; }
.yf--more summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.yf--more summary::-webkit-details-marker { display: none; }
.yf--more summary::before { content: "+ "; color: var(--signal); }
.yf--more[open] summary::before { content: "\2212 "; }
.yf--more > .yf__field { margin-top: .65rem; }

/* Segmented control */
.seg { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg-2); }
.seg label { position: relative; flex: 1; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: block;
  padding: .4rem .5rem;
  border-radius: 7px;
  text-align: center;
  white-space: nowrap;
  font-size: .83rem;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.seg input:checked + span { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--signal) 45%, transparent); }
.seg input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 1px; }
.seg--sm span { padding: .26rem .65rem; font-size: .76rem; }

/* ---- Results ---- */
.yagi__out { display: grid; gap: 1rem; min-width: 0; }

.ystats { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: .55rem; }
.ystat { min-width: 0; padding: .75rem .85rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ystat__k { display: block; font-family: var(--font-mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); }
.ystat__v { display: block; margin-top: .22rem; font-size: 1.32rem; font-weight: 700; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ystat__v small { margin-left: .18rem; font-size: .7rem; font-weight: 600; color: var(--muted); }
.ystat__s { display: block; margin-top: .18rem; font-size: .72rem; color: var(--muted); }
.ystat--sim { border-color: color-mix(in srgb, var(--signal) 28%, var(--line)); }
.ystat--sim .ystat__v { color: var(--signal); }
.ystat--wait .ystat__v { color: var(--muted-2); }

.ywarn { list-style: none; margin: 0; padding: 0; display: grid; gap: .42rem; }
.ywarn:empty { display: none; }
.ywarn li {
  display: flex;
  gap: .65rem;
  align-items: baseline;
  padding: .55rem .8rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: 10px;
  background: color-mix(in srgb, var(--cyan) 5%, transparent);
  color: #c2ccd8;
  font-size: .85rem;
  line-height: 1.45;
}
.ywarn__tag { flex: none; font-family: var(--font-mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan); }
.ywarn .is-caution { border-left-color: var(--amber); background: rgba(255, 180, 84, .06); }
.ywarn .is-caution .ywarn__tag { color: var(--amber); }
.ywarn .is-danger { border-left-color: var(--red); background: rgba(255, 93, 108, .07); }
.ywarn .is-danger .ywarn__tag { color: var(--red); }
.yerror { margin: 0; padding: .75rem .9rem; border: 1px solid color-mix(in srgb, var(--red) 55%, transparent); border-radius: 10px; background: rgba(255, 93, 108, .08); color: var(--text); font-size: .9rem; }

.ypanel { margin: 0; min-width: 0; padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.ypanel__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1rem; margin-bottom: .75rem; }
.ypanel__head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.ypanel__sub { font-size: .76rem; color: var(--muted-2); }

/* Layout drawing */
.ydraw__canvas svg { display: block; width: 100%; height: auto; overflow: visible; }
.yd-boom { stroke: var(--muted-2); stroke-width: 5; stroke-linecap: round; }
.yd-el { stroke-width: 3.2; stroke-linecap: round; transition: stroke-width .12s; }
.yd-el--R { stroke: var(--amber); }
.yd-el--DE { stroke: var(--signal); }
.yd-el--D { stroke: var(--cyan); }
.yd-hit { fill: transparent; cursor: pointer; }
.yd-g.is-hot .yd-el { stroke-width: 5.5; }
.yd-feed { fill: var(--bg); stroke: var(--signal); stroke-width: 2; }
.yd-label { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; text-anchor: middle; }
.yd-g.is-hot .yd-label { fill: var(--text); }
.yd-dim { stroke: var(--line-2); stroke-width: 1; }
.yd-dimtext { fill: var(--muted); font-family: var(--font-mono); font-size: 12px; text-anchor: middle; }

/* Cut list */
.ycut__wrap { margin: 0; }
.ycut { min-width: 620px; font-size: .88rem; }
.ycut th, .ycut td { padding: .48rem .8rem; }
.ycut thead th { white-space: nowrap; }
.ycut .n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ycut td.n { color: var(--text); }
.ycut td.n.dim { color: var(--muted); }
.ycut td.n.unc { color: var(--amber); }
.ycut tbody th { font-family: var(--font-mono); }
/* Keep the element name in view while the table scrolls sideways. */
.ycut thead th:first-child, .ycut tbody th { position: sticky; left: 0; z-index: 1; background: var(--panel); }
.ycut thead th:first-child { background: color-mix(in srgb, var(--panel) 96%, white); }
.ycut tbody tr.is-hot th { background: color-mix(in srgb, var(--signal) 9%, var(--panel)); }
.ycut tbody tr { transition: background .12s; }
.ycut tbody tr.is-hot { background: color-mix(in srgb, var(--signal) 9%, transparent); }
.ycut .ytag { margin-left: .45rem; padding: .1em .38em; border: 1px solid currentColor; border-radius: 4px; font-size: .58rem; letter-spacing: .06em; text-transform: uppercase; vertical-align: .12em; }
.ycut .ytag--tuned { color: var(--signal); }
.ycut .ytag--start { color: var(--amber); }
.ycut .ytag--sim { color: var(--violet); }

/* Simulation */
/* One line beside the heading, so the header never changes height mid-run. */
.ysim__status { flex: 1 1 0; min-width: 0; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: .75rem; color: var(--muted); }
.ysim__bar { height: 3px; margin: -.3rem 0 .9rem; border-radius: 3px; background: var(--line); overflow: hidden; }
.ysim__bar.is-idle { visibility: hidden; }
/* Last results, left up while the next run replaces them. */
.ysim__grid, .ychart { transition: opacity .2s; }
.ysim__grid.is-stale, .ychart.is-stale, .ystat--stale { opacity: .4; }
.ystat { transition: opacity .2s; }
.ysim__bar span { display: block; width: 0; height: 100%; background: var(--grad); transition: width .25s ease; }
.ysim__run { margin-bottom: .8rem; }
.ysim__grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(240px, 1.05fr); gap: 1.1rem 1.6rem; align-items: start; }
.ysim__kv { margin: 0; }
.ysim__kv .v b { color: var(--signal); font-weight: 700; }
.ysim__kv .v small { display: block; color: var(--muted-2); font-size: .74rem; }

.ychart { margin: 0; min-width: 0; }
.ychart--wide { grid-column: 1 / -1; }
.ychart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem .8rem; margin-bottom: .45rem; font-size: .8rem; color: var(--muted); }
.ychart svg { display: block; width: 100%; height: auto; }
.ylegend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-family: var(--font-mono); font-size: .68rem; color: var(--muted-2); }
.ylegend i { display: inline-block; width: 14px; height: 3px; margin-left: .45rem; border-radius: 2px; }
.ylegend--e, .ylegend--g { background: var(--signal); }
.ylegend--h { background: var(--cyan); }
.ylegend--s { background: var(--amber); }

.yc-grid { fill: none; stroke: var(--line); stroke-width: 1; }
.yc-ring3 { stroke-dasharray: 3 4; stroke: var(--line-2); }
.yc-axis { stroke: var(--line-2); stroke-width: 1; }
.yc-text { fill: var(--muted-2); font-family: var(--font-mono); font-size: 10px; }
.yc-e { fill: color-mix(in srgb, var(--signal) 12%, transparent); stroke: var(--signal); stroke-width: 1.7; stroke-linejoin: round; }
.yc-h { fill: none; stroke: var(--cyan); stroke-width: 1.3; stroke-linejoin: round; opacity: .9; }
.yc-gain { fill: none; stroke: var(--signal); stroke-width: 2; stroke-linejoin: round; }
.yc-swr { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; }
.yc-dot-g { fill: var(--signal); }
.yc-dot-s { fill: var(--amber); }
.yc-f0 { stroke: var(--muted-2); stroke-dasharray: 3 4; }
.yc-hit { fill: transparent; }
.yc-hit:hover + .yc-dot-g, .yc-hit:hover + .yc-dot-g + .yc-dot-s { r: 4.5; }

/* ---- Driven element ---- */
/* The panel lays itself out by its own width: just above 980 px it shares the
   page with the controls and is narrower than on a tablet. */
.yde { container-type: inline-size; }
.yde__top { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 1rem 1.4rem; align-items: start; }
.yde__controls { display: grid; gap: .6rem; min-width: 0; }
/* Driven element types: two rows of cards, split elements then unbroken ones. */
.ytypes { display: grid; gap: .35rem; margin-bottom: 1.1rem; }
.ytypes__h { margin: .2rem 0 0; font-family: var(--font-mono); font-size: .66rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); }
.ytypes__h span { margin-left: .4rem; font-weight: 400; letter-spacing: .04em; text-transform: none; color: var(--muted-2); opacity: .8; }
.ytypes__row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem; }
.ytype { position: relative; }
.ytype input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.ytype span { display: grid; gap: .12rem; height: 100%; padding: .5rem .65rem; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg-2); transition: border-color .15s, background .15s; }
.ytype b { font-weight: 600; font-size: .86rem; color: var(--text); }
.ytype small { font-size: .7rem; color: var(--muted-2); }
.ytype:hover span { border-color: color-mix(in srgb, var(--signal) 35%, var(--line-2)); }
.ytype input:checked + span { background: var(--panel-2); border-color: var(--signal); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--signal) 45%, transparent); }
.ytype input:checked + span small { color: var(--muted); }
.ytype input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.yde__hint { margin: 0; padding: .45rem .65rem; border-left: 2px solid var(--signal); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--signal) 5%, transparent); color: #c2ccd8; font-size: .8rem; line-height: 1.45; }
.yde__fig { margin: 0; min-width: 0; }
.yde__fig figcaption { margin-top: .35rem; font-size: .74rem; color: var(--muted-2); }
.yde__fig svg { display: block; width: 100%; height: auto; overflow: visible; }
.yde__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1.6rem; margin-top: 1.1rem; }
.yde__h { margin: 0 0 .5rem; font-family: var(--font-mono); font-size: .7rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--signal); }
.yde__kv { margin: 0; }
.yde__kv .v small { display: block; color: var(--muted-2); font-size: .74rem; }
.yde__tune { margin-top: 1.1rem; }
.yde__tune .ychart { margin-bottom: .8rem; }
.yde__steps { margin: 0; padding-left: 1.3rem; color: #c2ccd8; font-size: .88rem; line-height: 1.55; }
.yde__steps li { margin: .35rem 0; padding-left: .2rem; }
.yde__steps li::marker { color: var(--signal); font-family: var(--font-mono); font-weight: 700; }
.yde__steps strong { color: var(--text); }
.yde__explain { margin-top: 1.1rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .015); }
.yde__explain summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--text); }
.yde__explain summary::marker { color: var(--signal); }
.yde__explain .prose { margin-top: .6rem; max-width: none; font-size: .9rem; }
.yde__explain .prose p { margin: 0 0 .7rem; }

.ydd-boom { fill: color-mix(in srgb, var(--muted-2) 35%, var(--panel)); stroke: var(--muted-2); stroke-width: 1.5; }
.ydd-boom--plastic { fill: none; stroke-dasharray: 4 3; }
.ydd-rod { fill: none; stroke: var(--text); stroke-linecap: round; stroke-linejoin: round; }
.ydd-block { fill: color-mix(in srgb, var(--amber) 14%, transparent); stroke: var(--amber); stroke-width: 1.2; stroke-dasharray: 4 3; }
.ydd-bond { fill: var(--signal); stroke: var(--bg); stroke-width: 1.5; }
.ydd-term { fill: var(--bg); stroke: var(--signal); stroke-width: 2; }
.ydd-coax-out { fill: none; stroke: var(--muted-2); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.ydd-coax-in { fill: none; stroke: var(--bg-2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ydd-balun { fill: color-mix(in srgb, var(--cyan) 12%, var(--panel)); stroke: var(--cyan); stroke-width: 1.3; }
.ydd-strap { fill: none; stroke: var(--signal); stroke-width: 4; stroke-linecap: round; }
.ydd-cap { fill: none; stroke: var(--amber); stroke-width: 2.4; }
.ydd-sleeve { fill: none; stroke: var(--amber); stroke-width: 1.6; stroke-dasharray: 4 3; }
.ydd-sleeve-tube { fill: color-mix(in srgb, var(--cyan) 10%, transparent); stroke: var(--cyan); stroke-width: 1.3; }
.ydd-bead { fill: color-mix(in srgb, var(--muted-2) 45%, var(--panel)); stroke: var(--muted); stroke-width: 1; }
.ydd-coil { fill: none; stroke: var(--muted-2); stroke-width: 4; }
.ydd-shield { fill: none; stroke: var(--amber); stroke-width: 1.4; stroke-dasharray: 3 3; }
.ydd-conn { fill: color-mix(in srgb, var(--muted-2) 30%, var(--panel)); stroke: var(--muted); stroke-width: 1.2; }
.ydd-dim { stroke: var(--line-2); stroke-width: 1; fill: none; }
.ydd-text { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.ydd-text--hi { fill: var(--text); }
.ydd-text--sig { fill: var(--signal); }
.ydd-text--amber { fill: var(--amber); }

.yc-trim-cut { fill: none; stroke: var(--signal); stroke-width: 2.2; stroke-linejoin: round; }
.yc-trim-long { fill: none; stroke: var(--amber); stroke-width: 1.6; stroke-dasharray: 5 4; }
.yc-trim-short { fill: none; stroke: var(--cyan); stroke-width: 1.6; stroke-dasharray: 5 4; }

/* ---- Small screens ---- */
/* ---- Clips to print ---- */
.yclip__controls { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin: .2rem 0 .9rem; }
.yclip__pick:empty { display: none; }
.yclip__pick { flex: 1 1 18rem; max-width: 26rem; }
.yclip__fit { flex: 0 1 20rem; }
#clipHint { margin-bottom: .8rem; }
.yclip__grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(240px, 1fr); gap: 1rem 1.4rem; align-items: start; }
.yclip__view { display: block; width: 100%; height: auto; aspect-ratio: 560 / 440; border: 1px solid var(--line); border-radius: 12px; background: radial-gradient(circle at 50% 40%, var(--panel-2), var(--bg-2)); cursor: grab; touch-action: none; }
.yclip__view:active { cursor: grabbing; }
.yclip__side { display: grid; gap: .9rem; min-width: 0; }
.yclip__dl { justify-self: start; }
.yclip__dl:disabled { opacity: .5; cursor: progress; }
.yclip__notes { margin: 0; padding-left: 1.1rem; display: grid; gap: .35rem; font-size: .8rem; color: var(--muted); }
.yclip__notes b { color: var(--text); }
@media (max-width: 760px) {
  .yclip__grid { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .yagi { grid-template-columns: 1fr; }
  .yagi__controls { position: static; max-height: none; overflow: visible; padding: 0; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
}
/* Side by side only while the drawing still gets 480 px. */
@container (max-width: 800px) {
  .yde__top { grid-template-columns: 1fr; }
}
@container (max-width: 640px) {
  .yde__cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .ysim__grid { grid-template-columns: 1fr; }
  .ystats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ypanel { padding: .9rem .85rem 1rem; }
}
