/* UbiScouting builder page.
 *
 * Direction: official Cub Scouting colours — deep navy ink on warm khaki stock,
 * with wolf-red as the signal colour and cub-yellow / lion-gold for accents.
 * Rank colours (lion, tiger, wolf, bear, webelos, arrow-of-light) are available
 * as CSS variables via scouts.css for any element that needs them.
 */

@import url("scouts.css");

:root {
  --paper:      var(--white);
  --paper-2:    #f0f0ec;
  --paper-3:    #e4e4de;
  --ink:        var(--cub-blue);
  --ink-soft:   #2f4e7c;
  --ink-faint:  #3a5a80;
  --signal:     #5F4800;
  --gold:       #5F4800;
  --rule:       rgba(0, 47, 109, .18);
  --rule-firm:  rgba(0, 47, 109, .38);
  --shadow:     rgba(0, 47, 109, .10);

  --display: "Archivo", system-ui, sans-serif;
  --body:    "Archivo", system-ui, sans-serif;
  --serif:   "Newsreader", Georgia, serif;

  --accent-pack:   #5F4800;
  --accent-troop:  #7a0918;
  --accent-custom: #4d4d4d;

  --measure: 74rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     var(--cub-blue);
    --paper-2:   #0a3d7a;
    --paper-3:   #134b8e;
    --ink:       var(--white);
    --ink-soft:  #b0c6de;
    --ink-faint: #acc3dc;
    --signal:    var(--cub-yellow);
    --gold:      var(--cub-yellow);
    --rule:      rgba(255, 255, 255, .18);
    --rule-firm: rgba(255, 255, 255, .30);
    --shadow:    rgba(0, 0, 0, .50);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--rule-firm); text-underline-offset: .22em; }
a:hover { text-decoration-color: var(--signal); }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap {
  width: 100%;
  max-width: calc(58vw - 2.5rem);
  margin: 0;
  padding: 0 1.5rem 0 clamp(1.15rem, 3vw, 2rem);
}

.utility {
  font-size: .85rem;
  font-weight: 650;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ── masthead ─────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  color: var(--ink);
}

.wordmark svg { width: 1.35rem; height: 1.35rem; fill: var(--signal); flex: none; }

.wordmark-text {
  font-family: var(--display);
  font-size: .95rem;
  font-weight: 700;
  font-stretch: 118%;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.masthead-links { display: flex; gap: 1.4rem; }
.masthead-links a { font-size: .85rem; text-decoration: none; color: var(--ink-soft); }
.masthead-links a:hover { color: var(--signal); }

/* ── hero ─────────────────────────────────────────────────────────────── */

.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(2rem, 5vw, 3.25rem); }
.hero-eyebrow { margin: 0 0 1.4rem; }

.hero-title { margin: 0; max-width: 22ch; }

.hero-title-a {
  display: block;
  font-family: var(--display);
  font-size: clamp(2.4rem, 7.2vw, 5.1rem);
  font-weight: 750;
  font-stretch: 112%;
  line-height: .96;
  letter-spacing: -.025em;
  text-transform: uppercase;
}

.hero-title-b {
  display: block;
  margin-top: .12em;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.1rem, 6.1vw, 4.3rem);
  line-height: 1.02;
  letter-spacing: -.015em;
  color: var(--signal);
}

.hero-lede {
  margin: clamp(1.5rem, 3vw, 2.1rem) 0 0;
  max-width: 46ch;
  font-size: 1.06rem;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.hero-lede strong { color: var(--ink); font-weight: 600; }

/* ── section furniture ────────────────────────────────────────────────── */

.section { padding: clamp(2.75rem, 6vw, 4.5rem) 0; border-top: 1px solid var(--rule); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.section-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  font-stretch: 108%;
  letter-spacing: -.01em;
}

.section-note { margin: 0; max-width: 44ch; font-size: .9rem; color: var(--ink-soft); }

/* ── builder ──────────────────────────────────────────────────────────── */

/* ── fixed preview aside ──────────────────────────────────────────────── */

.preview-aside {
  position: fixed;
  top: 0;
  right: 0;
  width: 42vw;
  height: 100vh;
  padding: 1rem 1rem 1rem 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
  pointer-events: none;
}

.preview-aside > .card {
  flex: 1;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.preview-aside .stage-frame {
  flex: 1;
  display: flex;
}

.preview-aside .stage-frame iframe {
  flex: 1;
  height: auto;
}

.card {
  background: var(--paper-2);
  border: 1px solid var(--rule-firm);
  border-radius: 3px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem .95rem;
  border-bottom: 1px solid var(--rule);
}

.stage-frame { padding: .95rem; }

.stage-frame iframe {
  display: block;
  width: 100%;
  height: 260px;
  border: 0;
  background: transparent;
  transition: height .18s ease;
}

.panel-body { padding: .35rem .95rem .95rem; }

.ctrl {
  display: grid;
  grid-template-columns: 5.8rem minmax(0, 1fr);
  align-items: center;
  gap: .6rem 1rem;
  padding: .58rem 0;
  border-bottom: 1px solid var(--rule);
}

.ctrl:last-child { border-bottom: 0; }
.ctrl > .utility { font-size: .78rem; line-height: 1.3; }

.select {
  width: 100%;
  padding: .42rem .55rem;
  font: inherit;
  font-size: .88rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-firm);
  border-radius: 2px;
}

.select[multiple] {
  min-height: 5.2rem;
  padding: .25rem;
}

.select[multiple] option {
  padding: .25rem .45rem;
  border-radius: 2px;
}

.css-input {
  width: 100%;
  padding: .42rem .55rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-firm);
  border-radius: 2px;
  resize: vertical;
}

