/* --- breadcrumbs ------------------------------------------------------- */

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  color: var(--muted);
}

/* Every step is an `a`; only those with somewhere to go have an `href`. */
.crumbs a[href] {
  color: var(--muted);
}

.crumbs a[href]:hover {
  color: var(--accent-text);
}

.crumbs a:not([href]) {
  text-decoration: none;
  cursor: default;
}

.crumb-current {
  color: var(--ink);
  font-weight: 500;
}

/* Readable as text, if quieter than the steps (UX-10). */
.crumb-sep {
  color: var(--muted);
}

/* --- page header ------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.page-head-main {
  /* Sized by the room left beside the actions, not by its own content: then
     what editing adds to a line (the tag field) cannot tip the actions onto
     a row of their own. It wraps only below its minimum. */
  flex: 1 1 0;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-sub {
  margin: 0;
  /* A line even when empty: the deck page keeps its description line so
     editing has somewhere to type one without the page moving. */
  min-height: 1lh;
  font-size: 16px;
  color: var(--muted);
}

/* Shut — no description, and not editing — the line gives back the gap
   above it too. */
.page-head-main > .page-sub-fold:not(.open) {
  margin-top: -8px;
}

.deck-head .page-head-main > .page-sub-fold:not(.open) {
  margin-top: -12px;
}

/* The deck header's lines sit a little further apart: in edit mode the
   tag chips' remove badges poke up from the meta line, and must clear the
   title's underline. Set in both modes, so entering one moves nothing. */
.deck-head .page-head-main {
  gap: 12px;
}

.page-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  /* A tag chip's height (its min-height plus both borders), with or without
     tags: the line keeps its size whether the deck has any, and while that
     is still unknown. */
  min-height: calc(32px + 2 * var(--border-w));
  font-size: 14px;
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- editing a deck in place ------------------------------------------ */

/* An editable field is the very element it stands in for — same font, same
   wrapping, same box. Only a dashed underline marks it, drawn as a text
   decoration so it takes no space. */
.editable,
button.access-toggle {
  outline: none;
  text-decoration: underline dashed var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

.editable {
  cursor: text;
}

.editable:focus {
  text-decoration-style: solid;
}

/* A title asked for — Save, or a first card, on a new deck without one. */
.editable.needed {
  text-decoration-color: var(--danger);
  text-decoration-style: solid;
}

/* An emptied field shows what goes there. */
.editable.blank::before {
  content: attr(data-placeholder);
  color: var(--placeholder);
  pointer-events: none;
}

/* The access label turned toggle: a button with none of a button's box, so
   it occupies exactly what the label did. */
button.access-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
}

button.access-toggle:hover:not(:disabled) {
  background: transparent;
  color: var(--ink);
}

/* A removable tag carries its remove button as a badge on its corner, out
   of the flow, so the chip is exactly as wide as in view mode. */
.tag-chip.removable {
  position: relative;
}

button.tag-remove {
  position: absolute;
  top: -5px;
  right: -7px;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
}

button.tag-remove:hover:not(:disabled) {
  background: var(--accent);
}

button.tag-remove .ico {
  width: 10px;
  height: 10px;
}

/* The field that adds a tag: a chip-sized dashed outline at the end of the
   line, where it pushes nothing along. It is there in view mode as well,
   hidden, so the line wraps alike in both; it gives way down to a sliver
   before it wraps at all. */
.page-meta input.tag-add {
  flex: 0 1 7.5em;
  width: auto;
  min-width: 3.5em;
  min-height: 0;
  height: calc(32px + 2 * var(--border-w));
  padding: 0 12px;
  border: var(--border-w) dashed var(--accent);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.page-meta input.tag-add.off {
  visibility: hidden;
}

/* "Edit deck" and "Cancel / Save" in one grid cell, the idle pair hidden but
   still sizing it: the cell is the width of the wider pair in both modes. */
.deck-actions {
  display: grid;
}

.deck-actions > .action-set {
  grid-area: 1 / 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.deck-actions > .action-set.off {
  visibility: hidden;
}
