/* Quick bites: the inline {{term}}, its hover card, the write/edit window and the Quick bites page. */

/* ---------- In the text ---------- */

.bite {
  border-bottom: 1.5px dotted color-mix(in oklab, var(--clinical) 75%, transparent);
  cursor: help;
  transition: background-color 0.12s;
}

.bite:hover,
.bite:focus-visible {
  background: color-mix(in oklab, var(--clinical) 12%, transparent);
  outline: 0;
}

.bite.missing {
  border-bottom: 1.5px dashed color-mix(in oklab, var(--destructive) 60%, transparent);
  color: var(--destructive);
}

.ve-surface .bite {
  cursor: text;
}

/* ---------- Hover card ---------- */

.bite-card {
  position: fixed;
  z-index: 85;
  width: 340px;
  max-width: calc(100vw - 24px);
  padding: 12px 16px 10px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--clinical);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 14px 40px color-mix(in oklab, var(--foreground) 22%, transparent);
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  animation: preview-in 0.12s ease-out;
}

.bite-card[hidden] {
  display: none;
}

.bite-card-static {
  position: static;
  width: auto;
  max-width: none;
  box-shadow: none;
  animation: none;
}

.bc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-bottom: 4px;
}

.bc-term {
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
}

.bc-aka {
  color: var(--muted-foreground);
  font-size: 12px;
}

.bc-body {
  margin: 0 0 8px;
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
}

.bc-body > :first-child {
  margin-top: 0;
}

.bc-body p,
.bc-body ul,
.bc-body ol {
  margin: 0 0 0.5em;
}

.bc-body ul,
.bc-body ol {
  padding-left: 1.3em;
}

.bc-body ul {
  list-style: disc;
}

.bc-body ol {
  list-style: decimal;
}

.bc-body h2,
.bc-body h3 {
  margin: 0.4em 0 0.2em;
  font-size: 1.05em;
}

.bc-body table {
  font-size: 0.9em;
}

/* hover card: long descriptions fade out, the card opens the full bite in a new tab */
.bite-card:not(.bite-card-static)[data-id] {
  cursor: pointer;
}

.bite-card:not(.bite-card-static) .bc-body {
  position: relative;
  max-height: 9.5em;
  overflow: hidden;
}

.bite-card:not(.bite-card-static) .bc-body.is-cut::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3em;
  background: linear-gradient(transparent, var(--paper));
}

.bc-body.is-cut ~ .bc-foot .bc-open {
  text-decoration: underline;
}

.bd-means {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bd-lab {
  color: var(--muted-foreground);
  font-size: 11.5px;
  font-weight: 600;
}

.bd-lab em {
  font-style: normal;
  font-weight: 400;
}

.bite-dialog .bd-surface {
  min-height: 150px;
  max-height: 340px;
  padding: 10px 14px 24px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 16px;
}

.bd-surface:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 14%, transparent);
}

.bite-dialog .ve-toolbar {
  position: static;
  margin-bottom: 6px;
}

.bite-dialog .ve-surface.is-empty::before {
  content: "One or two plain sentences: what it is and why it matters.";
}

/* the full bite page */
.bite-full .bite-card-static {
  margin-bottom: 14px;
}

.bf-cover {
  float: right;
  width: auto;
  height: auto;
  max-width: min(40%, 340px);
  margin: 4px 0 14px 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.bite-full::after {
  content: "";
  display: table;
  clear: both;
}

@media (max-width: 720px) {
  .bf-cover {
    float: none;
    max-width: 100%;
    margin: 0 0 14px;
  }
}

.bite-full .prose {
  margin: 8px 0 18px;
}

.bc-none {
  color: var(--muted-foreground);
  font-style: italic;
}

.bc-row {
  display: flex;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 13px;
}

.bc-tag {
  flex: none;
  align-self: flex-start;
  min-width: 36px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--clinical-soft);
  color: var(--clinical);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.bc-hook .bc-tag {
  background: var(--paper-soft);
  color: var(--muted-foreground);
}

.bite-card strong {
  color: var(--foreground);
}

.bite-card mark {
  background: color-mix(in oklab, var(--primary) 20%, transparent);
  color: inherit;
}

.bc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 11.5px;
}

