/* ==================================================================
   /tools/youtube-banner-maker on the foundation look
   (switch tools-banner-maker-fnd, markup templates/tools/_bnr-fnd.twig).

   Layout only. Every box, button, switch, picker, slider, card, upload
   zone and accordion is the shared foundation part; this file places
   them and draws the three things the kit does not have: the banner
   frame with its safe-area boxes, the style swatches and the colour
   swatch around a native colour input.

   The banner leads. From 1024px it holds the left column and stays in
   view while the controls on the right change it. On a phone it comes
   first and stays pinned under the header while you type.
   ================================================================== */

/* ------------------------------------------------------------------
   1. THE LAYOUT
   ------------------------------------------------------------------ */
.bnr3-top__in { padding-bottom: var(--fnd-s7); }
.bnr3-lead .fnd-display { text-wrap: balance; }
.bnr3 p, .bnr3-guide p, .bnr3-guide li { text-wrap: pretty; }

/* Below 1024px the left rail dissolves so the order reads lead, banner,
   bar, controls, screens, offer. */
.bnr3-left { display: contents; }
.bnr3-ctrl, .bnr3-views, .bnr3-offer, .bnr3-dl { margin-top: var(--fnd-s5); }
@media (max-width: 1023px) {
  /* The download comes after the controls on a phone, though it sits
     under the banner in the markup for the computer layout. */
  .bnr3-top__in { display: flex; flex-direction: column; }
  .bnr3-top__in > * { min-width: 0; }
  .bnr3-lead { order: 1; }
  .bnr3-stage { order: 2; }
  .bnr3-bar { order: 3; }
  .bnr3-bar__help { order: 4; }
  .bnr3-ctrl { order: 5; }
  .bnr3-dl { order: 6; }
  .bnr3-views { order: 7; }
  .bnr3-offer { order: 8; }
}

@media (min-width: 1024px) {
  .bnr3-top__in {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr);
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      "lead ctrl"
      "left ctrl"
      "left views"
      "left offer";
    column-gap: var(--fnd-s7);
    align-items: start;
  }
  .bnr3-lead { grid-area: lead; }
  .bnr3-left {
    display: block; grid-area: left; grid-row: 2 / span 3;
    position: sticky; top: calc(var(--header-height, 60px) + var(--fnd-s4));
  }
  .bnr3-lead { margin-bottom: var(--fnd-s5); }
  .bnr3-left .bnr3-dl { margin-top: var(--fnd-s3); }
  .bnr3-ctrl { grid-area: ctrl; margin-top: 0; grid-row: 1 / span 2; }
  .bnr3-views { grid-area: views; }
  .bnr3-offer { grid-area: offer; }
}

/* ------------------------------------------------------------------
   2. THE BANNER with what each screen shows
   Boxes from YouTube's help: the phone box is the safe area, 1546 x 423
   of 2560 x 1440 (60.39% x 29.375%); the computer strip is the full
   width at the same height; a TV shows the whole frame.
   ------------------------------------------------------------------ */
.bnr3-stage { background: var(--fnd-paper); }
.bnr3-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--fnd-r); overflow: hidden;
  background: var(--fnd-ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .10);
}
.bnr3-frame canvas { display: block; width: 100%; height: 100%; }

.bnr3-safe { position: absolute; inset: 0; pointer-events: none; display: none; }
.bnr3-safe.bnr3-safe-zone--visible { display: block; }
.bnr3-safe__tv, .bnr3-safe__pc, .bnr3-safe__ph { position: absolute; box-sizing: border-box; }
.bnr3-safe__tv { inset: 0; border: 2px dashed rgba(255, 255, 255, .35); border-radius: var(--fnd-r); }
.bnr3-safe__pc {
  left: 0; right: 0; top: 35.3125%; height: 29.375%;
  border-top: 2px dashed rgba(255, 255, 255, .6); border-bottom: 2px dashed rgba(255, 255, 255, .6);
}
.bnr3-safe__ph {
  left: 19.805%; width: 60.39%; top: 35.3125%; height: 29.375%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.bnr3-safe__k {
  position: absolute; left: 4px; top: 4px;
  padding: 1px 6px; border-radius: var(--fnd-r-xs);
  font-family: var(--fnd-body-font); font-size: 12px; font-weight: 700; line-height: 1.4;
  color: #fff; background: rgba(15, 23, 42, .72); white-space: nowrap;
}
.bnr3-safe__pc .bnr3-safe__k, .bnr3-safe__ph .bnr3-safe__k { top: auto; bottom: calc(100% + 3px); }
.bnr3-safe__ph .bnr3-safe__k { left: auto; right: 0; }

.bnr3-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--fnd-s3);
  margin-top: var(--fnd-s3);
}
.bnr3-bar__safe > span:last-child { white-space: nowrap; }
.bnr3-bar__end { display: flex; gap: var(--fnd-s1); }
.bnr3-bar__help { margin: var(--fnd-s2) 0 0; font-size: var(--fnd-t-meta); color: var(--fnd-text-soft); }

