/* =====================================================================
   YouTube pane — owned by js/youtube.js.
   Only tokens and shared components from base.css; every class starts with yt-.
   data-size on .yt / .yt-tools: xs (< 420 px wide or < 300 px tall) · s · m · l
   ===================================================================== */

.yt {
  --yt-stage: #04060a;                      /* the video area is dark in both themes, like the player itself */
  --yt-on-stage: #dbe3f2;
  --yt-pad: clamp(10px, 1.8vmin, 18px);
  --yt-thumb-w: 116px;
  --yt-badge-bg: rgba(6, 9, 15, .84);
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--yt-stage);
}

/* ---------- header (lives in the shell's .pane__tools) ---------- */
.yt-tools {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 880px;                           /* a search bar wider than this only gets harder to reach */
  display: flex;
  align-items: center;
  gap: clamp(4px, .8vmin, 8px);
}
.yt-lead { display: grid; place-items: center; flex: none; }
.yt-browse[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.yt-tools[data-size="xs"] .yt-lead { display: none; }
.yt-tools[data-size="xs"] .yt-field { padding-left: 14px; }
/* Under ~340 px the pill would shrink to a stub. Idle, it stays small and drops the clear button; while it is being used it
   takes over the whole header (the shell's header is positioned against .pane, which is position: relative). */
.yt-tools[data-narrow]:not(:focus-within) .yt-clear { display: none; }
.yt-tools[data-narrow] .yt-field:focus-within {
  position: absolute;
  top: calc((var(--hdr) - var(--field-h)) / 2);
  right: 8px;
  left: 8px;
  z-index: 6;
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
/* The clear button fills the right end cap of the pill; ::after adds the last pixels so the touch target stays >= 44 px. */
.yt-field .yt-clear { position: relative; width: calc(var(--field-h) - 2px); height: calc(var(--field-h) - 2px); margin-right: -5px; border-radius: 50%; }
.yt-clear::after { content: ""; position: absolute; top: -3px; right: -3px; bottom: -3px; left: -3px; }

/* ---------- the player area ---------- */
.yt-stage { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: var(--yt-stage); }
.yt-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #000; }
.yt-stage.is-settling .yt-frame { pointer-events: none; }      /* right after a card tap: a double tap must not pause the video */

.yt-state {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: var(--yt-pad);
  overflow: auto;
  text-align: center;
  color: var(--yt-on-stage);
}
.yt-state:empty { opacity: 0; pointer-events: none; }          /* stays in the tree so screen readers hear the next message */
.yt-state[data-kind="error"] { background: var(--surface); color: var(--text-2); }
.yt-state[data-kind="busy"] .spinner { border-color: rgba(255, 255, 255, .2); border-top-color: var(--accent); }
.yt-state__card { display: grid; justify-items: center; gap: 10px; max-width: 460px; }
.yt-state__card > .icon { --icon: 44px; color: var(--warn); }
.yt-state__card h3 { color: var(--text); font-size: 1.2em; line-height: 1.25; }
.yt-state__card p { margin: 0; }
.yt-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.yt[data-size="xs"] .yt-state__card > .icon { --icon: 32px; }
.yt[data-tiny] .yt-state__card > .icon,
.yt[data-tiny] .yt-state__card p { display: none; }

/* ---------- the browse overlay ---------- */
.yt-overlay { outline: none; }
.yt-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--yt-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.yt-tabs { flex: 1 1 auto; min-width: 0; padding: 4px 3px; }   /* room for the focus ring that overflow would clip */
.yt-tabs .chip { min-height: var(--tap); }                          /* touch target >= 44 px */
.yt[data-size="xs"] .yt-tabs .chip { padding: 0 12px; }
.yt[data-size="xs"] .yt-tabs .chip .icon,
.yt[data-size="s"] .yt-tabs .chip .icon { display: none; }          /* five tabs must fit a narrow pane */

.yt-panel {
  min-height: 100%;
  padding: var(--yt-pad);
  display: grid;
  align-content: start;
  gap: var(--yt-pad);
}
.yt-panel > .empty-state { height: auto; align-self: center; padding-top: 28px; padding-bottom: 28px; }
/* very short panes (3 stacked on a small screen): spend the height on content, not on bars and headings */
.yt[data-tiny] .yt-bar { padding-top: 2px; padding-bottom: 2px; }
.yt[data-tiny] .yt-tabs { padding-top: 2px; padding-bottom: 2px; }
.yt[data-tiny] .yt-panel { padding-top: 6px; }
.yt[data-tiny] .yt-head--bare { display: none; }
.yt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.yt-head .section-title { margin: 0; font-size: max(15px, .95em); }
.yt-loading { display: flex; align-items: center; gap: 12px; padding: 18px 4px; color: var(--text-2); }
.yt-hint { margin: 0; color: var(--muted); font-size: max(15px, .92em); }
.yt-source { margin: 0; text-align: center; color: var(--muted); font-size: max(15px, .9em); }
.yt-more { display: grid; justify-items: center; gap: 8px; }

/* notices: the base component, plus a body column for title / text / buttons */
.yt-notice__body { display: grid; gap: 4px; min-width: 0; }
.yt-notice__body strong { color: var(--text); }
.yt-notice__body .yt-actions { justify-content: flex-start; margin-top: 6px; }

/* ---------- cards: tiles on wide panes, rows on narrow / short ones ---------- */
.yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: var(--yt-pad);
}
.yt-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: transform .1s;
}
.yt-card:active { transform: scale(.98); }
.yt-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding-top: 56.25%;                                   /* 16:9 without aspect-ratio (Safari 14) */
  overflow: hidden;
  border-radius: calc(var(--radius) * .5);
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2));
}
.yt-thumb > img,
.yt-thumb__ph { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.yt-thumb > img { object-fit: cover; }
.yt-thumb__ph { display: grid; place-items: center; color: var(--muted); }
.yt-thumb__ph .icon { --icon: 34px; }
.yt-card[aria-current="true"] .yt-thumb { box-shadow: 0 0 0 3px var(--accent); }
.yt-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 7px;
  background: var(--yt-badge-bg);
  color: #fff;
  font-size: max(15px, .9em);                              /* text stays >= 15 px even on badges */
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}
.yt-badge .icon { --icon: 13px; }
.yt-badge--live { background: #e0112b; letter-spacing: .03em; }
.yt-card__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.yt-card__title { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.yt-card__meta { color: var(--muted); font-size: max(15px, .92em); }

.yt[data-size="xs"] .yt-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.yt[data-size="xs"] .yt-card {
  display: grid;
  grid-template-columns: var(--yt-thumb-w) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}
.yt[data-size="xs"] .yt-card[aria-current="true"] { border-color: var(--accent); }
.yt[data-size="xs"] .yt-card__stats { display: none; }
.yt[data-size="xs"] .yt-thumb { border-radius: 9px; }
.yt[data-size="xs"] .yt-thumb__ph .icon { --icon: 24px; }

/* ---------- settings ---------- */
.yt-settings { display: grid; gap: var(--yt-pad); width: 100%; max-width: 680px; margin: 0 auto; }
.yt-box { display: grid; gap: 10px; padding: clamp(12px, 2vmin, 18px); }
.yt-box p { margin: 0; color: var(--text-2); }
.yt-box p.muted { color: var(--muted); }
.yt-box__title { display: flex; align-items: center; gap: 10px; font-size: 1.05em; }
.yt-box__title .icon { --icon: 22px; color: var(--accent); }
.yt-keyrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.yt-keyrow .field { flex: 1 1 240px; background: var(--surface); }
.yt-saved code {
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font: 600 max(15px, .95em) ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .03em;
}
.yt-steps { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; color: var(--text-2); }
.yt-steps li::marker { color: var(--accent); font-weight: 700; }
