/* =====================================================================
   SyntaxMonkey  -  app.css   (typing arena: practice.html)
   Colours come from theme.css (var(--token)); nothing here is hard-coded.
   CUSTOMISE: fonts and colours -> theme.css.  Unlock rules / modes -> CONFIG in app.js.
   --acc = accent   --grn = accuracy   --bad = mistake   --bg = page
   --side = panels  --line = borders   --dim = untyped code
   ===================================================================== */

html,
body {
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px var(--ui);
  overflow: hidden;
}

.wm {
  background: linear-gradient(90deg, var(--wm-from), var(--wm-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
}

.wm span{
  color: var(--accent-blue);
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 230px 1fr 230px;
  grid-template-rows: auto 1fr 22px;
  gap: 12px;
  padding: 12px 12px 0;
  grid-template-areas: "top top top" "side main stats" "bar bar bar";
}
.top {
  grid-area: top;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 0;
  font-size: 20px;
}
.ctl {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 auto;
}
.seg {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button {
  background: none;
  border: 0;
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--fg);
}
.seg button.on {
  background: var(--acc);
  color: #fff;
}
.tools {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn {
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 13px;
}
.btn:hover {
  border-color: var(--acc);
}

#levelbtn {
  background: var(--danger-fill);
  color: #fff;
  font-weight: 600;
  border-color: var(--danger-fill);
}

.side,
.main,
.stats {
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 0;
}
.side {
  grid-area: side;
  overflow: auto;
  padding: 14px 8px;
}
.side h3 {
  margin: 4px 12px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--dim);
}
.file {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: center;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
}
.file:hover {
  background: rgba(128, 128, 128, 0.1);
}
.file.on {
  background: rgba(128, 128, 128, 0.2);
}
.file b {
  font-weight: 400;
  flex: 1;
}
.file small {
  color: var(--dim);
  background: var(--bg);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
}
.main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.tab {
  padding: 10px 18px 4px;
  display: flex;
  gap: 14px;
  align-items: baseline;
}
.crumb {
  color: var(--dim);
  font-size: 12px;
}
.lv {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 4px 18px 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.lv:empty {
  display: none;
}
.lv button {
  flex: none;
  min-width: 30px;
  height: 26px;
  border: 1px solid var(--line);
  background: none;
  border-radius: 6px;
}
.lv button.on {
  background: var(--acc);
  color: #fff;
  border-color: var(--acc);
}
.lv button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.ed {
  flex: 1;
  display: flex;
  overflow: auto;
  font: 22px/1.65 var(--mono);
  padding: 14px 0;
  min-height: 0;
}
#ln {
  position: sticky;
  left: 0;
  background: var(--side);
  color: var(--dim);
  text-align: right;
  padding: 0 18px;
  margin: 0;
  font: inherit;
  user-select: none;
}
#code {
  margin: 0;
  font: inherit;
  white-space: pre;
  padding-right: 40px;
}
.c {
  color: var(--dim);
}
.c.ok {
  color: var(--ok);
}
.c.bad {
  color: var(--bad);
  background: var(--badbg);
  text-decoration: underline wavy var(--bad);
}
.c.cur {
  background: var(--acc);
  color: #fff;
  border-radius: 3px;
  box-shadow: 0 0 12px var(--glow);
}
.stats {
  grid-area: stats;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stats label {
  display: block;
  color: var(--dim);
  font-size: 14px;
  margin-bottom: 2px;
}
.stats .n {
  font: 600 64px/1 var(--mono);
  color: var(--wpm-color);
  text-shadow: 0 0 26px var(--glow);
}
:root[data-theme="light"] .stats .n {
  text-shadow: none;
}
.stats .m {
  font: 600 32px var(--mono);
}
#acc {
  color: var(--grn);
}
#errs {
  color: var(--bad);
}
.bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.bar div {
  height: 100%;
  width: 0;
  background: var(--acc);
  transition: width 0.2s;
}
.stats .btn {
  margin-top: auto;
}
.hint {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}
.status {
  grid-area: bar;
  display: flex;
  gap: 16px;
  padding: 0 4px;
  align-items: center;
  font-size: 12px;
  color: var(--dim);
}
.status .sp {
  flex: 1;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal.show {
  display: flex;
}
.card {
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 22px;
}
.card p {
  margin: 0 0 16px;
  color: var(--dim);
}
.rings {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.ring {
  flex: 1;
  text-align: center;
}
.ring div {
  width: 84px;
  height: 84px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0);
}
.ring div span {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--side);
  display: grid;
  place-items: center;
  font: 600 20px var(--mono);
}
.ring small {
  color: var(--dim);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 14px;
}
.chips code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font: 13px var(--mono);
}
.card h4 {
  margin: 8px 0 0;
  font-size: 13px;
}
.acts {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.btn.pri {
  background: var(--acc);
  color: #fff;
  border-color: var(--acc);
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto 22px;
    grid-template-areas: "top" "side" "main" "stats" "bar";
    overflow: auto;
  }
  .ctl {
    margin: 0;
  }
  .side {
    display: flex;
    overflow-x: auto;
    padding: 6px;
  }
  .side h3 {
    display: none;
  }
  .file {
    width: auto;
    white-space: nowrap;
  }
  .stats {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 14px;
  }
  .stats .n {
    font-size: 34px;
  }
  .stats .m {
    font-size: 22px;
  }
  .stats .bar {
    flex-basis: 100%;
  }
  .hint {
    display: none;
  }
  .stats .btn {
    margin: 0;
  }
  .ed {
    font-size: 16px;
    min-height: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.err {
  color: var(--bad);
  max-width: 56ch;
  margin: 0 auto 24px;
  line-height: 1.6;
}

/* ---------- Accessibility & input additions ---------- */

.ed {
  position: relative;
  cursor: text;
}
.typing-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  font-size: 16px; /* 16px stops iOS zooming in when the input is focused */
}
.ed:focus-within {
  outline: 2px solid var(--acc);
  outline-offset: -2px;
  border-radius: 12px;
}
select:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}
.focus-hint {
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}
.focus-hint[hidden] {
  display: none;
}
.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 10px 18px 12px;
  list-style: none;
  color: var(--dim);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.shortcuts kbd {
  font: 600 11px var(--mono);
  padding: 1px 6px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
}
.card .note {
  margin: 0 0 12px;
  font-size: 12px;
}

.lang-menu {
  display: none;
}
@media (max-width: 820px) {
  .lang-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 10px;
    color: var(--dim);
  }
  .lang-menu select {
    flex: 1;
    padding: 8px 10px;
    font-size: 16px;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .side .file {
    display: none;
  }
}

/* A newline has no width, so show a return glyph when it is the cursor or a mistake */
.c.nl.cur::before,
.c.nl.bad::before {
  content: "\21B5";
}

/* "Back to Home" link under the stats */

.backhome{
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 1px;
  text-align: center;
  text-decoration: none;
  color: var(--text-main);
}

.backhome:hover{
  border:  1px solid var(--dim);
  transform:scale(1.02);

}