/* ------------------------------------------------------------------
   3. THE CONTROLS
   ------------------------------------------------------------------ */
/* Style swatches: a little banner and its name. */
.bnr3-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--fnd-s2); }
.bnr3-preset {
  display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 4px;
  border: 1px solid var(--fnd-rule); border-radius: var(--fnd-r-sm); background: var(--fnd-card);
  font: inherit; color: var(--fnd-text); cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.bnr3-preset:hover { border-color: var(--fnd-edge); transform: translateY(-1px); }
.bnr3-preset:focus-visible { outline: 2px solid var(--fnd-accent-deep); outline-offset: 2px; }
.bnr3-preset--active, .bnr3-preset--active:hover { border-color: var(--fnd-ink); box-shadow: 0 0 0 1px var(--fnd-ink); }
.bnr3-preset__sw { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--fnd-r-xs); }
.bnr3-preset__n { font-size: 12px; font-weight: 600; line-height: 1.3; text-align: center; }

.bnr3-acc { margin-top: var(--fnd-s4); }
.bnr3-acc .fnd-acc-body > * + * { margin-top: var(--fnd-s4); }
.bnr3-acc .fnd-acc-body > .fnd-field { margin-bottom: 0; }
.bnr3-seg { display: flex; width: 100%; }
.bnr3-seg button { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.bnr3-bg-options { margin-top: var(--fnd-s4); }
.bnr3-bg-options > * + * { margin-top: var(--fnd-s4); }
.bnr3-bg-options--hidden { display: none; }
.bnr3-upload-zone--dragover { border-color: var(--fnd-text-faint); background: var(--fnd-paper); }

/* Colour swatch: the native colour input, drawn as a 44px swatch with
   its name beside it. Page-local; worth promoting as .fnd-color. */
.bnr3-colors { display: flex; flex-wrap: wrap; gap: var(--fnd-s3) var(--fnd-s5); }
.bnr3-color {
  display: inline-flex; align-items: center; gap: var(--fnd-s2);
  min-height: 44px; font-size: var(--fnd-t-sm); font-weight: 600; cursor: pointer;
}
.bnr3-color input[type="color"] {
  flex: none; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--fnd-edge); border-radius: var(--fnd-r-sm);
  background: none; cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease;
}
.bnr3-color input[type="color"]:hover { transform: translateY(-1px); border-color: var(--fnd-text-faint); }
.bnr3-color input[type="color"]:focus-visible { outline: 2px solid var(--fnd-accent-deep); outline-offset: 2px; }
.bnr3-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.bnr3-color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.bnr3-color input[type="color"]::-moz-color-swatch { border: 0; border-radius: 6px; }

/* A size slider with its number, and its colour beside it. */
.bnr3-line + .bnr3-line { margin-top: var(--fnd-s4); }
.bnr3-line__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--fnd-s3); }
.bnr3-line__top .fnd-label { margin-bottom: 0; }
.bnr3-val { font-size: var(--fnd-t-meta); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--fnd-text-soft); }
.bnr3-line__row { display: flex; align-items: center; gap: var(--fnd-s3); margin-top: var(--fnd-s1); }
.bnr3-line__row .fnd-range { flex: 1 1 auto; min-width: 0; }
.bnr3-outline { display: flex; align-items: center; justify-content: space-between; gap: var(--fnd-s3); margin-top: var(--fnd-s4); }

/* Where the words sit: a 3 x 3 pad. */
.bnr3-pos { display: grid; grid-template-columns: repeat(3, 52px); gap: var(--fnd-s2); }
/* Each pad key is the shared .fnd-iconbtn, outlined so the pad reads as
   a grid; the chosen key fills with ink (aria-pressed mirrors the
   engine's chosen class). */
.bnr3-pos .fnd-iconbtn { width: 52px; height: 52px; border: 1px solid var(--fnd-rule); border-radius: var(--fnd-r-sm); }
.bnr3-pos .fnd-iconbtn[aria-pressed="true"],
.bnr3-pos .fnd-iconbtn[aria-pressed="true"]:hover { background: var(--fnd-ink); border-color: var(--fnd-ink); color: var(--fnd-on-ink); }

