/* Maker Buddy - 8-bit arcade theme (built on NES.css) */

:root {
  --ink: #212529;
  --nes-blue: #209cee;
  --nes-green: #92cc41;
  --nes-red: #e76e55;
  --nes-yellow: #f7d51d;
  --nes-purple: #6b4ea3;
  --night: #2b1a54;
  --night-2: #3b2a7a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  /* Readable rounded font for body text (kids need to read instructions!) */
  font-family: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  /* Retro arcade backdrop: night sky + faint pixel grid */
  background-color: var(--night);
  background-image: linear-gradient(180deg, #3b2a7a 0%, #2b1a54 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 24px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 24px);
  background-blend-mode: normal;
}

/* Pixel font ONLY for headings, titles, and short labels */
.pixel,
.nes-container > .title,
h2.pixel {
  font-family: "Press Start 2P", "Baloo 2", cursive;
  line-height: 1.6;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: #000;
  border-bottom: 4px solid var(--nes-yellow);
  color: #fff;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  color: var(--nes-yellow);
  text-shadow: 3px 3px 0 #b58900;
}
.tagline {
  flex: 1;
  min-width: 160px;
  color: #cfd8ff;
  font-weight: 700;
}
.topbar-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* NES buttons: keep the readable font so long labels fit, add a chunky feel */
.nes-btn {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
}
.topbar-btns .nes-btn {
  font-size: 0.85rem;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  padding: 18px;
  align-items: stretch;
  height: calc(100vh - 62px);
}
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* Panels are NES containers; make them fill and lay out as columns */
.viewer-panel,
.chat-panel {
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}
.viewer-panel {
  padding-top: 2.5rem;
}
.chat-panel {
  padding-top: 2.5rem;
}
@media (max-width: 900px) {
  .viewer-panel {
    min-height: 46vh;
  }
  .chat-panel {
    min-height: 60vh;
  }
}

/* ---------- Viewer ---------- */
.viewer-wrap {
  position: relative;
  flex: 1;
  min-height: 240px;
  border: 4px solid #000;
  background: repeating-conic-gradient(#eaf0ff 0% 25%, #dbe6ff 0% 50%) 50% / 32px 32px;
  overflow: hidden;
}
#viewer {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#viewer:active {
  cursor: grabbing;
}
.viewer-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--nes-yellow);
  color: #000;
  padding: 6px 12px;
  border: 3px solid #000;
  font-weight: 800;
  font-size: 0.85rem;
  pointer-events: none;
  white-space: nowrap;
}
.size-readout {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: #000;
  color: var(--nes-green);
  padding: 6px 10px;
  border: 3px solid var(--nes-green);
  font-size: 0.8rem;
  font-weight: 700;
  display: none;
}
.viewer-tools {
  padding-top: 14px;
}
.model-name {
  font-weight: 800;
  font-size: 1.15rem;
  margin-bottom: 10px;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-row .nes-btn {
  font-size: 0.8rem;
}
.btn-row .nes-btn.is-success {
  margin-left: auto;
}
.nes-btn:disabled,
.nes-btn.is-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ---------- Chat ---------- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: #555;
  padding-bottom: 8px;
  border-bottom: 4px dotted #d0d0d0;
  margin-bottom: 8px;
}
.dot {
  width: 14px;
  height: 14px;
  background: var(--nes-yellow);
  border: 3px solid #000;
  /* blocky, not round = pixel vibe */
}
.dot.online {
  background: var(--nes-green);
}
.dot.offline {
  background: var(--nes-blue);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
/* Chat bubbles styled as chunky 8-bit boxes */
.msg {
  max-width: 88%;
  padding: 10px 12px;
  line-height: 1.4;
  font-size: 1rem;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
  animation: pop 0.12s steps(3);
}
@keyframes pop {
  from {
    transform: translateY(4px);
  }
  to {
    transform: translateY(0);
  }
}
.msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
}
.msg.user {
  align-self: flex-end;
  background: var(--nes-blue);
  color: #fff;
}
.msg.typing {
  color: #777;
  font-style: italic;
  background: #f0f0f0;
}

.quick-ideas {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 2px 4px;
}
/* Idea chips = mini pixel buttons */
.idea-chip {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--nes-yellow);
  color: #000;
  border: 3px solid #000;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  cursor: pointer;
}
.idea-chip:hover {
  background: #fff08a;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}
.idea-chip:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.chat-input {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 4px dotted #d0d0d0;
  margin-top: 6px;
}
.chat-input .nes-input {
  flex: 1;
}
.chat-input .nes-btn {
  font-size: 0.85rem;
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 45, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.modal.hidden,
.hidden {
  display: none !important;
}
.modal-card {
  background: #fff;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  padding: 26px 26px 30px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 10px;
  font-size: 0.8rem;
}
.modal-card h2 {
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--nes-purple);
}
.modal-sub {
  color: #555;
  font-weight: 600;
}

/* How-to-print guide (readable) */
.steps {
  padding-left: 22px;
  line-height: 1.55;
}
.steps li {
  margin-bottom: 12px;
}
.settings {
  margin: 6px 0;
}
code {
  background: #000;
  color: var(--nes-green);
  padding: 1px 6px;
  font-size: 0.85em;
  word-break: break-all;
}
.tip {
  background: #fffbe6;
  border: 3px dashed var(--nes-yellow);
  padding: 12px 14px;
  color: #7a5c00;
  margin-top: 14px;
}

/* ---------- Parent settings fields ---------- */
.gate-question {
  font-size: 1.1rem;
  text-align: center;
  color: var(--nes-purple);
  margin: 14px 0;
}
.gate-form {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.gate-form .nes-input {
  width: 160px;
}
.gate-error {
  color: var(--nes-red);
  text-align: center;
  font-weight: 800;
  margin-top: 10px;
}
.field {
  display: block;
  margin: 16px 0;
}
.field-label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}
.field-hint {
  display: block;
  color: #666;
  font-size: 0.85rem;
  margin-top: 6px;
}
.field-row {
  display: flex;
  gap: 12px;
}
.field-row.end {
  justify-content: flex-end;
  margin-top: 8px;
}
.field.small {
  flex: 1;
}

/* Blocky pixel range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: #e7e7e7;
  border: 3px solid #000;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--nes-red);
  border: 3px solid #000;
  margin-top: -2px;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--nes-red);
  border: 3px solid #000;
  border-radius: 0;
}

.nes-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  font-weight: 700;
}
.toggle-text {
  font-size: 0.95rem;
}
.save-note {
  text-align: right;
  color: var(--nes-green);
  font-weight: 800;
}

/* Scrollbars a touch retro */
.chat-log::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 12px;
}
.chat-log::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb {
  background: #b7b7b7;
  border: 3px solid #fff;
}
