/* The website's face, colours and compact controls (gustavecortal.com src/styles/global.css and
   workbench.css), restated in plain CSS for a page served on its own. */

@font-face {
  font-family: 'Elegant Typewriter';
  src: url('fonts/elegant-typewriter-light.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Elegant Typewriter';
  src: url('fonts/elegant-typewriter-regular.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --text: #f7ffe0;
  --text-muted: #b9c2a4;
  --background: #1a0f20;
  --surface: #271b2e;
  --border: #3d2f44;
  --accent: #dbffa3;
  --size-meta: 0.9rem;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 72rem;
  padding: 1.5rem 1.25rem 3rem;
  background: var(--background);
  color: var(--text);
  font-family: 'Elegant Typewriter', ui-monospace, 'Courier New', monospace;
  font-size: 1.05rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.4rem;
}

p {
  text-wrap: pretty;
}

.intro {
  margin: 0 0 0.5rem;
  max-width: 44rem;
}

.fixture {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
  font-size: var(--size-meta);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.controls label {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  max-width: 100%;
}

button,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
}

select {
  min-width: 0;
  max-width: min(30rem, calc(100vw - 7rem));
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button[aria-pressed='true'] {
  border-color: var(--accent);
  color: var(--accent);
}

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

.note,
.status {
  margin: 0.5rem 0;
  font-size: var(--size-meta);
}

.note {
  color: var(--text-muted);
}

.note button {
  font-size: var(--size-meta);
  padding: 0.05rem 0.4rem;
  margin-left: 0.4rem;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  gap: 1rem 2.5rem;
  align-items: start;
  margin-top: 0.75rem;
}

/* The passage is quoted material: a rule at its left keeps it apart from the interface, and colour
   emoji get a face that has them. */
.passage {
  max-width: 42rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--border);
  font-family: 'Elegant Typewriter', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', ui-monospace, monospace;
}

.passage p:last-child {
  margin-bottom: 0;
}

.passage p {
  margin: 0 0 0.9rem;
}

.passage[contenteditable='true'] {
  outline: 1px dashed var(--border);
  outline-offset: 0.5rem;
}

aside {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.explain {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.explain__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  font-size: var(--size-meta);
}

.explain__bar button {
  font-size: var(--size-meta);
  padding: 0.05rem 0.5rem;
}

.legend {
  font-size: var(--size-meta);
  color: var(--text-muted);
  margin: 0;
}

.records {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  max-width: 42rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.4rem;
}

.records button {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  height: 100%;
  margin: 0;
  line-height: 1.4;
}

.records button[aria-current='true'] {
  border-color: var(--accent);
}

.records small {
  text-wrap: balance;
  color: var(--text-muted);
  font-size: var(--size-meta);
}

@media (max-width: 52rem) {
  body {
    padding: 1rem 1rem 3rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  main {
    grid-template-columns: minmax(0, 1fr);
  }

  aside {
    position: static;
  }

  .controls label {
    flex: 1 1 100%;
  }

  select {
    flex: 1;
    max-width: none;
  }

  /* Room to scroll the passage's last lines above the open explanation. */
  body:has(.explain:not([hidden])) {
    padding-bottom: 40vh;
  }

  /* On a phone the explanation sits over the bottom of the screen, next to the phrase that was
     tapped, instead of below the whole passage. */
  .explain {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 36vh;
    overflow: auto;
    padding: 0.4rem 0.8rem;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -4px 16px rgb(0 0 0 / 0.5);
    z-index: 1;
  }
}
