/* API design: this game's own styles. The site's look, the same on every page
   (tokens for both themes, base, controls, top bar, floating panels, the stage
   panel and the end-of-level card), is ../site.css, loaded first. This file
   adds only what this game draws, using the site's tokens: it names no colour
   and no corner of its own. See _doctrine/design.md. */

/* ---- layout: the reasons, the code, the stage ----
   Wide: the reasons on the left, the code in the middle, the stage
   on the right. Medium: the code beside one column that holds the stage
   and then the reasons. Narrow: one column, and the page scrolls. */

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 304px;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: 'controls centre mission';
}

.side {
  display: contents;
}

.controls,
.mission {
  padding: 16px;
  overflow-y: auto;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls {
  grid-area: controls;
  border-right: 1px solid var(--line);
}

.mission {
  grid-area: mission;
  border-left: 1px solid var(--line);
  gap: 12px;
}

.centre {
  grid-area: centre;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ---- the reasons ---- */

.control {
  display: flex;
  flex-direction: column;
}

.reasons-pick {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.reason {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  white-space: normal;
  line-height: 1.35;
  padding: 8px 10px;
}

.reason.on {
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---- the pull request ---- */

.field-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 320px;
  overflow: hidden;
  background-color: color-mix(in srgb, var(--level) var(--tint), var(--paper));
}

/* the rule in the level's colour, drawn over the picture */
.field-wrap::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--level);
}


.pr {
  position: relative;
  margin: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.pr-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
  font: 600 12px/1.4 var(--font-mono);
}

.pr-tag {
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
}

.code {
  margin: 0;
  padding: 6px 0;
  font: 13px/1.6 var(--font-mono);
}

.line {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.line:hover {
  background: var(--sunken);
}

.line .num {
  padding-right: 12px;
  text-align: right;
  color: var(--muted);
  user-select: none;
}

.line code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* before Start: each line a bar as long as the code, so nothing can be read */
.line code.veil {
  display: block;
  align-self: center;
  max-width: 100%;
  height: 0.7em;
  background: var(--line);
  border-radius: 3px;
}

/* the line the keyboard is on */
.line.cursor {
  border-left-color: var(--line-strong);
}

/* a line the player says the bug is on */
.line.flagged {
  border-left-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

/* the bug, shown with the answer */
.line.bug {
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.fix {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  background: color-mix(in srgb, var(--ok) 8%, var(--panel));
}

.fix h3 {
  margin-bottom: 6px;
}

.fix pre {
  margin: 0;
  font: 13px/1.6 var(--font-mono);
  white-space: pre-wrap;
}

/* the marks the opening explains */
.swatch {
  flex: none;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--line-strong);
}

.swatch.flagged {
  background: var(--warn);
}

.swatch.reason {
  background: var(--accent);
}

.swatch.fix {
  background: var(--ok);
}

/* the line work of the story pictures */
.box,
.detail {
  stroke: var(--box-line);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph {
  fill: var(--box-line);
}

/* ---- medium screens: two columns ---- */

@media (max-width: 1279px) {
  main {
    grid-template-columns: minmax(0, 1fr) 304px;
    grid-template-areas: 'centre side';
  }

  .side {
    grid-area: side;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--panel);
    border-left: 1px solid var(--line);
  }

  .controls,
  .mission {
    overflow-y: visible;
    border: 0;
  }

  .mission {
    order: 1;
    border-bottom: 1px solid var(--line);
  }

  .controls {
    order: 2;
  }

  .field-wrap {
    min-height: 300px;
  }
}

/* ---- narrow screens: one column, and the page scrolls ---- */

@media (max-width: 759px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  main {
    display: flex;
    flex-direction: column;
  }

  .side {
    display: contents;
  }

  .centre {
    order: 2;
    overflow-y: visible;
  }

  /* the story first, then the code, then the reasons */
  .mission {
    order: 1;
    border-bottom: 1px solid var(--line);
  }

  .controls {
    order: 3;
    border-top: 1px solid var(--line);
  }

  .field-wrap {
    flex: none;
    min-height: 220px;
  }
}
