/* app/assets/stylesheets/components/tiles.css
   Tiling working area — chromeless panes split by hairline separators. A new pane splits the
   largest pane; you can swap two panes, extract a pane to a tab, or close it. (Resizing and
   collapse are intentionally off for now — we'll reach for a library if we want them back.)
   The pane is lean; the content decides its own header (embeds get a title bar, app views bring
   their own heading). */

/* .tiles-area fills its parent's height — the host gives it a definite-height ancestor
   (the app shell's `flex-1 min-h-0` scroll container provides this). */
.tiles-area { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tiles-tree { flex: 1 1 auto; display: flex; min-width: 0; min-height: 0; }
/* The master tile's content frame is layout-transparent — its children flow directly in the
   tile body (the scroll container), so wrapping the page in it changes nothing visually. */
turbo-frame#app_content { display: contents; }
.tiles-node { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; }
.tiles-node--row { flex-direction: row; }
.tiles-node--col { flex-direction: column; }

/* a pane: bare content, no border/shadow */
.tile { position: relative; display: flex; flex-direction: column; flex: 1 1 0; min-width: 34px; min-height: 34px; background: #fff; overflow: hidden; }
.tile.is-flash::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--color-gondola, #007390); animation: tile-flash .9s ease forwards; pointer-events: none; z-index: 5; }
@keyframes tile-flash { to { box-shadow: inset 0 0 0 0 rgba(0,0,0,0); } }

.tile-body { flex: 1 1 auto; overflow: auto; min-width: 0; min-height: 0; background: #fff; }
/* app views breathe; embeds fill. The master pane is now the app's main scroll container, so
   match the shell's responsive page padding (px-3 sm:px-4 md:px-5 lg:px-6 py-5) exactly. */
.tile-body:not(.is-embed) { padding: 20px 12px; }
@media (min-width: 640px)  { .tile-body:not(.is-embed) { padding-left: 16px; padding-right: 16px; } }
@media (min-width: 768px)  { .tile-body:not(.is-embed) { padding-left: 20px; padding-right: 20px; } }
@media (min-width: 1024px) { .tile-body:not(.is-embed) { padding-left: 24px; padding-right: 24px; } }
.tile-body.is-embed { background: #525659; overflow: hidden; padding: 0; }
.tile-body .tile-frame, .tile-body .tile-iframe { width: 100%; height: 100%; border: 0; display: block; }
.tile-body .img-wrap { min-height: 100%; display: flex; align-items: flex-start; justify-content: center; padding: 16px; }
.tile-body .img-wrap img { max-width: 100%; background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.4); }

/* documents: a slim title bar (filename + actions) ABOVE the iframe, so the browser's native
   PDF/image toolbar stays reachable (floating controls would cover it) */
.tile-bar { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: #f8fafc; border-bottom: 1px solid #eef2f4; flex: 0 0 auto; }
.tile-bar-title { font-size: 12px; font-weight: 600; color: #334155; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-bar-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.tile-bar .tile-btn { background: transparent; box-shadow: none; backdrop-filter: none; }
.tile-bar .tile-btn:hover { background: var(--color-gondola-light, #DFEEF1); }

/* app-view panes: chromeless — controls float over the corner and fade in on hover/focus */
.tile-chrome { position: absolute; top: 0; right: 0; display: flex; padding: 6px 8px; pointer-events: none; z-index: 3; }
.tile-actions { pointer-events: auto; display: flex; gap: 3px; opacity: 0; transition: opacity .12s ease; }
.tile:hover .tile-actions, .tile.is-focused .tile-actions { opacity: 1; }
.tile-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); color: #64748b; box-shadow: 0 1px 3px rgba(15,23,42,.12); font-size: 12px; line-height: 1; cursor: pointer; }
.tile-btn:hover { color: var(--color-gondola-dark, #006380); background: #fff; }
.tile-btn.is-close:hover { color: #b91c1c; }

/* hairline separator — divides two panes; hover reveals the control cluster (grow / swap / grow) */
.tiles-gutter { flex: 0 0 1px; background: #e5e7eb; position: relative; z-index: 4; }
.tiles-gutter::before { content: ""; position: absolute; }   /* widened hover target for the controls */
.tiles-gutter--row::before { top: 0; bottom: 0; left: -4px; right: -4px; }
.tiles-gutter--col::before { left: 0; right: 0; top: -4px; bottom: -4px; }
.tiles-gutter:hover { background: var(--color-gondola, #007390); }
/* control cluster, centred on the separator and laid out ALONG it (so moving between buttons never
   leaves the hover zone): a row on a horizontal (col) separator, a stack on a vertical (row) one. */
.tiles-gutter-controls { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; gap: 2px; opacity: 0; transition: opacity .12s ease; z-index: 6; }
.tiles-gutter--row .tiles-gutter-controls { flex-direction: column; }
.tiles-gutter:hover .tiles-gutter-controls { opacity: 1; }
.tiles-gutter-btn { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 4px; background: #fff; color: #64748b; box-shadow: 0 1px 4px rgba(15,23,42,.28); font-size: 12px; line-height: 1; cursor: pointer; }
.tiles-gutter-btn:hover { color: var(--color-gondola-dark, #006380); }

/* mobile: one pane at a time (the tree shows only the active pane) */
@media (max-width: 767px) {
  .tiles-tree.is-mobile .tile:not(.is-active-mobile) { display: none; }
  .tiles-tree.is-mobile .tiles-node { flex-direction: column; }
  .tiles-tree.is-mobile .tiles-gutter { display: none; }
}
