/* lern: the interface in the direction "Hochkant".
   The unit owns the screen. lern is white type on black and one line at the bottom edge. */

:root {
  --void: #0a0a0b;
  --ink: #121316;
  --slate: #1e2026;
  --mist: #2a2f39;
  --edge: #5a6472;
  --fog: #8e97a6;
  --haze: #c9ced8;
  --paper: #ffffff;
  --paper-hover: #dfe2e7;
  --paper-press: #c5c9d1;
  --alarm: #ff7a6b;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-meta: 0.8125rem;
  --fs-body: 1rem;
  --fs-row: 1.0625rem;
  --fs-h2: 1.25rem;
  --fs-h1: 2rem;

  --pad: 20px;
  --hair: 1px solid var(--mist);
  --radius: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
  accent-color: var(--paper);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--void);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scrollbar-color: var(--mist) var(--void);
}

body {
  margin: 0;
  background: var(--void);
  color: var(--paper);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--paper);
}

::selection {
  background: var(--paper);
  color: var(--void);
}

:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

:where(a):focus-visible {
  border-radius: 6px;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

svg.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg.icon .fill {
  fill: transparent;
  transition: fill 240ms var(--ease);
}

svg.icon .cut {
  transition: stroke 240ms var(--ease);
}

svg.icon.filled .fill {
  fill: currentColor;
}

svg.icon.filled .cut {
  stroke: var(--void);
}

/* A state that is still open is drawn in outline and stays quiet. */
svg.icon.open {
  color: var(--fog);
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--paper);
  color: var(--void);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

/* Page frame ------------------------------------------------------------------ */

.page {
  max-width: 36rem;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right))
    calc(56px + env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 32px;
}

.top a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
}

.top a.back {
  margin-left: -6px;
  color: var(--fog);
  transition: color 160ms var(--ease);
}

@media (hover: hover) {
  .top a.back:hover {
    color: var(--paper);
  }
}

.top a.me {
  justify-content: center;
  margin-right: -12px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.375rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.logo svg {
  width: 22px;
  height: 36px;
  flex: none;
}

h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 8px;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

h2 {
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 44px 0 10px;
}

p {
  margin: 0 0 12px;
  max-width: 62ch;
}

.quiet {
  color: var(--fog);
}

.small {
  font-size: var(--fs-meta);
}

/* Lists ----------------------------------------------------------------------- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rows > li {
  border-top: var(--hair);
}

.rows > li:last-child {
  border-bottom: var(--hair);
}

a.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 10px;
  margin: 0 -10px;
  min-height: 60px;
  text-decoration: none;
  border-radius: 10px;
  transition: background-color 160ms var(--ease);
}

@media (hover: hover) {
  a.row:hover {
    background: var(--ink);
  }
}

a.row:active {
  background: var(--slate);
}

.row-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.row-title {
  font-size: var(--fs-row);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.row-meta {
  color: var(--fog);
  font-size: var(--fs-meta);
}

.row-state {
  display: inline-grid;
  grid-template-columns: 20px 20px;
  gap: 12px;
}

.row-state .slot {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
}

/* Finished rows step back, so the rows that are due lead the page. */
.done .row-title {
  font-weight: 400;
  color: var(--haze);
}

.done .row-state .slot:last-child {
  color: var(--fog);
}

/* The facts of a row, joined by middle dots. A dot never ends or starts a line:
   every fact carries its dot on the left, and the first one of each line is clipped away. */
.row-meta {
  display: flex;
  flex-wrap: wrap;
  margin-left: -1em;
  clip-path: inset(0 0 0 1em);
}

.nb {
  position: relative;
  padding-left: 1em;
  white-space: nowrap;
}

.nb::before {
  content: "\00b7";
  position: absolute;
  left: 0;
  width: 1em;
  text-align: center;
}

.courses .row-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.courses a.row {
  min-height: 72px;
}

.empty {
  border-top: var(--hair);
  padding-top: 16px;
  color: var(--fog);
}

h1 + .rows,
h1 + .empty {
  margin-top: 24px;
}

.leave {
  margin-top: 44px;
  border-top: var(--hair);
  padding-top: 20px;
}

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

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--paper);
  background: var(--paper);
  color: var(--void);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease);
}

@media (hover: hover) {
  .btn:hover {
    background: var(--paper-hover);
    border-color: var(--paper-hover);
  }
}

.btn:active {
  background: var(--paper-press);
  border-color: var(--paper-press);
}

