/* Koodiva: ink, warm paper and one signal colour. System fonts only, nothing
   is loaded from elsewhere. A state is never told by colour alone. */

:root {
  color-scheme: light dark;
  --paper: #f5f2ec;
  --surface: #fffdf8;
  --line: #d6cfc2;
  --text: #17202a;
  --muted: #55606c;
  --signal: #0b6b5c;
  --on-signal: #ffffff;
  --warn: #8a5200;
  --danger: #a8231c;
  --on-danger: #ffffff;
  --focus: #1d5fd1;
  --stage: #0d141b;
  --shadow: 0 1px 2px rgb(16 24 32 / 0.08), 0 10px 28px rgb(16 24 32 / 0.1);
  --radius: 10px;
  --gap: 1rem;
  /* Fonts of the device, chosen on purpose: the page loads nothing from
     elsewhere. A book serif for headings, the system sans for controls. */
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f161d;
    --surface: #18222c;
    --line: #2e3d4b;
    --text: #e9edf0;
    --muted: #a3afbb;
    --signal: #3fc7ae;
    --on-signal: #05231e;
    --warn: #ffc46b;
    --danger: #ff8a80;
    --on-danger: #2b0704;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 28px rgb(0 0 0 / 0.35);
  }
}

/* The meeting is a dark stage in either scheme: faces read best on it. */
body[data-screen="meeting"] {
  --paper: var(--stage);
  --surface: #18222c;
  --line: #2e3d4b;
  --text: #e9edf0;
  --muted: #a3afbb;
  --signal: #3fc7ae;
  --on-signal: #05231e;
  --warn: #ffc46b;
  --danger: #ff8a80;
  --on-danger: #2b0704;
  --focus: #8ab4ff;
}

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

/* A class that sets `display` must not bring a hidden element back. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--text);
}

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

h1,
h2 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem);
  font-weight: 600;
}

h1:focus {
  outline: none;
}

h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

p {
  margin: 0;
}

/* Masthead: brand on the left, connection and protection on the right. */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem var(--gap);
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 3px solid var(--line);
}

/* The signal line: the rule under the masthead takes the colour of the
   connection. The status next to it says the same in words. */
.masthead:has(.state:not([hidden]) .status) {
  border-bottom-color: var(--warn);
}

.masthead:has(.state:not([hidden]) .status[data-status="connected"]) {
  border-bottom-color: var(--signal);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.state {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.status,
.protection summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.9rem;
}

.status::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}

.status[data-status="connected"]::before {
  background: var(--signal);
  animation: none;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* The way media takes: a quiet note beside the status, not a state of its own. */
.path:not([hidden]) {
  display: flex;
  align-items: center;
  min-height: 2.25rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.protection {
  position: relative;
}

.protection summary {
  cursor: pointer;
}

.protection-panel p {
  margin: 0;
}

.protection-panel .button {
  margin-top: 0.75rem;
}

.protection-panel {
  position: absolute;
  right: 0;
  z-index: 2;
  width: min(24rem, 86vw);
  margin-top: 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

/* Screens */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  padding: clamp(1rem, 4vw, 2.5rem);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
}

.screen.narrow {
  max-width: 34rem;
  margin-top: clamp(0rem, 6vh, 4rem);
}

/* The form of a narrow screen lies on a sheet of its own. */
.screen.narrow > form {
  padding: clamp(1rem, 4vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.screen.narrow > form input,
.screen.narrow > form select {
  background: var(--paper);
}

.screen.wide {
  flex: 1;
  max-width: none;
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.preflight {
  display: grid;
  gap: calc(var(--gap) * 2);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  align-items: start;
}

/* Forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  margin-bottom: 0.35rem;
}

.hint {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 600;
}

.choice input {
  margin-top: 0.3rem;
}

input[type="text"],
select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

input[readonly] {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.85rem;
}

/* Buttons and device switches */

.button,
.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms ease, filter 120ms ease, transform 120ms ease;
}

.button:hover,
.toggle:hover {
  border-color: var(--text);
  filter: brightness(1.06);
}

.button:active,
.toggle:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--signal);
  background: var(--signal);
  color: var(--on-signal);
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-danger);
}

.button.quiet {
  background: transparent;
}

.button[aria-disabled="true"],
.toggle[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button svg,
.toggle svg {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* A switch says its state in a word, and shows it with its edge and fill. */
.toggle {
  min-width: 9.5rem;
  justify-content: flex-start;
}

.toggle-state {
  margin-left: auto;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.toggle[aria-pressed="true"] {
  border-color: var(--signal);
  box-shadow: inset 0 0 0 1px var(--signal);
}

.toggle[aria-pressed="true"] .toggle-state {
  border-color: var(--signal);
  background: var(--signal);
  color: var(--on-signal);
}

/* The sign of a recording (F35): there for everybody while something is
   written down, and only then. It stays in view while the meeting scrolls,
   and says what it means in words: never by its colour alone. */
.recording-sign:not([hidden]) {
  position: sticky;
  top: 0.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--danger);
  color: var(--on-danger);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.recording-sign::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

/* Messages */

.error,
.problem,
.notice,
.note {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
}

.error,
.problem {
  border-left-color: var(--danger);
}

.notice {
  border-left-color: var(--warn);
}

.note {
  border-left-color: var(--signal);
  color: var(--muted);
}

.problem,
.notice {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
}

.problem-message {
  font-weight: 700;
}

/* Preview and tiles share one frame. */

.preview,
.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: #1a242e;
  color: #e9edf0;
  box-shadow: var(--shadow);
}

/* The own tile carries a signal edge, above its picture. */
.tile.self::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--signal);
  border-radius: inherit;
  pointer-events: none;
}

.preview video,
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The own picture is mirrored, as in a mirror. What is sent is not. */
.preview video,
.tile.self video {
  transform: scaleX(-1);
}

.preview-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #a3afbb;
}

