/* GraySky - /dev API builder styles. Builds on styles.css + dev/dev.css.
   The builder is one card (the STYLE-GUIDE card recipe: white surface,
   1px var(--rule) hairline, --shadow-card). Sections separate with the
   same hairline. Dense UI type ladder, 13px workhorse, 2px sub-grid.
   No dark mode on purpose: the whole /dev portal is hard light-mode. */

/* An author display rule in this file must never beat the hidden
   attribute (documented in-house trap - see dev-usage-bar in dev.css). */
.b-card [hidden],
.b-card-outer [hidden] { display: none !important; }

.b-card-outer { max-width: var(--maxw); margin: 0 auto; }

.b-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-16);
  box-shadow: var(--shadow-card);
  /* clip, not hidden: hidden makes this a scroll container and kills the
     sticky URL bar; clip rounds the corners without one. */
  overflow: clip;
}

.b-part {
  padding: 20px clamp(16px, 3vw, 28px) 24px;
  border-top: 1px solid var(--rule);
  border-inline: 0;
  border-bottom: 0;
  margin: 0;
  min-width: 0;
}
fieldset.b-part { border-top: 1px solid var(--rule); }
.b-part legend,
.b-part-title {
  display: block;
  font-size: 15px;
  font-weight: var(--w-semibold, 590);
  color: var(--ink);
  padding: 0;
  margin: 0 0 14px;
}
/* Legend only: float pulls it into normal flow so the fieldset pads the
   same as the div sections. clear:both on the next box keeps a flex
   container from shrink-wrapping beside the full-width float. */
.b-part legend { float: left; width: 100%; }
.b-part legend + * { clear: both; }

/* ---------- Presets ---------- */
.b-presets {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px clamp(16px, 3vw, 28px);
}
.b-presets-label {
  font-size: 11.5px;
  letter-spacing: var(--track-caps, 0.06em);
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: var(--w-semibold, 590);
}
.b-preset {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  color: var(--ink);
  font-size: 13px;
  font-weight: var(--w-medium, 510);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.b-preset:hover { background: #ececec; }
.b-preset:active { scale: 0.98; }

/* ---------- Location ---------- */
.b-loc-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.b-place-wrap { position: relative; flex: 1 1 260px; min-width: 0; }
.b-input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-8);
  font-size: 15px;
  background: var(--bg-muted);
  min-width: 0;
}
.b-input:focus { outline: 2px solid var(--dev-accent); outline-offset: -1px; }
.b-place-list {
  position: absolute;
  inset-inline: 0;
  top: 44px;
  z-index: 30;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-10);
  box-shadow: var(--shadow-pop);
}
.b-place-list [role="option"] {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-6);
  font-size: 13.5px;
  cursor: pointer;
}
.b-place-list [role="option"][aria-selected="true"],
.b-place-list [role="option"]:hover { background: var(--bg-muted); }
.b-opt-primary { color: var(--ink); font-weight: var(--w-medium, 510); }
.b-opt-secondary {
  color: var(--ink-3);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.b-coord-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.b-coord-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-3);
}
.b-coord-row .b-input { width: 160px; height: 36px; font-size: 14px; }
.b-snap {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}

