/* boxes.css – the Boxes view. Four squares, each holding four more.
   Every box has its own hue (--h, set inline); its colours are derived from it.
   Open one and its three siblings fold to strips along its edges. */
body.boxes { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #0A0B14; --bg: #0A0B14; }
body.boxes .top { flex: 0 0 auto; padding-top: 10px; padding-bottom: 10px; background: #0A0B14; }
.view-toggle { display: inline-flex; margin-left: auto; border: 2px solid var(--bone); font-family: var(--mono); font-size: 14px; }
.view-toggle a { min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; text-decoration: none; }
.view-toggle a[aria-current="page"] { background: var(--bone); color: var(--ink); }
.view-toggle a:not([aria-current]):hover { background: rgba(236,234,228,0.14); }

.bx-crumbs { flex: 0 0 auto; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; padding: 0 16px; border-bottom: 1px solid var(--rule-soft); font-family: var(--mono); font-size: 14px; color: var(--mute); }
.bx-crumbs button { min-height: 44px; padding: 0 8px; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
.bx-crumbs button:hover { color: var(--bone); }
.bx-crumbs button[aria-current] { color: var(--bone); cursor: default; }
.bx-crumbs .sep { color: rgba(236,234,228,0.3); }
.bx-crumbs .hint { margin-left: auto; padding-right: 8px; }

.bx-stage { flex: 1 1 auto; min-height: 0; padding: 2px; }
.bx-grid { width: 100%; height: 100%; display: grid; gap: 2px; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  transition: grid-template-columns 1.5s cubic-bezier(0.25, 0.1, 0.25, 1), grid-template-rows 1.5s cubic-bezier(0.25, 0.1, 0.25, 1); }

.bx { --c: oklch(0.8 0.16 var(--h)); --deep: oklch(0.2 0.05 var(--h)); --text: oklch(0.86 0.04 var(--h));
  position: relative; min-width: 0; min-height: 0; overflow: hidden; container-type: size; border-radius: 3px;
  background: var(--deep); color: var(--text);
  transition: box-shadow 0.9s ease; }
.bx .bx { --deep: oklch(0.17 0.045 var(--h)); }
.bx .bx .bx { --deep: oklch(0.15 0.04 var(--h)); }
/* the glow that comes up under the pointer */
.bx::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.9s ease;
  background: radial-gradient(circle at center, oklch(0.8 0.16 var(--h) / 0.5) 0%, oklch(0.8 0.16 var(--h) / 0.14) 48%, transparent 72%); }
.bx:not(.open):not(.bx-over):hover::before, .bx:not(.open):not(.bx-over):focus-within::before { opacity: 1; }
.bx:not(.open):not(.bx-over):hover { box-shadow: inset 0 0 0 1px oklch(0.8 0.16 var(--h) / 0.7), inset 0 0 60px oklch(0.8 0.16 var(--h) / 0.28); }
.bx.open { box-shadow: inset 0 0 0 1px oklch(0.8 0.16 var(--h) / 0.45); }

/* little things: a faint numeral and a lamp in each box */
.bx-num { position: absolute; right: 4cqmin; bottom: 1cqmin; font-weight: 900; font-stretch: 125%; font-size: 34cqmin; line-height: 0.8; letter-spacing: -0.04em; color: oklch(0.8 0.16 var(--h) / 0.07); pointer-events: none; transition: color 0.9s ease, opacity 0.5s ease; }
.bx:hover > .bx-num { color: oklch(0.8 0.16 var(--h) / 0.16); }
.bx.open > .bx-num, .bx.shut > .bx-num { opacity: 0; }
.bx-face::before { content: ''; position: absolute; top: 5cqmin; left: 5cqmin; width: 9px; height: 9px; background: oklch(0.8 0.16 var(--h) / 0.4); transition: background 0.6s ease, box-shadow 0.6s ease; }
.bx:hover > .bx-face::before { background: var(--c); box-shadow: 0 0 14px 2px oklch(0.8 0.16 var(--h) / 0.8); }
.bx.shut > .bx-face::before { display: none; }

.bx-face { position: absolute; inset: 0; width: 100%; height: 100%; padding: 5cqmin; display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: inherit; font: inherit; text-align: center; cursor: pointer; transition: opacity 0.5s ease; }
.bx-face:focus-visible { outline: 2px solid var(--c); outline-offset: -5px; }
.bx-name { font-weight: 800; font-stretch: 112%; font-size: clamp(13px, 6.2cqw, 54px); line-height: 1.15; letter-spacing: 0.22em; text-transform: uppercase; margin-right: -0.22em;
  color: oklch(0.82 0.05 var(--h) / 0.72); transition: color 0.8s ease, text-shadow 0.8s ease, letter-spacing 0.9s ease, transform 0.9s ease; overflow-wrap: anywhere; }
.bx:not(.shut) > .bx-face:hover .bx-name, .bx:not(.shut) > .bx-face:focus-visible .bx-name { color: var(--c); letter-spacing: 0.3em; transform: scale(1.06);
  text-shadow: 0 0 28px oklch(0.8 0.16 var(--h) / 0.6), 0 0 60px oklch(0.8 0.16 var(--h) / 0.3); }

.bx-in { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0s linear 0.4s; }
.bx.open > .bx-face { opacity: 0; pointer-events: none; }
.bx.open > .bx-in, .bx-over:not(.shut) > .bx-in { opacity: 1; visibility: visible; transition: opacity 0.7s ease 0.8s, visibility 0s linear 0s; }
.bx-over:not(.shut) > .bx-in { transition-delay: 0s; }
.bx.open > .bx-in { padding: 2px; }
.bx-over.open > .bx-in { padding: 0; }
.bx-over:not(.shut) > .bx-face { display: none; }
.bx-over.shut > .bx-in { opacity: 0; visibility: hidden; }

/* folded siblings */
.bx.shut > .bx-face { padding: 4px; }
.bx.shut > .bx-face .bx-name { font-family: var(--mono); font-weight: 500; font-stretch: 100%; font-size: 12px; letter-spacing: 0.12em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: oklch(0.85 0.06 var(--h) / 0.85); }
.bx.shut.tall > .bx-face .bx-name { writing-mode: vertical-rl; max-width: none; max-height: 100%; }
.bx.shut.corner > .bx-face .bx-name { display: none; }
.bx.shut.corner > .bx-face::after { content: ''; width: 9px; height: 9px; background: var(--c); }
.bx.shut:hover > .bx-face .bx-name { color: var(--c); }

/* overview box: a band of the room's colour, then the words */
.bx-over { background: oklch(0.16 0.035 var(--h)); box-shadow: inset 0 0 0 1px oklch(0.8 0.16 var(--h) / 0.18); }
.bx-leaf { position: absolute; inset: 0; overflow: auto; display: flex; flex-direction: column; }
.bx-art { flex: 0 0 30%; min-height: 28px; position: relative; overflow: hidden;
  background: linear-gradient(120deg, oklch(0.26 0.07 var(--h)), oklch(0.46 0.14 calc(var(--h) + 30))); }
.bx-art::before { content: ''; position: absolute; left: 8%; right: 8%; top: 50%; height: 1px; background: oklch(0.9 0.12 var(--h) / 0.55); }
.bx-art i { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; background: var(--c); box-shadow: 0 0 16px 3px oklch(0.8 0.16 var(--h) / 0.7); }
.bx-art i:nth-child(1) { left: 24%; transform: scale(0.6); } .bx-art i:nth-child(2) { left: 50%; } .bx-art i:nth-child(3) { left: 76%; transform: scale(0.6); }
.bx-copy { flex: 1 1 auto; padding: clamp(10px, 4.5cqmin, 36px); display: flex; flex-direction: column; align-items: flex-start; gap: clamp(6px, 2.2cqh, 16px); }
.bx-kick { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--c); }
.bx-leaf h2 { font-weight: 900; font-stretch: 115%; font-size: clamp(17px, 6.4cqw, 60px); line-height: 0.98; letter-spacing: -0.02em; color: oklch(0.95 0.03 var(--h)); text-wrap: balance; }
.bx-leaf p { font-size: clamp(13px, 2.9cqw, 20px); line-height: 1.45; color: oklch(0.84 0.03 var(--h)); max-width: 36em; text-wrap: pretty; }
.bx-over .bx-leaf p { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden; }
.bx-stats { display: flex; gap: clamp(12px, 5cqw, 40px); padding-top: 6px; border-top: 1px solid oklch(0.8 0.16 var(--h) / 0.25); align-self: stretch; }
.bx-stats div { display: flex; flex-direction: column; }
.bx-stats b { font-weight: 900; font-stretch: 115%; font-size: clamp(15px, 4.4cqw, 32px); color: oklch(0.95 0.03 var(--h)); }
.bx-stats span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: oklch(0.8 0.05 var(--h)); }
.bx-go { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; gap: 10px; border: 1px solid oklch(0.8 0.16 var(--h) / 0.6); color: var(--c); text-decoration: none; font-family: var(--mono); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; transition: background 0.3s ease, color 0.3s ease; }
.bx-go:hover { background: var(--c); color: oklch(0.16 0.04 var(--h)); }
.bx-go svg { flex: 0 0 auto; }
/* a box with no page of its own: centred, like the label it grew from */
.bx-detail { justify-content: center; align-items: center; text-align: center; gap: clamp(8px, 3cqh, 22px); padding: 6cqmin; }
.bx-detail h2 { font-weight: 800; font-stretch: 112%; font-size: clamp(16px, 4.6cqw, 40px); letter-spacing: 0.2em; text-transform: uppercase; color: var(--c); text-shadow: 0 0 40px oklch(0.8 0.16 var(--h) / 0.4); }
@container (max-height: 300px) { .bx-stats { display: none; } .bx-over .bx-leaf p { -webkit-line-clamp: 3; } }
@container (max-height: 200px) { .bx-art { flex-basis: 18%; } .bx-over .bx-leaf p { display: none; } .bx-kick { display: none; } }
@container (max-width: 240px) { .bx-stats { display: none; } }

/* a page shown inside its box */
.bx-frame { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; background: var(--ink); opacity: 0; transition: opacity 0.5s ease; }
.bx-frame.ready { opacity: 1; }
.bx-frame-bar { flex: 0 0 auto; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 0 12px; background: oklch(0.2 0.05 var(--h)); color: oklch(0.85 0.05 var(--h)); border-bottom: 1px solid oklch(0.8 0.16 var(--h) / 0.4); font-family: var(--mono); font-size: 13px; }
.bx-frame-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bx-frame-bar a { flex: 0 0 auto; min-height: 44px; padding: 0 10px; display: inline-flex; align-items: center; color: var(--c); text-decoration: none; }
.bx-frame-bar a:hover { text-decoration: underline; }
.bx-page { flex: 1 1 auto; min-height: 0; width: 100%; border: 0; display: block; background: var(--ink); }

@media (max-width: 700px) { .bx-crumbs .hint { display: none; } .view-toggle a { padding: 0 10px; } }
@media (prefers-reduced-motion: reduce) { .bx-grid, .bx-in, .bx-face, .bx, .bx::before, .bx-name { transition-duration: 0.01s !important; transition-delay: 0s !important; } }
