/**
 * LandLords: Epos — Viewer Page Layout
 * Phase 1: www/index.html, www/preview-map.html, index.html (root)
 *
 * Layout-only rules. Components come from ui-kit.css.
 * Tokens come from design-tokens.css (via core/variables.css).
 */

@layer layout {

/* === Base page styles === */
body {
  background: var(--color-bg-dark);
  color: var(--color-text);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

/* === Canvas (full screen) === */
#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}

/* === Loading overlay === */
#loading {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.8s;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading h1 {
  font-family: var(--font-heading);
  font-size: clamp(24px, 4vw, 48px);
  margin-bottom: var(--spacing-12);
  color: var(--color-accent);
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.loading__shield {
  width: 64px;
  height: 64px;
  color: var(--color-accent);
  margin-bottom: var(--spacing-24);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#status {
  margin-top: var(--spacing-24);
  text-align: center;
  max-width: 600px;
  padding: 0 var(--spacing-20);
  line-height: var(--leading-normal);
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-size: var(--text-14);
}

#info {
  margin-top: var(--spacing-16);
  padding: var(--spacing-16);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--color-gold-dim);
  border-radius: var(--radius-8);
  font-family: var(--font-mono);
  font-size: 0.85em;
  max-width: 700px;
  text-align: left;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#actions {
  margin-top: var(--spacing-24);
  display: flex;
  gap: var(--spacing-8);
  flex-wrap: wrap;
  justify-content: center;
}

/* === Seed panel (top-right) === */
#seed-panel {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--spacing-8);
  padding: var(--spacing-8) var(--spacing-12);
  font-family: var(--font-mono);
  font-size: var(--text-14);
  transition: opacity var(--transition-normal);
}

#seed-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
}

#seed-panel label {
  color: var(--color-text-muted);
  white-space: nowrap;
}

#seed-input {
  width: 180px;
}

#seed-panel .btn {
  padding: var(--spacing-4) 14px;
  margin: 0;
  font-size: var(--text-12);
}

/* === Player panel (right sidebar) === */
#player-panel {
  position: fixed;
  right: 16px;
  top: 80px;
  width: 260px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  z-index: 10;
  font-size: 13px;
  transition: opacity 0.2s ease;
  opacity: 1;
}

#player-panel.is-hidden {
  display: none;
  opacity: 0;
}

#panel-toggle {
  position: absolute;
  right: 8px;
  top: 8px;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0.6;
  padding: 0 4px;
}

#panel-toggle:hover {
  opacity: 1;
}

#panel-header {
  font-size: 15px;
  font-weight: bold;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(107, 91, 79, 0.4);
  color: #c9a84c;
}

#pp-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#panel-footer {
  margin-top: 10px;
  text-align: right;
}

/* === HUD (top-left) === */
#fps {
  padding: var(--spacing-4) 10px;
  margin-bottom: var(--spacing-4);
}

#hud-info {
  padding: var(--spacing-4) 10px;
  font-size: var(--text-12);
}

/* === Console (bottom) === */
#console {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  overflow-y: auto;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: var(--text-12);
  display: none;
}

#console.show {
  display: block;
}

/* === Preview map config panel === */
#config-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 380px;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  font-size: 13px;
  transition: transform 0.3s ease;
  transform: translateX(0);
}

#config-panel.collapsed {
  transform: translateX(-380px);
}

#config-panel h2 {
  padding: 14px 16px 8px;
  margin: 0;
  font-size: 16px;
  border-bottom: 1px solid rgba(139, 90, 43, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#config-panel h3 {
  padding: 10px 16px 4px;
  margin: 0;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

#config-panel h3 .arrow {
  display: inline-block;
  transition: transform 0.2s;
  margin-right: 6px;
}

#config-panel h3.collapsed .arrow {
  transform: rotate(-90deg);
}

.section-body {
  padding: 0 16px 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}

.section-body.collapsed {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 11px;
  margin-bottom: 2px;
}

.field input,
.field select {
  padding: 4px 6px;
  font-size: 12px;
}

.field input[type="checkbox"] {
  width: auto;
  margin-top: 4px;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-check label {
  margin-bottom: 0;
  font-size: 12px;
}

#config-panel .preset-bar {
  padding: 8px 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(139, 90, 43, 0.3);
}

.preset-btn {
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}

#config-panel .actions {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(139, 90, 43, 0.3);
  position: sticky;
  bottom: 0;
}

.gen-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  cursor: pointer;
}

#panel-toggle {
  position: fixed;
  top: 10px;
  left: 390px;
  z-index: 101;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.3s ease;
}

#panel-toggle.shifted {
  left: 10px;
}

#preview-img-wrap {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 90;
  padding: 4px;
  display: none;
}

#preview-img-wrap.visible {
  display: block;
}

#preview-img-wrap img {
  max-width: 320px;
  max-height: 240px;
  display: block;
}

#preview-status {
  position: fixed;
  bottom: 10px;
  left: 400px;
  z-index: 90;
  padding: 6px 12px;
  font-size: 12px;
  display: none;
}

#preview-status.visible {
  display: block;
}

/* === Root index.html specific === */
#server-badge {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 200;
  padding: 6px 14px;
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
}

.border-right {
  position: fixed;
  top: 0;
  right: 0;
  width: 1px;
  height: 100vh;
  z-index: 50;
}
} /* end @layer layout */