/* boxes.css: owned by stream B (Boxes + chat); linked from index.html after food.css.
   The box pages (mantras, vision board, an agent's box), the chat sheet, and Capture's box bar. */

/* ------------------------------------------------------------------ a box's page */
.bx-page { padding-bottom: 72px; }
.bx-back { min-height: 0; }
.bx-kicker { margin: 0 0 6px; font: 500 var(--fs-2xs) var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--bone-faint); }
.bx-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 28px 36px; align-items: start; }
.bx-cols.one { grid-template-columns: minmax(0, 1fr); }
.bx-main, .bx-aside { min-width: 0; }
.bx-aside { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 959px) { .bx-cols { grid-template-columns: minmax(0, 1fr); } }

.bx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.bx-grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.bx-tile { position: relative; min-width: 0; display: flex; flex-direction: column; border-radius: var(--radius); border: 1px solid var(--line-card); background: var(--card); }
.bx-cardbox { padding: 16px; gap: 8px; }
.bx-ct { margin: 0; font: 400 var(--fs-2xl)/1.4 var(--serif); color: var(--bone); overflow-wrap: anywhere; }
.bx-row { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.bx-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin: 0; font-size: var(--fs-xs); color: var(--bone-faint); }
.bx-meta a { color: var(--sea); }
.bx-info { margin: -6px 0 10px; font-size: var(--fs-xs); line-height: 1.45; color: var(--bone-faint); }
.bx-actions { display: flex; flex-wrap: wrap; gap: 10px 12px; margin: 16px 0 6px; }
.bx-drop { margin-top: 18px; max-width: 640px; }

/* The same small control for Copy, Take out, Chat */
.bx-copy { border: 0; background: none; padding: 6px 4px; min-height: 32px; font-size: var(--fs-xs); color: var(--bone-faint); }
.bx-copy:hover { color: var(--sea); }
.bx-tile > .bx-copy { position: absolute; top: 6px; right: 8px; opacity: 0; transition: opacity .2s; }
.bx-tile:hover > .bx-copy, .bx-tile:focus-within > .bx-copy, .bx-copy:focus-visible { opacity: 1; }
@media (hover: none) { .bx-tile > .bx-copy { opacity: .7; } }
.bx-chat {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 16px; cursor: pointer;
  border-radius: var(--pill); border: 1px solid var(--sea-line); background: none; color: var(--sea); font-size: var(--fs-md);
}
.bx-chat svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bx-chat:hover { background: var(--sea-wash); }
.bx-chat.danger { border-color: var(--line-strong); color: var(--bone-dim); }
.bx-chat.danger:hover { color: var(--rose); border-color: var(--rose-line); background: none; }
.bx-tag { display: inline-block; padding: 1px 7px; border-radius: var(--pill); border: 1px solid var(--moon-line-strong); color: var(--moon); font: 400 var(--fs-2xs) var(--sans); letter-spacing: .04em; text-transform: none; }

/* Mantras */
.bx-mantra { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 24px; border-radius: var(--radius); color: inherit; }
.bx-mantra:hover { background: var(--panel-hover); }
.bx-mk { font: 500 var(--fs-sm) var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--bone-dim); }
.bx-mt { font: 400 var(--fs-h3)/1.5 var(--serif); color: var(--bone); overflow-wrap: anywhere; }
.bx-mantra-text { position: relative; padding: 26px 28px; border-radius: var(--radius); border: 1px solid var(--line-card); background: var(--card); }
.bx-mantra-text p { margin: 0; font: 400 var(--fs-h2)/1.55 var(--serif); color: var(--bone); overflow-wrap: anywhere; }
.bx-mantra-text .bx-copy { position: absolute; top: 8px; right: 10px; }

