/* Instant-Voxel page layout. Colours, type and components come from tokens.css and
   components.css (the Instant-Voxel design system); this file only places them, after the
   system's reference editor: header, panel | viewport | panel. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface-dim); color: var(--fg); font: 400 var(--text-base)/var(--leading-body) var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, p, dl, dd { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app { display: grid; grid-template-columns: 16rem minmax(0, 1fr) 16rem; grid-template-rows: auto minmax(0, 1fr); gap: 12px; height: 100dvh; padding: 12px; }

/* Header */
header.top { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 8px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { display: block; height: 30px; width: auto; }
.brand p { font-size: var(--text-sm); color: var(--muted); margin-left: 6px; }
.acts { display: flex; align-items: center; gap: 4px; }

/* Panels */
.panel { display: grid; align-content: start; gap: 12px; overflow: hidden auto; scrollbar-width: thin; padding-bottom: 12px; }
.pcard-label { line-height: 1.4; }
.stack { display: grid; gap: var(--space-4); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.label, .field .row label { font-size: var(--text-sm); font-weight: 600; color: var(--fg-2); }   /* the system styles direct-child labels only */
.help.ok { color: var(--success); }
.help.error { color: var(--danger); }
.drop:has(input:focus-visible) { box-shadow: var(--ring-focus); }
.drop .help { font-size: var(--text-xs); }
.file .ms { font-size: 20px; }
.file .mono { color: var(--muted); }
.dims { font-size: var(--text-xs); color: var(--muted); text-align: center; text-wrap: balance; }
.progress { height: 4px; border-radius: var(--radius-pill); background: var(--surface-low); overflow: hidden; }
#progress-fill { width: 0; height: 100%; background: var(--accent); transition: width 300ms var(--ease-out); }
.tools button:disabled { color: var(--meta); cursor: default; }
.note { font-size: var(--text-xs); color: var(--muted); padding: 0 6px; }
.note a { color: var(--accent); text-underline-offset: 3px; border-radius: 4px; }
.note a:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* Swatches: buttons, so the keyboard can pick a paint colour too */
.swatches { max-height: 124px; overflow-y: auto; scrollbar-width: thin; padding: 4px; margin: -4px; }
.swatches button { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 7px; background: var(--c); cursor: pointer; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.swatches button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), var(--ring-focus); }

/* Viewport */
.view { position: relative; border-radius: var(--radius-xl); background: var(--surface-low); overflow: hidden; min-height: 320px; }
.view canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.status { position: absolute; top: 16px; left: 16px; max-width: calc(100% - 32px); }
.status #status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.error { color: var(--danger); }
.status.error .dot { background: var(--danger); }
.gizmos { position: absolute; bottom: 16px; left: 50%; translate: -50% 0; height: auto; gap: 4px; padding: 4px; }
.gizmos .icon-btn { width: 34px; height: 34px; }
.hint { position: absolute; bottom: 20px; right: 20px; font-size: var(--text-xs); color: var(--muted); pointer-events: none; }

/* Files dragged over the window */
#drop-overlay { position: fixed; inset: 0; z-index: 10; display: none; place-items: center; background: color-mix(in srgb, var(--lichen) 45%, transparent); pointer-events: none; }
body.dragging #drop-overlay { display: grid; }
#drop-overlay .glass { height: 48px; padding: 0 24px; font-size: var(--text-base); }

/* Shortcuts dialog */
dialog { width: min(24rem, calc(100vw - 32px)); padding: var(--space-6); border: 0; border-radius: var(--radius-lg); background: var(--bg); color: var(--fg); box-shadow: var(--elev-modal); }
dialog::backdrop { background: color-mix(in srgb, var(--fg) 20%, transparent); }
dialog form { display: grid; gap: var(--space-4); }
dialog h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: var(--h2-tracking); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; font-size: var(--text-sm); color: var(--fg-2); }
kbd { display: inline-block; min-width: 28px; padding: 2px 8px; border-radius: 8px; background: var(--surface-low); color: var(--fg); font: 500 var(--text-sm) var(--font-mono); text-align: center; }

/* 860 to 1179px: the right panel tucks under the left one; the viewport stays in view */
@media (max-width: 1179px) {
  .app { grid-template-columns: 16rem minmax(0, 1fr); height: auto; min-height: 100dvh; }
  .view { grid-row: span 2; align-self: start; position: sticky; top: 12px; height: calc(100dvh - 80px); }   /* 80px: header + gaps, so the gizmos show before scrolling */
  .panel { overflow: visible; padding-bottom: 0; }
}

/* Under 860px: the viewport first, then the panels. Phones are for viewing and export. */
@media (max-width: 859px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  header.top { order: -2; }
  .view { order: -1; grid-row: auto; position: relative; top: auto; height: 60dvh; }
  .brand p, .hint { display: none; }
}
