/* ==========================================================================
   Minshan in graphite: every lesson, the win screen, Review, Daily, Profile,
   and the sheets and toasts over them. The whole theme is this file.

   Grey is the room. White is what you press or pick. Green and orange are
   right and wrong. Pink is a column name, teal a row, violet pandas' own,
   yellow text, blue numbers: the same in code and table.

   The story board (#screen-path) and the launch page keep the navy in :root.
   They are never touched: while the path is on screen nothing here matches
   outside the screens named below.
   ========================================================================== */

/* :is() so that a browser without :has() loses only that one branch. */
:is(
  #screen-mission, #screen-complete, #screen-review, #screen-daily, #screen-profile,
  #app:has(> #screens > #screen-path[hidden]),
  html:has(#screen-path[hidden]) .lp-dialog
) {
  /* The room */
  --bg: #1C1D20;  --mission-bg: #1C1D20;  --surface-1: #26272B;  --surface-2: #2F3035;
  --df-head-bg: #2E2F34;  --code-bg: #131417;  --code-bg-clear: rgba(19, 20, 23, 0);
  --tab-bg: #131417;  --tab-line: #26272B;  --scrim: rgba(10, 10, 12, .62);
  --text: #F2F2F4;  --text-2: #C9CBD1;  --muted: #ADAFB6;  --dim: #9A9CA3;

  /* White: what you press or pick. The gold tokens are its name in the older CSS. */
  --gold: #F4F4F6;  --gold-ink: #1C1D20;  --gold-lip: #B4B6BD;  --gold-soft: rgba(244, 244, 246, .13);
  --win-ring: #3A3B41;

  /* Right and wrong */
  --good: #34E38F;  --good-soft: rgba(52, 227, 143, .14);
  --bad: #FF8E53;  --bad-soft: rgba(255, 142, 83, .14);

  /* Syntax. Column names share --column, pandas' own words share --index. */
  --code-str: #FFD159;  --code-num: #57CBFF;  --code-kw: #C6A0FF;  --code-punc: #A4A6AD;  --code-err: #FF7B7B;
  --column: #FF8FC7;  --row: #3FE0D0;  --index: #C6A0FF;
  --column-soft: rgba(255, 143, 199, .12);  --row-soft: rgba(63, 224, 208, .13);  --index-soft: rgba(198, 160, 255, .08);  --index-focus: rgba(198, 160, 255, .12);
  --column-lit: rgba(255, 143, 199, .24);  --row-lit: rgba(63, 224, 208, .25);

  /* Text inherits its colour from body, which is navy's. */
  color: var(--text);
}

/* Behind the page: Safari's bars and the keyboard's edge take it from here. */
html:has(#screen-path[hidden]),
html:has(#screen-path[hidden]) body { background: #1C1D20; }

/* Increase Contrast on iPhone: the same step up as css/base.css. */
@media (prefers-contrast: more) {
  :is(
    #screen-mission, #screen-complete, #screen-review, #screen-daily, #screen-profile,
    #app:has(> #screens > #screen-path[hidden]),
    html:has(#screen-path[hidden]) .lp-dialog
  ) {
    --muted: var(--text-2);
    --dim: var(--text-2);
  }
}

.sheet__backdrop { background: var(--scrim); }

/* ---------- Code ---------- */

#screen-mission .tk-col,
.pg-prose .t-col { color: var(--column); }

/* Red only inside code: a word in a sentence reads like the sentence. */
#screen-mission .tk-err,
.pg-prose > .t-e { color: inherit; }

#screen-mission code .tk-err,
#screen-mission .ms-chip .tk-err,
#screen-mission .ms-option--code .tk-err,
#screen-mission .ms-option--word .tk-err { color: var(--code-err); }

/* A tappable word keeps its token colour under the dotted line. */
#screen-mission .term.tk-kw { color: var(--code-kw); }
#screen-mission .term.tk-col { color: var(--column); }
#screen-mission .term[aria-expanded="true"] { color: var(--gold); }

/* ---------- The screen ---------- */

#screen-mission .ms-eyebrow { color: var(--muted); }
#screen-mission .btn[disabled] { opacity: .38; }

/* Options sit as far under the table as chips do. */
#screen-mission .ms-options { margin-top: 0; }

/* ---------- The table ---------- */

/* Pink headers, violet index. */
#screen-mission .df-head .df-cell { color: var(--column); }
#screen-mission .df-cell.df-idx { color: var(--index); }
#screen-mission .df-head .df-cell.df-idx { color: var(--text-2); }
#screen-mission .ms-ot-i { color: var(--index); }

/* A value lights up only when the line of code touches it: js/lesson.js lightFrom(). */
#screen-mission .df-cell { transition: color 200ms var(--ease-out); }
#screen-mission .df--lit .df-body .df-cell { color: var(--text-2); }

#screen-mission .df-body .df-cell.is-lit,
#screen-mission .df-body .df-cell.is-focus,
#screen-mission .df--series .df-body .df-cell { color: var(--code-str); }

#screen-mission .df-body .df-cell.df-num.is-lit,
#screen-mission .df-body .df-cell.df-num.is-focus,
#screen-mission .df--series .df-body .df-cell.df-num { color: var(--code-num); }

#screen-mission .df-body .df-cell.df-idx,
#screen-mission .df--series .df-body .df-cell.df-idx { color: var(--index); }

/* The labels a step points at: they are violet anyway, so they get a soft light. */
#screen-mission .df-cell.df-idx.is-focus .df-txt {
  border-radius: 4px;
  background: var(--index-focus);
  box-shadow: 0 0 0 2px var(--index-focus);
}

/* ---------- The first screen's arrows ---------- */

#screen-mission .ms-anno--col { --c: var(--column); }
#screen-mission .ms-anno--row { --c: var(--row); }
#screen-mission .ms-anno--idx { --c: var(--index); }

#screen-mission .ms-anno-pill {
  padding: 0 10px;
  background: var(--c);
  box-shadow: none;
  color: var(--gold-ink);
}

#screen-mission .ms-anno-line {
  border-radius: 1px;
  background: var(--c);
}

/* Each arrow lands on a ring around the whole column, row or index.
   Above the rows' backgrounds, under their text. */
#screen-mission .ms-ring {
  position: absolute;
  z-index: 0;
  border-radius: 10px;
  pointer-events: none;
}

