/* ILUSTILE Editor UI Shell Layout — Tactical Pixel Craft Studio */

.il-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--surface-void);
}

/* 1. Top Menu & Action Bar */
.il-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--topbar-height);
  flex-shrink: 0;
  padding: 0 var(--space-3);
  background: linear-gradient(180deg, #0E424A 0%, #092B30 100%);
  border-bottom: 1px solid var(--hairline-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 6px rgba(0, 0, 0, 0.35);
  z-index: var(--z-topbar);
}

.il-topbar__left,
.il-topbar__center,
.il-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.il-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  margin-right: 2px;
  border-right: 1px solid rgba(242, 242, 242, 0.14);
  user-select: none;
  text-decoration: none;
  flex-shrink: 0;
}

.il-wordmark__logo {
  display: block;
  height: 24px;
  width: auto;
  object-fit: contain;
}

.il-menubar {
  display: flex;
  align-items: center;
  gap: 2px;
}

.il-menubar .il-btn--ghost {
  color: #D2E4E8;
  font-weight: 500;
  padding: 0 9px;
}

.il-menubar .il-btn--ghost:hover:not(:disabled) {
  color: #FFFFFF;
  background-color: rgba(255, 255, 255, 0.10);
}

.il-topbar__cluster {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background-color: rgba(7, 17, 20, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.38);
}

.il-topbar__divider {
  width: 1px;
  height: 20px;
  background-color: rgba(242, 242, 242, 0.14);
  margin: 0 2px;
}

.il-project-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background-color: rgba(7, 17, 20, 0.56);
  border: 1px solid rgba(62, 198, 211, 0.20);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.40);
  font-size: var(--text-xs);
  color: var(--accent-teal-bright);
  max-width: 320px;
  overflow: hidden;
}

