/* Persona 3 font */
@font-face {
  font-family: "BM Space";
  src: url("../fonts/BMSPA___.TTF") format("truetype");
  font-weight: normal;
  font-style: normal;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0d0f;
  --panel: #14141a;
  --panel2: #1a1a22;
  --border: #252530;
  --border2: #303040;
  --text: #c0c0d0;
  --dim: #555566;
  --bright: #e0e0f0;
  --accent: #1ed87b;
  --accent-dim: #138f51;
  --font: "BM Space", "JetBrains Mono", monospace;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  display: flex;
  flex-direction: column;
}

/* Top bar */
#topbar {
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 14px;
}

#topbar h1 {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  -webkit-text-stroke: 0.5px #ffffff;
  paint-order: stroke fill;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

#home-link {
  color: inherit;
  text-decoration: none;
  -webkit-text-stroke: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

#home-link:hover {
  opacity: 0.75;
}

#map-info {
  color: var(--dim);
  font-size: 11px;
}

#map-info strong {
  color: var(--text);
}

.topbar-hint {
  margin-left: auto;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.05em;
}

.topbar-hint kbd {
  background: var(--panel2);
  border: 1px solid var(--border2);
  padding: 1px 4px;
  border-radius: 2px;
  color: var(--text);
  font-size: 10px;
}

/* Main layout */
#main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Sidebar */
#sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.section {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.section-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--dim);
  margin-bottom: 9px;
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.row:last-child {
  margin-bottom: 0;
}

.row label {
  color: var(--dim);
  font-size: 10px;
  min-width: 72px;
  flex-shrink: 0;
}

input[type="text"],
input[type="number"],
select {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 2px;
  width: 100%;
  transition: border-color 0.15s;
}

input[type="number"] {
  width: 80px;
  flex-shrink: 0;
}

input[type="checkbox"] {
  cursor: pointer;
}

input[type="color"] {
  border: 1px solid var(--border2);
  background: transparent;
  height: 20px;
  width: 30px;
  padding: 0;
  cursor: pointer;
}

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

button {
  background: var(--panel2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 2px;
  transition:
    border-color 0.12s,
    color 0.12s;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.active-btn {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}

button.primary:hover {
  background: #ffb840;
  border-color: #ffb840;
  color: #000;
}

.file-btn {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  text-align: left;
  padding: 5px 8px;
  font-size: 11px;
}

/* Apply button highlight */
#btn-apply {
  transition: all 0.2s ease;
}

#btn-apply.needs-apply {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
  animation: pulse-apply 1.5s infinite;
}

@keyframes pulse-apply {
  0% {
    box-shadow: 0 0 0 0 rgba(240, 160, 48, 0.4);
  }

  70% {
    box-shadow: 0 0 0 5px rgba(240, 160, 48, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(240, 160, 48, 0);
  }
}

input:disabled,
select:disabled,
button:disabled {
  background: var(--panel);
  color: var(--dim);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Tile palette */
.tile-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}

.tile-btn {
  padding: 6px 4px;
  text-align: center;
  cursor: pointer;
  position: relative;
  border-radius: 2px;
  font-size: 10px;
  border: 1px solid transparent;
  transition: all 0.1s;
  line-height: 1.4;
}

.tile-btn:hover {
  opacity: 0.85;
}

.tile-btn.active {
  outline: 2px solid #ffffffaa;
  outline-offset: 1px;
}

.tile-btn .tile-key {
  font-size: 9px;
  opacity: 0.7;
}

.tile-btn .tile-code {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.tile-btn .tile-name {
  font-size: 9px;
  opacity: 0.6;
}

.sep {
  height: 1px;
  background: var(--border);
  margin: 7px 0;
}

.hint {
  color: var(--dim);
  font-size: 10px;
  margin-top: 4px;
  line-height: 1.5;
}

.computed {
  color: var(--accent-dim);
  font-size: 10px;
  margin-top: 5px;
  font-style: italic;
}

/* Viewport */
#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#three-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#paint-warning {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(200, 50, 50, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  display: none;
  pointer-events: none;
}

/* Status bar */
#statusbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(13, 13, 15, 0.9);
  border-top: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--dim);
  display: flex;
  gap: 20px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