/* The cards beside a page: sources, drops, what a card is */
.bx-side { padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line-card); background: var(--card); }
.bx-side .m-lbl { margin-bottom: 10px; }
.bx-side.inferred-card { border-color: var(--moon-line); background: var(--moon-wash); }
.bx-instr { margin: 0; font: 400 var(--fs-md)/1.55 var(--sans); color: var(--moon); white-space: pre-wrap; }
.bx-drops { list-style: none; margin: 0; padding: 0; }
.bx-drops li { position: relative; padding: 10px 0; }
.bx-drops li + li { border-top: 1px solid var(--line); }
.bx-drops li:first-child { padding-top: 0; }
.bx-drops a { display: flex; flex-direction: column; gap: 4px; color: inherit; padding-right: 40px; }
.bx-dw { font: 400 var(--fs-base)/1.45 var(--serif); color: var(--bone); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bx-drops a:hover .bx-dw { color: var(--sea); }
.bx-drops .bx-copy { position: absolute; top: 4px; right: 0; opacity: 0; }
.bx-drops li:first-child .bx-copy { top: -4px; }
.bx-drops li:hover .bx-copy, .bx-drops li:focus-within .bx-copy { opacity: 1; }
@media (hover: none) { .bx-drops .bx-copy { opacity: .7; } }
.bx-src { padding: 6px 0; }
.bx-src + .bx-src { border-top: 1px solid var(--line); }
.bx-quote { display: block; margin: 0 0 4px; font: italic 400 var(--fs-base)/1.5 var(--serif); color: var(--bone-dim); quotes: "“" "”"; }
.bx-fold { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line-card); background: var(--card); }
.bx-fold summary { cursor: pointer; font-size: var(--fs-sm); color: var(--bone-dim); }
.bx-fold .bx-info { margin: 8px 0 10px; }
.bx-earlier { padding: 8px 0; border-top: 1px solid var(--line); }
.bx-earlier p:first-child { margin: 0 0 4px; font: 400 var(--fs-md)/1.5 var(--serif); color: var(--bone-dim); }

/* The vision board: a collage of prints and notes laid out by boxes.js */
.bx-page.over { outline: 2px dashed var(--sea); outline-offset: -6px; border-radius: var(--radius); }
.bx-stage { position: relative; isolation: isolate; width: 100%; margin: 14px 0 8px; }
.bx-piece { position: absolute; cursor: pointer; border-radius: 3px; box-shadow: 0 2px 8px rgba(0,0,0,.4); transition: transform .25s var(--ease), opacity .25s, box-shadow .25s; -webkit-tap-highlight-color: transparent; }
.bx-piece:focus-visible { outline: 2px solid var(--sea); outline-offset: 3px; }
.bx-stage.has-sel .bx-piece:not(.on) { opacity: .5; }
.bx-piece.on { box-shadow: 0 0 0 3px var(--sea), 0 12px 28px rgba(0,0,0,.55); }
.bx-print { width: 100%; height: 100%; box-sizing: border-box; background: #fff; border-radius: 3px; }
.bx-frame { position: relative; width: 100%; height: 100%; overflow: hidden; background: #d9dce2; }
.bx-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bx-cap { position: absolute; left: 0; right: 0; bottom: 0; box-sizing: border-box; font-family: var(--serif); line-height: 1.2; color: #fff;
  background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,.55)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bx-cap.him { font-style: italic; }
.bx-note { width: 100%; height: 100%; box-sizing: border-box; overflow: hidden; border-radius: 3px; font-family: var(--serif); line-height: 1.22; color: #1f2328; position: relative; }
.bx-making { position: absolute; right: 6px; bottom: 6px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(31,35,40,.25); border-top-color: rgba(31,35,40,.7); animation: bxspin 1s linear infinite; }
@keyframes bxspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bx-making { animation: none; } }

/* The selected card's panel, stuck to the foot of the page */
.bx-panel-wrap { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); z-index: 20; display: flex; justify-content: center; pointer-events: none; }
@media (min-width: 960px) { .bx-panel-wrap { bottom: 12px; } }
.bx-sel { pointer-events: auto; width: min(720px, 100%); max-height: 46vh; overflow: auto; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--ink-1); box-shadow: 0 -4px 24px rgba(0,0,0,.45); animation: rise .3s var(--ease) both; }
.bx-sel-top { display: flex; gap: 12px; align-items: flex-start; }
.bx-thumb { width: 64px; height: 64px; flex: none; object-fit: cover; border-radius: var(--radius-sm); }
.bx-sel-words { flex: 1; min-width: 0; }
.bx-sel-words p:first-child { margin: 0 0 4px; font: 400 var(--fs-2xl)/1.4 var(--serif); color: var(--bone); overflow-wrap: anywhere; }
.bx-sel-words p.him { font-size: var(--fs-lg); font-style: italic; }
.bx-x { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--ink-2); color: var(--bone-dim); font-size: 18px; line-height: 1; }
.bx-sel .m-lbl-sm { margin: 12px 0 4px; }
.bx-srcs { max-height: 150px; overflow: auto; }
.bx-sel-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 12px; }
.bx-sel-acts .bx-chat { min-height: 40px; padding: 0 14px; }