.btn.ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--edge);
}

@media (hover: hover) {
  .btn.ghost:hover {
    background: var(--ink);
    border-color: var(--fog);
  }
}

.btn.ghost:active {
  background: var(--slate);
}

.btn.wide {
  width: 100%;
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.55;
  cursor: progress;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

label {
  font-size: var(--fs-meta);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  transition: border-color 160ms var(--ease);
}

input::placeholder {
  color: var(--fog);
}

@media (hover: hover) {
  input:hover,
  select:hover {
    border-color: var(--fog);
  }
}

input:focus-visible,
select:focus-visible {
  border-color: var(--paper);
  outline-offset: 1px;
}

.hint {
  color: var(--fog);
  font-size: var(--fs-meta);
}

.msg {
  min-height: 1.45em;
  margin: 12px 0 0;
  font-size: var(--fs-meta);
}

.msg.error {
  color: var(--alarm);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.inline-form .field {
  flex: 1;
  margin: 0;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  min-height: 60px;
}

.item .row-text {
  flex: 1;
}

.keybox {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--fog);
  border-radius: var(--radius);
  background: var(--ink);
}

.keybox code {
  display: block;
  margin: 8px 0 12px;
  font-family: var(--mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  user-select: all;
}

pre {
  margin: 12px 0 0;
  padding: 14px;
  border: var(--hair);
  border-radius: var(--radius);
  background: var(--ink);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.6;
  overflow-x: auto;
}

.steps {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  counter-reset: step;
}

.steps > li {
  border-top: var(--hair);
  padding: 20px 0 24px;
}

.steps h2 {
  margin: 0 0 6px;
}

.steps h2::before {
  counter-increment: step;
  content: counter(step) ". ";
  color: var(--fog);
}

.steps .btn {
  margin-top: 4px;
}

/* Sign-in and registration ------------------------------------------------------ */

.gate {
  max-width: 22rem;
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top)) var(--pad) calc(48px + env(safe-area-inset-bottom));
}

.gate .logo {
  margin-bottom: 40px;
}

.gate h1 {
  font-size: 1.625rem;
  margin-bottom: 24px;
}

.gate .or {
  margin-top: 10px;
}

.gate .foot {
  margin-top: 28px;
}

/* The unit page: the signature of the direction -------------------------------- */

body.unit {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding-top: env(safe-area-inset-top);
  overflow: hidden;
}

.unit-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  color-scheme: light;
}

.capline {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom))
    max(4px, env(safe-area-inset-left));
  background: var(--void);
  border-top: var(--hair);
  touch-action: none;
}

.capline a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  text-decoration: none;
  border-radius: 10px;
  transition: background-color 160ms var(--ease);
}

@media (hover: hover) {
  .capline a:hover {
    background: var(--slate);
  }
}

.cap-text {
  flex: 1;
  min-width: 0;
  display: grid;
  line-height: 1.25;
}

.cap-text b {
  font-size: 0.9375rem;
  font-weight: 700;
}

.cap-text span {
  font-size: var(--fs-meta);
  color: var(--haze);
}

.cap-text b,
.cap-text span,
.cap-next span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cap-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 44px;
}

.cap-state.open {
  color: var(--fog);
}

.cap-state[hidden] {
  display: none;
}

.cap-next {
  max-width: 34%;
  padding: 0 12px 0 8px;
  font-size: var(--fs-meta);
  font-weight: 700;
}

@media (max-width: 340px) {
  .cap-next span {
    display: none;
  }

  .cap-next {
    padding: 0;
  }
}

/* The snap: the next due unit slides in from below. The caption line stays where it is. */
@view-transition {
  navigation: auto;
}

.unit-frame {
  view-transition-name: unit;
}

.capline {
  view-transition-name: capline;
}

::view-transition-old(*),
::view-transition-new(*) {
  animation: none;
}

/* Without this the browser holds every navigation for its default quarter second. */
::view-transition-group(*) {
  animation-duration: 0s;
}

@media (prefers-reduced-motion: no-preference) {
  html:active-view-transition-type(snap)::view-transition-old(unit) {
    animation: snap-out 320ms var(--ease) both;
  }

  html:active-view-transition-type(snap)::view-transition-new(unit) {
    animation: snap-in 320ms var(--ease) both;
  }
}

@keyframes snap-out {
  to {
    transform: translateY(-100%);
  }
}

@keyframes snap-in {
  from {
    transform: translateY(100%);
  }
}

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