.bnr3-dl__btn { width: 100%; }
.bnr3-dl__meta { margin: var(--fnd-s2) 0 0; text-align: center; font-size: var(--fnd-t-meta); color: var(--fnd-text-soft); }
.bnr3-dl__note { margin-top: var(--fnd-s3); }

/* ------------------------------------------------------------------
   4. EACH SCREEN: a channel page top, as YouTube lays it out
   ------------------------------------------------------------------ */
.bnr3-views .fnd-tool-h3 { margin: 0 0 var(--fnd-s3); }
.bnr3-view { margin: 0; }
.bnr3-view + .bnr3-view { margin-top: var(--fnd-s4); }
.bnr3-view__k {
  display: flex; align-items: center; gap: 6px; margin-bottom: var(--fnd-s2);
  font-size: var(--fnd-t-meta); font-weight: 700; color: var(--fnd-text-soft);
}
.bnr3-view__pic { overflow: hidden; border-radius: var(--fnd-r-sm); background: var(--fnd-ink); }
.bnr3-view__pic canvas { display: block; width: 100%; height: auto; }
.bnr3-view__pic--ph { max-width: 320px; }
.bnr3-yt { display: flex; align-items: center; gap: var(--fnd-s2); margin-top: var(--fnd-s2); min-width: 0; }
.bnr3-yt__av { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--fnd-paper-2); border: 1px solid var(--fnd-rule); }
.bnr3-yt__name {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--fnd-display-font); font-size: var(--fnd-t-sm); font-weight: 700;
}
.bnr3-yt__sub {
  flex: none; padding: 4px 12px; border-radius: 999px;
  background: var(--fnd-ink); color: var(--fnd-on-ink); font-size: 12px; font-weight: 700;
}
.bnr3-views__note { margin-top: var(--fnd-s3); }

.bnr3-offer p { margin: var(--fnd-s2) 0 var(--fnd-s3); color: var(--fnd-text-soft); }
.bnr3-offer .fnd-tool-h3 { margin: 0; }

/* ------------------------------------------------------------------
   5. THE GUIDE
   ------------------------------------------------------------------ */
.bnr3-tbl td:last-child { font-variant-numeric: tabular-nums; }
.fnd .bnr3-tbl tbody td:not(:first-child) { white-space: normal; }
.bnr3-tbl__sub { display: block; margin-top: 2px; font-size: var(--fnd-t-meta); color: var(--fnd-text-soft); }
/* Links inside the reading text get a 24px hit area without moving the
   lines. Questions balance so no word sits alone. */
.bnr3-guide .fnd-tool-read p a { padding: 3px 0; }
.bnr3-qa__list summary { text-wrap: balance; }
.bnr3-src { margin-top: var(--fnd-s4); font-size: var(--fnd-t-meta); color: var(--fnd-text-soft); }

/* ------------------------------------------------------------------
   6. PHONE: the banner stays pinned under the header while you type
   ------------------------------------------------------------------ */
/* Pinned only on a phone tall enough to keep the box being typed in on
   screen (a 375px banner is about 190px high), and let go while typing on
   a short screen (.bnr3-typing, set by banner-maker.js). Tablets do not
   pin: at 768px the banner alone would be over 400px. */
@media (max-width: 767px) and (min-height: 600px) {
  .bnr3-stage {
    position: sticky; top: var(--header-height, 60px); z-index: 5;
    margin: 0 calc(-1 * var(--fnd-s4)); padding: var(--fnd-s2) var(--fnd-s4);
  }
  .bnr3-typing .bnr3-stage { position: static; }
  .bnr3-ctrl .fnd-input, .bnr3-ctrl .fnd-picker-btn, .bnr3-ctrl select {
    scroll-margin-top: calc(var(--header-height, 60px) + 56.25vw + 24px);
  }
}
@media (max-width: 1023px) {
  .bnr3-top__in { padding-bottom: 0; }
}
@media (max-width: 767px) {
  .bnr3-frame { border-radius: var(--fnd-r-sm); }
  .bnr3-safe__tv { border-radius: var(--fnd-r-sm); }
  .bnr3-safe__tv .bnr3-safe__k { display: none; }
  .bnr3-presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bnr3-pos { grid-template-columns: repeat(3, 56px); }
  .bnr3-pos .fnd-iconbtn { width: 56px; height: 56px; }
  .bnr3-view__pic--ph { max-width: none; }
}
@media (max-width: 359px) {
  .bnr3-presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