.ctrl-css { align-items: start; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  background: var(--paper);
  border: 1px solid var(--rule-firm);
  border-radius: 2px;
}

.seg-btn {
  appearance: none;
  border: 0;
  border-radius: 1px;
  padding: .3rem .58rem;
  font: inherit;
  font-size: .85rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.seg-btn:hover { color: var(--ink); }

.seg-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.accent-row { display: flex; align-items: center; gap: .6rem; }

.swatch {
  appearance: none;
  width: 2.1rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--rule-firm);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}
.swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 1px; }
.swatch::-moz-color-swatch { border: 0; border-radius: 1px; }

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: .85rem;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule-firm);
  text-underline-offset: .2em;
}
.link-btn:hover { color: var(--signal); }

/* ── snippet ──────────────────────────────────────────────────────────── */

.snippet { margin-top: clamp(1.25rem, 2.5vw, 2rem); }

.code {
  margin: 0;
  padding: .95rem 1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem;
  line-height: 1.75;
  white-space: pre;
  color: var(--ink);
  tab-size: 2;
}

.code .attr { color: var(--ink-soft); }
.code .str  { color: var(--gold); }

/* The signature: change a control and the exact token you changed lights up,
   so the connection between the panel and the tag you are pasting is visible. */
.tok { border-radius: 2px; padding: 0 1px; margin: 0 -1px; }

@media (prefers-reduced-motion: no-preference) {
  .tok.is-hot { animation: tok-flash 1s ease-out; }
  @keyframes tok-flash {
    0%, 32% { background: var(--signal); color: var(--paper); }
    100%    { background: transparent; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .tok.is-hot { background: var(--signal); color: var(--paper); }
}

.btn {
  appearance: none;
  padding: .38rem .8rem;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}

.btn:hover { background: var(--signal); border-color: var(--signal); }
.btn.is-done { background: var(--gold); border-color: var(--gold); }

/* ── catalog ──────────────────────────────────────────────────────────── */

.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .7rem;
}

.catalog-item {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .85rem .95rem;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}

.catalog-item:hover { border-color: var(--signal); background: var(--paper-3); }
.catalog-item[aria-current="true"] { border-color: var(--signal); }

.catalog-name { font-size: .95rem; font-weight: 600; }
.catalog-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  color: var(--ink-faint);
}

/* ── prose columns ────────────────────────────────────────────────────── */

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: clamp(1.5rem, 3vw, 2.75rem);
}

.col h3 {
  margin: 0 0 .55rem;
  font-size: .95rem;
  font-weight: 650;
}

.col p { margin: 0 0 .8rem; font-size: .92rem; color: var(--ink-soft); text-wrap: pretty; }
.col p:last-child { margin-bottom: 0; }
.col code, .inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em;
  color: var(--ink);
  background: var(--paper-3);
  padding: .05em .3em;
  border-radius: 2px;
}

/* ── footer ───────────────────────────────────────────────────────────── */

.footer {
  padding: 2.5rem 0 3.5rem;
  border-top: 1px solid var(--rule);
}

/* The disclaimer is something people may actually need to read, so it gets
   readable contrast rather than the faint tone used for slugs. */
.footer p {
  margin: 0 0 .7rem;
  max-width: 62ch;
  font-size: .85rem;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.footer p:last-child { margin-bottom: 0; }

/* ── utility ──────────────────────────────────────────────────────────── */

.is-hidden { display: none; }
.sr-only { position: fixed; opacity: 0; pointer-events: none; }

/* ── responsive ───────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .wrap {
    max-width: none;
    padding: 0 clamp(1.15rem, 4vw, 3rem);
  }
  .preview-aside {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    padding: .5rem clamp(1.15rem, 4vw, 3rem);
    background: var(--paper);
  }
  .preview-aside > .card { flex: none; }
  .preview-aside .stage-frame iframe { height: 220px; flex: none; }
}

@media (max-width: 460px) {
  .ctrl { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  .masthead-links { gap: 1rem; }
}
