/*
  Scoped to the tag, for the reason `offline-panel` gives: a bare `[state]` here would reach out and
  restyle whatever page this is dropped into. Colours mix from `--text` and `--background`, which
  every layout defines and flips with the theme.
*/

offline-state {
  display: block;
  width: 100%;
}

offline-state [state] {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
  box-sizing: border-box;
  padding: 14px 16px;
  margin: 0 0 18px;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 4%, var(--background, transparent));
  color: var(--text);
}

offline-state [state][hidden] {
  display: none;
}

offline-state [tag] {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}

offline-state [dot] {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 45%, transparent);
}

offline-state[mode='online'] [dot] {
  background: #16a34a;
}

offline-state [headline] {
  grid-column: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

offline-state [needs] {
  grid-column: 1;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: color-mix(in srgb, var(--text) 70%, transparent);
}

offline-state [needs]:empty {
  display: none;
}

offline-state [retry] {
  grid-column: 2;
  grid-row: 2 / span 2;
  align-self: center;
  padding: 9px 16px;
  border: 1px solid color-mix(in srgb, var(--text) 25%, transparent);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

offline-state[mode='online'] [retry] {
  background: var(--text);
  color: var(--background, #fff);
  border-color: var(--text);
}

offline-state [retry]:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

@media (max-width: 520px) {
  offline-state [state] {
    grid-template-columns: 1fr;
  }

  offline-state [retry] {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    margin-top: 6px;
  }
}

/*
  What `hold` names, while there is no connection: still readable, visibly not pressable. `inert`
  does the work — no clicks, no focus — and this only makes it look like what it is.
*/
[offline-held] {
  opacity: 0.55;
  filter: grayscale(0.4);
  transition: opacity 160ms linear;
}
