/* Purpose: Pixel Forge workshop theme — flat, viewport-height layout, no panel chrome. */

:root {
  --checker-light: #262626;
  --checker-dark: #1c1c1c;
  --page-bg: var(--checker-dark);
  --panel-dark: #0a0806;
  --ink: #fff8e8;
  --ink-soft: #d4b878;
  --line: #5c4828;
  --line-bright: #c88818;
  --accent: #ff9800;
  --accent-bright: #ffc400;
  --danger: #ff4444;
  --danger-bg: #2a1010;
  --font-display: "Press Start 2P", monospace;
  --font-mono: "IBM Plex Mono", monospace;
  --preview-size: 512px;
}

html {
  font-size: 18px;
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  background: var(--page-bg);
}

.page-shell {
  width: min(98vw, 1560px);
  height: 100vh;
  margin: 0 auto;
  padding: 10px 20px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tool-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  min-height: 44px;
  margin-bottom: 10px;
}

.home-link {
  justify-self: start;
  color: var(--accent-bright);
  text-decoration: none;
  font-size: 0.85rem;
}

.home-link:hover,
.home-link:focus-visible {
  color: var(--ink);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1 {
  justify-self: center;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--accent-bright);
}

.layout-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
  align-items: flex-start;
}

.sidebar {
  align-self: flex-start;
  padding-top: 4px;
}

.generator-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  padding: 8px 6px;
  border: 2px solid var(--line);
  background: var(--panel-dark);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.5rem;
  line-height: 1.5;
  cursor: pointer;
  text-align: left;
}

.nav-btn:hover:not(:disabled),
.nav-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent-bright);
  outline: none;
}

.nav-btn--active {
  border-color: var(--accent-bright);
  color: var(--accent-bright);
  background: #2a2010;
}

.nav-btn--soon {
  opacity: 0.45;
  cursor: not-allowed;
}

.workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 56px;
  min-height: 0;
  align-items: flex-start;
  justify-content: flex-start;
}

.control-column {
  align-self: flex-start;
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.res-block label,
.slider-block label,
.ore-block > label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}

.res-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.gen-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.gen-btn {
  padding: 12px 6px;
  border: 3px solid var(--line);
  background: var(--panel-dark);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
}

.gen-btn:hover,
.gen-btn:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.gen-btn--active {
  border-color: var(--accent-bright);
  color: var(--accent-bright);
  background: #2a2010;
}

.res-btn {
  padding: 14px 6px;
  border: 3px solid var(--line);
  background: var(--panel-dark);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.62rem;
  cursor: pointer;
}

.res-btn:hover,
.res-btn:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.res-btn--active {
  border-color: var(--accent-bright);
  color: var(--accent-bright);
  background: #2a2010;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slider-header label {
  margin-bottom: 0;
}

.value-badge {
  display: inline-block;
  min-width: 2.8rem;
  padding: 4px 8px;
  border: 2px solid var(--line-bright);
  background: var(--panel-dark);
  color: var(--accent-bright);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  height: 14px;
  appearance: none;
  background: var(--panel-dark);
  border: 3px solid var(--line);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 24px;
  border: 3px solid var(--line-bright);
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 24px;
  border: 3px solid var(--line-bright);
  background: var(--accent);
}

.ore-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.ore-swatch {
  position: relative;
  width: 100%;
  min-height: 40px;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid var(--line);
  cursor: pointer;
}

.ore-swatch:hover,
.ore-swatch:focus-visible {
  border-color: var(--ink);
  outline: none;
}

.ore-swatch--active {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 2px var(--accent-bright);
}

.ore-swatch-label {
  position: absolute;
  top: 1px;
  right: 1px;
  max-width: calc(100% - 4px);
  padding: 1px 3px;
  background: #000;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.48rem;
  font-weight: 500;
  line-height: 1.1;
  text-align: right;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ore-swatch--custom {
  background: #444;
}

.ore-swatch--custom .ore-swatch-fill {
  position: absolute;
  inset: 4px;
  border: 1px solid #000;
}

.custom-color-row {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.custom-picker-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin-bottom: 6px;
}

.custom-hue,
.custom-sv {
  display: block;
  border: 2px solid var(--line-bright);
  background: var(--checker-dark);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: default;
  touch-action: none;
}

.custom-hue {
  width: 20px;
  height: 120px;
}

.custom-sv {
  width: 120px;
  height: 120px;
}

.hex-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
}

#customHex {
  width: 92px;
  padding: 3px 5px;
  border: 2px solid var(--line-bright);
  background: var(--panel-dark);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
}

#customHex:focus {
  border-color: var(--accent);
  outline: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  min-width: 120px;
  padding: 14px 10px;
  border: 3px solid var(--line-bright);
  font-family: var(--font-display);
  font-size: 0.55rem;
  line-height: 1.6;
  cursor: pointer;
}

.btn:active {
  transform: translate(2px, 2px);
}

.btn-primary {
  background: var(--accent);
  color: #1a1000;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--accent-bright);
  outline: none;
}

.btn-secondary {
  background: var(--panel-dark);
  color: var(--ink);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--accent);
  color: var(--accent-bright);
  outline: none;
}

.preview-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.preview-stage-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pen-toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

.pen-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--line);
  background: var(--panel-dark);
  cursor: pointer;
}

.pen-btn--stone:first-of-type {
  margin-top: 4px;
}

.pen-btn--erase {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--checker-light);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.pen-btn__mark {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1;
  color: var(--danger);
  pointer-events: none;
}

.pen-btn:hover,
.pen-btn:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.pen-btn--active {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 1px var(--accent-bright);
}

.preview-actions {
  width: 512px;
  margin-top: 0;
}

.preview-mount {
  width: 512px;
  height: 512px;
  line-height: 0;
  flex-shrink: 0;
  background: #12100c;
}

.preview-mount canvas {
  display: block;
  width: 512px;
  height: 512px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.error-panel {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 3px solid var(--danger);
  background: var(--danger-bg);
  color: #ffaaaa;
  font-size: 0.9rem;
}

.soon-panel {
  padding: 14px;
  border: 3px dashed var(--line-bright);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .page-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .layout-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  html {
    font-size: 16px;
  }

  .ore-swatch {
    min-height: 48px;
  }
}