.bc-acts {
  display: inline-flex;
  gap: 12px;
}

.bc-foot a,
.bc-foot button,
.bt-foot button,
.bt-foot a {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.bc-foot button:hover,
.bt-foot button:hover,
.bc-foot a:hover,
.bt-foot a:hover {
  text-decoration: underline;
}

/* pictures are never cropped: natural proportions, floated right like an encyclopedia infobox */
.bc-image {
  float: right;
  width: auto;
  height: auto;
  max-width: 45%;
  max-height: 130px;
  margin: 2px 0 8px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.bc-head,
.bc-body {
  overflow: visible;
}

.bc-foot,
.bc-row {
  clear: both;
}

/* ---------- Write / edit window ---------- */

.bd-pic {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bd-pic-box {
  display: grid;
  flex: none;
  place-items: center;
  width: 84px;
  height: 64px;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: 5px;
  color: var(--muted-foreground);
}

.bd-pic-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.bd-pic-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--muted-foreground);
  font-size: 11.5px;
}

.bd-pic-text strong {
  color: var(--foreground);
  font-size: 11.5px;
}

.bd-pic-text em {
  font-style: normal;
}

.bd-pic-btns {
  display: flex;
  gap: 8px;
}

.bd-pic-btns .btn {
  height: 30px;
  font-size: 12.5px;
}

.bd-pic-btns [hidden] {
  display: none;
}

.bite-dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  gap: 12px;
}

.bite-dialog .bd-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bite-dialog .dialog-hint {
  margin: 0;
}

.bite-dialog code,
.home-hero code {
  padding: 0 4px;
  border-radius: 3px;
  background: var(--paper-soft);
  font-size: 0.92em;
}

.bite-dialog label > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.bite-dialog label em {
  color: var(--muted-foreground);
  font-style: normal;
  font-weight: 400;
}

.bite-dialog .bd-count.near {
  color: var(--destructive);
  font-weight: 600;
}

.bite-dialog textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: var(--foreground);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.45;
  resize: vertical;
}

.bite-dialog textarea:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 14%, transparent);
}

.bd-warn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 5px;
  background: var(--paper-soft);
  font-size: 12.5px;
  line-height: 1.45;
}

.bd-warn[hidden] {
  display: none;
}

.bd-warn p {
  margin: 0;
  color: var(--ink-soft);
}

.bd-warn .bd-bad {
  color: var(--destructive);
}

.bd-warn button {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.bd-tagpick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -6px;
}

.bd-tagpick:empty {
  display: none;
}

.bd-tagpick button {
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-foreground);
  font-size: 11.5px;
}

.bd-tagpick button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.bd-label {
  margin: 0 0 6px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bd-actions {
  justify-content: space-between;
}

/* ---------- Quick bites page ---------- */

.bt-filters {
  align-items: flex-start;
}

.bt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.bt-tags:empty {
  display: none;
}

.bt-tags small {
  opacity: 0.7;
}

.bite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.bite-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  transition: box-shadow 0.4s;
}

.bite-tile .bite-card-static {
  background: var(--paper);
}

.bite-tile.flash .bite-card-static {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 45%, transparent);
}

.bt-use {
  margin: 0 4px;
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.45;
}

.bt-use a {
  color: var(--primary);
}

.bt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 4px;
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: 12px;
}

.bt-foot .bc-tags button {
  color: var(--muted-foreground);
  font-weight: 500;
}

@media (max-width: 720px) {
  .bite-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Print ---------- */

@media print {
  .bite-card {
    display: none;
  }

  .bite,
  .bite.missing {
    border-bottom: 1px dotted #777;
    color: inherit;
  }
}
