/* Barn code (package e): the share dialog, the confirmation and the viewport status chip.
 * Follows the studio's glass look — sky-tinted panels on navy ink, Lora headings, Inter body —
 * and the foundation z-index contract (#viewport-status is layer 6). Only transform and opacity
 * animate, and the one pulse stops under prefers-reduced-motion. */

:root {
  --bc-ink: #173950; --bc-navy: #1e3a5f; --bc-blue: #3d6bb4; --bc-sky: #b8d0ec;
  --bc-live: #2f9e6b; --bc-wait: #3d6bb4; --bc-warn: #c98a1b; --bc-rest: #7b8b97;
}

/* ---- status chip --------------------------------------------------------------------------- */

/* The display rule below outranks the browser's [hidden] rule, so restate it (same contract as
 * studio-foundation.css for the menu button). */
.barn-code-chip[hidden], #barn-code-join-form[hidden], [data-bc-view][hidden] { display: none !important; }

.barn-code-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 13px;
  border: 1px solid #fff; border-radius: 999px; background: #eaf3f7e6; backdrop-filter: blur(16px);
  color: var(--bc-ink); font: 600 12px/1 Inter, system-ui, sans-serif; letter-spacing: .01em;
  box-shadow: 0 8px 20px #0d2c4a1f, 0 1px 0 #ffffffb0 inset; cursor: pointer;
  transition: transform .16s cubic-bezier(.2,.9,.25,1.15), box-shadow .16s ease, background-color .16s ease;
}
.barn-code-chip:hover { background: #f3f9fce8; box-shadow: 0 10px 24px #0d2c4a2b, 0 1px 0 #fff inset; }
.barn-code-chip:active { transform: scale(.97); }
.barn-code-chip:focus-visible { outline: 3px solid var(--bc-blue); outline-offset: 3px; }
.bc-chip-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .08em; }
.bc-chip-state { color: #3c5f7c; font-weight: 600; }
.bc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bc-rest); box-shadow: 0 0 0 3px #ffffff8c; flex: none; }
.barn-code-chip[data-state="live"] .bc-dot { background: var(--bc-live); }
.barn-code-chip[data-state="waiting"] .bc-dot { background: var(--bc-wait); animation: bc-pulse 1.6s ease-in-out infinite; }
.barn-code-chip[data-state="error"] .bc-dot,
.barn-code-chip[data-state="offline"] .bc-dot { background: var(--bc-warn); }
.barn-code-chip[data-state="error"] .bc-dot { animation: bc-pulse 1.6s ease-in-out infinite; }
.barn-code-chip[data-state="paused"] .bc-dot,
.barn-code-chip[data-state="disabled"] .bc-dot { background: var(--bc-rest); }
@keyframes bc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* The code alone on phones: the state is on the button's aria-label, and the pill has to stay
 * clear of the add-on tray on the right (the foundation's phone width for the status slot). */
html.studio-phone .viewport-status { left: 18px; max-width: calc(100% - 200px); }
html.studio-phone .barn-code-chip { min-height: 44px; padding: 8px 14px; font-size: 13px; }
html.studio-phone .bc-chip-state { display: none; }
@media (max-width: 360px) {
  html.studio-phone .barn-code-chip { padding-inline: 8px; gap: 6px; font-size: 12px; }
}

/* The code beside "Barn code" in the app menu. */
#barn-code { display: flex; align-items: baseline; gap: 8px; }
.barn-code-menu-code:not(:empty) {
  font: 700 11px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em;
  padding: 3px 7px; border-radius: 7px; background: #dceaf6; color: var(--bc-navy);
}

/* ---- dialogs ------------------------------------------------------------------------------- */

.bc-dialog {
  border: 1px solid #fff; border-radius: 24px; max-width: 440px; width: calc(100% - 28px);
  margin: max(16px, env(safe-area-inset-top)) auto auto; max-height: calc(100dvh - 32px); overflow: auto;
  background: #edf5fa; color: var(--bc-ink); padding: 32px 25px 26px;
  box-shadow: 0 30px 100px #082c4960, 0 2px 0 #ffffffcc inset;
}
.bc-dialog::backdrop { background: #0825379c; backdrop-filter: blur(8px); }
.bc-dialog .bc-title { font-family: 'Lora', Georgia, serif; font-size: 27px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
.bc-dialog p { font-size: 14px; line-height: 1.7; margin: 0 0 10px; }
.bc-lead { color: #2c5170; }
.bc-note { font-size: 12.5px !important; line-height: 1.6 !important; color: #4a6b86; }
.bc-eyebrow { font: 700 11px/1 Inter, system-ui, sans-serif; letter-spacing: .18em; color: #5b7e9c; margin: 0 0 8px !important; }
.bc-message:empty { display: none; }
.bc-message { margin-top: 12px; padding: 9px 12px; border-radius: 12px; background: #dceaf6; color: #1d4363; font-size: 13px !important; }
.bc-close { position: absolute; right: 9px; top: 7px; border: 0; background: none; font-size: 25px; line-height: 1; color: #3c5f7c; cursor: pointer; border-radius: 10px; padding: 2px 8px; }
.bc-close:hover { color: var(--bc-navy); background: #ffffffa8; }
.bc-close:focus-visible { outline: 3px solid var(--bc-blue); outline-offset: 2px; }

#barn-code-value {
  font: 700 36px/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .14em;
  margin: 0 0 16px; color: var(--bc-navy); text-align: center;
  padding: 14px 10px; border-radius: 16px; background: linear-gradient(160deg, #ffffff, #dceaf6);
  box-shadow: 0 10px 26px #14365018, 0 1px 0 #fff inset;
}

.bc-field { display: block; font: 600 12px/1.4 Inter, system-ui, sans-serif; color: #4a6b86; margin: 0 0 12px; }
.bc-field input {
  display: block; width: 100%; margin-top: 5px; min-height: 44px; padding: 10px 12px;
  border: 1px solid #c3d8ea; border-radius: 12px; background: #fff; color: var(--bc-ink);
  font: 600 15px/1.2 Inter, system-ui, sans-serif; box-sizing: border-box;
}
#barn-code-link { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
#barn-code-input { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; }
.bc-field input:focus-visible { outline: 3px solid var(--bc-blue); outline-offset: 1px; border-color: var(--bc-blue); }
.bc-hint { font-size: 12.5px !important; color: #7a5a12; background: #fdf3dd; border-radius: 10px; padding: 7px 10px; }

.bc-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 12px; }
.bc-actions-quiet { margin-top: 16px; padding-top: 14px; border-top: 1px solid #d3e3f0; }
.bc-dialog button.bc-primary, .bc-dialog button.bc-ghost {
  min-height: 44px; padding: 11px 18px; border-radius: 13px; cursor: pointer;
  font: 650 14px/1 Inter, system-ui, sans-serif; touch-action: manipulation;
  transition: transform .16s cubic-bezier(.2,.9,.25,1.15), box-shadow .16s ease, background-color .16s ease;
}
.bc-dialog button.bc-primary {
  border: 0; color: #fff; background: linear-gradient(150deg, #345979, #122f4b);
  box-shadow: 0 8px 20px #16365036, 0 1px 0 #ffffff38 inset;
}
.bc-dialog button.bc-primary:hover { background: linear-gradient(150deg, #3d6787, #17395a); }
.bc-dialog button.bc-ghost { border: 1px solid #c3d8ea; background: #ffffffcc; color: #22506f; }
.bc-dialog button.bc-ghost:hover { background: #fff; border-color: var(--bc-blue); }
.bc-dialog button.bc-primary:active, .bc-dialog button.bc-ghost:active { transform: scale(.97); }
.bc-dialog button.bc-primary:focus-visible, .bc-dialog button.bc-ghost:focus-visible { outline: 3px solid var(--bc-blue); outline-offset: 3px; }
.bc-dialog button[disabled] { opacity: .6; cursor: default; }
#barn-code-create { width: 100%; }
#barn-code-join-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid #d3e3f0; }
#barn-code-join-form .bc-join { width: 100%; }
.bc-link-out { color: var(--bc-blue); font-weight: 650; border-radius: 8px; }
.bc-link-out:focus-visible { outline: 3px solid var(--bc-blue); outline-offset: 3px; }

.bc-confirm { max-width: 390px; }
.bc-confirm .bc-actions { margin-bottom: 0; }

@media (max-width: 650px) {
  #barn-code-value { font-size: 32px; }
  .bc-dialog { padding: 26px 18px 22px; }
  .bc-dialog .bc-title { font-size: 24px; }
  .bc-actions button { flex: 1 1 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .barn-code-chip, .bc-dialog button.bc-primary, .bc-dialog button.bc-ghost { transition: none; }
  .barn-code-chip[data-state] .bc-dot { animation: none; }
  .barn-code-chip:active, .bc-dialog button.bc-primary:active, .bc-dialog button.bc-ghost:active { transform: none; }
}
