/* micron-art */

:root {
  --bg: #121212;
  --panel: #2C2C2C;
  --ink: #e6e6df;
  --muted: #6a6a64;
  --line: #d9d9d3;
  --accent: #2f6f4f;
  --warn-bg: #fdf3d8;
  --warn-ink: #e6e6df;
  --term-bg: #14140f;
  --term-ink: #e6e6df;
  --mono: ui-monospace, "SF Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14140f;
    --panel: #1c1c18;
    --ink: #e6e6df;
    --muted: #9a9a90;
    --line: #333330;
    --accent: #7fbf9a;
    --warn-bg: #37301a;
    --warn-ink: #e8d9a0;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1.5rem 1rem 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.masthead {
  max-width: 78rem;
  margin: 0 auto 1.5rem;
}

.masthead h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

main {
  max-width: 78rem;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
  /* Micron and Preview sit side by side, like a split-pane editor. */
  grid-template-columns: 1fr 1fr;
}

/* Art is the input for both, so it spans the full width above them. */
main > section:first-of-type {
  grid-column: 1 / -1;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.panel-head {
  display: flex;
  align-items: center;
  /* Matches the segmented control's height, so both panels' boxes start
     at the same point and the panes line up. */
  min-height: 2rem;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.panel h2 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button,
.file-button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled),
.file-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  cursor: default;
  color: var(--muted);
}

.file-button input {
  display: none;
}

textarea {
  width: 100%;
  min-height: 11rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.35;
  /* Art alignment depends on no wrapping and no tab reflow. */
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  resize: vertical;
  tab-size: 4;
}

textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#output,
.preview {
  flex: 1;
  min-height: 20rem;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  /* Pushes the Copy/Download group to the far end of the header. */
  margin-right: auto;
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  white-space: nowrap;
  border-right: 1px solid var(--line);
}

.segmented label:last-child span {
  border-right: 0;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--panel);
  font-weight: 600;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.warnings {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 6px;
  font-size: 0.85rem;
}

.warnings ul {
  margin: 0;
  padding-left: 1.1rem;
}

.preview {
  padding: 0.75rem;
  border-radius: 6px;
  background: var(--term-bg);
  color: var(--term-ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.25;
  overflow-x: auto;
}

.preview-line {
  white-space: pre;
  min-height: 1.25em;
}

.preview-heading {
  background: #bbbbbb;
  color: #222222;
}

.preview-divider {
  color: var(--muted);
  overflow: hidden;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

footer {
  max-width: 78rem;
  margin: 2rem auto 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* One column below the point where two panes stop being readable. */
@media (max-width: 64rem) {
  .masthead,
  main,
  footer {
    max-width: 60rem;
  }

  main {
    grid-template-columns: 1fr;
  }
}
