/*
  Two layouts from one stylesheet: a paper-like preview on screen, and the real
  thing on paper. The printed sheet is sized by height so that five rooms, the
  heading and the answer key always land on a single A4 page - see the print
  block at the bottom.
*/

:root {
  --ink: #111111;
  --muted: #5a5a5a;
  --paper: #ffffff;
  --desk: #e9e7e2;
  --rule: #cfcbc4;
  --accent: #6d4c9f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1.5rem 1rem 3rem;
  background: var(--desk);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  max-width: 210mm;
  margin: 0 auto 1.5rem;
  padding: 1rem;
  background: var(--paper);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.controls__intro {
  flex: 1 1 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls__intro strong {
  color: var(--accent);
  font-size: 1.05rem;
  margin-right: 0.5rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control select,
.control input {
  font: inherit;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
}

.button {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

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

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* ---------- The sheet ---------- */

.sheet {
  display: flex;
  flex-direction: column;
  width: min(210mm, 100%);
  margin: 0 auto;
  padding: 10mm;
  background: var(--paper);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
}

.sheet__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2mm;
  margin-bottom: 2mm;
}

.sheet__title {
  margin: 0;
  font-size: 12pt;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sheet__meta {
  margin: 0;
  font-size: 8pt;
  color: var(--muted);
}

.sheet__seed {
  font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
}

.dungeon {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Rooms butt up against each other so the opening in one room's floor lines up
   with the opening in the next room's ceiling. Any gap here breaks the join. */
.room {
  display: block;
  width: 100%;
  height: auto;
}

.puzzle-text {
  fill: var(--ink);
}

.answer-box {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.room-label {
  fill: var(--muted);
}

/* ---------- Answer key ---------- */

.answer-key {
  margin-top: auto;
  padding-top: 2mm;
  border-top: 1px solid var(--rule);
}

/* Printed upside down at the foot of the sheet, puzzle-book style: readable if
   you turn the page around, ignorable while you are solving. */
.answer-key__line {
  margin: 0;
  transform: rotate(180deg);
  font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  font-size: 7.5pt;
  color: var(--muted);
  text-align: center;
}

/* ---------- Print ---------- */

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  body {
    margin: 0;
    padding: 0;
    background: var(--paper);
  }

  .controls {
    display: none;
  }

  .sheet {
    width: auto;
    /* A4 height less the page margins declared above. */
    height: 277mm;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  /* Sized by height, not width: five 48mm rooms leave room for the heading and
     the answer key inside 277mm. Width follows from the 18x5 tile aspect. */
  .room {
    width: auto;
    height: 48mm;
  }

  .answer-box {
    stroke: #999999;
  }
}