/* "Where it went", in a capture's detail */
.bx-went-link { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font: 400 var(--fs-2xl) var(--serif); color: var(--bone); }
.bx-went-link svg { width: 16px; height: 16px; fill: none; stroke: var(--bone-faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bx-went-link:hover { color: var(--sea); }

/* ------------------------------------------------------------------ the chat sheet */
.chat-sheet { width: min(560px, 100vw); height: min(680px, 86vh); display: flex; flex-direction: column; overflow: hidden; }
.chat-sheet[open] { display: flex; }
.chat-head { display: flex; align-items: baseline; gap: 14px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; margin: 0; font: 400 var(--fs-h3)/1.2 var(--serif); overflow-wrap: anywhere; }
.chat-head .link-btn { margin: 0; flex: none; }
.chat-done { font-weight: 600; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-intro { margin: 0; font: italic 400 var(--fs-xl)/1.5 var(--serif); color: var(--bone-dim); }
.chat-msg { max-width: 92%; }
.chat-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 var(--fs-xl)/1.5 var(--serif); color: var(--bone); }
.chat-msg.him { align-self: flex-end; padding: 10px 14px; border-radius: var(--radius); background: var(--ink-2); }
.chat-msg.him p { font: 400 var(--fs-base)/1.45 var(--sans); }
.chat-msg .chat-did { display: flex; gap: 6px; align-items: baseline; margin-top: 6px; font: 400 var(--fs-sm)/1.4 var(--sans); color: var(--sea); }
.chat-did svg { width: 14px; height: 14px; flex: none; align-self: center; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat-thinking { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-sm); color: var(--bone-faint); }
.chat-dots { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--bone-dim); animation: bxspin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .chat-dots { animation: none; } }
.chat-error { margin: 0; font-size: var(--fs-sm); color: var(--rose); }
.sheet .chat-composer { width: auto; margin: 0 14px 14px; padding: 7px 7px 7px 18px; }
@media (max-width: 559px) {
  .chat-sheet { width: 100vw; max-width: 100vw; height: 88vh; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; }
  .sheet .chat-composer { margin-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* ------------------------------------------------------------------ Capture's boxes */
.boxbar-wrap { position: relative; z-index: 5; align-self: stretch; display: flex; flex-direction: column; align-items: center; margin: 0 0 clamp(14px, 3vh, 26px); }
.boxbar { display: flex; align-items: center; max-width: 100%; padding: 4px; border-radius: var(--radius); background: var(--ink-2); border: 1px solid var(--line-card); }
.box-seg, .box-more {
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--bone-dim); font-size: var(--fs-lg); white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.box-seg svg, .box-more svg, .box-tile-ico svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.box-seg.on { background: var(--sea); color: var(--ink-0); }
.box-more { width: 50px; justify-content: center; padding: 0; color: var(--bone-dim); }
@media (hover: hover) { .box-seg:not(.on):hover, .box-more:hover { color: var(--bone); background: var(--ink-3); } }
@media (max-width: 559px) { .box-seg:not(.on) .box-seg-t { display: none; } .box-seg { padding: 0 14px; } }
.box-into { margin: 10px 0 0; max-width: 460px; font-size: var(--fs-sm); line-height: 1.45; color: var(--sea); }
.box-panel {
  position: absolute; z-index: 41; top: 56px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); max-height: 50vh; overflow: auto;
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--line-card); background: var(--ink-1); box-shadow: 0 16px 40px rgba(0,0,0,.5);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 16px 12px; text-align: center;
}
.box-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; padding: 0; color: var(--bone-dim); font-size: var(--fs-xs); line-height: 1.25; }
.box-tile-ico { width: 52px; height: 52px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--ink-2); color: var(--bone-dim); }
.box-tile.on { color: var(--sea); }
.box-tile.on .box-tile-ico { background: var(--sea); color: var(--ink-0); }
.box-tile.new .box-tile-ico { background: none; border: 1px dashed var(--line-strong); color: var(--bone-dim); }
.box-tile.new { color: var(--bone-faint); }
@media (hover: hover) { .box-tile:not(.on):hover .box-tile-ico { background: var(--ink-3); color: var(--bone); } }
.kind-btn[hidden] { display: none; }
