/* ====================================================================
   TOP BAR (.hdr) — header strip
   ====================================================================
   3-column grid: breadcrumb / search / user-tile.
   Pink progress sweep along the bottom edge tracks the main column.
   ==================================================================== */

.hdr {
  display: grid;
  grid-template-columns: auto auto 1fr 320px;
  align-items: center;
  height: 100%;
  padding: 0 0 0 24px;
  gap: 18px;
  position: relative;
}

/* vertical divider used between header sections */
.hdr-sep {
  width: 1px;
  align-self: stretch;
  background: var(--io-border);
  flex-shrink: 0;
}

.hdr-bc {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  font-family: var(--io-font-mono);
  font-size: var(--io-fs-micro);
  color: var(--io-text-tertiary);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hdr-bc-trail {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.hdr-bc-trail .sep {
  color: var(--io-text-tertiary);
  opacity: 0.5;
}

.hdr-bc-trail .last {
  color: var(--io-text-primary);
}

.hdr-bc-dot {
  color: var(--io-text-tertiary);
  opacity: 0.7;
  font-size: 0.9em;
}

.hdr-bc-page {
  color: var(--io-accent-bright);
  font-family: var(--io-font-pixel);
  letter-spacing: 0.04em;
  display: inline-block;
  line-height: 1;
  transform: translateY(1px);
}

/* ─── search ─── */

.hdr-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 32px;
  background: var(--io-surface-base);
  border: 1px solid var(--io-border);
  border-radius: 4px;
  width: 100%;
  justify-self: center;
  min-width: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.hdr-search:hover {
  border-color: var(--io-border);
  background: var(--io-surface-overlay);
}

.hdr-search:focus-within {
  border-color: var(--io-accent);
  background: var(--io-surface-base);
  box-shadow:
    0 0 0 1px var(--io-accent-subtle),
    inset 0 0 10px var(--io-accent-subtle);
}

.hdr-search-ic {
  color: var(--io-text-tertiary);
  font-size: var(--io-fs-sm);
  transition: color 160ms ease;
}

.hdr-search:focus-within .hdr-search-ic {
  color: var(--io-accent);
}

.hdr-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  padding: 0;
  font-family: var(--io-font-mono);
  font-size: var(--io-fs-sm);
  color: var(--io-text-secondary);
  letter-spacing: 0.02em;
}

.hdr-search-input::placeholder {
  color: var(--io-text-tertiary);
  font-style: italic;
}

.hdr-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.hdr-search-kbd {
  font-family: var(--io-font-mono);
  font-size: var(--io-fs-micro);
  color: var(--io-text-tertiary);
  letter-spacing: 0;
  border: 1px solid var(--io-border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 6px 0;
  background: var(--io-surface-sunken);
  user-select: none;
  white-space: nowrap;
  line-height: 1.4;
}

/* ─── actions row (theme + chat + bell + settings + sep + user) ─── */
/* Fixed 320px column to match the right-rail width below it. */

.hdr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  width: 320px;
  padding: 0 14px;
  box-sizing: border-box;
}

/* sep pushes everything after it (the user tile) to the right edge */
.hdr-actions .hdr-sep {
  margin-left: auto;
}

/* shared icon-button base for theme + bell */
.hdr-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--io-radius-sm);
  color: var(--io-text-secondary);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.hdr-icon-btn:hover {
  color: var(--io-text-primary);
  background: var(--io-surface-overlay);
  border-color: var(--io-border);
}

.hdr-icon-btn:active {
  box-shadow: inset 0 0 6px var(--io-accent-subtle);
}

.hdr-icon-btn i {
  font-size: var(--io-fs-sm);
  line-height: 1;
}

/* search — accent + glow on hover */
.hdr-search-btn:hover i {
  color: var(--io-accent);
  text-shadow: 0 0 6px var(--io-accent-glow);
}

/* theme moon — slight accent glow on hover */
.hdr-theme:hover i {
  color: var(--io-accent);
  text-shadow: 0 0 8px var(--io-accent-glow);
}

/* chat — accent color on hover */
.hdr-chat:hover i {
  color: var(--io-accent);
  text-shadow: 0 0 6px var(--io-accent-glow);
}