/* ---------- Data toggles + matrix ---------- */
.b-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.b-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px; /* touch target */
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  font-size: 13.5px;
  font-weight: var(--w-medium, 510);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.b-toggle:hover { background: #ececec; }
.b-toggle:active { scale: 0.98; }
.b-toggle input { accent-color: var(--dev-accent); width: 15px; height: 15px; margin: 0; }
.b-toggle:has(input:checked) { background: #e3f2fd; }

.b-matrix-scroll { overflow-x: auto; }
.b-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.b-matrix th,
.b-matrix td {
  text-align: left;
  padding: 7px 12px;
}
.b-matrix thead th {
  font-weight: var(--w-semibold, 590);
  color: var(--ink);
  background: var(--bg-muted);
  white-space: nowrap;
}
.b-matrix thead th + th,
.b-matrix td + td,
.b-matrix tbody th + td ~ td { text-align: center; }
.b-matrix td { text-align: center; color: var(--ink-2); }
.b-matrix tbody th[scope="row"] { font-weight: var(--w-normal, 400); color: var(--ink); }
.b-matrix tbody tr:nth-child(even) { background: var(--rule-soft); }
.b-matrix .b-group th {
  font-size: 11px;
  letter-spacing: var(--track-caps, 0.06em);
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: var(--w-semibold, 590);
  padding-top: 14px;
  background: none;
}
.b-matrix .b-dot::before { content: "●"; font-size: 8px; color: var(--ink-2); }
.b-matrix .b-no { color: var(--ink-3); }
/* Columns of unselected blocks dim so the matrix mirrors the toggles. */
.b-matrix:not([data-on~="current"]) [data-b="current"],
.b-matrix:not([data-on~="hourly"]) [data-b="hourly"],
.b-matrix:not([data-on~="daily"]) [data-b="daily"] { opacity: 0.35; }
.b-matrix-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* ---------- Units ---------- */
.b-units-row { display: flex; gap: 18px; flex-wrap: wrap; }
.b-units-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.b-units-row input { accent-color: var(--dev-accent); width: 15px; height: 15px; margin: 0; }
.b-units-note { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); line-height: 1.5; }

/* ---------- URL bar ---------- */
.b-urlbar {
  position: sticky;
  top: 0; /* measured topnav height set from JS */
  z-index: 40;
  /* Match the "Use it in code" frames: the same inset as .b-part and the
     same rounded corners. The bar carries its own background because a
     rounded inset frame no longer masks the card scrolling behind it. */
  padding: 12px clamp(16px, 3vw, 28px);
  background: #fff;
}
/* Keyboard focus and programmatic scrolls must clear the sticky chrome
   (topnav + URL bar), or a focused control lands hidden under it. */
.b-card button,
.b-card input,
.b-card [tabindex] { scroll-margin-top: 180px; scroll-margin-bottom: 120px; }
.b-url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--dev-code-bg);
}
.b-url-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: #ebcb8b; /* the frame's URL tone (.c-url) */
  font-family: var(--dev-mono);
  font-size: 13.5px;
  padding: 4px 0;
}
.b-url-input:focus { outline: 2px solid var(--dev-accent); outline-offset: 2px; border-radius: 4px; }
.b-copy {
  height: 24px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12px;
  font-weight: var(--w-medium, 510);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.b-copy:hover { background: rgba(255, 255, 255, 0.2); }
.b-copy:active { scale: 0.98; }
.b-copy:disabled { opacity: 0.45; cursor: default; }

/* ---------- Preview ---------- */
.b-preview-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.b-preview-meta {
  font-size: 13px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.b-tabs { display: inline-flex; gap: 2px; background: var(--bg-muted); border-radius: var(--radius-pill); padding: 2px; }
.b-tab {
  height: 28px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: var(--w-medium, 510);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.b-tab[aria-selected="true"] { background: #fff; color: var(--ink); }
.b-note {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.b-empty {
  margin: 0;
  padding: 20px 0 4px;
  font-size: 14px;
  color: var(--ink-3);
}
.b-pane {
  max-height: 45svh;
  overflow-y: auto;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.b-json { margin: 0; font-size: 12.5px; }
.b-bytes { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Code tabs ---------- */
.b-code-frames .dev-code-frame { margin-top: 12px; }
.b-code-frames .dev-code { font-size: 13px; }
.b-frame-copy {
  margin-left: auto;
  height: 24px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.b-frame-copy:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- Page sections below the builder ---------- */

/* The rules slab. A solid fill gives the short lines a left edge to
   resolve against. Flat fill, no border, no shadow - the same card
   language as .dev-feature on this page.
   It used to centre itself (margin: 0 auto) because the section heading
   was centred too. On the merged one-page /dev the heading is left
   aligned in the docs column, so a centred slab reads as indented. */
.b-rules-card {
  max-width: 620px;
  margin: 0;
  padding: 24px 28px;
  border-radius: var(--radius-12);
  background: var(--bg-muted);
}
.dev-section--muted .b-rules-card { background: #fff; }
@media (max-width: 560px) { .b-rules-card { padding: 20px; } }
/* The slab owns the outer rhythm, so each rule carries only the gap to the
   next one. Item padding would double up against the slab padding. */
.b-rules {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
}
.b-rules li {
  padding-left: 22px;
  position: relative;
}
.b-rules li + li { margin-top: 14px; }
.b-rules li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
}
.b-docs-links {
  display: flex;
  gap: 10px 28px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 28px;
  font-size: 15px;
}
.b-docs-links a { color: var(--dev-accent); }
.b-facts {
  display: flex;
  gap: 8px 24px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 4px;
}
.b-facts span { display: inline-flex; align-items: center; gap: 8px; }
.b-facts span + span::before {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-3);
}

/* ---------- Mobile ---------- */
@media (max-width: 719px) {
  .b-urlbar {
    position: fixed;
    top: auto !important; /* JS sets top for desktop; the bottom bar wins */
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 30vh;
    overflow-y: auto;
    z-index: 60;
  }
  /* The fixed bottom bar spans the viewport, so it drops the desktop
     inset, the rounding, and the background, and its Copy grows back to
     a comfortable tap target. */
  .b-urlbar { padding: 0; background: none; }
  .b-urlbar .dev-code-frame { border-radius: 0; }
  .b-copy { height: 32px; padding: 0 16px; font-size: 13px; }
  .b-url-row { flex-wrap: wrap; }
  /* One block at a time: the toggles double as the view filter. The hide
     selector MUST target the body cells too - hiding only the th leaves
     the column behind. */
  [data-view="current"] th[data-b="hourly"], [data-view="current"] td[data-b="hourly"],
  [data-view="current"] th[data-b="daily"], [data-view="current"] td[data-b="daily"],
  [data-view="hourly"] th[data-b="current"], [data-view="hourly"] td[data-b="current"],
  [data-view="hourly"] th[data-b="daily"], [data-view="hourly"] td[data-b="daily"],
  [data-view="daily"] th[data-b="current"], [data-view="daily"] td[data-b="current"],
  [data-view="daily"] th[data-b="hourly"], [data-view="daily"] td[data-b="hourly"] {
    display: none;
  }
  .b-coord-row .b-input { width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  .b-preset, .b-toggle, .b-copy, .b-tab, .b-frame-copy, .b-pane { transition: none; }
  .b-preset:active, .b-toggle:active, .b-copy:active { scale: 1; }
}
