/* Bonjour Bob — elements and controls, wherever they are. Colours come from tokens.css only. */

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

[hidden] {
  display: none !important;
}

html {
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-size: var(--text-base);
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
blockquote,
fieldset {
  margin: 0;
  padding: 0;
}

/* Young Serif has one weight and is kept for what is 22px or more. */
h1,
h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-display);
}

h2 {
  font-size: var(--text-xl);
}

h3,
h4,
legend {
  font-size: var(--text-base);
  font-weight: var(--weight-strong);
  line-height: var(--leading-snug);
}

ol,
ul.lines,
ul.plain {
  list-style: none;
}

fieldset {
  min-width: 0;
  border: 0;
}

legend {
  padding: 0;
}

p,
li,
dd,
dt,
td,
th {
  overflow-wrap: anywhere;
}

a {
  color: var(--color-text);
  text-decoration-color: var(--color-primary);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

/* Selected text takes the colours of the main button: the sun at night, ink on paper. */
::selection {
  color: var(--color-on-primary);
  background: var(--color-primary);
}

/* One focus ring everywhere: the sun at night, ink on paper. */
:focus-visible,
input[type="time"]:focus-within,
input[type="date"]:focus-within {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

/* Headings receive the focus when something opens: no ring around a sentence. */
[tabindex="-1"]:focus-visible {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.hint,
.source,
.stamp,
.save-state {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.tag,
.by-ai {
  display: inline-block;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-control);
  border-radius: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.7;
  white-space: nowrap;
}

/* Words of the model are signed, like a note in the margin. */
.by-ai {
  border-style: dashed;
}

/* --- icons: files used as masks, so that they take the colour of the text --- */

.icon {
  display: inline-block;
  flex: none;
  width: var(--size-icon);
  height: var(--size-icon);
  background: currentcolor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-alert { --icon: url("icons/alert.svg"); }
.icon-back { --icon: url("icons/back.svg"); }
.icon-bell { --icon: url("icons/bell.svg"); }
.icon-check { --icon: url("icons/check.svg"); }
.icon-clip { --icon: url("icons/clip.svg"); }
.icon-clock { --icon: url("icons/clock.svg"); }
.icon-close { --icon: url("icons/close.svg"); }
.icon-down { --icon: url("icons/down.svg"); }
.icon-file { --icon: url("icons/file.svg"); }
.icon-mail { --icon: url("icons/mail.svg"); }
.icon-phone { --icon: url("icons/phone.svg"); }
.icon-plus { --icon: url("icons/plus.svg"); }
.icon-search { --icon: url("icons/search.svg"); }
.icon-send { --icon: url("icons/send.svg"); }
.icon-settings { --icon: url("icons/settings.svg"); }
.icon-sun { --icon: url("icons/sun.svg"); }
.icon-table { --icon: url("icons/table.svg"); }
.icon-undo { --icon: url("icons/undo.svg"); }

@media (forced-colors: active) {
  .icon {
    background: CanvasText;
    forced-color-adjust: none;
  }
}

/* --- buttons: a button always says what it does, in words --- */

.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--size-control);
  max-width: 100%;
  padding: var(--space-2) 1.125rem;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--color-text);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--color-control);
  font: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-strong);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--duration-fast);
}

.button:hover {
  background: var(--color-sunken);
  box-shadow: inset 0 0 0 2px var(--color-text);
}

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

/* The one thing to do next. One per group of buttons at most. */
.button.strong {
  color: var(--color-on-primary);
  background: var(--color-primary);
  box-shadow: none;
}

.button.strong:hover {
  background: var(--color-primary-hover);
}

/* Something that can wait: words with the sun under them. */
.button.quiet {
  padding-inline: var(--space-3);
  box-shadow: none;
  text-decoration: underline;
  text-decoration-color: var(--color-primary);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.button.quiet:hover {
  background: var(--color-raised);
}

.button.danger {
  color: var(--color-danger);
  box-shadow: inset 0 0 0 1.5px var(--color-danger);
}

.button.danger:hover {
  background: var(--color-danger-soft);
  box-shadow: inset 0 0 0 2px var(--color-danger);
}

.button[aria-busy="true"],
.icon-button[aria-busy="true"] {
  opacity: 0.65;
  cursor: progress;
}

/* A word in a sentence that does something. The target stays tall enough for a finger. */
.button.link,
.button.name,
.button.sort {
  min-height: var(--size-control);
  padding: 0;
  border-radius: var(--space-1);
  background: transparent;
  box-shadow: none;
  text-align: start;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.button.link {
  color: inherit;
  font-weight: inherit;
  text-decoration-color: var(--color-primary);
}

.button.link:hover,
.button.name:hover,
.button.sort:hover {
  text-decoration-color: currentcolor;
}

/* Only where the picture is known to all (close, back) or sits next to its word. */
.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: var(--space-2);
  width: var(--size-control);
  height: var(--size-control);
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--color-text);
  background: transparent;
  font: inherit;
  font-weight: var(--weight-strong);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--color-raised);
}

.icon-button.labelled {
  width: auto;
  padding-inline: var(--space-3);
}

/* --- fields --- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.field > label {
  font-weight: var(--weight-strong);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: var(--size-control);
  padding: 0.625rem 0.875rem;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--color-text);
  background: var(--color-raised);
  box-shadow: inset 0 0 0 1.5px var(--color-control);
  font: inherit;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  caret-color: var(--color-accent);
}

textarea {
  display: block;
  resize: vertical;
  field-sizing: content;
  max-height: 60vh;
}

::placeholder {
  color: var(--color-muted);
  opacity: 1;
}

/* The file picker is opened by a button that says what to attach; the input itself is not shown. */
input[type="file"] {
  min-height: 0;
  padding: 0;
  box-shadow: none;
}

input[type="checkbox"],
input[type="radio"] {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  min-height: 0;
  padding: 0;
  box-shadow: none;
  accent-color: var(--color-primary);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--size-control);
  cursor: pointer;
}

/* A field or two and the button that applies them, on one line when there is room. */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
}

.inline-form > .field {
  flex: 1 1 11rem;
  max-width: 24rem;
}

.inline-form > .errors {
  flex-basis: 100%;
}

/* --- errors, notices, what a person said --- */

.errors:empty,
.notice:empty {
  display: none;
}

/* An error says what happened and what to do, in one or two lines. Never a code. */
.error,
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sheet);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-weight: var(--weight-strong);
}

.notice {
  font-weight: var(--weight-strong);
}

.quote {
  padding-inline-start: var(--space-3);
  border-inline-start: 2px solid var(--color-control);
  color: var(--color-muted);
}

summary {
  min-height: var(--size-control);
  padding-block: var(--space-3);
  font-weight: var(--weight-strong);
  cursor: pointer;
}