.level {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

meter {
  width: 100%;
  height: 0.75rem;
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.checks li {
  display: flex;
  gap: 0.6rem;
}

.checks li::before {
  flex: none;
  width: 1.2rem;
  font-weight: 700;
  text-align: center;
}

.checks .ok::before {
  content: "✓";
  color: var(--signal);
}

.checks .missing::before {
  content: "!";
  color: var(--warn);
}

/* Meeting */

.tiles {
  flex: 1;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile-initial {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 700;
  color: #6f7d8a;
}

.tile video:not([hidden]) + audio + .tile-initial,
.tile video:not([hidden]) + .tile-initial {
  display: none;
}

.tile-name {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  max-width: calc(100% - 1rem);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgb(13 20 27 / 0.82);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.tile-flag {
  color: #a3afbb;
}

.controls {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  background: var(--paper);
}

/* What somebody shares is read, not watched: the whole of it, across the row. */
.tile.screen {
  grid-column: 1 / -1;
  max-height: 70vh;
  justify-self: center;
  width: 100%;
}

.tile.screen video {
  object-fit: contain;
}

.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.field.inline select {
  max-width: 14rem;
}

/* People: who is here, who waits, and what a host can do about it. */

.people {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
}

.people-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.6rem 0.9rem;
  overflow-wrap: anywhere;
}

.person + .person {
  border-top: 1px solid var(--line);
}

/* Whoever waits stands out by an edge and by the words beside the name. */
.person[data-waiting="true"] {
  border-left: 4px solid var(--warn);
}

.person-notes,
.room-state {
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
}

/* A link that looks like the buttons beside it. */
a.button {
  display: inline-block;
  text-decoration: none;
}

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

.rooms li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.rooms .room-name {
  flex: 1 1 10rem;
  overflow-wrap: anywhere;
}

.button.small {
  min-height: 2.25rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.9rem;
}

/* Chat and questions: what was written, and a field to write into each. */

.texts,
.text-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.texts {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
}

.text-panel h3 {
  margin: 0;
}

/* A list that scrolls is reachable by keyboard: it takes the focus itself. */
.text-list {
  display: flex;
  flex-direction: column;
  max-height: 20rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.text-list:empty::after {
  padding: 0.6rem 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  content: "Noch nichts geschrieben.";
}

.text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.6rem 0.9rem;
  overflow-wrap: anywhere;
}

.text + .text {
  border-top: 1px solid var(--line);
}

/* A question that waits stands out by an edge and by the words beside the name. */
.text[data-state="pending"] {
  border-left: 4px solid var(--warn);
}

.text-meta,
.text-body {
  flex: 1 1 100%;
  margin: 0;
}

.text-meta {
  font-weight: 600;
}

.text-notes {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

/* Line breaks of the text stay. Nothing in it is markup. */
.text-body {
  white-space: pre-wrap;
}

.composer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.composer .field {
  flex: 1 1 16rem;
}

dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog[open] {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

dialog::backdrop {
  background: rgb(13 20 27 / 0.6);
}

/* Colophon: the privacy notice, at the foot of every screen. A quiet line
   until it is opened, then a sheet of terms and what stands behind each. */

.colophon {
  padding: 0.5rem clamp(1rem, 4vw, 2.5rem) 1rem;
  border-top: 1px solid var(--line);
}

.privacy {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  font-size: 0.9rem;
}

.privacy summary {
  width: fit-content;
  padding: 0.5rem 0;
  color: var(--muted);
  cursor: pointer;
}

.privacy summary:hover,
.privacy[open] summary {
  color: var(--text);
}

.privacy[open] summary {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
}

.privacy-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 0.5rem 0 1rem;
}

.privacy dl {
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) 1fr;
  gap: 0.75rem 1.5rem;
  margin: 0;
  padding: 1rem 0;
  border-block: 1px solid var(--line);
}

.privacy dt {
  font-weight: 600;
}

.privacy dd {
  margin: 0;
  color: var(--muted);
}

.privacy ul {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.privacy code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* The ID of the person in this meeting: theirs to quote, so it stands out. */
.privacy-own {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--signal);
  border-radius: var(--radius);
  background: var(--surface);
}

.privacy a {
  color: var(--signal);
  font-weight: 600;
}

/* Where the licenses of the foreign software in the application are (F36). */
.licenses {
  max-width: 60rem;
  margin: 0.5rem auto 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.licenses a {
  color: inherit;
}

@media (max-width: 36rem) {
  .privacy dl {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .privacy dd {
    margin-bottom: 0.6rem;
  }
}

@media (max-width: 30rem) {
  .controls .toggle,
  .controls .button {
    flex: 1 1 40%;
    min-width: 0;
  }
}

/* The player of the watch page (watch.html): the picture of the stage. */
.watch-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
}

/* The admin screen (F29): parts that open one by one, and tables that
   scroll within themselves on a narrow screen. */

.admin-part {
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

.admin-part > summary {
  padding: 0.35rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-part[open] > summary {
  margin-bottom: var(--gap);
}

.admin-part h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-part .field.inline input {
  width: 7rem;
}

.admin-scroll {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table caption {
  padding-bottom: 0.35rem;
  font-weight: 600;
  text-align: start;
}

.admin-table th,
.admin-table td {
  padding: 0.45rem 0.75rem 0.45rem 0;
  border-top: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.admin-table thead th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.admin-lines {
  margin: 0;
  padding-left: 1.1rem;
}

.admin-answer {
  max-height: 24rem;
  margin: 0;
  padding: 0.75rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .status::before,
  .recording-sign::before {
    animation: none;
  }

  .button,
  .toggle {
    transition: none;
  }
}