/* settings — accent + subtle spin on hover */
.hdr-settings:hover i {
  color: var(--io-accent);
  text-shadow: 0 0 6px var(--io-accent-glow);
}

/* bell — accent color on hover, wobble periodically if there's a count */
.hdr-bell:hover i {
  color: var(--io-accent);
  text-shadow: 0 0 6px var(--io-accent-glow);
}

.hdr-bell[data-has-count="true"] i {
  transform-origin: 50% 18%;
  animation: hdr-bell-wobble 6s ease-in-out infinite;
}

@keyframes hdr-bell-wobble {
  0%,  88%, 100% { transform: rotate(0); }
  90% { transform: rotate(10deg); }
  92% { transform: rotate(-8deg); }
  94% { transform: rotate(6deg); }
  96% { transform: rotate(-4deg); }
  98% { transform: rotate(2deg); }
}

.hdr-bell-count {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 13px;
  height: 13px;
  padding: 0 4px;
  border-radius: var(--io-radius-lg);
  background: var(--io-accent);
  color: var(--io-on-accent);
  font-family: var(--io-font-mono);
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 4px var(--io-accent-glow);
  letter-spacing: 0;
  pointer-events: none;
}

/* ─── ticker / marquee ─── */

.hdr-ticker {
  min-width: 0;
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 6%,
    #000 94%,
    transparent 100%
  );
          mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 6%,
    #000 94%,
    transparent 100%
  );
}

.marquee-wrap {
  width: 100%;
  overflow: hidden;
}

.marquee-track {
  display: inline-flex;
  gap: 0;
  white-space: nowrap;
  font-family: var(--style-font-bitcraft);
  letter-spacing: 0.02em;
  /* tertiary base with a narrow secondary-tone band that tiles every 45vw */
  background: linear-gradient(
    90deg,
    var(--io-text-tertiary) 0%,
    var(--io-text-tertiary) 47%,
    var(--io-text-secondary) 50%,
    var(--io-text-tertiary) 53%,
    var(--io-text-tertiary) 100%
  );
  background-size: 45vw 100%;
  background-repeat: repeat-x;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  transform: translateX(0);
  background-position: 0 0;
  /* two independent animations: marquee scroll + shimmer sweep */
  animation:
    hdr-marquee 60s linear infinite,
    hdr-marquee-shimmer 11s linear infinite;
  will-change: transform, background-position;
}

.hdr-ticker:hover .marquee-track {
  animation-play-state: paused, paused;
}

@keyframes hdr-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes hdr-marquee-shimmer {
  0%   { background-position: 0 0; }
  100% { background-position: 45vw 0; }
}

/* accent divider between items — sits inside each item's tail */
.marquee-item::after {
  content: "▮";
  color: var(--io-accent);
  -webkit-text-fill-color: var(--io-accent);
  padding: 0 18px;
  font-size: 0.9em;
}

/* ─── user tile ─── */

.hdr-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.hdr-user-tile {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--io-surface-overlay);
  border: 1px solid var(--io-border-subtle);
  display: block;
}

.hdr-user-tile-img {
  object-fit: cover;
}

.hdr-user-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  line-height: 1;
  min-width: 0;
}

.hdr-user-name {
  font-family: var(--io-font-mono);
  font-size: var(--io-fs-micro);
  line-height: 1;
  color: var(--io-text-secondary);
  letter-spacing: 0;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hdr-user-role {
  font-family: var(--io-font-mono);
  font-size: var(--io-fs-micro);
  line-height: 1;
  color: var(--io-text-tertiary);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ─── progress sweep along bottom edge ─── */

.hdr-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--io-accent) 50%,
    transparent 100%
  );
  background-size: 30% 100%;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}

.hdr.is-loading .hdr-progress {
  opacity: 1;
  /* One-shot sweep — plays through to the right edge regardless of how
     fast the htmx swap finishes. Class auto-removed by nav-sync.js on
     animationend. `forwards` keeps the end frame (off-screen right) so
     the laser fades cleanly instead of snapping back. */
  animation: hdr-progress-sweep 1.4s cubic-bezier(0.4, 0, 0.2, 1) 1 forwards;
}

@keyframes hdr-progress-sweep {
  0%   { background-position: -30% 0; }
  100% { background-position: 130% 0; }
}