#screen-mission .ms-ring-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

/* While it draws: js/lesson.js sweep(). */
#screen-mission .ms-ring.is-sweeping { overflow: hidden; }

#screen-mission .ms-ring--col .ms-ring-face { background: var(--column-soft); box-shadow: inset 0 0 0 1.5px var(--column); }
#screen-mission .ms-ring--row .ms-ring-face { background: var(--row-soft); box-shadow: inset 0 0 0 1.5px var(--row); }
#screen-mission .ms-ring--idx .ms-ring-face { background: var(--index-soft); box-shadow: inset 0 0 0 1.5px var(--index); }

/* The same values, lit in the code as their ring lands. */
#screen-mission .ms-lit {
  transition: background-color 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

#screen-mission .ms-lit--col {
  padding: .12em 0;
  border-radius: 6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* 4 px past the words on each side. A shadow, so the line's measured width stays its own. */
#screen-mission .ms-lit--col.is-on {
  background-color: var(--column-lit);
  box-shadow: -4px 0 0 0 var(--column-lit), 4px 0 0 0 var(--column-lit);
}

#screen-mission .ms-code--fit:has(.ms-lit--col) > code { overflow: visible; }
#screen-mission .ms-lit--row { border-radius: 4px; }

#screen-mission .ms-lit--row.is-on {
  background-color: var(--row-lit);
  box-shadow: 0 0 0 2px var(--row-lit);
}

/* ---------- The feedback sheet ----------
   A title with its icon, one short calm explanation, one main button. The
   button is the same size and in the same place as the Check it replaced, and
   the only coloured words are the title and any code in backticks. */

#screen-mission .ms-fb {
  padding-top: 14px;
  padding-bottom: calc(12px + var(--safe-b));
}

#screen-mission .ms-fb-head {
  gap: 8px;
  min-height: 24px;
  margin-bottom: 6px;
}

#screen-mission .ms-fb-icon {
  width: 24px;
  height: 24px;
}

#screen-mission .ms-fb-icon svg {
  width: 16px;
  height: 16px;
}

#screen-mission .ms-fb-title {
  font-size: 18px;
  line-height: 24px;
}

#screen-mission .ms-fb-answer,
#screen-mission .ms-fb-text {
  margin: 0 0 14px;
  color: var(--text-2);
  font-size: 17px;
  line-height: 1.4;
  text-wrap: pretty;
}

/* "Show the answer": an answer line, then whatever is said under it. */
#screen-mission .ms-fb-answer:not([hidden]) + .ms-fb-text { margin-top: -8px; }
#screen-mission .ms-fb-label { color: inherit; }

/* A number on its own in a sentence is a word of the sentence, like the 100 beside it.
   Whole code, like [4, 7, 2] or df["city"], keeps its colours. */
#screen-mission .ms-fb-text .ic--num,
#screen-mission .ms-fb-text .ic--num span { color: inherit; font: inherit; }

#screen-mission .ms-fb-code {
  font-size: 16px;
}

/* With nothing to say, the button keeps its distance from the title. */
#screen-mission .ms-fb-answer[hidden] + .ms-fb-text[hidden] + .ms-fb-next { margin-top: 14px; }

#screen-mission .ms-fb .btn { height: 48px; }

/* Its 44 px hangs past the 24 px title row, so it sits above the text it overlaps. */
#screen-mission .ms-fb-alt {
  position: relative;
  z-index: 1;
  margin: -10px 0 -10px auto;
}

/* When nothing else is left to give the footer tightens, and the button stays on it. */
#screen-mission .ms-shell.is-tight .ms-fb { padding-bottom: calc(8px + var(--safe-b)); }
#screen-mission .ms-shell.is-tight .ms-fb .btn { height: 44px; }

/* ---------- The win screen: colours above, this is the canvas's press ---------- */

@media (prefers-reduced-motion: no-preference) {
  #screen-complete .win-btn {
    transition: transform 80ms ease-out, box-shadow 80ms ease-out;
  }

  #screen-complete .win-btn:not(.win-btn--plain):active {
    transform: translateY(4px);
    box-shadow: 0 0 0 0 var(--lip);
  }

  /* Going between the path and a tab, the bar changes colour with the screen. */
  .tabbar {
    transition: transform 260ms var(--ease-in-out), background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
  }
}

@media (prefers-reduced-motion: reduce) {
  #screen-mission .df-cell,
  #screen-mission .ms-lit { transition: none; }
}
