/* ==================================================
   RUNEGATE APPLICATION BAR
   --------------------------------------------------
   Component stylesheet loaded after main.css.
   Uses the Nordic Grit tokens defined in main.css
   :root and introduces no new colour system.
================================================== */

/* --------------------------------------------------
   BAR SURFACE
-------------------------------------------------- */

.app-bar {
  border-bottom: 1px solid rgb(195 138 61 / 65%);

  background: linear-gradient(180deg, rgb(22 32 31 / 97%), rgb(12 20 21 / 95%));

  color: var(--color-text);

  box-shadow: 0 8px 30px rgb(0 0 0 / 32%);
}

/*
 * Width mirrors .character-sheet in main.css so the bar
 * and the dashboard share the same left and right edges.
 */
.app-bar__content {
  width: min(1200px, calc(100% - 2rem));

  margin: 0 auto;

  display: grid;

  grid-template-areas:
    "brand identity actions"
    "conditions conditions conditions";

  grid-template-columns:
    auto
    minmax(0, 1fr)
    auto;

  align-items: center;

  gap: var(--space-3) var(--space-5);

  min-height: 3.2rem;

  padding: 0.35rem 0;
}

/* --------------------------------------------------
   BRAND
-------------------------------------------------- */

.app-bar__brand {
  grid-area: brand;

  align-self: center;

  min-width: 0;
}

.app-bar__kicker {
  margin: 0;

  color: var(--color-amber);

  text-transform: uppercase;

  font-size: 0.6rem;
  font-weight: 700;

  letter-spacing: 0.15em;
}

.app-bar__title {
  margin: 0;

  color: var(--color-text-strong);

  font-family: Georgia, "Times New Roman", serif;

  font-size: 1.2rem;
  font-weight: 600;

  line-height: 1.15;

  letter-spacing: 0.025em;

  white-space: nowrap;
}

/* --------------------------------------------------
   IDENTITY SUMMARY
-------------------------------------------------- */

.app-bar__identity {
  grid-area: identity;

  display: grid;

  grid-template-columns:
    minmax(9rem, 1.7fr)
    minmax(6rem, 1fr)
    minmax(6rem, 1fr)
    minmax(5.5rem, 0.7fr)
    minmax(3rem, 0.35fr);

  gap: var(--space-3);

  min-width: 0;
}

.app-bar__field {
  display: flex;
  flex-direction: column;

  gap: 0.1rem;

  min-width: 0;
}

/* Desktop: single row. The labels stay for screen readers. */
@media (min-width: 981px) {
  .app-bar__label {
    position: absolute;

    width: 1px;
    height: 1px;

    overflow: hidden;

    clip: rect(0 0 0 0);
  }

  .app-bar__brand {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
  }
}

.app-bar__label {
  color: var(--color-text-muted);

  text-transform: uppercase;

  font-size: 0.6rem;
  font-weight: 700;

  letter-spacing: 0.09em;
}

/* Editable identity input: visibly active. */
.app-bar__input {
  width: 100%;
  min-height: 1.9rem;

  padding: 0.3rem 0.5rem;

  border: 1px solid var(--color-border-strong);

  border-radius: var(--radius-small);

  background: rgb(54 65 63 / 92%);

  color: var(--color-text-strong);

  box-shadow: inset 0 1px 3px rgb(0 0 0 / 26%);

  font-variant-numeric: tabular-nums;
}

/* XP is typed, not stepped: no spin arrows. */
.app-bar__input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.app-bar__input[type="number"]::-webkit-inner-spin-button,
.app-bar__input[type="number"]::-webkit-outer-spin-button {
  margin: 0;

  appearance: none;
}

.app-bar__input:focus-visible {
  outline: 2px solid var(--color-amber-bright);

  outline-offset: 2px;

  border-color: var(--color-amber);
}

/* Derived or not-yet-editable value: calm and read-only. */
.app-bar__value {
  display: block;

  min-height: 1.9rem;

  padding: 0.3rem 0.5rem;

  border-radius: var(--radius-small);

  background: rgb(10 19 20 / 48%);

  color: #d9d6cb;

  font-weight: 700;

  line-height: 1.3rem;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.app-bar__value--number {
  text-align: center;

  font-variant-numeric: tabular-nums;
}

/* Empty state uses text and style, not colour alone. */
.app-bar__value--empty {
  color: var(--color-text-muted);

  font-style: italic;
  font-weight: 400;
}

/* --------------------------------------------------
   ACTIONS
-------------------------------------------------- */

.app-bar__actions {
  grid-area: actions;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;

  gap: var(--space-2) var(--space-4);
}

.app-bar__action-group {
  display: flex;
  flex-wrap: wrap;

  gap: var(--space-2);
}

.app-bar__action-group + .app-bar__action-group {
  padding-left: var(--space-4);

  border-left: 1px solid rgb(70 83 80 / 52%);
}

.app-bar__action {
  min-height: 1.9rem;

  padding: 0.3rem 0.7rem;

  border: 1px solid var(--color-border-strong);

  border-radius: var(--radius-small);

  background: rgb(39 50 49 / 90%);

  color: var(--color-text);

  font-size: 0.75rem;
  font-weight: 700;

  letter-spacing: 0.03em;

  cursor: pointer;
}

.app-bar__action:hover {
  border-color: var(--color-amber);
}

.app-bar__action:focus-visible {
  outline: 2px solid var(--color-amber-bright);

  outline-offset: 2px;
}

/* A dot on Save while there are unsaved changes. */
.app-bar__action.is-unsaved::after {
  content: "";

  display: inline-block;

  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.4rem;

  border-radius: 50%;

  background: var(--color-amber-bright);
}

/*
 * Planned hooks: still focusable, but visibly inactive
 * through a dashed edge and muted text.
 */
.app-bar__action[aria-disabled="true"] {
  border-style: dashed;

  background: transparent;

  color: var(--color-text-muted);

  cursor: not-allowed;
}

.app-bar__action[aria-disabled="true"]:hover {
  border-color: var(--color-border-strong);
}

/* --------------------------------------------------
   RESPONSIVE: COMPACT DESKTOP ALIGNMENT
-------------------------------------------------- */

@media (min-width: 981px) {
  .app-bar__content {
    width: min(1600px, 90vw);
  }
}

/* --------------------------------------------------
   RESPONSIVE: TWO-ROW BAR
-------------------------------------------------- */

@media (max-width: 1180px) {
  .app-bar__content {
    grid-template-areas:
      "brand actions"
      "identity identity";

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

/* --------------------------------------------------
   RESPONSIVE: NARROW
-------------------------------------------------- */

@media (max-width: 760px) {
  .app-bar__content {
    grid-template-areas:
      "brand"
      "identity"
      "actions";

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

  .app-bar__identity {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-bar__field--name {
    grid-column: 1 / -1;
  }

  .app-bar__actions {
    justify-content: flex-start;
  }
}

/* --------------------------------------------------
   RESPONSIVE: SMALL MOBILE
-------------------------------------------------- */

@media (max-width: 420px) {
  .app-bar__content {
    width: min(100% - 1rem, 1200px);
  }

  .app-bar__action-group + .app-bar__action-group {
    padding-left: 0;

    border-left: 0;
  }
}

/* Ancestry select shares the input look. */
.app-bar__select {
  color-scheme: dark;
}