#statusbar .val {
  color: var(--bright);
}

#statusbar .type-indicator {
  padding: 0 6px;
  border-radius: 2px;
  font-weight: 700;
  font-size: 10px;
}

#no-model-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--dim);
  text-align: center;
  pointer-events: none;
  font-size: 13px;
  line-height: 2;
}

#no-model-hint .big {
  font-size: 15px;
  color: var(--border2);
  display: block;
  margin-bottom: 6px;
}

/* Tooltip */
#tooltip {
  position: fixed;
  background: rgba(20, 20, 26, 0.96);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 10px;
  font-family: var(--font);
  padding: 4px 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  display: none;
  max-width: 220px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Minimap */
#minimap-container {
  position: absolute;
  bottom: 30px;
  /* clear the statusbar */
  right: 10px;
  border: 1px solid var(--border2);
  background: rgba(13, 13, 15, 0.88);
  backdrop-filter: blur(4px);
  padding: 4px;
  border-radius: 2px;
  z-index: 5;
  /* Subtle accent glow */
  box-shadow:
    0 0 0 1px rgba(240, 160, 48, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.5);
}

#minimap-label {
  font-size: 10px;
  font-family: var(--font);
  color: var(--dim);
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 3px;
  line-height: 1;
}

#minimap {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

#minimap:hover {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* Persona 3 font */
@font-face {
  font-family: "BM Space";
  src: url("../fonts/BMSPA___.TTF") format("truetype");
  font-weight: normal;
  font-style: normal;
}

/* Accent colors */
/* 1f6db7, 1ed87b */
:root {
  --accent: #1ed87b;
  /* Dual green */
  --accent2: #1f6db7;
  /* P3 Portable blue */
}

/* Light theme */
:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fc;
  --border: #e2e8f0;
  --text: #374151;
  --text-muted: #9ca3af;
  --text-head: #0f172a;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0d0d0f;
  --bg-subtle: #14141a;
  --border: #252530;
  --text: #c0c0d0;
  --text-muted: #555566;
  --text-head: #e0e0f0;
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: "BM Space", "JetBrains Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.2s,
    color 0.2s;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Nav */
nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Brand */
.brand {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 2px;
}

.brand .p3 {
  color: #000;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
}

.brand .dual {
  color: var(--accent);
  -webkit-text-stroke: 0.5px #fff;
  paint-order: stroke fill;
}

/* Nav right side */
.nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  transition:
    color 0.15s,
    background 0.15s;
}

.nav-link:hover {
  color: var(--text-head);
  background: var(--bg-subtle);
}

.nav-link.active {
  color: var(--accent);
}

/* Theme toggle button */
.theme-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition:
    color 0.15s,
    background 0.15s,
    border-color 0.15s;
  margin-left: 6px;
}

.theme-btn:hover {
  color: var(--text-head);
  background: var(--bg-subtle);
}

.theme-btn svg {
  width: 16px;
  height: 16px;
}

/* Main */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 80px;
  width: 100%;
  flex: 1;
}

/* Page heading block */
.page-hero {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-head);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.page-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 460px;
}

/* Section */
.section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Tool card */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
  gap: 16px;
}

.card:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-head);
  margin-bottom: 3px;
}

.card:hover .card-title {
  color: var(--accent);
}

.card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-desc code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  background: var(--bg-subtle);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Arrow icon */
.card-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition:
    color 0.15s,
    transform 0.15s;
}

.card:hover .card-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.card-arrow svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-inner a:hover {
  color: var(--text-head);
}

/* Responsive */
@media (max-width: 480px) {
  main {
    padding-top: 40px;
  }

  h1 {
    font-size: 1.4rem;
  }
}