.il-project-pill__name {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 2. Workspace Main Row */
.il-workspace {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* Vertical Tool Rail — Tactile Pixel Craft */
.il-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: var(--toolbar-width);
  flex-shrink: 0;
  padding: 8px 0;
  background-color: var(--surface-rail);
  border-right: 1px solid var(--hairline-dark);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.il-toolbar .il-btn--icon {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.il-toolbar .il-btn--icon:hover:not(:disabled) {
  color: var(--text-primary);
  background-color: rgba(38, 56, 62, 0.72);
  border-color: var(--border-default);
}

.il-toolbar .il-btn--icon.is-active {
  background: linear-gradient(180deg, #00705F 0%, #005B4D 100%);
  border-color: rgba(199, 164, 34, 0.78);
  color: #FFFFFF;
  box-shadow: var(--bevel-raised), 0 2px 8px rgba(0, 91, 77, 0.45);
}

.il-toolbar .il-btn--icon.is-active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background-color: var(--accent-primary);
}

.il-toolbar__divider {
  width: 26px;
  height: 1px;
  background-color: var(--border-subtle);
  margin: 4px 0;
}

/* Collapsible & Resizable Side Docks */
.il-dock {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  background-color: var(--surface-panel);
  border-color: var(--hairline-dark);
  border-style: solid;
  border-width: 0;
  overflow: hidden;
}

.il-dock--left {
  border-right-width: 1px;
}

.il-dock--right {
  border-left-width: 1px;
}

.il-dock.is-collapsed {
  display: none;
}

.il-dock__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 var(--space-2) 0 var(--space-3);
  background-color: var(--surface-elevated);
  border-bottom: 1px solid var(--hairline-dark);
  flex-shrink: 0;
}

.il-dock__title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Drag Splitter Handle */
.il-splitter {
  width: var(--splitter-size);
  flex-shrink: 0;
  cursor: col-resize;
  background-color: var(--surface-void);
  position: relative;
  z-index: var(--z-splitter);
  transition: background-color var(--transition-fast);
}

.il-splitter::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1px;
  width: 3px;
  background-color: transparent;
  transition: background-color var(--transition-fast);
}

.il-splitter:hover::after,
.il-splitter:focus-visible::after,
.il-splitter.is-dragging::after {
  background-color: var(--accent-primary);
}

.il-splitter[hidden] {
  display: none;
}

/* Central Dominant Canvas Stage (Plane 0 Void + Subtle Dot Matrix) */
.il-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background-color: var(--surface-void);
  background-image: radial-gradient(rgba(194, 212, 218, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.il-stage__pixi-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.il-stage.is-panning {
  cursor: grabbing;
}

.il-stage.is-space-pan {
  cursor: grab;
}

/* Floating Camera & Grid Glass HUD (bottom-right of canvas stage) */
.il-stage__hud {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(242, 242, 242, 0.14);
  background-color: var(--surface-glass);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.il-stage__hud-zoom {
  min-width: 50px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
}

.il-stage__hud-sep {
  width: 1px;
  height: 16px;
  background-color: var(--border-default);
  margin: 0 3px;
}

/* Floating Brush Transform & Selection Action Strip (top-center of canvas) */
.il-stage__toolstrip {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(242, 242, 242, 0.14);
  background-color: var(--surface-glass);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
}

.il-stage__toolstrip .il-select--compact {
  flex: 0 1 168px;
  width: 168px;
  min-width: 116px;
  max-width: 176px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.il-stage__toolstrip-msg {
  font-size: var(--text-xs);
  color: #F2D874;
  padding: 0 6px;
  white-space: nowrap;
}

/* Active Layer Opacity Slider Block */
.il-layer-opacity {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--surface-panel-recessed);
}

.il-layer-opacity__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.il-layer-opacity__header span {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #F2D874;
}

.il-stage__overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.il-stage__pixi-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* Foundation / Welcome Status Card centered lightly over canvas */
.il-stage__overlay {
  position: relative;
  z-index: 2;
  max-width: 460px;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(62, 198, 211, 0.24);
  background: linear-gradient(180deg, rgba(22, 37, 43, 0.94) 0%, rgba(12, 23, 27, 0.96) 100%);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: auto;
}

.il-stage__overlay-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.il-stage__overlay-sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Floating Panel Expand Buttons when Collapsed */
.il-stage__expand-btn {
  position: absolute;
  top: 10px;
  z-index: 5;
  background-color: var(--surface-glass);
  border: 1px solid var(--border-default);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
}

.il-stage__expand-btn--left {
  left: 10px;
}

.il-stage__expand-btn--right {
  right: 10px;
}

.il-stage__expand-btn[hidden] {
  display: none;
}

/* Loading Overlay */
.il-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background-color: var(--surface-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-loading);
}

.il-loading-overlay[hidden] {
  display: none;
}

.il-loading-overlay__text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* 3. Bottom Status Bar (28px, strictly <= 32px) */
.il-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--statusbar-height);
  flex-shrink: 0;
  padding: 0 var(--space-3);
  background-color: var(--surface-shell);
  border-top: 1px solid var(--hairline-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  user-select: none;
}

.il-statusbar__group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.il-statusbar__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.il-statusbar__item + .il-statusbar__item::before {
  content: '';
  display: inline-block;
  width: 1px;
  height: 11px;
  margin-right: 6px;
  background-color: var(--border-subtle);
}

.il-statusbar__item--text {
  font-family: var(--font-sans);
  color: var(--text-muted);
}

.il-statusbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: var(--text-2xs);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.il-statusbar__btn:hover {
  background-color: var(--surface-elevated);
  color: var(--text-primary);
}

.il-statusbar__btn.has-errors {
  color: #FFB4B4;
  background-color: var(--status-error-bg);
}

/* Responsive behavior for smaller viewports */
@media (max-width: 1040px) {
  .il-project-pill {
    max-width: 190px;
  }
}

@media (max-width: 920px) {
  .il-project-pill {
    display: none;
  }
}

/* Runtime Playtest Mode (Sprint 05 / RUNTIME.md) */
.il-shell.is-playtesting .il-toolbar,
.il-shell.is-playtesting .il-dock {
  opacity: 0.36;
  pointer-events: none;
  filter: saturate(0.75);
}

.il-stage:focus {
  outline: none;
}

.il-runtime-hud {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(199, 164, 34, 0.72);
  background-color: rgba(8, 18, 22, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg), 0 0 18px rgba(199, 164, 34, 0.14);
  max-width: calc(100% - 20px);
  flex-wrap: wrap;
}

.il-runtime-hud__metric {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  background-color: rgba(33, 52, 58, 0.65);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.il-runtime-hint {
  position: absolute;
  bottom: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  max-width: calc(100% - 20px);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(242, 242, 242, 0.14);
  background-color: var(--surface-glass);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: var(--text-2xs);
  pointer-events: none;
}

.il-runtime-hint__item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.il-runtime-modal {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(6, 13, 16, 0.70);
  backdrop-filter: blur(4px);
}

.il-runtime-modal[hidden] {
  display: none;
}

.il-runtime-modal__card {
  width: min(390px, calc(100% - 32px));
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(199, 164, 34, 0.65);
  background: linear-gradient(180deg, #1A2C33 0%, #111F24 100%);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
}

.il-runtime-modal__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.il-runtime-modal__sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.il-runtime-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
