/*
 * The MangoKeys demo.
 *
 * The palette is the palette of the Android keyboard, value for value, so
 * the page and the phone are the same product in two places. The accent is
 * the default of the app, Ocean, and it does the jobs the app gives it: the
 * first candidate, the enter key, the caret and the focus ring.
 */

:root {
  --ground: #101215;
  --body: #1b1d21;
  --strip: #23262b;
  --key: #31353b;
  --function: #3a3f46;
  --field: #23262b;
  --line: #2b2f35;
  --line-soft: #24272c;
  --text: #e8eaed;
  --muted: #a2a9b2;
  --faint: #8b939d;
  --accent: #2c5f8a;
  --accent-bright: #7fb0de;
  --accent-wash: rgba(44, 95, 138, 0.18);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-native: "Noto Sans Malayalam", "Nirmala UI", Kartika, var(--font-ui);

  --radius: 14px;
  --radius-panel: 20px;
  --key-radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: #fff;
}

.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 36px 20px 72px;
}

/* ------------------------------------------------------------- masthead */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.masthead h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.state {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.state .status {
  color: var(--muted);
}

.state .status.bad {
  color: #e79a9a;
}

.state .clock:not(:empty)::before {
  content: "·";
  margin-right: 8px;
}

/* --------------------------------------------------------------- compose */

.compose {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 420ms ease-out, box-shadow 420ms ease-out;
}

.compose.committed {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

#field {
  display: block;
  width: 100%;
  min-height: 30px;
  max-height: 150px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-native);
  font-size: 21px;
  line-height: 1.45;
  resize: none;
  caret-color: var(--accent-bright);
}

#field:focus {
  outline: none;
}

#field::placeholder {
  color: var(--faint);
}

/* -------------------------------------------------------------- keyboard */

.keyboard {
  margin-top: 18px;
  padding: 0 8px 10px;
  background: var(--body);
  border-radius: var(--radius-panel);
  overflow: hidden;
  box-shadow: 0 12px 28px -18px rgba(0, 0, 0, 0.85);
}

.strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 0 14px;
  overflow-x: auto;
  background: var(--strip);
  border-bottom: 1px solid var(--function);
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--function) transparent;
}

.strip::-webkit-scrollbar {
  height: 4px;
}

.strip::-webkit-scrollbar-thumb {
  background: var(--function);
  border-radius: 2px;
}

/* The candidates fade at the edge, so that it is clear there are more. */
.strip.overflowing::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to right, transparent, var(--strip));
  pointer-events: none;
}

.strip-hint {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 12.5px;
}

.candidate {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--function);
  color: var(--text);
  font-family: var(--font-native);
  font-size: 17px;
  line-height: 1.35;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.candidate:hover {
  background: var(--function);
}

.candidate:active {
  transform: translateY(1px);
}

.candidate-first {
  padding: 6px 18px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
}

.candidate-first:hover {
  background: #35709f;
}

.keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
}

.key-row {
  display: flex;
  gap: 5px;
}

.key-row.inset {
  padding: 0 14px;
}

.key {
  flex-basis: 0;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--key-radius);
  background: var(--key);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  transition: background 90ms ease, transform 90ms ease;
}

.key:hover {
  background: #383d44;
}

.key:active,
.key.pressed {
  background: var(--function);
  transform: translateY(1px);
}

.key-function {
  background: var(--function);
  color: #c9ced5;
  font-size: 14px;
}

.key-function:hover {
  background: #454b53;
}

/* The shift key is lit while it is on. */
.key.active {
  background: var(--accent);
  color: #fff;
}

.key.active:hover {
  background: #35709f;
}

.key-accent {
  background: var(--accent);
  color: #fff;
}

.key-accent:hover {
  background: #35709f;
}

.key-space {
  font-size: 13px;
  color: var(--muted);
  transition: background 160ms ease, color 160ms ease;
}

/* When there is a candidate to take, the space bar says so quietly. */
.key-space.key-ready {
  background: var(--function);
  color: var(--accent-bright);
}

.key-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.key-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- results */

.results {
  margin-top: 40px;
}

.results h2 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.results .caption {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--faint);
}

#bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

#bench-table th {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

#bench-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
}

#bench-table tbody tr:last-child td {
  border-bottom: 0;
}

#bench-table td.num {
  width: 84px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#bench-table th:nth-child(2),
#bench-table th:nth-child(3) {
  width: 84px;
  text-align: right;
}

.note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--faint);
}

.note:empty {
  display: none;
}

/* ---------------------------------------------------------------- footer */

footer {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

footer p {
  margin: 0;
  font-size: 13px;
  color: var(--faint);
}

footer nav {
  display: flex;
  gap: 18px;
  margin-top: 10px;
}

footer a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
}

footer a:hover {
  color: var(--text);
  border-bottom-color: var(--accent-bright);
}

/* -------------------------------------------------------------- narrower */

@media (min-width: 1100px) {
  /* A bigger screen gets a bigger keyboard, with the same proportions. */
  .page {
    max-width: 720px;
  }

  .key {
    height: 54px;
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 24px 12px 56px;
  }

  .masthead {
    flex-wrap: wrap;
    gap: 4px;
  }

  .keyboard {
    padding: 0 5px 8px;
    border-radius: 16px;
  }

  .key-row.inset {
    padding: 0 8px;
  }

  .candidate {
    font-size: 16px;
  }

  #field {
    font-size: 19px;
  }
}

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